Merge branch 'master' of http://10.153.19.25:10101/r/CanadaMes
| | |
| | | VUE_APP_BASE_API=/api |
| | | VUE_APP_BASE_API=/api
|
| | |
| | | "address": "DB100.0", |
| | | "count": 3, |
| | | "unit": "°", |
| | | "value": "" |
| | | "value": "", |
| | | "min": 0, |
| | | "max": 100 |
| | | }, |
| | | { |
| | | "name": "A01行走低速角度", |
| | |
| | | "address": "DB100.0", |
| | | "unit": "°", |
| | | "type": "0", |
| | | "value": "" |
| | | "value": "", |
| | | "min": 0, |
| | | "max": 100 |
| | | }, |
| | | { |
| | | "name": "A01输送接片角度", |
| | |
| | | "unit": "°", |
| | | "address": "DB100.0", |
| | | "type": "0", |
| | | "value": "" |
| | | "value": "", |
| | | "min": 0, |
| | | "max": 100 |
| | | }, |
| | | { |
| | | "name": "A01笼子角度", |
| | |
| | | "unit": "°", |
| | | "address": "DB100.0", |
| | | "type": "0", |
| | | "value": "" |
| | | "value": "", |
| | | "min": 0, |
| | | "max": 100 |
| | | } |
| | | ], |
| | | [ |
| | |
| | | "unit": "°", |
| | | "address": "DB100.0", |
| | | "count": 3, |
| | | "value": "" |
| | | "value": "", |
| | | "min": 0, |
| | | "max": 100 |
| | | }, |
| | | { |
| | | "name": "A02行走低速角度", |
| | |
| | | "unit": "°", |
| | | "address": "DB100.0", |
| | | "type": "0", |
| | | "value": "" |
| | | "value": "", |
| | | "min": 0, |
| | | "max": 100 |
| | | }, |
| | | { |
| | | "name": "A02输送接片角度", |
| | |
| | | "unit": "°", |
| | | "address": "DB100.0", |
| | | "type": "0", |
| | | "value": "" |
| | | "value": "", |
| | | "min": 0, |
| | | "max": 100 |
| | | }, |
| | | { |
| | | "name": "A02笼子角度", |
| | |
| | | "unit": "°", |
| | | "address": "DB100.0", |
| | | "type": "0", |
| | | "value": "" |
| | | "value": "", |
| | | "min": 0, |
| | | "max": 100 |
| | | } |
| | | ], |
| | | [ |
| | |
| | | "unit": "m/min", |
| | | "address": "DB100.0", |
| | | "count": 3, |
| | | "value": "" |
| | | "value": "", |
| | | "min": 0, |
| | | "max": 100 |
| | | } |
| | | ], |
| | | [ |
| | |
| | | "unit": "m/min", |
| | | "address": "DB100.0", |
| | | "type": "0", |
| | | "value": "" |
| | | "value": "", |
| | | "min": 0, |
| | | "max": 100 |
| | | } |
| | | ], |
| | | [ |
| | |
| | | "unit": "m/min", |
| | | "address": "DB100.0", |
| | | "type": "0", |
| | | "value": "" |
| | | "value": "", |
| | | "min": 0, |
| | | "max": 100 |
| | | } |
| | | ], |
| | | [ |
| | |
| | | "type": "0", |
| | | "unit": "m/min", |
| | | "count":3, |
| | | "value":0 |
| | | "value":0, |
| | | "min": 0, |
| | | "max": 1000 |
| | | }, |
| | | { |
| | | "name": "高速线速度", |
| | |
| | | "sending": 0, |
| | | "type": "0", |
| | | "unit": "m/min", |
| | | "value":0 |
| | | "value":0, |
| | | "min": 0, |
| | | "max": 100 |
| | | }, |
| | | { |
| | | "name": "低速线速度", |
| | |
| | | "sending": 0, |
| | | "type": "0", |
| | | "unit": "m/min", |
| | | "value":0 |
| | | "value":0, |
| | | "min": 0, |
| | | "max": 100 |
| | | }, |
| | | { |
| | | "name": "手动速度", |
| | |
| | | "sending": 0, |
| | | "type": "0", |
| | | "unit": "m/min", |
| | | "value":0 |
| | | "value":0, |
| | | "min": 0, |
| | | "max": 100 |
| | | } |
| | | |
| | | |
| | |
| | | "type": "0", |
| | | "unit": "m/min", |
| | | "count":3, |
| | | "value":0 |
| | | "value":0, |
| | | "min": 0, |
| | | "max": 100 |
| | | }, |
| | | { |
| | | "name": "高速线速度", |
| | |
| | | "sending": 0, |
| | | "unit": "m/min", |
| | | "type": "0", |
| | | "value":0 |
| | | "value":0, |
| | | "min": 0, |
| | | "max": 100 |
| | | }, |
| | | { |
| | | "name": "低速线速度", |
| | |
| | | "sending": 0, |
| | | "unit": "m/min", |
| | | "type": "0", |
| | | "value":0 |
| | | "value":0, |
| | | "min": 0, |
| | | "max": 100 |
| | | }, |
| | | { |
| | | "name": "手动速度", |
| | |
| | | "sending": 0, |
| | | "unit": "m/min", |
| | | "type": "0", |
| | | "value":0 |
| | | "value":0, |
| | | "min": 0, |
| | | "max": 100 |
| | | } |
| | | |
| | | |
| | |
| | | "type": "0", |
| | | "unit": "m/min", |
| | | "count":3, |
| | | "value":0 |
| | | "value":0, |
| | | "min": 0, |
| | | "max": 100 |
| | | }, |
| | | { |
| | | "name": "高速线速度", |
| | |
| | | "sending": 0, |
| | | "type": "0", |
| | | "unit": "m/min", |
| | | "value":0 |
| | | "value":0, |
| | | "min": 0, |
| | | "max": 100 |
| | | }, |
| | | { |
| | | "name": "低速线速度", |
| | |
| | | "sending": 0, |
| | | "type": "0", |
| | | "unit": "m/min", |
| | | "value":0 |
| | | "value":0, |
| | | "min": 0, |
| | | "max": 100 |
| | | }, |
| | | { |
| | | "name": "手动速度", |
| | |
| | | "sending": 0, |
| | | "type": "0", |
| | | "unit": "m/min", |
| | | "value":0 |
| | | "value":0, |
| | | "min": 0, |
| | | "max": 100 |
| | | } |
| | | |
| | | |
| | |
| | | "unit": "mm/S", |
| | | |
| | | "count":3, |
| | | "value":0 |
| | | "value":0, |
| | | "min": 0, |
| | | "max": 100 |
| | | } |
| | | |
| | | |
| | |
| | | "sending": 0, |
| | | "unit": "mm/S", |
| | | "type": "0", |
| | | "value":0 |
| | | "value":0, |
| | | "min": 0, |
| | | "max": 100 |
| | | } |
| | | |
| | | |
| | |
| | | "button": { |
| | | "name": "D01输送", |
| | | "value": 0, |
| | | "value2": 0, |
| | | "address": "DB10.0", |
| | | "state": 0 |
| | | }, |
| | |
| | | "button": { |
| | | "name": "D02输送", |
| | | "value": 0, |
| | | "value2": 0, |
| | | "address": "DB10.0", |
| | | "state": 0 |
| | | }, |
| | |
| | | "button": { |
| | | "name": "D03输送", |
| | | "value": 0, |
| | | "value2": 0, |
| | | "address": "DB10.0", |
| | | "state": 1 |
| | | }, |
| | |
| | | "button": { |
| | | "name": "D04输送", |
| | | "value": 0, |
| | | "value2": 0, |
| | | "address": "DB10.0", |
| | | "state": 1 |
| | | }, |
| | |
| | | "button": { |
| | | "name": "D05输送", |
| | | "value": 0, |
| | | "value2": 0, |
| | | "address": "DB10.0", |
| | | "state": 1 |
| | | }, |
| | |
| | | "button": { |
| | | "name": "D06输送", |
| | | "value": 0, |
| | | "value2": 0, |
| | | "address": "DB10.0", |
| | | "state": 1 |
| | | }, |
| | |
| | | "button": { |
| | | "name": "A01输送正向", |
| | | "value": 0, |
| | | "value2": 0, |
| | | "address": "DB10.0", |
| | | "state": 0 |
| | | }, |
| | |
| | | "button": { |
| | | "name": "A01输送反向", |
| | | "value": 0, |
| | | "value2": 0, |
| | | "address": "DB10.0", |
| | | "state": 1 |
| | | }, |
| | |
| | | "button": { |
| | | "name": "A01行走点动", |
| | | "value": 0, |
| | | "value2": 0, |
| | | "address": "DB10.0", |
| | | "state": 0 |
| | | }, |
| | |
| | | "button": { |
| | | "name": "A01翻转", |
| | | "value": 0, |
| | | "value2": 0, |
| | | "address": "DB10.0", |
| | | "state": 1 |
| | | }, |
| | |
| | | "button": { |
| | | "name": "A01注电泵", |
| | | "value": 0, |
| | | "value2": 0, |
| | | "address": "DB10.0", |
| | | "state": 0 |
| | | }, |
| | |
| | | "button": { |
| | | "name": "A02输送正向", |
| | | "value": 0, |
| | | "value2": 0, |
| | | "address": "DB10.0", |
| | | "state": 0 |
| | | }, |
| | |
| | | "button": { |
| | | "name": "A02输送反向", |
| | | "value": 0, |
| | | "value2": 0, |
| | | "address": "DB10.0", |
| | | "state": 1 |
| | | }, |
| | |
| | | "button": { |
| | | "name": "A02行走点动", |
| | | "value": 0, |
| | | "value2": 0, |
| | | "address": "DB10.0", |
| | | "state": 0 |
| | | }, |
| | |
| | | "button": { |
| | | "name": "A02翻转", |
| | | "value": 0, |
| | | "value2": 0, |
| | | "address": "DB10.0", |
| | | "state": 1 |
| | | }, |
| | |
| | | "button": { |
| | | "name": "A02注电泵", |
| | | "value": 0, |
| | | "value2": 0, |
| | | "address": "DB10.0", |
| | | "state": 0 |
| | | }, |
| | |
| | | "button": { |
| | | "name": "B01输送", |
| | | "value": 0, |
| | | "value2": 0, |
| | | "address": "DB10.0", |
| | | "state": 1 |
| | | }, |
| | |
| | | "button": { |
| | | "name": "B01行走点动", |
| | | "value": 0, |
| | | "value2": 0, |
| | | "address": "DB10.0", |
| | | "state": 1 |
| | | }, |
| | |
| | | "button": { |
| | | "name": "B01翻转气缸", |
| | | "value": 0, |
| | | "value2": 0, |
| | | "address": "DB10.0", |
| | | "state": 0 |
| | | }, |
| | |
| | | "button": { |
| | | "name": "B01升降气缸", |
| | | "value": 0, |
| | | "value2": 0, |
| | | "address": "DB10.0", |
| | | "state": 0 |
| | | }, |
| | |
| | | "button": { |
| | | "name": "B01吹气", |
| | | "value": 0, |
| | | "value2": 0, |
| | | "address": "DB10.0", |
| | | "state": 1 |
| | | }, |
| | |
| | | "button": { |
| | | "name": "B02输送", |
| | | "value": 0, |
| | | "value2": 0, |
| | | "address": "DB10.0", |
| | | "state": 1 |
| | | }, |
| | |
| | | "button": { |
| | | "name": "B02行走点动", |
| | | "value": 0, |
| | | "value2": 0, |
| | | "address": "DB10.0", |
| | | "state": 1 |
| | | }, |
| | |
| | | "button": { |
| | | "name": "B02翻转气缸", |
| | | "value": 0, |
| | | "value2": 0, |
| | | "address": "DB10.0", |
| | | "state": 0 |
| | | }, |
| | |
| | | "button": { |
| | | "name": "B02升降气缸", |
| | | "value": 0, |
| | | "value2": 0, |
| | | "address": "DB10.0", |
| | | "state": 0 |
| | | }, |
| | |
| | | "button": { |
| | | "name": "B02吹气", |
| | | "value": 0, |
| | | "value2": 0, |
| | | "address": "DB10.0", |
| | | "state": 1 |
| | | }, |
| | |
| | | } |
| | | |
| | | |
| | | ], |
| | | [ |
| | | { |
| | | "button": { |
| | | "name": "A01行走伺服回零", |
| | | "value": 0, |
| | | "value2": 0, |
| | | "address": "DB10.0", |
| | | "state": 1 |
| | | }, |
| | | "type": "3" |
| | | }, |
| | | { |
| | | "button": { |
| | | "name": "A02行走伺服回零", |
| | | "value": 0, |
| | | "value2": 0, |
| | | "address": "DB10.0", |
| | | "state": 1 |
| | | }, |
| | | "type": "3" |
| | | } |
| | | |
| | | |
| | | ] |
| | | ] |
| | |
| | | "sending": 0, |
| | | "type": "0", |
| | | "unit": "mm", |
| | | "value":"0" |
| | | "value":"0", |
| | | "min": 0, |
| | | "max": 100 |
| | | |
| | | }], |
| | | [{ |
| | |
| | | "A01输送反向": "A01 VFD conveyor reverse",
|
| | | "A02输送反向": "A02 VFD conveyor reverse",
|
| | | "A01注电泵": "A01 oil pump",
|
| | | "A02注电泵": "A02 oil pump"
|
| | | "A02注电泵": "A02 oil pump",
|
| | | "A01行走伺服回零":"A01 SERVE TRAVEL Home",
|
| | | "A02行走伺服回零":"A02 SERVE TRAVEL Home"
|
| | | }
|
| | |
|
| | |
|
| | |
| | | }}</router-link> |
| | | <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action') |
| | | }}</router-link> |
| | | <!-- <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action') |
| | | }}</router-link> --> |
| | | <!-- <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter') |
| | | }}</router-link> --> |
| | | <router-link to="/Electrical/Sign" tag="el-button" type="text" active-class="blue-button">{{ $t('Sign') |
| | |
| | | }}</router-link> |
| | | <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action') |
| | | }}</router-link> |
| | | <!-- <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action') |
| | | }}</router-link> --> |
| | | <!-- <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter') |
| | | }}</router-link> --> |
| | | <router-link to="/Electrical/Sign" tag="el-button" type="text" active-class="blue-button">{{ $t('Sign') |
| | |
| | | <div v-for="(item, itemIndex) in dataGroup" :key="itemIndex" class="item-container"> |
| | | <div class="item-row"> |
| | | <span class="name" style="width:250px;">{{ item.name }}</span> |
| | | <el-input v-if="item.type === '0'" v-model="item.value" class="input-box" |
| | | @keyup.enter.native="submitDataToBackend"></el-input> |
| | | <span v-if="item.unit" :name="item.unit" >{{ item.unit }}</span> |
| | | <!-- <el-input v-if="item.type === '0'" |
| | | v-model="item.value" |
| | | class="input-box" |
| | | :oninput="`value=value.replace(/^0|[^0-9]/g,'');if(value<`+item.min+`){value=`+item.value+`}else if(value>`+item.max+`){value=`+item.value+`}`" |
| | | @keyup.enter.native="submitDataToBackend"> |
| | | </el-input> --> |
| | | |
| | | <el-input v-if="item.type === '0'" |
| | | v-model="item.value" |
| | | class="input-box" |
| | | |
| | | @keyup.enter.native="submitDataToBackend"> |
| | | </el-input> |
| | | |
| | | <span v-if="item.unit" :name="item.unit" >{{ item.unit }}</span> |
| | | |
| | | |
| | | |
| | | </div> |
| | | </div> |
| | |
| | | <script> |
| | | import LanguageMixin from '../../lang/LanguageMixin' |
| | | import data from '../../configuration/AutomaticParameterSetting' |
| | | import { throttle } from 'lodash'; |
| | | |
| | | let socket; |
| | | |
| | | export default { |
| | |
| | | }, |
| | | updateButtonValue (dataGroup, itemIndex) { |
| | | this.$set(dataGroup[itemIndex].button, 'value', 1); // 点击按钮后将值改为1 |
| | | }, |
| | | checkInputValue() { |
| | | if (this.item.value < this.item.min || this.item.value > this.item.max) { |
| | | this.item.value = ''; // 清空输入框的值 |
| | | } |
| | | }, |
| | | submitDataToBackend () { |
| | | const inputData = this.jsonData.map(dataGroup => { |
| | |
| | | |
| | | // 收到消息 |
| | | socket.onmessage = (msg) => { |
| | | if (!msg.data) { |
| | | return; // 如果收到空数据,则直接返回,不执行后续逻辑 |
| | | } |
| | | if (!msg.data) { |
| | | return; // 如果收到空数据,则直接返回,不执行后续逻辑 |
| | | } |
| | | |
| | | let obj = JSON.parse(msg.data); |
| | | const jsonData2 = this.jsonData; |
| | | // console.log(obj); |
| | | const handleMouseMove = throttle(function (event) { |
| | | let obj = JSON.parse(msg.data); |
| | | const jsonData2 = this.jsonData; |
| | | |
| | | const inputBox = document.querySelectorAll('.input-box'); |
| | | const target = event.target; |
| | | if (inputBox && Array.from(inputBox).every(box => !box.contains(target))) { |
| | | const parms = obj.params; |
| | | const fanzhuan = obj.fanzhuan; |
| | | const xiaoche = obj.xiaoche; |
| | | const dache = obj.dache1; |
| | | const handleMouseMove = (event) => { |
| | | if (!event || !event.target) { |
| | | return; // 如果 event 或 event.target 不存在,则直接返回,不执行后续逻辑 |
| | | } |
| | | |
| | | const parms2 = obj.params2; |
| | | const fanzhuan2 = obj.fanzhuan2; |
| | | const xiaoche2 = obj.xiaoche2; |
| | | const inputBox = document.querySelectorAll('.input-box'); |
| | | const target = event.target; |
| | | const isMouseInInput = Array.from(inputBox).some(box => box.contains(target)); |
| | | |
| | | // console.log('parms:', parms); |
| | | // console.log('fanzhuan:', fanzhuan); |
| | | // console.log('xiaoche:', xiaoche); |
| | | // console.log('dache:', dache); |
| | | if (!isMouseInInput) { |
| | | const parms = obj.params; |
| | | const fanzhuan = obj.fanzhuan; |
| | | const xiaoche = obj.xiaoche; |
| | | const dache = obj.dache1; |
| | | |
| | | let index = 0; |
| | | for (let i = 0; i < jsonData2.length - 1; i++) { |
| | | let arr = jsonData2[i]; |
| | | const parms2 = obj.params2; |
| | | const fanzhuan2 = obj.fanzhuan2; |
| | | const xiaoche2 = obj.xiaoche2; |
| | | |
| | | for (let j = 0; j < arr.length; j++) { |
| | | let obj = arr[j]; |
| | | if (obj.type === '0' && Object.prototype.hasOwnProperty.call(obj, 'value')) { |
| | | if (Array.isArray(parms) && Array.isArray(parms[0]) && parms[0][index] !== undefined) { |
| | | obj.value = parms[0][index]; |
| | | index++; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (Array.isArray(fanzhuan) && Array.isArray(fanzhuan[0]) && fanzhuan[0][0] !== undefined) { |
| | | jsonData2[4][0]['value'] = fanzhuan[0][0]; |
| | | } |
| | | if (Array.isArray(xiaoche) && Array.isArray(xiaoche[0]) && xiaoche[0][0] !== undefined) { |
| | | jsonData2[3][0]['value'] = xiaoche[0][0]; |
| | | } |
| | | if (Array.isArray(dache) && Array.isArray(dache[0]) && dache[0][0] !== undefined) { |
| | | jsonData2[2][0]['value'] = dache[0][0]; |
| | | } |
| | | |
| | | let index = 0; |
| | | for (let i = 0; i < jsonData2.length - 1; i++) { |
| | | let arr = jsonData2[i]; |
| | | |
| | | |
| | | |
| | | |
| | | let index2 = 0; |
| | | for (let i =5; i < jsonData2.length; i++) { |
| | | let arr = jsonData2[i]; |
| | | |
| | | for (let j = 0; j < arr.length; j++) { |
| | | let obj2 = arr[j]; |
| | | if (obj2.type === '0' && Object.prototype.hasOwnProperty.call(obj2, 'value')) { |
| | | if (Array.isArray(parms2) && Array.isArray(parms2[0]) && parms2[0][index2] !== undefined) { |
| | | obj2.value = parms2[0][index2]; |
| | | index2++; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (Array.isArray(fanzhuan2) && Array.isArray(fanzhuan2[0]) && fanzhuan2[0][0] !== undefined) { |
| | | jsonData2[8][0]['value'] = fanzhuan2[0][0]; |
| | | } |
| | | if (Array.isArray(xiaoche2) && Array.isArray(xiaoche2[0]) && xiaoche2[0][0] !== undefined) { |
| | | jsonData2[9][0]['value'] = xiaoche2[0][0]; |
| | | } |
| | | |
| | | for (let j = 0; j < arr.length; j++) { |
| | | let obj = arr[j]; |
| | | if (obj.type === '0' && Object.prototype.hasOwnProperty.call(obj, 'value')) { |
| | | if (Array.isArray(parms) && Array.isArray(parms[0]) && parms[0][index] !== undefined) { |
| | | obj.value = parms[0][index]; |
| | | index++; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (Array.isArray(fanzhuan) && Array.isArray(fanzhuan[0]) && fanzhuan[0][0] !== undefined) { |
| | | jsonData2[4][0]['value'] = fanzhuan[0][0]; |
| | | } |
| | | if (Array.isArray(xiaoche) && Array.isArray(xiaoche[0]) && xiaoche[0][0] !== undefined) { |
| | | jsonData2[3][0]['value'] = xiaoche[0][0]; |
| | | } |
| | | if (Array.isArray(dache) && Array.isArray(dache[0]) && dache[0][0] !== undefined) { |
| | | jsonData2[2][0]['value'] = dache[0][0]; |
| | | } |
| | | |
| | | let index2 = 0; |
| | | for (let i = 5; i < jsonData2.length; i++) { |
| | | let arr = jsonData2[i]; |
| | | |
| | | for (let j = 0; j < arr.length; j++) { |
| | | let obj2 = arr[j]; |
| | | if (obj2.type === '0' && Object.prototype.hasOwnProperty.call(obj2, 'value')) { |
| | | if (Array.isArray(parms2) && Array.isArray(parms2[0]) && parms2[0][index2] !== undefined) { |
| | | obj2.value = parms2[0][index2]; |
| | | index2++; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (Array.isArray(fanzhuan2) && Array.isArray(fanzhuan2[0]) && fanzhuan2[0][0] !== undefined) { |
| | | jsonData2[8][0]['value'] = fanzhuan2[0][0]; |
| | | } |
| | | if (Array.isArray(xiaoche2) && Array.isArray(xiaoche2[0]) && xiaoche2[0][0] !== undefined) { |
| | | jsonData2[9][0]['value'] = xiaoche2[0][0]; |
| | | } |
| | | } |
| | | }; |
| | | |
| | | setInterval(() => handleMouseMove(event), 1000); // 每隔 1000ms 检测一次鼠标位置 |
| | | |
| | | |
| | | |
| | | }, 50); |
| | | |
| | | document.addEventListener('mouseover', handleMouseMove); |
| | | }; |
| | | |
| | | document.addEventListener('mousemove', event => handleMouseMove(event)); |
| | | }; |
| | | |
| | | |
| | | |
| | |
| | | }); |
| | | |
| | | |
| | | console.log(this.jsonData) |
| | | //console.log(this.jsonData) |
| | | |
| | | } |
| | | |
| | |
| | | }}</router-link> |
| | | <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action') |
| | | }}</router-link> |
| | | <!-- <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action') |
| | | }}</router-link> --> |
| | | <!-- <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter') |
| | | }}</router-link> --> |
| | | <router-link to="/Electrical/Sign" tag="el-button" type="text" active-class="blue-button">{{ $t('Sign') |
| | |
| | | </el-breadcrumb> |
| | | |
| | | <el-row :gutter="40" > |
| | | <el-col :span="16" v-for="(dataGroup, groupIndex) in jsonData" :key="groupIndex"> |
| | | <el-col :span="26" v-for="(dataGroup, groupIndex) in jsonData" :key="groupIndex"> |
| | | <el-card class="json-block" style="width:100%;"> |
| | | |
| | | <div class="button-row" style="display: flex; justify-content: flex-start;flex-wrap:wrap;"> |
| | | <div v-for="(item, itemIndex) in dataGroup" :key="itemIndex" style="margin: 10px;"> |
| | | <el-button v-if="item.button" :name="item.button.name" |
| | | :class="{ 'dow': false, 'op': item.button.value === 1 }" class="action-button" |
| | | @click="updateButtonValue(dataGroup, itemIndex); submitDataToBackend();">{{ |
| | | <el-button v-if="item.button" v-model="item.button.value" :name="item.button.name" style='width:200px;' |
| | | :class="{ 'dow': item.button.value === 0, 'op': item.button.value === 1 }" class="action-button" |
| | | @click="updateButtonValue(dataGroup, itemIndex); submitDataToBackend(item.button.name);">{{ |
| | | item.button.name |
| | | }}</el-button> |
| | | </div> |
| | |
| | | <script> |
| | | import LanguageMixin from '../../lang/LanguageMixin' |
| | | import data from '../../configuration/ManualJog' |
| | | import {SelectPassword} from "../../api/home"; |
| | | let socket; |
| | | export default { |
| | | name: "ManualJog", |
| | | mixins: [LanguageMixin], |
| | | data () { |
| | | return { |
| | | jsonData: data // 加载整个data.json文件作为jsonData |
| | | jsonData: data, // 加载整个data.json文件作为jsonData |
| | | password: 1, |
| | | } |
| | | }, |
| | | activated () { |
| | | |
| | | |
| | | this.initWebSocket(); |
| | | const language = this.$i18n.locale; |
| | |
| | | if (language === 'en-US') { |
| | | this.replaceChineseWithEnglish(); |
| | | } |
| | | this.$forceUpdate(); |
| | | // this.$forceUpdate(); |
| | | |
| | | |
| | | SelectPassword().then(res => { |
| | | this.password = res.data.password; |
| | | console.log(this.password) |
| | | }); |
| | | }, |
| | | methods: { |
| | | closeSocket () { |
| | |
| | | socket.close(); |
| | | }, |
| | | updateButtonValue (dataGroup, itemIndex) { |
| | | if (dataGroup[itemIndex].button.value === 1) { |
| | | if (dataGroup[itemIndex].button.value2 === 0) { |
| | | // 如果当前按钮的值是 0,将其设为 1 |
| | | this.$set(dataGroup[itemIndex].button, 'value', 0); |
| | | this.$set(dataGroup[itemIndex].button, 'value2', 1); |
| | | } else { |
| | | // 否则将其设为 0 |
| | | this.$set(dataGroup[itemIndex].button, 'value', 1); |
| | | this.$set(dataGroup[itemIndex].button, 'value2', 0); |
| | | } |
| | | }, |
| | | submitDataToBackend () { |
| | | const inputData = this.jsonData.map(dataGroup => { |
| | | return dataGroup.map(item => { |
| | | if (item.type === '3') { |
| | | return { value: item.button.value }; |
| | | submitDataToBackend (currentButtonName) { |
| | | |
| | | if (currentButtonName === 'A01 SERVE TRAVEL Home' || currentButtonName === 'A02 SERVE TRAVEL Home' || currentButtonName === 'A01行走伺服回零' || currentButtonName === 'A02行走伺服回零') { |
| | | this.$prompt( |
| | | this.$t('Are you sure to perform this operation?'), |
| | | this.$t('prompt'), |
| | | { |
| | | inputType: 'password', |
| | | inputPlaceholder: this.$t('Please enter the password'), |
| | | confirmButtonText: this.$t('Yes'), |
| | | cancelButtonText: this.$t('No'), |
| | | type: 'warning', |
| | | } |
| | | return null; |
| | | ).then(({ value }) => { |
| | | // 验证密码是否正确 |
| | | if (value !== this.password) { |
| | | this.$message.error(this.$t('Incorrect password')); |
| | | return; |
| | | } |
| | | |
| | | // 密码正确,继续提交数据到后端 |
| | | const inputData = this.jsonData.map(dataGroup => { |
| | | return dataGroup.map(item => { |
| | | if (item.type === '3') { |
| | | return { value: item.button.value2 }; |
| | | } |
| | | return null; |
| | | }); |
| | | }); |
| | | |
| | | const values = inputData.flat().filter(item => item !== null).map(item => item.value); |
| | | |
| | | const jsonObject = { data: values }; |
| | | |
| | | // 提交数据到后端 |
| | | const jsonString = JSON.stringify(jsonObject); |
| | | console.log('Type为3的value:', jsonString); |
| | | socket?.send(jsonString); |
| | | |
| | | }).catch(() => { |
| | | // 取消操作 |
| | | console.log('取消'); |
| | | }); |
| | | }); |
| | | } else { |
| | | // 如果不是 A01 SERVE TRAVEL Home 按钮,继续提交数据到后端 |
| | | const inputData = this.jsonData.map(dataGroup => { |
| | | return dataGroup.map(item => { |
| | | if (item.type === '3') { |
| | | return { value: item.button.value2 }; |
| | | } |
| | | return null; |
| | | }); |
| | | }); |
| | | |
| | | const values = inputData.flat().filter(item => item !== null).map(item => item.value); |
| | | const values = inputData.flat().filter(item => item !== null).map(item => item.value); |
| | | |
| | | const jsonObject = { data: values }; |
| | | const jsonObject = { data: values }; |
| | | |
| | | // 提交数据到后端 |
| | | const jsonString = JSON.stringify(jsonObject); |
| | | console.log('Type为3的value:', jsonString); |
| | | socket?.send(jsonString); |
| | | |
| | | // 提交数据到后端 |
| | | const jsonString = JSON.stringify(jsonObject); |
| | | console.log('Type为3的value:', jsonString); |
| | | socket?.send(jsonString); |
| | | } |
| | | }, |
| | | //根据读取PLC的值,根据名称改变颜色1打开,0关闭 |
| | | // getStatusClass (zhuangtai) { |
| | |
| | | let obj = JSON.parse(msg.data); |
| | | |
| | | const jsonData2 = this.jsonData; |
| | | |
| | | const parms = obj.params; |
| | | // console.log(obj) |
| | | //console.log(this.jsonData) |
| | | if(parms){ |
| | | // 如果鼠标不在输入框内,更新输入框的值 |
| | | // this.submitDataToBackend() |
| | | const parms = obj.params; |
| | | // const xiaoche = obj.params[3]; |
| | | |
| | | // console.log(parms); |
| | | |
| | | if(obj.params){ |
| | | |
| | | |
| | | |
| | | |
| | | for (let i = 0; i < jsonData2.length; i++) { |
| | | let arr = jsonData2[i]; |
| | | for (let j = 0; j < arr.length; j++) { |
| | | let obj = arr[j]; |
| | | obj.button.value = parms[0][j]; |
| | | obj.button.value2 =obj.button.value; |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | }}</router-link>
|
| | | <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State')
|
| | | }}</router-link>
|
| | | <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action')
|
| | | }}</router-link>
|
| | | <!-- <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action')
|
| | | }}</router-link> -->
|
| | | <!-- <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter')
|
| | | }}</router-link> -->
|
| | | <router-link to="/Electrical/Sign" tag="el-button" type="text" active-class="blue-button">{{ $t('Sign')
|
| | |
| | | <div class="item-row">
|
| | | <span class="name" style="width:300px;">{{ item.name }}</span>
|
| | |
|
| | | <el-input style="width:250px;" v-if="item.state != 0 && item.type === '0' && groupIndex === 0" v-model="item.value" @keyup.enter.native="A01start"
|
| | | <el-input style="width:250px;" v-if="item.state != 0 && item.type === '0' && groupIndex === 0 && (itemIndex === 2)" readonly v-model="item.value" |
| | | class="input-box"></el-input>
|
| | |
|
| | | <el-input style="width:250px;" v-else-if="item.state != 0 && item.type === '0' && groupIndex === 0 " v-model="item.value" @keyup.enter.native="A01start"
|
| | | class="input-box"></el-input>
|
| | | <el-input style="width: 250px;" v-else-if="(item.state !== 0) && (item.type === '0') && (itemIndex === 2)" v-model="item.value" readonly class="input-box"></el-input>
|
| | |
|
| | | |
| | | <el-input style="width:250px;" v-else-if="item.state != 0 && item.type === '0' && groupIndex === 1" v-model="item.value" @keyup.enter.native="A02start"
|
| | | class="input-box"></el-input>
|
| | | <el-input style="width:250px;" v-else-if="item.state != 0 && item.type === '0' && groupIndex === 2" v-model="item.value" @keyup.enter.native="B01start"
|
| | |
| | | <div v-for="(item, itemIndex) in dataGroup" :key="itemIndex">
|
| | | <el-button v-if="item.button && language === 'en-US' && item.state != 0" :name="item.button.name"
|
| | | v-model="item.button.value"
|
| | | :class="{ 'action-button': true, 'error-button': item.button.name === 'Fault' && item.button.value === 1, 'error-button2': item.button.name === 'NotZero' && item.button.value === 0,'error-button3': item.button.name === 'NotZero' && item.button.value === 1,'greenbutton': item.button.name !== 'NotZero' && item.button.name !== 'Fault' && item.button.value === 1 }"
|
| | | :class="{ 'action-button': true, 'error-button': item.button.name === 'Fault' && item.button.value === 1, 'error-button2': item.button.name === 'NotZero' && item.button.value === 0,'error-button3': item.button.name === 'Zero' && item.button.value === 1,'greenbutton': item.button.name !== 'NotZero' && item.button.name !== 'Fault' && item.button.value === 1 }"
|
| | | @click="updateButtonValue(dataGroup, itemIndex); submitDataToBackend(item.button.name);">{{
|
| | | item.button.name }}</el-button>
|
| | | <el-button v-if="item.button && language === 'zh-CN' && item.state != 0" :name="item.button.name"
|
| | | v-model="item.button.value"
|
| | | :class="{ 'action-button': true, 'error-button': item.button.name === '故障' && item.button.value === 1, 'error-button2': item.button.name === '未回零' && item.button.value === 0,'error-button3': item.button.name === '未回零' && item.button.value === 1,'greenbutton': item.button.name !== '未回零' && item.button.name !== '故障' && item.button.value === 1 }"
|
| | | :class="{ 'action-button': true, 'error-button': item.button.name === '故障' && item.button.value === 1, 'error-button2': item.button.name === '未回零' && item.button.value === 0,'error-button3': item.button.name === '已回零' && item.button.value === 1,'greenbutton': item.button.name !== '未回零' && item.button.name !== '故障' && item.button.value === 1 }"
|
| | | @click="updateButtonValue(dataGroup, itemIndex); submitDataToBackend(item.button.name);">{{
|
| | | item.button.name }}</el-button>
|
| | | </div>
|
| | |
| | | <script>
|
| | | import LanguageMixin from '../../lang/LanguageMixin'
|
| | | import data from '../../configuration/Manualoneposition'
|
| | | import { throttle } from 'lodash';
|
| | |
|
| | | import ManualonePosition2 from './ManualonePosition2.vue';
|
| | | let socket;
|
| | | export default {
|
| | |
| | | }
|
| | |
|
| | | if (currentButtonName === '故障' || currentButtonName === 'Fault') {
|
| | | return false;
|
| | |
|
| | | const data2 = [];
|
| | | const resetButtonValues = this.jsonData.map(item => {
|
| | | // const buttonItem = item.find(subItem => subItem.button && subItem.button.name === '故障' || subItem.button.name === 'Fault');
|
| | | const buttonItem = item.find(subItem => subItem.button && ['故障', 'Fault'].includes(subItem.button.name));
|
| | | return buttonItem ? buttonItem.button.value : null;
|
| | | }).filter(value => value !== null);
|
| | | // const data2 = [];
|
| | | // const resetButtonValues = this.jsonData.map(item => {
|
| | | // // const buttonItem = item.find(subItem => subItem.button && subItem.button.name === '故障' || subItem.button.name === 'Fault');
|
| | | // const buttonItem = item.find(subItem => subItem.button && ['故障', 'Fault'].includes(subItem.button.name));
|
| | | // return buttonItem ? buttonItem.button.value : null;
|
| | | // }).filter(value => value !== null);
|
| | |
|
| | | // 将得到的值添加到 data 数组中
|
| | | data2.push(...resetButtonValues);
|
| | | data2.unshift([], [], [], []);
|
| | | const jsonObject2 = { data:data2 };
|
| | | data.push([],[]);
|
| | | // // 将得到的值添加到 data 数组中
|
| | | // data2.push(...resetButtonValues);
|
| | | // data2.unshift([], [], [], []);
|
| | | // const jsonObject2 = { data:data2 };
|
| | | // data.push([],[]);
|
| | |
|
| | | // 提交数据到后端
|
| | | const jsonString2 = JSON.stringify(jsonObject2);
|
| | | console.log('所有故障的value:', jsonString2);
|
| | | socket?.send(jsonString2);
|
| | | // // 提交数据到后端
|
| | | // const jsonString2 = JSON.stringify(jsonObject2);
|
| | | // console.log('所有故障的value:', jsonString2);
|
| | | // socket?.send(jsonString2);
|
| | |
|
| | |
|
| | | }
|
| | |
| | |
|
| | | }
|
| | |
|
| | | if (currentButtonName === '回零' || currentButtonName === 'Zero') {
|
| | | if (currentButtonName === '回零' || currentButtonName === 'Home') {
|
| | |
|
| | | const data2 = [];
|
| | | const resetButtonValues = this.jsonData.map(item => {
|
| | | const buttonItem = item.find(subItem => subItem.button && ['回零', 'Zero'].includes(subItem.button.name));
|
| | | const buttonItem = item.find(subItem => subItem.button && ['回零', 'Home'].includes(subItem.button.name));
|
| | |
|
| | | return buttonItem ? buttonItem.button.value : null;
|
| | | }).filter(value => value !== null);
|
| | |
| | | }
|
| | |
|
| | | let obj = JSON.parse(msg.data);
|
| | | // console.log(obj);
|
| | | const jsonData2 = this.jsonData;
|
| | | const weihuiling = obj.weihuiling;
|
| | | const handleMouseMove = throttle(function (event) {
|
| | | const inputBox = document.querySelectorAll('.el-card__body');
|
| | | const target = event.target;
|
| | | if (obj.zuhe1 &&inputBox && Array.from(inputBox).every(box => !box.contains(target))) {
|
| | | const handleMouseMove = (event) => {
|
| | | if (!event || !event.target) {
|
| | | return; // 如果 event 或 event.target 不存在,则直接返回,不执行后续逻辑
|
| | | }
|
| | |
|
| | | const inputBox = document.querySelectorAll('.input-box');
|
| | | const target = event.target;
|
| | | // console.log(obj);
|
| | | |
| | | const isMouseInInput = Array.from(inputBox).some(box => box.contains(target));
|
| | |
|
| | | if (!isMouseInInput) {
|
| | |
|
| | |
|
| | | if(obj.zuhe1){
|
| | |
|
| | |
|
| | | |
| | | // 执行更新逻辑
|
| | | for (let i = 0; i < 4; i++) {
|
| | | jsonData2[i].forEach((item, index) => {
|
| | |
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | |
| | |
|
| | |
|
| | |
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | | }, 50);
|
| | | }
|
| | |
|
| | | document.addEventListener('mouseover', handleMouseMove);
|
| | | // console.log(jsonData2);
|
| | | setInterval(() => handleMouseMove(event), 1000); // 每隔 1000ms 检测一次鼠标位置
|
| | |
|
| | | document.addEventListener('mousemove', event => handleMouseMove(event));
|
| | |
|
| | |
|
| | |
|
| | | if(obj.zuhe1){
|
| | |
| | | <div class="item-row">
|
| | | <span class="name" style="width:300px;">{{ item.name }}</span>
|
| | |
|
| | | <el-input style="width:250px;" v-if="item.state != 0 && item.type === '0' && groupIndex === 0" v-model="item.value" @keyup.enter.native="A01start"
|
| | | |
| | | <el-input style="width:250px;" v-if="item.state != 0 && item.type === '0' && groupIndex === 0 && (itemIndex === 2)" readonly v-model="item.value" |
| | | class="input-box"></el-input>
|
| | | <el-input style="width:250px;" v-else-if="item.state != 0 && item.type === '0' && groupIndex === 1" v-model="item.value" @keyup.enter.native="A02start"
|
| | |
|
| | |
|
| | | <el-input style="width:250px;" v-else-if="item.state != 0 && item.type === '0' && groupIndex === 1 && (itemIndex === 2)" readonly v-model="item.value"
|
| | | class="input-box"></el-input>
|
| | |
|
| | | <el-input style="width:250px;" v-else-if="item.state != 0 && item.type === '0' && groupIndex === 0 " v-model="item.value" @keyup.enter.native="A01start"
|
| | | class="input-box"></el-input>
|
| | |
|
| | |
|
| | | <el-input style="width:250px;" v-else-if="item.state != 0 && item.type === '0' && groupIndex === 1 " v-model="item.value" @keyup.enter.native="A02start"
|
| | | class="input-box"></el-input>
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | <el-input style="width:250px;" v-else-if="item.state != 0 && item.type === '0'" v-model="item.value"
|
| | | class="input-box"></el-input>
|
| | | </div>
|
| | |
| | | <div class="button-row" style="display: flex; justify-content: space-between;">
|
| | | <div v-for="(item, itemIndex) in dataGroup" :key="itemIndex">
|
| | | <el-button v-if="item.button && language === 'en-US'" :name="item.button.name" v-model="item.button.value"
|
| | | :class="{ 'action-button': true, 'error-button': item.button.name === 'Fault' && item.button.value === 1, 'error-button2': item.button.name === 'NotZero' && item.button.value === 0,'greenbutton': item.button.name !== 'NotZero' && item.button.name !== 'Fault' && item.button.value === 1 }"
|
| | | :class="{ 'action-button': true, 'error-button': item.button.name === 'Fault' && item.button.value === 1, 'error-button2': item.button.name === 'NotZero' && item.button.value === 0,'error-button3': item.button.name === 'Zero' && item.button.value ===1,'greenbutton': item.button.name !== 'NotZero' && item.button.name !== 'Fault' && item.button.value === 1 }"
|
| | | @click="updateButtonValue(dataGroup, itemIndex); submitDataToBackend(item.button.name);">{{
|
| | | item.button.name }}</el-button>
|
| | | <el-button v-if="item.button && language === 'zh-CN'" :name="item.button.name" v-model="item.button.value"
|
| | | :class="{ 'action-button': true, 'error-button': item.button.name === '故障' && item.button.value === 1, 'error-button2': item.button.name === '未回零' && item.button.value === 0,'greenbutton': item.button.name !== '未回零' && item.button.name !== '故障' && item.button.value === 1 }"
|
| | | :class="{ 'action-button': true, 'error-button': item.button.name === '故障' && item.button.value === 1, 'error-button2': item.button.name === '未回零' && item.button.value === 0,'error-button3': item.button.name === '已回零' && item.button.value === 1,'greenbutton': item.button.name !== '未回零' && item.button.name !== '故障' && item.button.value === 1 }"
|
| | | @click="updateButtonValue(dataGroup, itemIndex); submitDataToBackend(item.button.name);">{{
|
| | | item.button.name }}</el-button>
|
| | | </div>
|
| | |
| | | <script>
|
| | | import LanguageMixin from '../../lang/LanguageMixin'
|
| | | import data from '../../configuration/Manualoneposition2'
|
| | | import { throttle } from 'lodash';
|
| | |
|
| | | let socket;
|
| | | export default {
|
| | | name: "ManualonePosition2",
|
| | |
| | | }
|
| | |
|
| | | if (currentButtonName === '故障' || currentButtonName === 'Fault') {
|
| | | return false;
|
| | |
|
| | | const data2 = [];
|
| | | const resetButtonValues = this.jsonData.map(item => {
|
| | | const buttonItem = item.find(subItem => subItem.button && ['故障', 'Fault'].includes(subItem.button.name));
|
| | | // const data2 = [];
|
| | | // const resetButtonValues = this.jsonData.map(item => {
|
| | | // const buttonItem = item.find(subItem => subItem.button && ['故障', 'Fault'].includes(subItem.button.name));
|
| | |
|
| | | return buttonItem ? buttonItem.button.value : null;
|
| | | }).filter(value => value !== null);
|
| | | // return buttonItem ? buttonItem.button.value : null;
|
| | | // }).filter(value => value !== null);
|
| | |
|
| | | // 将得到的值添加到 data 数组中
|
| | | data2.push(...resetButtonValues);
|
| | | data2.unshift([], []);
|
| | | const jsonObject2 = { data2 };
|
| | | data2.push([], []);
|
| | | // // 将得到的值添加到 data 数组中
|
| | | // data2.push(...resetButtonValues);
|
| | | // data2.unshift([], []);
|
| | | // const jsonObject2 = { data2 };
|
| | | // data2.push([], []);
|
| | |
|
| | | // 提交数据到后端
|
| | | const jsonString2 = JSON.stringify(jsonObject2);
|
| | | console.log('所有故障的value:', jsonString2);
|
| | | socket?.send(jsonString2);
|
| | | // // 提交数据到后端
|
| | | // const jsonString2 = JSON.stringify(jsonObject2);
|
| | | // console.log('所有故障的value:', jsonString2);
|
| | | // socket?.send(jsonString2);
|
| | |
|
| | |
|
| | | }
|
| | |
| | |
|
| | | }
|
| | |
|
| | | if (currentButtonName === '回零' || currentButtonName === 'Zero') {
|
| | | if (currentButtonName === '回零' || currentButtonName === 'Home') {
|
| | |
|
| | | const data2 = [];
|
| | | const resetButtonValues = this.jsonData.map(item => {
|
| | | const buttonItem = item.find(subItem => subItem.button && ['回零', 'Zero'].includes(subItem.button.name));
|
| | | const buttonItem = item.find(subItem => subItem.button && ['回零', 'Home'].includes(subItem.button.name));
|
| | |
|
| | | return buttonItem ? buttonItem.button.value : null;
|
| | | }).filter(value => value !== null);
|
| | |
| | | }
|
| | |
|
| | | let obj = JSON.parse(msg.data);
|
| | |
|
| | |
|
| | | // console.log(obj)
|
| | | const jsonData2 = this.jsonData;
|
| | | const weihuiling = obj.weihuiling;
|
| | | const handleMouseMove = throttle(function (event) {
|
| | | const inputBox = document.querySelectorAll('.el-card__body');
|
| | | const target = event.target;
|
| | | if (obj.zuhe1 && inputBox && Array.from(inputBox).every(box => !box.contains(target))) {
|
| | | const handleMouseMove = (event) => {
|
| | | if (!event || !event.target) {
|
| | | return; // 如果 event 或 event.target 不存在,则直接返回,不执行后续逻辑
|
| | | }
|
| | |
|
| | | const inputBox = document.querySelectorAll('.input-box');
|
| | | const target = event.target;
|
| | | // console.log(obj);
|
| | | |
| | | const isMouseInInput = Array.from(inputBox).some(box => box.contains(target));
|
| | | |
| | |
|
| | | if (!isMouseInInput) {
|
| | | |
| | | if (obj.zuhe1 ) {
|
| | | // 执行更新逻辑
|
| | | for (let i = 0; i < 2; i++) {
|
| | | jsonData2[i].forEach((item, index) => {
|
| | |
| | |
|
| | |
|
| | | }
|
| | | }, 50);
|
| | | |
| | |
|
| | | document.addEventListener('mouseover', handleMouseMove);
|
| | | }
|
| | | |
| | | }
|
| | | // console.log(jsonData2);
|
| | | setInterval(() => handleMouseMove(event), 1000); // 每隔 1000ms 检测一次鼠标位置
|
| | |
|
| | | document.addEventListener('mousemove', event => handleMouseMove(event));
|
| | |
|
| | |
|
| | | if(obj.zuhe1){
|
| | |
| | |
|
| | | background-color: green;
|
| | | }
|
| | |
|
| | | .error-button3{
|
| | | background-color: green;
|
| | |
|
| | |
|
| | | }
|
| | | </style> |
| | |
| | | if (typeof WebSocket === "undefined") {
|
| | | console.log("您的浏览器不支持WebSocket");
|
| | | } else {
|
| | | let socketUrl = "ws://" + "localhost:8888" + "/springboot-vue3/api/talk/" + viewname;
|
| | | let socketUrl = "ws://" + "192.168.10.21:8888" + "/springboot-vue3/api/talk/" + viewname;
|
| | |
|
| | | if (socket != null) {
|
| | | socket.close();
|
| | |
| | | }}</router-link> |
| | | <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action') |
| | | }}</router-link> |
| | | <!-- <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action') |
| | | }}</router-link> --> |
| | | <!-- <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter') |
| | | }}</router-link> --> |
| | | <router-link to="/Electrical/Sign" tag="el-button" type="text" active-class="blue-button">{{ $t('Sign') |
| | |
| | | active-class="blue-button" |
| | | >{{ $t("State") }}</router-link |
| | | > |
| | | <router-link |
| | | <!-- <router-link |
| | | to="/Electrical/Action" |
| | | tag="el-button" |
| | | type="text" |
| | | active-class="blue-button" |
| | | >{{ $t("Action") }}</router-link |
| | | > |
| | | >{{ $t("Action") }}</router-link --> |
| | | |
| | | <!-- <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter') |
| | | }}</router-link> --> |
| | | <router-link |
| | |
| | | item.button.value === 2 && item.button.name !== 'Clear ID', |
| | | 'yellow-button': |
| | | item.button.value === 1 && item.button.name !== 'Clear ID', |
| | | id: item.button.value === 1 && item.button.name == 'Clear ID', |
| | | 'id': item.button.value === 1 && item.button.name === 'Clear ID', |
| | | }" |
| | | >{{ item.button.name }}</el-button |
| | | > |
| | |
| | | item.button.value === 2 && item.button.name !== '清除ID', |
| | | 'yellow-button': |
| | | item.button.value === 1 && item.button.name !== '清除ID', |
| | | id: item.button.value === 1 && item.button.name == '清除ID', |
| | | 'id': item.button.value === 1 && item.button.name === '清除ID', |
| | | }" |
| | | >{{ item.button.name }}</el-button |
| | | > |
| | |
| | | }, |
| | | |
| | | updateButtonValue(dataGroup, itemIndex) { |
| | | if (dataGroup[itemIndex].button.value === 0) { |
| | | // 如果当前按钮的值是 0,将其设为 1 |
| | | this.$set(dataGroup[itemIndex].button, "value", 1); |
| | | } else { |
| | | // 否则将其设为 0 |
| | | this.$set(dataGroup[itemIndex].button, "value", 0); |
| | | } |
| | | }, |
| | | if (dataGroup[itemIndex].button.value === 1) { |
| | | // 如果当前按钮的值是 0,将其设为 1 |
| | | this.$set(dataGroup[itemIndex].button, 'value', 0); |
| | | } else { |
| | | // 否则将其设为 0 |
| | | this.$set(dataGroup[itemIndex].button, 'value', 1); |
| | | } |
| | | }, |
| | | submitDataToBackend(currentButtonName) { |
| | | if (currentButtonName === "清除ID" || currentButtonName === "Clear ID") { |
| | | const data2 = []; |
| | |
| | | |
| | | const parms = obj.params; |
| | | |
| | | console.log(obj); |
| | | // console.log(obj); |
| | | |
| | | // const handleMouseMove = throttle(function(event) { |
| | | // const inputBox = document.querySelectorAll('.id'); |
| | | // const target = event.target; |
| | | |
| | | // if (parms && inputBox && Array.from(inputBox).every(box => !box.contains(target))) { |
| | | if (parms ) { |
| | | //急停按钮 |
| | | jsonData2[13][0].button.value = obj.jiting[0][0]; |
| | | |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | |
| | | // console.log(jsonData2); |
| | | // }, 50); |
| | | |
| | |
| | | active-class="blue-button" |
| | | >{{ $t("State") }}</router-link |
| | | > |
| | | <router-link |
| | | <!-- <router-link |
| | | to="/Electrical/Action" |
| | | tag="el-button" |
| | | type="text" |
| | | active-class="blue-button" |
| | | >{{ $t("Action") }}</router-link |
| | | > |
| | | > --> |
| | | <!-- <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter') |
| | | }}</router-link> --> |
| | | <router-link |
| | |
| | | |
| | | // 提交数据到后端 |
| | | const jsonString = JSON.stringify(jsonObject); |
| | | // console.log('提交以下数据到后端:', jsonString); |
| | | console.log('提交以下数据到后端:', jsonString); |
| | | socket?.send(jsonString); |
| | | }, |
| | | initWebSocket() { |
| | |
| | | |
| | | // 收到消息 |
| | | socket.onmessage = (msg) => { |
| | | if (!msg.data) { |
| | | return; // 如果收到空数据,则直接返回,不执行后续逻辑 |
| | | } |
| | | if (!msg.data) { |
| | | return; // 如果收到空数据,则直接返回,不执行后续逻辑 |
| | | } |
| | | |
| | | let obj = JSON.parse(msg.data); |
| | | const jsonData2 = this.jsonData; |
| | | document.addEventListener("mouseover", function (event) { |
| | | const inputBox = document.querySelectorAll(".input-box"); |
| | | const target = event.target; |
| | | let obj = JSON.parse(msg.data); |
| | | const jsonData2 = this.jsonData; |
| | | |
| | | const handleMouseMove = (event) => { |
| | | if (!event || !event.target) { |
| | | return; // 如果 event 或 event.target 不存在,则直接返回,不执行后续逻辑 |
| | | } |
| | | |
| | | const inputBox = document.querySelectorAll('.input-box'); |
| | | const target = event.target; |
| | | const isMouseInInput = Array.from(inputBox).some(box => box.contains(target)); |
| | | |
| | | if (!isMouseInInput) { |
| | | |
| | | |
| | | const parms = obj.params; |
| | | if ( |
| | | parms && |
| | | inputBox && |
| | | Array.from(inputBox).every((box) => !box.contains(target)) |
| | | ) { |
| | | |
| | | // 如果鼠标不在输入框内,更新输入框的值 |
| | | // this.submitDataToBackend() |
| | | |
| | | // console.log(parms) |
| | | if(parms){ |
| | | |
| | | |
| | | |
| | | let index = 0; |
| | | for (let i = 0; i < jsonData2.length; i++) { |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // console.log(jsonData2); |
| | | } |
| | | }); |
| | | }; |
| | | setInterval(() => handleMouseMove(event), 1000); // 每隔 1000ms 检测一次鼠标位置 |
| | | |
| | | document.addEventListener('mousemove', event => handleMouseMove(event)); |
| | | }; |
| | | |
| | | |
| | | // 关闭事件 |
| | | socket.onclose = function () { |
| | |
| | | }}</router-link> |
| | | <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action') |
| | | }}</router-link> |
| | | <!-- <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action') |
| | | }}</router-link> --> |
| | | <!-- <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter') |
| | | }}</router-link> --> |
| | | <router-link to="/Electrical/Sign" tag="el-button" type="text" active-class="blue-button">{{ $t('Sign') |
| | |
| | | }}</router-link> |
| | | <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action') |
| | | }}</router-link> |
| | | <!-- <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action') |
| | | }}</router-link> --> |
| | | <!-- <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter') |
| | | }}</router-link> --> |
| | | <router-link to="/Electrical/Sign" tag="el-button" type="text" active-class="blue-button">{{ $t('Sign') |
| | |
| | | |
| | | <el-input v-if="item.type === '0' && groupIndex === 0" v-model="item.value" @keyup.enter.native="zuhe1" class='input-box' :class="{ 'special-class': groupIndex === 0,'special-class2': groupIndex === 1 }" v-show="groupIndex !== 0 && groupIndex !== 1" ></el-input> |
| | | <el-input v-else-if="item.type === '0' && groupIndex === 1" v-model="item.value" @keyup.enter.native="zuhe2" class='input-box' :class="{ 'special-class': groupIndex === 0,'special-class2': groupIndex === 1 }" v-show="groupIndex !== 0 && groupIndex !== 1" ></el-input> |
| | | <el-input v-else-if="item.type === '0' && groupIndex === 2" v-model="item.value" readonly class='input-box' ></el-input> |
| | | <el-input v-else-if="item.type === '0' && groupIndex === 3" v-model="item.value" readonly class='input-box' ></el-input> |
| | | <el-input v-else-if="item.type === '0' && groupIndex === 4" v-model="item.value" readonly class='input-box' ></el-input> |
| | | <el-input v-else-if="item.type === '0' && groupIndex === 5" v-model="item.value" readonly class='input-box' ></el-input> |
| | | <el-input v-else-if="item.type === '0' " v-model="item.value" class='input-box' :class="{ 'special-class': groupIndex === 0,'special-class2': groupIndex === 1 }" v-show="groupIndex !== 0 && groupIndex !== 1" ></el-input> |
| | | </div> |
| | | </div> |
| | |
| | | </el-row> |
| | | <div class="button-row" style="display: flex; justify-content: space-between;"> |
| | | <div v-for="(item, itemIndex) in dataGroup" :key="itemIndex"> |
| | | <el-button v-if="item.button && language === 'en-US' " :name="item.button.name" v-model="item.button.value" :class="{'action-button': true, 'error-button': item.button.name === 'Fault' && item.button.value === 1,'error-button2': item.button.name === 'NotZero' && item.button.value === 0,'error-button3': item.button.name === 'NotZero' && item.button.value === 1,'fuwei': item.button.name === 'Reset' && item.button.value === 1,'huiling': item.button.name === 'Home' && item.button.value === 1,'qidong': item.button.name === 'A01 Semi-Auto' && item.button.value === 1,'qidong2': item.button.name === 'A02 Semi-Auto' && item.button.value === 1,'qidong3': item.button.name === 'A01 Semi-Auto Start' && item.button.value === 1,'qidong4': item.button.name === 'A02 Semi-Auto Start' && item.button.value === 1,'qidong5': item.button.name === 'A02 Semi-Auto' && item.button.value === 1,'jiting': item.button.name === 'Abort/ResumeTasks' && item.button.value === 1,'yihuiling': item.button.name === 'Zero' && item.button.value === 1}" @click="updateButtonValue(dataGroup, itemIndex); submitDataToBackend(item.button.name);">{{ item.button.name }}</el-button> |
| | | <el-button v-if="item.button && language === 'zh-CN' " :name="item.button.name" v-model="item.button.value" :class="{'action-button': true, 'error-button': item.button.name === '故障' && item.button.value === 1,'error-button3': item.button.name === '未回零' && item.button.value === 1,'error-button2': item.button.name === '未回零' && item.button.value === 0,'fuwei': item.button.name === '复位' && item.button.value === 1,'huiling': item.button.name === '回零' && item.button.value === 1,'qidong': item.button.name === 'A01半自动' && item.button.value === 1,'qidong2': item.button.name === 'A02半自动' && item.button.value === 1,'qidong3': item.button.name === 'A01半自动启动' && item.button.value === 1,'qidong4': item.button.name === 'A02半自动启动' && item.button.value === 1,'qidong5': item.button.name === 'A02半自动' && item.button.value === 1,'jiting': item.button.name === '急停后中止/继续选择' && item.button.value === 1,'yihuiling': item.button.name === '已回零' && item.button.value === 1 }" @click="updateButtonValue(dataGroup, itemIndex); submitDataToBackend(item.button.name);">{{ item.button.name }}</el-button> |
| | | <el-button v-if="item.button && language === 'en-US' " :name="item.button.name" v-model="item.button.value" :class="{'action-button': true, 'error-button': item.button.name === 'Fault' && item.button.value === 1,'error-button2': item.button.name === 'NotZero' && item.button.value === 0,'error-button3': item.button.name === 'Zero' && item.button.value === 1,'fuwei': item.button.name === 'Reset' && item.button.value === 1,'huiling': item.button.name === 'Home' && item.button.value === 1,'qidong': item.button.name === 'A01 Semi-Auto' && item.button.value === 1,'qidong2': item.button.name === 'A02 Semi-Auto' && item.button.value === 1,'qidong3': item.button.name === 'A01 Semi-Auto Start' && item.button.value === 1,'qidong4': item.button.name === 'A02 Semi-Auto Start' && item.button.value === 1,'qidong5': item.button.name === 'A02 Semi-Auto' && item.button.value === 1,'jiting': item.button.name === 'Abort/ResumeTasks' && item.button.value === 1,'yihuiling': item.button.name === 'Zero' && item.button.value === 1}" @click="updateButtonValue(dataGroup, itemIndex); submitDataToBackend(item.button.name);">{{ item.button.name }}</el-button> |
| | | <el-button v-if="item.button && language === 'zh-CN' " :name="item.button.name" v-model="item.button.value" :class="{'action-button': true, 'error-button': item.button.name === '故障' && item.button.value === 1,'error-button3': item.button.name === '已回零' && item.button.value === 1,'error-button2': item.button.name === '未回零' && item.button.value === 0,'fuwei': item.button.name === '复位' && item.button.value === 1,'huiling': item.button.name === '回零' && item.button.value === 1,'qidong': item.button.name === 'A01半自动' && item.button.value === 1,'qidong2': item.button.name === 'A02半自动' && item.button.value === 1,'qidong3': item.button.name === 'A01半自动启动' && item.button.value === 1,'qidong4': item.button.name === 'A02半自动启动' && item.button.value === 1,'qidong5': item.button.name === 'A02半自动' && item.button.value === 1,'jiting': item.button.name === '急停后中止/继续选择' && item.button.value === 1,'yihuiling': item.button.name === '已回零' && item.button.value === 1 }" @click="updateButtonValue(dataGroup, itemIndex); submitDataToBackend(item.button.name);">{{ item.button.name }}</el-button> |
| | | </div> |
| | | </div> |
| | | </el-card> |
| | |
| | | <script> |
| | | import LanguageMixin from '../../lang/LanguageMixin' |
| | | import data from '../../configuration/ServoManualone' |
| | | import { throttle } from 'lodash'; |
| | | |
| | | let socket; |
| | | export default { |
| | |
| | | |
| | | }, |
| | | submitDataToBackend(currentButtonName) { |
| | | |
| | | //A01半自动启动提交 |
| | | if (currentButtonName === 'A01半自动启动' ||currentButtonName === 'A01 Semi-Auto Start') { |
| | | const data = []; |
| | | |
| | | |
| | | const values = [this.jsonData[0][10].button.value] |
| | | |
| | | data.push(values); |
| | | |
| | | |
| | | data.unshift([], [],[],[], [],[],[], []); |
| | | |
| | | |
| | | const jsonObject = { data }; |
| | | |
| | | // 提交数据到后端 |
| | | const jsonString = JSON.stringify(jsonObject); |
| | | console.log('所有Type为0的value:', jsonString); |
| | | socket?.send(jsonString); |
| | | |
| | | } |
| | | //A02半自动启动 提交 |
| | | |
| | | if (currentButtonName === 'A02半自动启动' ||currentButtonName === 'A02 Semi-Auto Start') { |
| | | const data2 = []; |
| | | |
| | | const values2 = [this.jsonData[1][8].button.value] |
| | | |
| | | data2.push(values2); |
| | | |
| | | |
| | | data2.unshift([],[], [],[],[], [],[],[], []); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | const jsonObject = { data:data2 }; |
| | | |
| | | // 提交数据到后端 |
| | | const jsonString = JSON.stringify(jsonObject); |
| | | console.log('所有Type为0的value:', jsonString); |
| | | socket?.send(jsonString); |
| | | const data = []; |
| | | let jsonObject; |
| | | if (currentButtonName === '故障' || currentButtonName === 'Fault') { |
| | | return false; |
| | | |
| | | } |
| | | |
| | | //复位提交 |
| | | if (currentButtonName === 'A01半自动启动' || currentButtonName === 'A01 Semi-Auto Start') { |
| | | const values = [this.jsonData[0][10].button.value]; |
| | | data.push(values); |
| | | data.unshift([], [],[],[], [],[],[], []); |
| | | jsonObject = { data }; |
| | | } |
| | | |
| | | if (currentButtonName === 'A02半自动启动' || currentButtonName === 'A02 Semi-Auto Start') { |
| | | const values2 = [this.jsonData[1][8].button.value]; |
| | | data.push(values2); |
| | | data.unshift([],[], [],[],[], [],[],[], []); |
| | | jsonObject = { data }; |
| | | } |
| | | |
| | | if (currentButtonName === '复位' || currentButtonName === 'Reset') { |
| | | const data2 = []; |
| | | const resetButtonValues = this.jsonData.map(item => { |
| | | const buttonItem = item.find(subItem => subItem.button && ['复位', 'Reset'].includes(subItem.button.name)); |
| | | const resetButtonValues = this.jsonData |
| | | .map(item => item.find(subItem => subItem.button && ['复位', 'Reset'].includes(subItem.button.name))) |
| | | .filter(value => value !== null) |
| | | .map(item => item.button.value); |
| | | |
| | | |
| | | return buttonItem ? buttonItem.button.value : null; |
| | | }).filter(value => value !== null); |
| | | data.push(resetButtonValues.flat()); |
| | | data.unshift([], []); |
| | | data.push([], [], [], [], []); |
| | | jsonObject = { data }; |
| | | } |
| | | |
| | | // 将得到的值添加到 data 数组中 |
| | | data2.push(resetButtonValues.flat()); |
| | | |
| | | // 在 data2 数组前面添加两个空数组 |
| | | data2.unshift([], []); |
| | | data2.push([], [], [], [], []); |
| | | |
| | | // 创建 jsonObject2 对象,并添加 data2 属性 |
| | | const jsonObject2 = { data: data2 }; |
| | | |
| | | // 提交数据到后端 |
| | | const jsonString2 = JSON.stringify(jsonObject2); |
| | | console.log('所有Type为0的value:', jsonString2); |
| | | socket?.send(jsonString2); |
| | | // setTimeout(()=> |
| | | // window.location.reload(),2000 |
| | | // ) |
| | | |
| | | } |
| | | ////回零提交 |
| | | if (currentButtonName === '回零' || currentButtonName === 'Home') { |
| | | if (currentButtonName === '回零' || currentButtonName === 'Home') { |
| | | const data3 = []; |
| | | const resetButtonValues3 = this.jsonData.map(item => { |
| | | const buttonItem3 = item.find(subItem => subItem.button && ['回零', 'Home'].includes(subItem.button.name)); |
| | |
| | | data3.push([], [], [], []); |
| | | |
| | | // 创建 jsonObject3 对象,并添加 data3 属性 |
| | | const jsonObject3 = { data: data3 }; |
| | | jsonObject = { data: data3 }; |
| | | |
| | | // 提交数据到后端 |
| | | const jsonString3 = JSON.stringify(jsonObject3); |
| | | console.log('回零:', jsonString3); |
| | | socket?.send(jsonString3); |
| | | // setTimeout(()=> |
| | | // window.location.reload(),2000 |
| | | // ) |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | //A01半自动提交 |
| | | |
| | | if (currentButtonName === 'A01半自动' || currentButtonName === 'A01 Semi-Auto' ) { |
| | | const elements = document.getElementsByClassName('special-class'); |
| | | const data = []; |
| | |
| | | |
| | | |
| | | |
| | | const jsonObject = { data }; |
| | | jsonObject = { data }; |
| | | |
| | | // 提交数据到后端 |
| | | const jsonString = JSON.stringify(jsonObject); |
| | | console.log('所有Type为0的value:', jsonString); |
| | | socket?.send(jsonString); |
| | | |
| | | } |
| | | |
| | |
| | | data.unshift([],[],[],[],[],[],[]); |
| | | |
| | | |
| | | const jsonObject = { data }; |
| | | jsonObject = { data }; |
| | | |
| | | // 提交数据到后端 |
| | | const jsonString = JSON.stringify(jsonObject); |
| | | console.log('所有Type为0的value:', jsonString); |
| | | socket?.send(jsonString); |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | const jsonString = JSON.stringify(jsonObject); |
| | | console.log('所有Type为0的value:', jsonString); |
| | | socket?.send(jsonString); |
| | | |
| | | }, |
| | | |
| | | |
| | | initWebSocket () { |
| | | |
| | |
| | | } |
| | | |
| | | let obj = JSON.parse(msg.data); |
| | | console.log(obj) |
| | | |
| | | |
| | | |
| | | |
| | | // console.log(obj) |
| | | const weihuiling=obj.weihuiling; |
| | | const jsonData2 = this.jsonData; |
| | | const handleMouseMove = (event) => { |
| | | if (!event || !event.target) { |
| | | return; // 如果 event 或 event.target 不存在,则直接返回,不执行后续逻辑 |
| | | } |
| | | |
| | | const handleMouseMove = throttle(function(event) { |
| | | const inputBox = document.querySelectorAll('.el-card__body'); |
| | | const target = event.target; |
| | | if (obj.zuhe1 && inputBox && Array.from(inputBox).every(box => !box.contains(target))) { |
| | | const inputBox = document.querySelectorAll('.input-box'); |
| | | const target = event.target; |
| | | // console.log(obj); |
| | | |
| | | const isMouseInInput = Array.from(inputBox).some(box => box.contains(target)); |
| | | |
| | | |
| | | if (!isMouseInInput) { |
| | | |
| | | if (obj.zuhe1) { |
| | | |
| | | //启动按钮 |
| | | |
| | |
| | | |
| | | |
| | | } |
| | | }, 50); |
| | | |
| | | document.addEventListener('mouseover', handleMouseMove); |
| | | } |
| | | |
| | | } |
| | | // console.log(jsonData2); |
| | | setInterval(() => handleMouseMove(event), 1000); // 每隔 1000ms 检测一次鼠标位置 |
| | | |
| | | document.addEventListener('mousemove', event => handleMouseMove(event)); |
| | | |
| | | if (obj.qidong){ |
| | | |
| | |
| | | }}</router-link> |
| | | <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action') |
| | | }}</router-link> |
| | | <!-- <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action') |
| | | }}</router-link> --> |
| | | <!-- <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter') |
| | | }}</router-link> --> |
| | | <router-link to="/Electrical/Sign" tag="el-button" type="text" active-class="blue-button">{{ $t('Sign') |
| | |
| | | }}</router-link>
|
| | | <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State')
|
| | | }}</router-link>
|
| | | <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action')
|
| | | }}</router-link>
|
| | | <!-- <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action')
|
| | | }}</router-link> -->
|
| | | <!-- <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter')
|
| | | }}</router-link> -->
|
| | | <router-link to="/Electrical/Sign" tag="el-button" type="text" active-class="blue-button">{{ $t('Sign')
|
| | |
| | | }}</router-link>
|
| | | <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State')
|
| | | }}</router-link>
|
| | | <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action')
|
| | | }}</router-link>
|
| | | <!-- <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action')
|
| | | }}</router-link> -->
|
| | | <!-- <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter')
|
| | | }}</router-link> -->
|
| | | <router-link to="/Electrical/Sign" tag="el-button" type="text" active-class="blue-button">{{ $t('Sign')
|
| | |
| | | |
| | | <router-link to="/Electrical/alarm" tag="el-button" type="text" active-class="blue-button">{{ $t('Alarm') }}</router-link> |
| | | <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State') }}</router-link> |
| | | <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action') }}</router-link> |
| | | <!-- <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action') }}</router-link> --> |
| | | <!-- <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter') }}</router-link> --> |
| | | <router-link to="/Electrical/Sign" tag="el-button" type="text" active-class="blue-button">{{ $t('Sign') }}</router-link> |
| | | <router-link to="/Electrical/Servomanual" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter') |
| | |
| | | <template> |
| | | <div class="container"> |
| | | <iframe src="http://localhost:8080/GERP/optimize/optimize/html/youhuacaidan.jsp"></iframe> |
| | | <!-- <iframe src="http://localhost:8080/GERP/optimize/optimize/html/youhuacaidan.jsp"></iframe> --> |
| | | </div> |
| | | </template> |
| | | |
| | | |
| | | <style> |
| | | .container { |
| | | position: fixed; |
| | |
| | | </el-table-column>
|
| | | <el-table-column :min-width="250" :label="$t('Operate')">
|
| | | <template slot-scope='scope'>
|
| | | <el-button type="primary" style="padding: 4px 10px;font-size: 12px;" :disabled="scope.row.state == 1 ? false : true"
|
| | | <el-button type="primary" style="padding: 4px 10px;font-size: 12px;"
|
| | | :disabled="scope.row.state == 1 ? false : true"
|
| | | @click="deleteglass(scope.row.glassId, scope.row.state)">{{ $t('Delete') }}</el-button>
|
| | | <el-button type="primary" style="padding: 4px 10px;font-size: 12px;"
|
| | | :disabled="scope.row.state == 1 ? false : true"
|
| | |
| | | <el-table-column prop="storageCage.glassheightmm" :label="$t('Width')"></el-table-column>
|
| | | <el-table-column :min-width="90" prop="state" :label="$t('Glass State')">
|
| | | <template slot-scope='scope'>
|
| | | {{ scope.row.state == 0 ? $t('Waiting') : scope.row.state == 1 ? $t('Outing') : scope.row.state == 2 ? $t('Completed') :scope.row.state == 3 ? $t('Absent') :$t('Deleted') }}
|
| | | {{ scope.row.state == 0 ? $t('Waiting') : scope.row.state == 1 ? $t('Outing') : scope.row.state == 2
|
| | | ? $t('Completed') : scope.row.state == 3 ? $t('Absent') : $t('Deleted') }}
|
| | | </template>
|
| | | </el-table-column>
|
| | | <el-table-column prop="sequence" :label="$t('Sequence')"></el-table-column>
|
| | |
| | |
|
| | | <el-table-column prop="barcode" :label="$t('Complete')">
|
| | | <template slot-scope='scope'>
|
| | | <el-button type="primary" style="padding: 4px 10px;font-size: 12px;" :disabled="(!isAllowQueue||scope.row.state!=1)"
|
| | | <el-button type="primary" style="padding: 4px 10px;font-size: 12px;"
|
| | | :disabled="(!isAllowQueue || scope.row.state != 1)"
|
| | | @click="CompleteQueue(scope.row.id, scope.row.barcode, scope.row.glassId)">{{ $t('Complete')
|
| | | }}</el-button>
|
| | | </template>
|
| | |
| | | </el-dialog>
|
| | |
|
| | | <el-dialog :visible.sync="dialogFormCountDown" :title="$t('Approximately resettable time')" top="5vh">
|
| | | <div style="font-size: 500px;text-align: center;">
|
| | | <div :style="'font-size: ' + PromptSize + 'px;text-align: center;'">
|
| | | {{ this.CountDowns }}
|
| | | </div>
|
| | | </el-dialog>
|
| | |
| | | dialogFormVisible5: false,
|
| | | dialogFormVisible6: false,
|
| | | dialogFormVisible7: false,
|
| | | dialogFormCountDown:false,
|
| | | dialogFormCountDown: false,
|
| | | form: {
|
| | | orderId: "",
|
| | | glassId: "",
|
| | |
| | | OutingQueue: true,
|
| | | OrderInfo: true,
|
| | | CageDetails: true,
|
| | | CountDowns:0,
|
| | | D01RequestState:false
|
| | | CountDowns: "EMERGENCY STOP",
|
| | | D01RequestState: false,
|
| | | EmergencyStop: false,
|
| | | PromptSize: 250
|
| | | };
|
| | | },
|
| | | created() {
|
| | | this.load();
|
| | | |
| | |
|
| | | this.init();
|
| | | }
|
| | | ,
|
| | | methods: {
|
| | |
|
| | |
|
| | | init() {
|
| | | let viewname = "Home";
|
| | | if (typeof (WebSocket) == "undefined") {
|
| | |
| | | //console.log("您的浏览器支持WebSocket");
|
| | | let socketUrl = "ws://" + this.$t('ip') + ":8888" + "/springboot-vue3/api/talk/" + viewname;
|
| | | if (socket != null) {
|
| | | socket.close();this.car1
|
| | | socket.close();
|
| | | socket = null;
|
| | | }
|
| | | // 开启一个websocket服务
|
| | |
| | | //console.log("收到数据====" + msg.data);
|
| | | let obj = JSON.parse(msg.data);
|
| | | if (obj.params != null) {
|
| | | |
| | |
|
| | | this.car1 = 145 + 8.15 * Math.abs(obj.params[0][0] - this.carlist[0]['start']) / Math.abs(this.carlist[0]['end'] - this.carlist[0]['start']) * 100;
|
| | | this.car2 = 210 + 8.15 * Math.abs(obj.params[0][1] - this.carlist[1]['start']) / Math.abs(this.carlist[1]['end'] - this.carlist[1]['start']) * 100;
|
| | | // this.car1 = 210 + 11.25 * (obj.params[0][1]-this.carlist[1]['start'])/(this.carlist[1]['end']-this.carlist[1]['start'])*100;
|
| | |
| | | this.tasklist1 = obj.tasklist1[0];
|
| | | this.tasklist2 = obj.tasklist2[0];
|
| | | this.alarm = obj.alarmmg[0];
|
| | | if(this.alarm.length>0){
|
| | | this.dialogFormVisible2=true;
|
| | | if (this.alarm.length > 0) {
|
| | | this.dialogFormVisible2 = true;
|
| | | } else {
|
| | | this.dialogFormVisible2 = false;
|
| | | }
|
| | | //是否急停
|
| | | this.EmergencyStop = obj.emergencystop[0];
|
| | |
|
| | | //复位倒计时
|
| | | if (obj.countdown[0] == true&&this.CountDowns==0) {
|
| | | if ((obj.countdown[0] == true && this.CountDowns == 0) || this.EmergencyStop == true) {
|
| | | this.CountDown();
|
| | | }
|
| | | //是否有进片请求
|
| | | this.D01RequestState=obj.D01RequestState[0];
|
| | | |
| | | console.log(obj.D01RequestState[0]);
|
| | | this.D01RequestState = obj.D01RequestState[0];
|
| | |
|
| | | //是否允许出片
|
| | | this.isAllowQueue = obj.isAllowQueue[0];
|
| | | //出片队列
|
| | |
| | | this.form5 = obj.form3[0];
|
| | | this.showform3();
|
| | | this.glassid1 = "";
|
| | | if(this.D01RequestState==true){
|
| | | if (this.D01RequestState == true) {
|
| | | this.Sizerange(this.form5, 3);
|
| | | }else{
|
| | | this.disabled1=true;
|
| | | } else {
|
| | | this.disabled1 = true;
|
| | | }
|
| | | |
| | | |
| | | } else {
|
| | | if (this.glassid1 == "") {
|
| | | this.DeleteBarcodeGlass();
|
| | |
| | | },
|
| | | //手动上片
|
| | | FeedInglassid() {
|
| | | if (this.form.glassId != ""&&this.form.glassId != null) {
|
| | | if (this.form.glassId != "" && this.form.glassId != null) {
|
| | | Inglassid(this.insertcage, this.insertcell, this.inserttier, this.form).then(res => {
|
| | | if (res.data.message == 200) {
|
| | | this.$message.success(this.$t('Operation successful'));
|
| | |
| | | column = rowIndex;
|
| | | rowIndex = column;
|
| | | let style = "";
|
| | | if (columnIndex === 8 ) {
|
| | | if (columnIndex === 8) {
|
| | | style = "font-size:25px;text-align: center;";
|
| | | }
|
| | | if (columnIndex === 9 && row.flip == 1) {
|
| | |
| | | } else {
|
| | | this.disabled = false;
|
| | | }
|
| | | if (position == 3 && this.isConfirm == true&&this.D01RequestState==true) {
|
| | | if (position == 3 && this.isConfirm == true && this.D01RequestState == true) {
|
| | | this.InsertQueueGlass(1);
|
| | | }
|
| | | }
|
| | |
| | | }
|
| | | });
|
| | | },
|
| | | CountDown(){
|
| | | CountDown() {
|
| | | //50秒倒数计时
|
| | | let count = 45;
|
| | | let timer = setInterval(
|
| | | () => {
|
| | | if (count > 0) {
|
| | | this.CountDowns = count;
|
| | | count--;
|
| | | }
|
| | | else {
|
| | | if (this.EmergencyStop == true) {
|
| | | clearInterval(timer);
|
| | | this.CountDowns = 0;
|
| | | this.dialogFormCountDown=false;
|
| | | this.PromptSize = 250;
|
| | | this.CountDowns = "EMERGENCY STOP";
|
| | | } else {
|
| | | if (count > 0) {
|
| | | this.PromptSize = 500;
|
| | | this.CountDowns = count;
|
| | | count--;
|
| | | }
|
| | | else {
|
| | | this.PromptSize = 250;
|
| | | this.CountDowns = "Waiting for reset";
|
| | | |
| | | // if(复位完成==true){
|
| | | // clearInterval(timer);
|
| | | // this.dialogFormCountDown = false;
|
| | | // }
|
| | | }
|
| | | }
|
| | | },
|
| | | 1000
|
| | | );
|
| | | |
| | | this.dialogFormCountDown = true;
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | // 设置token |
| | | setToken(res.data.Authorization); |
| | | this.$router.push('/layout') |
| | | this.$message.success('登录成功'); |
| | | this.$message.success(this.$t('loginSuccess')); |
| | | }); |
| | | }) |
| | | }, |
| | |
| | | }
|
| | | }
|
| | |
|
| | | //写入Word
|
| | | //不连续地址 写入Word
|
| | | public void WriteWordToPLC(JSONArray messageArray, List<String> addresses, int index) {
|
| | | try {
|
| | | if (messageArray.getJSONArray(index).size() > 0) {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | public void WriteWordsToPLC(JSONArray jsonArray, String address,int index) {
|
| | | if (jsonArray.getJSONArray(index).size() > 0) {
|
| | | Object value = jsonArray.getJSONArray(index).get(0);
|
| | | if (value != null && !value.toString().equals("null")) {
|
| | | try {
|
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", "");
|
| | | short sValue = Short.parseShort(cleanedValue.trim());
|
| | | S7control.getinstance().WriteWord(address, Arrays.asList(sValue));
|
| | | System.out.println("messageValue:" + Arrays.asList(sValue) + " written to PLC at address " + address);
|
| | | } catch (NumberFormatException e) {
|
| | | // 如果无法解析为 short 类型,则忽略该部分
|
| | | System.err.println("Could not parse value: " + value);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | //写入String
|
| | | public void writeStringToPLC(JSONArray messageArray, String addresses, int index) {
|
| | | try {
|
| | |
| | | import java.util.List; |
| | | |
| | | public class PLCAutomaticParameterSetting extends Thread { |
| | | String name = ""; |
| | | Integer count = 0; |
| | | |
| | | public static String readFileToString(String filePath) throws IOException { |
| | | File file = new File(filePath); |
| | | return FileUtils.readFileToString(file, "UTF-8"); |
| | | // 用于存储应用程序的配置信息 |
| | | private Configuration config; |
| | | |
| | | // 创建一个自定义的 S7 控制器消息处理器对象 |
| | | MessageHandler customS7Control = new MessageHandler(); |
| | | |
| | | |
| | | public PLCAutomaticParameterSetting() throws IOException { |
| | | config = new Configuration("config.properties"); |
| | | } |
| | | |
| | | public void readValue() { |
| | | String str = ""; |
| | | BufferedReader bufferedReader = null; |
| | | FileInputStream fileInputStream; |
| | | try { |
| | | // 从文件中读取字节数据存入 fileInputStream |
| | | fileInputStream = new FileInputStream("CanadaMes-ui/src/configuration/address.json"); |
| | | // 读取 fileInputStream 中字节并将其解码为字符 |
| | | InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "utf-8"); |
| | | // 提高读取效率,在 BufferedReader 内包装 InputStreamReader |
| | | bufferedReader = new BufferedReader(inputStreamReader); |
| | | String line = null; |
| | | // 将 bufferedReader 内容一行一行赋值给str |
| | | while ((line = bufferedReader.readLine()) != null) { |
| | | str += line; |
| | | } |
| | | |
| | | // 将str字符串格式转为json |
| | | JSONObject jsonObject = new JSONObject(str); |
| | | |
| | | // 获取json中的值 |
| | | JSONArray address = jsonObject.getJSONArray("address"); |
| | | for (int i = 0; i < address.size(); i++) { |
| | | JSONObject ress = (JSONObject) address.get(i); |
| | | |
| | | this.name = ress.getStr("name"); |
| | | this.count = ress.getInt("count"); |
| | | |
| | | } |
| | | |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } catch (UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void run() { |
| | | while (this != null) { |
| | |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | // this.readValue(); |
| | | // String PlcAddress = this.name; |
| | | // Integer Plccount = this.count; |
| | | |
| | | |
| | | // System.out.println(stt); |
| | | |
| | | List<Short> arraylist = S7control.getinstance().ReadWord("DB100.120", 8); |
| | | List<Short> dache1 = S7control.getinstance().ReadWord("DB100.18", 1); |
| | | List<Short> xiaoche1 = S7control.getinstance().ReadWord("DB100.22", 1); |
| | | List<Short> fanzhuan1 = S7control.getinstance().ReadWord("DB100.14", 1); |
| | | List<String> addresses = new ArrayList<>(); |
| | | addresses.add("DB100.0"); |
| | | addresses.add("DB100.2"); |
| | | addresses.add("DB100.4"); |
| | | addresses.add("DB100.6"); |
| | | addresses.add("DB100.26"); |
| | | addresses.add("DB100.28"); |
| | | addresses.add("DB100.30"); |
| | | addresses.add("DB100.32"); |
| | | addresses.add("DB100.34"); |
| | | addresses.add("DB100.36"); |
| | | addresses.add("DB100.38"); |
| | | addresses.add("DB100.40"); |
| | | |
| | | List<String> addresses = Arrays.asList(config.getProperty("Auto.addresses").split(",")); |
| | | |
| | | List<Short> arraylist2 = S7control.getinstance().readWords(addresses); |
| | | //翻转 |
| | | List<Short> fanzhuan2 = S7control.getinstance().ReadWord("DB100.8", 1); |
| | |
| | | } |
| | | System.out.println(messageArray); |
| | | // 写入第一个地址 |
| | | if (messageArray.getJSONArray(2).size() > 0) { |
| | | Object value = messageArray.getJSONArray(2).get(0); |
| | | if (value != null && !value.toString().equals("null")) { |
| | | try { |
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", ""); |
| | | short sValue = Short.parseShort(cleanedValue.trim()); |
| | | S7control.getinstance().WriteWord(addressList2, Arrays.asList(sValue)); |
| | | System.out |
| | | .println("messageValue:" + Arrays.asList(sValue) + " written to PLC at address " + addressList2); |
| | | } catch (NumberFormatException e) { |
| | | // 如果无法解析为 short 类型,则忽略该部分 |
| | | System.err.println("Could not parse value: " + value); |
| | | } |
| | | } |
| | | } |
| | | customS7Control.WriteWordsToPLC(messageArray, addressList2,2); |
| | | |
| | | // 写入第二个地址 |
| | | if (messageArray.getJSONArray(3).size() > 0) { |
| | | Object value = messageArray.getJSONArray(3).get(0); |
| | | if (value != null && !value.toString().equals("null")) { |
| | | try { |
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", ""); |
| | | short sValue = Short.parseShort(cleanedValue.trim()); |
| | | S7control.getinstance().WriteWord(addressList3, Arrays.asList(sValue)); |
| | | System.out |
| | | .println("messageValue:" + Arrays.asList(sValue) + " written to PLC at address " + addressList3); |
| | | } catch (NumberFormatException e) { |
| | | // 如果无法解析为 short 类型,则忽略该部分 |
| | | System.err.println("Could not parse value: " + value); |
| | | } |
| | | } |
| | | } |
| | | customS7Control.WriteWordsToPLC(messageArray, addressList3,3); |
| | | |
| | | |
| | | // 写入第三个地址 |
| | | if (messageArray.getJSONArray(4).size() > 0) { |
| | | Object value = messageArray.getJSONArray(4).get(0); |
| | | if (value != null && !value.toString().equals("null")) { |
| | | try { |
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", ""); |
| | | short sValue = Short.parseShort(cleanedValue.trim()); |
| | | S7control.getinstance().WriteWord(addressList4, Arrays.asList(sValue)); |
| | | System.out |
| | | .println("messageValue:" + Arrays.asList(sValue) + " written to PLC at address " + addressList4); |
| | | } catch (NumberFormatException e) { |
| | | // 如果无法解析为 short 类型,则忽略该部分 |
| | | System.err.println("Could not parse value: " + value); |
| | | } |
| | | } |
| | | } |
| | | customS7Control.WriteWordsToPLC(messageArray, addressList4,4); |
| | | |
| | | |
| | | // 写入第四个地址 |
| | | if (!mergedList.isEmpty()) { |
| | |
| | | System.out.println("messageValue:" + mergedList + " written to PLC at address " + addressList1); |
| | | } |
| | | |
| | | List<String> waddresses1 = Arrays.asList(config.getProperty("Auto.shusong").split(",")); |
| | | |
| | | List<String> waddresses1 = new ArrayList<>(); |
| | | waddresses1.add("DB100.0"); |
| | | waddresses1.add("DB100.2"); |
| | | waddresses1.add("DB100.4"); |
| | | waddresses1.add("DB100.6"); |
| | | waddresses1.add("DB100.26"); |
| | | waddresses1.add("DB100.28"); |
| | | waddresses1.add("DB100.30"); |
| | | waddresses1.add("DB100.32"); |
| | | waddresses1.add("DB100.34"); |
| | | waddresses1.add("DB100.36"); |
| | | waddresses1.add("DB100.38"); |
| | | waddresses1.add("DB100.40"); |
| | | |
| | | String addressList22 = "DB100.8"; |
| | | String addressList33 = "DB100.12"; |
| | |
| | | } |
| | | |
| | | // 写入第伍个地址 |
| | | if (messageArray.getJSONArray(8).size() > 0) { |
| | | Object value = messageArray.getJSONArray(8).get(0); |
| | | if (value != null && !value.toString().equals("null")) { |
| | | try { |
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", ""); |
| | | short sValue = Short.parseShort(cleanedValue.trim()); |
| | | S7control.getinstance().WriteWord(addressList22, Arrays.asList(sValue)); |
| | | System.out |
| | | .println("messageValue:" + Arrays.asList(sValue) + " written to PLC at address " + addressList2); |
| | | } catch (NumberFormatException e) { |
| | | // 如果无法解析为 short 类型,则忽略该部分 |
| | | System.err.println("Could not parse value: " + value); |
| | | } |
| | | } |
| | | } |
| | | customS7Control.WriteWordsToPLC(messageArray, addressList22,8); |
| | | |
| | | |
| | | // 写入第六个地址 |
| | | if (messageArray.getJSONArray(9).size() > 0) { |
| | | Object value = messageArray.getJSONArray(9).get(0); |
| | | if (value != null && !value.toString().equals("null")) { |
| | | try { |
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", ""); |
| | | short sValue = Short.parseShort(cleanedValue.trim()); |
| | | S7control.getinstance().WriteWord(addressList33, Arrays.asList(sValue)); |
| | | System.out |
| | | .println("messageValue:" + Arrays.asList(sValue) + " written to PLC at address " + addressList3); |
| | | } catch (NumberFormatException e) { |
| | | // 如果无法解析为 short 类型,则忽略该部分 |
| | | System.err.println("Could not parse value: " + value); |
| | | } |
| | | } |
| | | } |
| | | customS7Control.WriteWordsToPLC(messageArray, addressList33,9); |
| | | |
| | | // 写入第七个地址 |
| | | if (!mergedList2.isEmpty()) { |
| | |
| | | public class PLCManualJog extends Thread {
|
| | |
|
| | |
|
| | | // 用于存储应用程序的配置信息
|
| | | private Configuration config;
|
| | | // 用于存储应用程序的配置信息
|
| | | private Configuration config;
|
| | |
|
| | | // 创建一个自定义的 S7 控制器消息处理器对象
|
| | | MessageHandler customS7Control = new MessageHandler();
|
| | | // 创建一个自定义的 S7 控制器消息处理器对象
|
| | | MessageHandler customS7Control = new MessageHandler();
|
| | |
|
| | |
|
| | | public PLCManualJog() throws IOException {
|
| | | config = new Configuration("config.properties");
|
| | | }
|
| | | public PLCManualJog() throws IOException {
|
| | | config = new Configuration("config.properties");
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public void run() {
|
| | | while (this != null) {
|
| | | try {
|
| | | Thread.sleep(500);
|
| | |
|
| | | } catch (InterruptedException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | List<String> addressList21 = Arrays.asList(config.getProperty("PLCManualJog.button").split(","));
|
| | | List<Boolean> arraylist = S7control.getinstance().readBits(addressList21);
|
| | |
|
| | | @Override
|
| | | public void run() {
|
| | | while (this != null) {
|
| | | try {
|
| | | Thread.sleep(500);
|
| | |
|
| | | } catch (InterruptedException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | // this.readValue();
|
| | | // String PlcAddress = this.name;
|
| | | // Integer Plccount = this.count;
|
| | |
|
| | | // System.out.println(stt);
|
| | |
|
| | |
|
| | | List<String> addressList21 = Arrays.asList(config.getProperty("PLCManualJog.button").split(","));
|
| | | // Boolean[] values1 = { false, true, true, true, false, false, true, false,
|
| | | // false, true, true, true, false, false,
|
| | | // true, false,false, true, true, true, false, false, true, false,
|
| | | // false, true, false, true };
|
| | | // List<Boolean> arraylist = new ArrayList<>(Arrays.asList(values1));
|
| | |
|
| | |
|
| | |
|
| | | JSONObject jsonObject = new JSONObject();
|
| | |
|
| | | List<Boolean> arraylist = S7control.getinstance().readBits(addressList21);
|
| | | short[] params = new short[arraylist.size()];
|
| | | for (int i = 0; i < arraylist.size(); i++) {
|
| | | boolean value = arraylist.get(i);
|
| | | params[i] = value ? (short) 1 : (short) 0;
|
| | | }
|
| | |
|
| | | // Boolean[] values1 = { false, true, true, true, false, false, true, false,
|
| | | // false, true, true, true, false, false,
|
| | | // true, false };
|
| | | // List<Boolean> arraylist = new ArrayList<>(Arrays.asList(values1));
|
| | | // Boolean[] values2 = { false, true, true, true, false, false, true, false };
|
| | | // List<Boolean> arraylist2 = new ArrayList<>(Arrays.asList(values2));
|
| | | // Boolean[] values3 = { false, false };
|
| | | // List<Boolean> arraylist3 = new ArrayList<>(Arrays.asList(values3));
|
| | |
|
| | |
|
| | |
|
| | | JSONObject jsonObject = new JSONObject();
|
| | |
|
| | | short[] params = new short[arraylist.size()];
|
| | | for (int i = 0; i < arraylist.size(); i++) {
|
| | | boolean value = arraylist.get(i);
|
| | | params[i] = value ? (short) 1 : (short) 0;
|
| | | }
|
| | |
|
| | | jsonObject.append("params", params);
|
| | | jsonObject.append("params", params);
|
| | |
|
| | | // System.out.println("messageValue:" + arraylist +"messageValue2:" + arraylist2 );
|
| | | // WebSocketServer sendwServer = WebSocketServer.sessionMap.get("ManualJog");
|
| | |
| | | // sendwServer.sendMessage(jsonObject.toString());
|
| | | // }
|
| | |
|
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("ManualJog");
|
| | | if (sendwServer != null) {
|
| | | for (WebSocketServer webserver : sendwServer) {
|
| | | webserver.sendMessage(jsonObject.toString());
|
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("ManualJog");
|
| | | if (sendwServer != null) {
|
| | | for (WebSocketServer webserver : sendwServer) {
|
| | | webserver.sendMessage(jsonObject.toString());
|
| | |
|
| | | // WebSocketServer webSocketServer = WebSocketServer.sessionMap.get("ManualJog");
|
| | |
|
| | | if (webserver != null) {
|
| | | if (webserver != null) {
|
| | |
|
| | |
|
| | | List<String> messages = webserver.getMessages();
|
| | | if (!messages.isEmpty()) {
|
| | | // 将最后一个消息转换为整数类型的列表
|
| | | String lastMessage = messages.get(messages.size() - 1);
|
| | | // System.out.println("messages:" + messages);
|
| | | String[] parts = lastMessage.split(",");
|
| | | List<Integer> messageValues = new ArrayList<>();
|
| | | for (String part : parts) {
|
| | | try {
|
| | | // 使用正则表达式清除非数字字符
|
| | | String cleanedPart = part.replaceAll("[^0-9-]", "");
|
| | | Integer value = Integer.parseInt(cleanedPart.trim());
|
| | | messageValues.add(value);
|
| | | } catch (NumberFormatException e) {
|
| | | // 如果无法解析为整数类型,则忽略该部分
|
| | | // e.printStackTrace();
|
| | | }
|
| | |
|
| | | List<String> messages = webserver.getMessages();
|
| | | if (!messages.isEmpty()) {
|
| | | // 将最后一个消息转换为整数类型的列表
|
| | | String lastMessage = messages.get(messages.size() - 1);
|
| | | // System.out.println("messages:" + messages);
|
| | | String[] parts = lastMessage.split(",");
|
| | | List<Integer> messageValues = new ArrayList<>();
|
| | | for (String part : parts) {
|
| | | try {
|
| | | // 使用正则表达式清除非数字字符
|
| | | String cleanedPart = part.replaceAll("[^0-9-]", "");
|
| | | Integer value = Integer.parseInt(cleanedPart.trim());
|
| | | messageValues.add(value);
|
| | | } catch (NumberFormatException e) {
|
| | | // 如果无法解析为整数类型,则忽略该部分
|
| | | // e.printStackTrace();
|
| | | }
|
| | | // 将消息值转换为布尔列表
|
| | | List<Boolean> messageBooleans = new ArrayList<>();
|
| | | for (Integer value : messageValues) {
|
| | | messageBooleans.add(value == 1 ? true : false);
|
| | | }
|
| | | // System.out.println(messageBooleans);
|
| | | List<Boolean> bolList = new ArrayList<>();
|
| | |
|
| | |
|
| | | for (int i = 0; i < 28 && i < messageBooleans.size(); i++) {
|
| | | bolList.add(messageBooleans.get(i));
|
| | | }
|
| | |
|
| | |
|
| | | if (!bolList.isEmpty()) {
|
| | | S7control.getinstance().WriteBit(addressList21, bolList);
|
| | | System.out.println("messageValue:" + bolList + " written to PLC at address " + addressList21);
|
| | | }
|
| | |
|
| | | webserver.clearMessages();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | // 将消息值转换为布尔列表
|
| | | List<Boolean> messageBooleans = new ArrayList<>();
|
| | | for (Integer value : messageValues) {
|
| | | messageBooleans.add(value == 1 ? true : false);
|
| | | }
|
| | | // System.out.println(messageBooleans);
|
| | | List<Boolean> bolList = new ArrayList<>();
|
| | |
|
| | |
|
| | | for (int i = 0; i < 26 && i < messageBooleans.size(); i++) {
|
| | | bolList.add(messageBooleans.get(i));
|
| | | }
|
| | |
|
| | |
|
| | | if (!bolList.isEmpty()) {
|
| | | S7control.getinstance().WriteBit(addressList21, bolList);
|
| | | System.out.println("messageValue:" + bolList + " written to PLC at address " + addressList21);
|
| | | }
|
| | |
|
| | | webserver.clearMessages();
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | // // TODO Auto-generated catch block |
| | | // e.printStackTrace(); |
| | | // } |
| | | List<Short> datas1List = S7control.getinstance().ReadWord("DB106.24", 1);// 获取prc进片请求数据 |
| | | List<Short> datas1List = S7control.getinstance().ReadWord("DB106.24", 1);// 获取prc进片请求数据 |
| | | List<Short> datas1ListState = S7control.getinstance().ReadWord("DB106.8", 1);// 获取进片车状态 |
| | | List<Short> datas1ListState2 = S7control.getinstance().ReadWord("DB105.16", 1);// 获取进片车任务是否启动 |
| | | |
| | |
| | | boolean B02backs = spianService.listbool("DB106.62");// b02汇报 |
| | | StringBuilder B01glassid = spianService.queGlassid("DB103.184", 14);// BO1的玻璃id |
| | | StringBuilder B02glassid = spianService.queGlassid("DB103.212", 14);// B02的玻璃id |
| | | int aaa=1; |
| | | // 当进片小车完成任务时 |
| | | if (B01backs == true) { |
| | | // 当B01小车汇报完成时更改玻璃状态 为1 |
| | | spianService.overtask(B01glassid.toString());// 完成任务 |
| | | S7control.getinstance().WriteWord("DB106.60", (short) 0);// 恢复B01小车应答改为0 |
| | | System.out.println("汇报时B01|" + B01glassid); |
| | | System.out.println("汇报时B01|第"+aaa+"次"+ B01glassid); |
| | | aaa+=1; |
| | | } |
| | | |
| | | // 当出片小车完成任务时 |
| | |
| | | import java.util.List; |
| | | |
| | | public class PlcManualonePosition extends Thread { |
| | | private Configuration config; |
| | | private Configuration config; |
| | | |
| | | public PlcManualonePosition() throws IOException { |
| | | config = new Configuration("config.properties"); |
| | | } |
| | | |
| | | |
| | | |
| | | // 创建一个自定义的 S7 控制器消息处理器对象 |
| | | MessageHandler customS7Control = new MessageHandler(); |
| | | |
| | | |
| | | |
| | | |
| | | public static class PLCBooleanConverter { |
| | | |
| | | public static short[] convertListsToBinaryShortArray(List<Boolean>... lists) { |
| | | // 计算所有列表中元素的总数 |
| | | int totalSize = 0; |
| | | for (List<Boolean> list : lists) { |
| | | totalSize += list.size(); |
| | | } |
| | | |
| | | // 创建一个足够大的数组来存放所有的二进制值 |
| | | short[] binaryShortArray = new short[totalSize]; |
| | | |
| | | // 当前数组填充位置指针 |
| | | int currentIndex = 0; |
| | | |
| | | // 遍历所有的列表 |
| | | for (List<Boolean> list : lists) { |
| | | // 将每个布尔值转换为 0 或 1 并填入数组 |
| | | for (Boolean value : list) { |
| | | binaryShortArray[currentIndex++] = (short) (value ? 1 : 0); |
| | | } |
| | | } |
| | | |
| | | return binaryShortArray; |
| | | public PlcManualonePosition() throws IOException { |
| | | config = new Configuration("config.properties"); |
| | | } |
| | | } |
| | | |
| | | |
| | | // 创建一个自定义的 S7 控制器消息处理器对象 |
| | | MessageHandler customS7Control = new MessageHandler(); |
| | | |
| | | |
| | | @Override |
| | | public void run() { |
| | | while (this != null) { |
| | | try { |
| | | Thread.sleep(500); |
| | | public static class PLCBooleanConverter { |
| | | |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | // this.readValue(); |
| | | // String PlcAddress = this.name; |
| | | // Integer Plccount = this.count; |
| | | public static short[] convertListsToBinaryShortArray(List<Boolean>... lists) { |
| | | // 计算所有列表中元素的总数 |
| | | int totalSize = 0; |
| | | for (List<Boolean> list : lists) { |
| | | totalSize += list.size(); |
| | | } |
| | | |
| | | List<String> addresses = new ArrayList<>(); |
| | | addresses.add("DB100.108"); |
| | | addresses.add("DB100.20"); |
| | | addresses.add("DB103.32"); |
| | | List<Short> arraylist = S7control.getinstance().readWords(addresses); |
| | | // System.out.println(arraylist); |
| | | // 创建一个足够大的数组来存放所有的二进制值 |
| | | short[] binaryShortArray = new short[totalSize]; |
| | | |
| | | List<String> addresses2 = new ArrayList<>(); |
| | | addresses2.add("DB100.110"); |
| | | addresses2.add("DB100.176"); |
| | | addresses2.add("DB103.34"); |
| | | List<Short> arraylist2 = S7control.getinstance().readWords(addresses2); |
| | | // 当前数组填充位置指针 |
| | | int currentIndex = 0; |
| | | |
| | | List<String> addresses3 = new ArrayList<>(); |
| | | addresses3.add("DB100.112"); |
| | | addresses3.add("DB100.24"); |
| | | addresses3.add("DB103.36"); |
| | | List<Short> arraylist3 = S7control.getinstance().readWords(addresses3); |
| | | // 遍历所有的列表 |
| | | for (List<Boolean> list : lists) { |
| | | // 将每个布尔值转换为 0 或 1 并填入数组 |
| | | for (Boolean value : list) { |
| | | binaryShortArray[currentIndex++] = (short) (value ? 1 : 0); |
| | | } |
| | | } |
| | | |
| | | List<String> addresses4 = new ArrayList<>(); |
| | | addresses4.add("DB100.114"); |
| | | addresses4.add("DB100.178"); |
| | | addresses4.add("DB103.40"); |
| | | List<Short> arraylist4 = S7control.getinstance().readWords(addresses4); |
| | | return binaryShortArray; |
| | | } |
| | | } |
| | | |
| | | List<Short> arraylist5 = S7control.getinstance().ReadWord("DB106.0", 1); |
| | | List<Short> arraylist6 = S7control.getinstance().ReadWord("DB106.12", 1); |
| | | List<Short> arraylist7 = S7control.getinstance().ReadWord("DB106.40", 1); |
| | | List<Short> arraylist8 = S7control.getinstance().ReadWord("DB106.50", 1); |
| | | List<String> addresses9 = new ArrayList<>(); |
| | | addresses9.add("DB104.1.2"); |
| | | addresses9.add("DB104.1.3"); |
| | | addresses9.add("DB104.1.6"); |
| | | addresses9.add("DB104.1.7"); |
| | | List<Boolean> arraylist9 = S7control.getinstance().readBits(addresses9); |
| | | |
| | | List<String> addresses10 = new ArrayList<>(); |
| | | addresses10.add("DB104.9.4"); |
| | | addresses10.add("DB104.9.5"); |
| | | addresses10.add("DB104.9.4"); |
| | | addresses10.add("DB104.9.5"); |
| | | List<Boolean> arraylist10 = S7control.getinstance().readBits(addresses10); |
| | | @Override |
| | | public void run() { |
| | | while (this != null) { |
| | | try { |
| | | Thread.sleep(500); |
| | | |
| | | //A01启动地址 |
| | | List<String> A01start = Arrays.asList(config.getProperty("mlp.A01start")); |
| | | //A02启动地址 |
| | | List<String> A02start = Arrays.asList(config.getProperty("mlp.A02start")); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | // this.readValue(); |
| | | // String PlcAddress = this.name; |
| | | // Integer Plccount = this.count; |
| | | |
| | | List<String> B01start = Arrays.asList(config.getProperty("mlp.B01start")); |
| | | List<String> addresses = new ArrayList<>(); |
| | | addresses.add("DB100.108"); |
| | | addresses.add("DB100.20"); |
| | | addresses.add("DB103.32"); |
| | | List<Short> arraylist = S7control.getinstance().readWords(addresses); |
| | | // System.out.println(arraylist); |
| | | |
| | | List<String> B02start = Arrays.asList(config.getProperty("mlp.B02start")); |
| | | List<String> addresses2 = new ArrayList<>(); |
| | | addresses2.add("DB100.110"); |
| | | addresses2.add("DB100.176"); |
| | | addresses2.add("DB103.34"); |
| | | List<Short> arraylist2 = S7control.getinstance().readWords(addresses2); |
| | | |
| | | List<Boolean> A01readstart = S7control.getinstance().readBits(A01start); |
| | | List<Boolean> A02readstart = S7control.getinstance().readBits(A02start); |
| | | List<Boolean> B01readstart = S7control.getinstance().readBits(B01start); |
| | | List<Boolean> B02readstart = S7control.getinstance().readBits(B02start); |
| | | List<String> addresses3 = new ArrayList<>(); |
| | | addresses3.add("DB100.112"); |
| | | addresses3.add("DB100.24"); |
| | | addresses3.add("DB103.36"); |
| | | List<Short> arraylist3 = S7control.getinstance().readWords(addresses3); |
| | | |
| | | short[] combinedBinaryShortArray = PLCBooleanConverter.convertListsToBinaryShortArray( |
| | | A01readstart, A02readstart,B01readstart, B02readstart |
| | | ); |
| | | List<String> addresses4 = new ArrayList<>(); |
| | | addresses4.add("DB100.114"); |
| | | addresses4.add("DB100.178"); |
| | | addresses4.add("DB103.40"); |
| | | List<Short> arraylist4 = S7control.getinstance().readWords(addresses4); |
| | | |
| | | // Short[] values1 = { 1, 2, 3 }; |
| | | // List<Short> arraylist = new ArrayList<>(Arrays.asList(values1)); |
| | | // Short[] values2 = { 1, 2, 3 }; |
| | | // List<Short> arraylist2 = new ArrayList<>(Arrays.asList(values2)); |
| | | // Short[] values3 = { 1, 2, 3 }; |
| | | // List<Short> arraylist3 = new ArrayList<>(Arrays.asList(values3)); |
| | | // Short[] values4 = { 1, 2, 3 }; |
| | | // List<Short> arraylist4 = new ArrayList<>(Arrays.asList(values4)); |
| | | // Short[] values5 = { 5 }; |
| | | // List<Short> arraylist5 = new ArrayList<>(Arrays.asList(values5)); |
| | | // Short[] values6 = { 6 }; |
| | | // List<Short> arraylist6 = new ArrayList<>(Arrays.asList(values6)); |
| | | // Short[] values7 = { 7 }; |
| | | // List<Short> arraylist7 = new ArrayList<>(Arrays.asList(values7)); |
| | | // Short[] values8 = { 8 }; |
| | | // List<Short> arraylist8 = new ArrayList<>(Arrays.asList(values8)); |
| | | // Boolean[] values9 = { false, false, true, true }; |
| | | // List<Boolean> arraylist9 = new ArrayList<>(Arrays.asList(values9)); |
| | | short[] params2 = new short[arraylist9.size()]; |
| | | for (int i = 0; i < arraylist9.size(); i++) { |
| | | boolean value = arraylist9.get(i); |
| | | params2[i] = value ? (short) 1 : (short) 0; |
| | | } |
| | | List<Short> arraylist5 = S7control.getinstance().ReadWord("DB106.0", 1); |
| | | List<Short> arraylist6 = S7control.getinstance().ReadWord("DB106.12", 1); |
| | | List<Short> arraylist7 = S7control.getinstance().ReadWord("DB106.40", 1); |
| | | List<Short> arraylist8 = S7control.getinstance().ReadWord("DB106.50", 1); |
| | | List<String> addresses9 = new ArrayList<>(); |
| | | addresses9.add("DB104.1.2"); |
| | | addresses9.add("DB104.1.3"); |
| | | addresses9.add("DB104.1.6"); |
| | | addresses9.add("DB104.1.7"); |
| | | List<Boolean> arraylist9 = S7control.getinstance().readBits(addresses9); |
| | | |
| | | // Boolean[] values10 = { false, false, true, true }; |
| | | // List<Boolean> arraylist10 = new ArrayList<>(Arrays.asList(values10)); |
| | | short[] params3 = new short[arraylist10.size()]; |
| | | for (int i = 0; i < arraylist10.size(); i++) { |
| | | boolean value = arraylist10.get(i); |
| | | params3[i] = value ? (short) 1 : (short) 0; |
| | | } |
| | | // List<Short> arraylist9 = S7control.getinstance().readWords(addresses9); |
| | | arraylist5.addAll(arraylist6); |
| | | arraylist5.addAll(arraylist7); |
| | | arraylist5.addAll(arraylist8); |
| | | List<String> addresses10 = new ArrayList<>(); |
| | | addresses10.add("DB104.9.4"); |
| | | addresses10.add("DB104.9.5"); |
| | | addresses10.add("DB104.9.4"); |
| | | addresses10.add("DB104.9.5"); |
| | | List<Boolean> arraylist10 = S7control.getinstance().readBits(addresses10); |
| | | |
| | | JSONObject jsonObject = new JSONObject(); |
| | | // System.out.println(arraylist6); |
| | | jsonObject.append("zuhe1", arraylist); |
| | | jsonObject.append("zuhe2", arraylist2); |
| | | jsonObject.append("zuhe3", arraylist3); |
| | | jsonObject.append("zuhe4", arraylist4); |
| | | jsonObject.append("shishi1", arraylist5); |
| | | jsonObject.append("guzhang", params2); |
| | | jsonObject.append("weihuiling", params3); |
| | | jsonObject.append("qidong", combinedBinaryShortArray); |
| | | //A01启动地址 |
| | | List<String> A01start = Arrays.asList(config.getProperty("mlp.A01start")); |
| | | //A02启动地址 |
| | | List<String> A02start = Arrays.asList(config.getProperty("mlp.A02start")); |
| | | |
| | | List<String> B01start = Arrays.asList(config.getProperty("mlp.B01start")); |
| | | |
| | | List<String> B02start = Arrays.asList(config.getProperty("mlp.B02start")); |
| | | |
| | | List<Boolean> A01readstart = S7control.getinstance().readBits(A01start); |
| | | List<Boolean> A02readstart = S7control.getinstance().readBits(A02start); |
| | | List<Boolean> B01readstart = S7control.getinstance().readBits(B01start); |
| | | List<Boolean> B02readstart = S7control.getinstance().readBits(B02start); |
| | | |
| | | short[] combinedBinaryShortArray = PLCBooleanConverter.convertListsToBinaryShortArray( |
| | | A01readstart, A02readstart, B01readstart, B02readstart |
| | | ); |
| | | |
| | | // Short[] values1 = { 1, 2, 3 }; |
| | | // List<Short> arraylist = new ArrayList<>(Arrays.asList(values1)); |
| | | // Short[] values2 = { 1, 2, 3 }; |
| | | // List<Short> arraylist2 = new ArrayList<>(Arrays.asList(values2)); |
| | | // Short[] values3 = { 1, 2, 3 }; |
| | | // List<Short> arraylist3 = new ArrayList<>(Arrays.asList(values3)); |
| | | // Short[] values4 = { 1, 2, 3 }; |
| | | // List<Short> arraylist4 = new ArrayList<>(Arrays.asList(values4)); |
| | | // Short[] values5 = { 5 }; |
| | | // List<Short> arraylist5 = new ArrayList<>(Arrays.asList(values5)); |
| | | // Short[] values6 = { 6 }; |
| | | // List<Short> arraylist6 = new ArrayList<>(Arrays.asList(values6)); |
| | | // Short[] values7 = { 7 }; |
| | | // List<Short> arraylist7 = new ArrayList<>(Arrays.asList(values7)); |
| | | // Short[] values8 = { 8 }; |
| | | // List<Short> arraylist8 = new ArrayList<>(Arrays.asList(values8)); |
| | | // Boolean[] values9 = { false, false, true, true }; |
| | | // List<Boolean> arraylist9 = new ArrayList<>(Arrays.asList(values9)); |
| | | short[] params2 = new short[arraylist9.size()]; |
| | | for (int i = 0; i < arraylist9.size(); i++) { |
| | | boolean value = arraylist9.get(i); |
| | | params2[i] = value ? (short) 1 : (short) 0; |
| | | } |
| | | |
| | | // Boolean[] values10 = { false, false, true, true }; |
| | | // List<Boolean> arraylist10 = new ArrayList<>(Arrays.asList(values10)); |
| | | short[] params3 = new short[arraylist10.size()]; |
| | | for (int i = 0; i < arraylist10.size(); i++) { |
| | | boolean value = arraylist10.get(i); |
| | | params3[i] = value ? (short) 1 : (short) 0; |
| | | } |
| | | // List<Short> arraylist9 = S7control.getinstance().readWords(addresses9); |
| | | arraylist5.addAll(arraylist6); |
| | | arraylist5.addAll(arraylist7); |
| | | arraylist5.addAll(arraylist8); |
| | | |
| | | JSONObject jsonObject = new JSONObject(); |
| | | // System.out.println(arraylist6); |
| | | jsonObject.append("zuhe1", arraylist); |
| | | jsonObject.append("zuhe2", arraylist2); |
| | | jsonObject.append("zuhe3", arraylist3); |
| | | jsonObject.append("zuhe4", arraylist4); |
| | | jsonObject.append("shishi1", arraylist5); |
| | | jsonObject.append("guzhang", params2); |
| | | jsonObject.append("weihuiling", params3); |
| | | jsonObject.append("qidong", combinedBinaryShortArray); |
| | | |
| | | // WebSocketServer sendwServer = WebSocketServer.sessionMap.get("ManualonePosition"); |
| | | // if (sendwServer != null) { |
| | | // sendwServer.sendMessage(jsonObject.toString()); |
| | | // } |
| | | |
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("ManualonePosition"); |
| | | if (sendwServer != null) { |
| | | for (WebSocketServer webserver : sendwServer) { |
| | | webserver.sendMessage(jsonObject.toString()); |
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("ManualonePosition"); |
| | | if (sendwServer != null) { |
| | | for (WebSocketServer webserver : sendwServer) { |
| | | webserver.sendMessage(jsonObject.toString()); |
| | | |
| | | // WebSocketServer webSocketServer = WebSocketServer.sessionMap.get("ManualonePosition"); |
| | | if (webserver != null) { |
| | | List<String> messages = webserver.getMessages(); |
| | | List<String> waddresses1 = new ArrayList<>(); |
| | | waddresses1.add("DB100.108"); |
| | | waddresses1.add("DB100.20"); |
| | | waddresses1.add("DB103.32"); |
| | | if (webserver != null) { |
| | | List<String> messages = webserver.getMessages(); |
| | | List<String> waddresses1 = new ArrayList<>(); |
| | | waddresses1.add("DB100.108"); |
| | | waddresses1.add("DB100.20"); |
| | | waddresses1.add("DB103.32"); |
| | | |
| | | List<String> waddresses2 = new ArrayList<>(); |
| | | waddresses2.add("DB100.110"); |
| | | waddresses2.add("DB100.176"); |
| | | waddresses2.add("DB103.34"); |
| | | List<String> waddresses2 = new ArrayList<>(); |
| | | waddresses2.add("DB100.110"); |
| | | waddresses2.add("DB100.176"); |
| | | waddresses2.add("DB103.34"); |
| | | |
| | | List<String> waddresses3 = new ArrayList<>(); |
| | | waddresses3.add("DB100.112"); |
| | | waddresses3.add("DB100.24"); |
| | | waddresses3.add("DB103.36"); |
| | | List<String> waddresses3 = new ArrayList<>(); |
| | | waddresses3.add("DB100.112"); |
| | | waddresses3.add("DB100.24"); |
| | | waddresses3.add("DB103.36"); |
| | | |
| | | List<String> waddresses4 = new ArrayList<>(); |
| | | waddresses4.add("DB100.114"); |
| | | waddresses4.add("DB100.178"); |
| | | waddresses4.add("DB103.40"); |
| | | List<String> waddresses4 = new ArrayList<>(); |
| | | waddresses4.add("DB100.114"); |
| | | waddresses4.add("DB100.178"); |
| | | waddresses4.add("DB103.40"); |
| | | |
| | | // 故障地址 |
| | | List<String> waddresses5 = new ArrayList<>(); |
| | | // waddresses5.add("DB103.244"); |
| | | // waddresses5.add("DB103.250"); |
| | | waddresses5.add("DB103.252"); |
| | | waddresses5.add("DB103.254"); |
| | | // 故障地址 |
| | | List<String> waddresses5 = new ArrayList<>(); |
| | | // waddresses5.add("DB103.244"); |
| | | // waddresses5.add("DB103.250"); |
| | | waddresses5.add("DB103.252"); |
| | | waddresses5.add("DB103.254"); |
| | | |
| | | // 复位地址 |
| | | List<String> waddresses6 = new ArrayList<>(); |
| | | waddresses6.add("DB101.4.0"); |
| | | waddresses6.add("DB101.4.3"); |
| | | waddresses6.add("DB101.4.4"); |
| | | waddresses6.add("DB101.4.6"); |
| | | // 复位地址 |
| | | List<String> waddresses6 = new ArrayList<>(); |
| | | waddresses6.add("DB101.4.0"); |
| | | waddresses6.add("DB101.4.3"); |
| | | waddresses6.add("DB101.4.4"); |
| | | waddresses6.add("DB101.4.6"); |
| | | |
| | | // 回零地址 |
| | | List<String> waddresses7 = new ArrayList<>(); |
| | | // 回零地址 |
| | | List<String> waddresses7 = new ArrayList<>(); |
| | | |
| | | waddresses7.add("DB101.4.5"); |
| | | waddresses7.add("DB101.4.7"); |
| | | waddresses7.add("DB101.4.5"); |
| | | waddresses7.add("DB101.4.7"); |
| | | |
| | | |
| | | // System.out.println(messages.isEmpty()); |
| | | if (!messages.isEmpty()) { |
| | | // 将最后一个消息转换为 short 类型的列表 |
| | | String lastMessage = messages.get(messages.size() - 1); |
| | | // System.out.println("lastMessage:" + lastMessage); |
| | | JSONArray messageArray = new JSONArray(lastMessage); |
| | | // 写入A01 |
| | | if (messageArray.getJSONArray(0).size() > 0) { |
| | | JSONArray jsonArray = messageArray.getJSONArray(0); |
| | | List<Short> sValue = new ArrayList<>(); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | Object value = jsonArray.get(i); |
| | | if (value != null && !value.toString().equals("null")) { |
| | | try { |
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", ""); |
| | | short val = Short.parseShort(cleanedValue.trim()); |
| | | sValue.add(val); |
| | | System.out.println("messageValue:" + Arrays.asList(val) + " added to the list"); |
| | | } catch (NumberFormatException e) { |
| | | // 如果无法解析为 short 类型,则忽略该部分 |
| | | System.err.println("Could not parse value: " + value); |
| | | // System.out.println(messages.isEmpty()); |
| | | if (!messages.isEmpty()) { |
| | | // 将最后一个消息转换为 short 类型的列表 |
| | | String lastMessage = messages.get(messages.size() - 1); |
| | | // System.out.println("lastMessage:" + lastMessage); |
| | | JSONArray messageArray = new JSONArray(lastMessage); |
| | | // 写入A01 |
| | | customS7Control.WriteWordToPLC(messageArray, waddresses1, 0); |
| | | |
| | | |
| | | // 写入A02 |
| | | customS7Control.WriteWordToPLC(messageArray, waddresses2, 1); |
| | | |
| | | |
| | | // 写入B01 |
| | | customS7Control.WriteWordToPLC(messageArray, waddresses3, 2); |
| | | |
| | | // 写入B02 |
| | | customS7Control.WriteWordToPLC(messageArray, waddresses4, 3); |
| | | |
| | | |
| | | // 写入故障地址 |
| | | |
| | | customS7Control.writeBitToPLC(messageArray, waddresses5, 4); |
| | | |
| | | |
| | | // 写入复位地址 |
| | | customS7Control.writeBitToPLC(messageArray, waddresses6, 5); |
| | | |
| | | // 写入回零地址 |
| | | |
| | | customS7Control.writeBitToPLC(messageArray, waddresses7, 6); |
| | | //A01启动 |
| | | customS7Control.writeBitToPLC(messageArray, A01start, 7); |
| | | //A02启动 |
| | | customS7Control.writeBitToPLC(messageArray, A02start, 8); |
| | | //B01启动 |
| | | customS7Control.writeBitToPLC(messageArray, B01start, 9); |
| | | //B02启动 |
| | | customS7Control.writeBitToPLC(messageArray, B02start, 10); |
| | | |
| | | // 清空消息列表 |
| | | webserver.clearMessages(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (!sValue.isEmpty()) { |
| | | S7control.getinstance().WriteWord(waddresses1, sValue); |
| | | |
| | | |
| | | System.out.println("Values " + sValue + " written to PLC at address " + waddresses1); |
| | | } |
| | | } |
| | | |
| | | // 写入A02 |
| | | |
| | | if (messageArray.getJSONArray(1).size() > 0) { |
| | | JSONArray jsonArray = messageArray.getJSONArray(1); |
| | | List<Short> sValue2 = new ArrayList<>(); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | Object value = jsonArray.get(i); |
| | | if (value != null && !value.toString().equals("null")) { |
| | | try { |
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", ""); |
| | | short val = Short.parseShort(cleanedValue.trim()); |
| | | sValue2.add(val); |
| | | System.out.println("messageValue:" + Arrays.asList(val) + " added to the list"); |
| | | } catch (NumberFormatException e) { |
| | | // 如果无法解析为 short 类型,则忽略该部分 |
| | | System.err.println("Could not parse value: " + value); |
| | | } |
| | | } |
| | | } |
| | | if (!sValue2.isEmpty()) { |
| | | S7control.getinstance().WriteWord(waddresses2, sValue2); |
| | | |
| | | |
| | | |
| | | System.out.println("Values " + sValue2 + " written to PLC at address " + waddresses2); |
| | | } |
| | | } |
| | | |
| | | // 写入B01 |
| | | if (messageArray.getJSONArray(2).size() > 0) { |
| | | JSONArray jsonArray = messageArray.getJSONArray(2); |
| | | List<Short> sValue2 = new ArrayList<>(); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | Object value = jsonArray.get(i); |
| | | if (value != null && !value.toString().equals("null")) { |
| | | try { |
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", ""); |
| | | short val = Short.parseShort(cleanedValue.trim()); |
| | | sValue2.add(val); |
| | | System.out.println("messageValue:" + Arrays.asList(val) + " added to the list"); |
| | | } catch (NumberFormatException e) { |
| | | // 如果无法解析为 short 类型,则忽略该部分 |
| | | System.err.println("Could not parse value: " + value); |
| | | } |
| | | } |
| | | } |
| | | if (!sValue2.isEmpty()) { |
| | | S7control.getinstance().WriteWord(waddresses3, sValue2); |
| | | |
| | | System.out.println("Values " + sValue2 + " written to PLC at address " + waddresses3); |
| | | } |
| | | } |
| | | |
| | | // 写入B02 |
| | | if (messageArray.getJSONArray(3).size() > 0) { |
| | | JSONArray jsonArray = messageArray.getJSONArray(3); |
| | | List<Short> sValue2 = new ArrayList<>(); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | Object value = jsonArray.get(i); |
| | | if (value != null && !value.toString().equals("null")) { |
| | | try { |
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", ""); |
| | | short val = Short.parseShort(cleanedValue.trim()); |
| | | sValue2.add(val); |
| | | System.out.println("messageValue:" + Arrays.asList(val) + " added to the list"); |
| | | } catch (NumberFormatException e) { |
| | | // 如果无法解析为 short 类型,则忽略该部分 |
| | | System.err.println("Could not parse value: " + value); |
| | | } |
| | | } |
| | | } |
| | | if (!sValue2.isEmpty()) { |
| | | S7control.getinstance().WriteWord(waddresses4, sValue2); |
| | | |
| | | System.out.println("Values " + sValue2 + " written to PLC at address " + waddresses4); |
| | | } |
| | | } |
| | | |
| | | // 写入故障地址 |
| | | if (messageArray.getJSONArray(4).size() > 0) { |
| | | JSONArray jsonArray = messageArray.getJSONArray(4); |
| | | List<Short> sValue2 = new ArrayList<>(); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | Object value = jsonArray.get(i); |
| | | if (value != null && !value.toString().equals("null")) { |
| | | try { |
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", ""); |
| | | short val = Short.parseShort(cleanedValue.trim()); |
| | | sValue2.add(val); |
| | | System.out.println("messageValue:" + Arrays.asList(val) + " added to the list"); |
| | | } catch (NumberFormatException e) { |
| | | // 如果无法解析为 short 类型,则忽略该部分 |
| | | System.err.println("Could not parse value: " + value); |
| | | } |
| | | } |
| | | } |
| | | if (!sValue2.isEmpty()) { |
| | | S7control.getinstance().WriteWord(waddresses5, sValue2); |
| | | System.out.println("Values " + sValue2 + " written to PLC at address " + waddresses5); |
| | | } |
| | | } |
| | | |
| | | // 写入复位地址 |
| | | if (messageArray.getJSONArray(5).size() > 0) { |
| | | JSONArray jsonArray3 = messageArray.getJSONArray(5); |
| | | List<Boolean> sValue3 = new ArrayList<>(); |
| | | for (int i = 0; i < jsonArray3.size(); i++) { |
| | | Object value = jsonArray3.get(i); |
| | | if (value != null && !value.toString().equals("null")) { |
| | | try { |
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", ""); |
| | | boolean val = "1".equals(cleanedValue.trim()); |
| | | sValue3.add(val); |
| | | System.out.println("messageValue: " + Arrays.asList(val) + " added to the list"); |
| | | } catch (NumberFormatException e) { |
| | | // 如果无法解析为 boolean 类型,则忽略该部分 |
| | | System.err.println("Could not parse value: " + value); |
| | | } |
| | | } |
| | | } |
| | | if (!sValue3.isEmpty()) { |
| | | S7control.getinstance().WriteBit(waddresses6, sValue3); |
| | | System.out.println("Values " + sValue3 + " written to PLC at address " + waddresses6); |
| | | } |
| | | } |
| | | |
| | | // 写入回零地址 |
| | | if (messageArray.getJSONArray(6).size() > 0) { |
| | | JSONArray jsonArray3 = messageArray.getJSONArray(6); |
| | | List<Boolean> sValue3 = new ArrayList<>(); |
| | | for (int i = 0; i < jsonArray3.size(); i++) { |
| | | Object value = jsonArray3.get(i); |
| | | if (value != null && !value.toString().equals("null")) { |
| | | try { |
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", ""); |
| | | boolean val = "1".equals(cleanedValue.trim()); |
| | | sValue3.add(val); |
| | | System.out.println("messageValue: " + Arrays.asList(val) + " added to the list"); |
| | | } catch (NumberFormatException e) { |
| | | // 如果无法解析为 boolean 类型,则忽略该部分 |
| | | System.err.println("Could not parse value: " + value); |
| | | } |
| | | } |
| | | } |
| | | if (!sValue3.isEmpty()) { |
| | | S7control.getinstance().WriteBit(waddresses7, sValue3); |
| | | System.out.println("Values " + sValue3 + " written to PLC at address " + waddresses7); |
| | | } |
| | | } |
| | | |
| | | customS7Control.writeBitToPLC( messageArray, A01start,7); |
| | | customS7Control.writeBitToPLC( messageArray, A02start,8); |
| | | customS7Control.writeBitToPLC( messageArray,B01start,9); |
| | | customS7Control.writeBitToPLC( messageArray, B02start,10); |
| | | |
| | | // 清空消息列表 |
| | | webserver.clearMessages(); |
| | | } |
| | | }} |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | import java.util.List;
|
| | |
|
| | | public class PlcManualonePosition2 extends Thread {
|
| | | private Configuration config;
|
| | | private Configuration config;
|
| | |
|
| | | public PlcManualonePosition2() throws IOException {
|
| | | config = new Configuration("config.properties");
|
| | | }
|
| | |
|
| | |
|
| | | MessageHandler customS7Control = new MessageHandler();
|
| | | public static class PLCBooleanConverter {
|
| | |
|
| | | public static short[] convertListsToBinaryShortArray(List<Boolean>... lists) {
|
| | | // 计算所有列表中元素的总数
|
| | | int totalSize = 0;
|
| | | for (List<Boolean> list : lists) {
|
| | | totalSize += list.size();
|
| | | }
|
| | |
|
| | | // 创建一个足够大的数组来存放所有的二进制值
|
| | | short[] binaryShortArray = new short[totalSize];
|
| | |
|
| | | // 当前数组填充位置指针
|
| | | int currentIndex = 0;
|
| | |
|
| | | // 遍历所有的列表
|
| | | for (List<Boolean> list : lists) {
|
| | | // 将每个布尔值转换为 0 或 1 并填入数组
|
| | | for (Boolean value : list) {
|
| | | binaryShortArray[currentIndex++] = (short) (value ? 1 : 0);
|
| | | }
|
| | | }
|
| | |
|
| | | return binaryShortArray;
|
| | | public PlcManualonePosition2() throws IOException {
|
| | | config = new Configuration("config.properties");
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | MessageHandler customS7Control = new MessageHandler();
|
| | |
|
| | | public static class PLCBooleanConverter {
|
| | |
|
| | | public static short[] convertListsToBinaryShortArray(List<Boolean>... lists) {
|
| | | // 计算所有列表中元素的总数
|
| | | int totalSize = 0;
|
| | | for (List<Boolean> list : lists) {
|
| | | totalSize += list.size();
|
| | | }
|
| | |
|
| | | // 创建一个足够大的数组来存放所有的二进制值
|
| | | short[] binaryShortArray = new short[totalSize];
|
| | |
|
| | | // 当前数组填充位置指针
|
| | | int currentIndex = 0;
|
| | |
|
| | | // 遍历所有的列表
|
| | | for (List<Boolean> list : lists) {
|
| | | // 将每个布尔值转换为 0 或 1 并填入数组
|
| | | for (Boolean value : list) {
|
| | | binaryShortArray[currentIndex++] = (short) (value ? 1 : 0);
|
| | | }
|
| | | }
|
| | |
|
| | | return binaryShortArray;
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public void run() {
|
| | | while (this != null) {
|
| | | try {
|
| | | Thread.sleep(500);
|
| | | @Override
|
| | | public void run() {
|
| | | while (this != null) {
|
| | | try {
|
| | | Thread.sleep(500);
|
| | |
|
| | | } catch (InterruptedException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | // this.readValue();
|
| | | // String PlcAddress = this.name;
|
| | | // Integer Plccount = this.count;
|
| | | } catch (InterruptedException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | // this.readValue();
|
| | | // String PlcAddress = this.name;
|
| | | // Integer Plccount = this.count;
|
| | |
|
| | | List<String> addresses = new ArrayList<>();
|
| | | addresses.add("DB100.116");
|
| | | addresses.add("DB100.16");
|
| | | List<String> addresses = new ArrayList<>();
|
| | | addresses.add("DB100.116");
|
| | | addresses.add("DB100.16");
|
| | |
|
| | | addresses.add("DB103.20");
|
| | | List<Short> arraylist = S7control.getinstance().readWords(addresses);
|
| | | // System.out.println(arraylist);
|
| | | addresses.add("DB106.2");
|
| | | List<Short> arraylist = S7control.getinstance().readWords(addresses);
|
| | | // System.out.println(arraylist);
|
| | |
|
| | | List<String> addresses2 = new ArrayList<>();
|
| | | addresses2.add("DB100.118");
|
| | | addresses2.add("DB100.192");
|
| | | List<String> addresses2 = new ArrayList<>();
|
| | | addresses2.add("DB100.118");
|
| | | addresses2.add("DB100.192");
|
| | |
|
| | | addresses2.add("DB103.22");
|
| | | List<Short> arraylist2 = S7control.getinstance().readWords(addresses2);
|
| | | addresses2.add("DB103.22");
|
| | | List<Short> arraylist2 = S7control.getinstance().readWords(addresses2);
|
| | |
|
| | | List<String> addresses9 = new ArrayList<>();
|
| | | List<String> addresses9 = new ArrayList<>();
|
| | |
|
| | | addresses9.add("DB104.1.2");
|
| | | addresses9.add("DB104.1.3");
|
| | | List<Boolean> arraylist9 = S7control.getinstance().readBits(addresses9);
|
| | | short[] params2 = new short[arraylist9.size()];
|
| | | for (int i = 0; i < arraylist9.size(); i++) {
|
| | | boolean value = arraylist9.get(i);
|
| | | params2[i] = value ? (short) 1 : (short) 0;
|
| | | }
|
| | | addresses9.add("DB104.1.2");
|
| | | addresses9.add("DB104.1.3");
|
| | | List<Boolean> arraylist9 = S7control.getinstance().readBits(addresses9);
|
| | | short[] params2 = new short[arraylist9.size()];
|
| | | for (int i = 0; i < arraylist9.size(); i++) {
|
| | | boolean value = arraylist9.get(i);
|
| | | params2[i] = value ? (short) 1 : (short) 0;
|
| | | }
|
| | |
|
| | | // Short[] values1 = { 1, 2, 3 };
|
| | | // List<Short> arraylist = new ArrayList<>(Arrays.asList(values1));
|
| | | // Short[] values2 = { 1, 2, 3 };
|
| | | // List<Short> arraylist2 = new ArrayList<>(Arrays.asList(values2));
|
| | | // Boolean[] values9 = { false, true };
|
| | | // List<Boolean> arraylist9 = new ArrayList<>(Arrays.asList(values9));
|
| | | // short[] params2 = new short[arraylist9.size()];
|
| | | // for (int i = 0; i < arraylist9.size(); i++) {
|
| | | // boolean value = arraylist9.get(i);
|
| | | // params2[i] = value ? (short) 1 : (short) 0;
|
| | | // }
|
| | | // Short[] values1 = { 1, 2, 3 };
|
| | | // List<Short> arraylist = new ArrayList<>(Arrays.asList(values1));
|
| | | // Short[] values2 = { 1, 2, 3 };
|
| | | // List<Short> arraylist2 = new ArrayList<>(Arrays.asList(values2));
|
| | | // Boolean[] values9 = { false, true };
|
| | | // List<Boolean> arraylist9 = new ArrayList<>(Arrays.asList(values9));
|
| | | // short[] params2 = new short[arraylist9.size()];
|
| | | // for (int i = 0; i < arraylist9.size(); i++) {
|
| | | // boolean value = arraylist9.get(i);
|
| | | // params2[i] = value ? (short) 1 : (short) 0;
|
| | | // }
|
| | |
|
| | | // Boolean[] values10 = { false, true };
|
| | | List<String> addresses10 = new ArrayList<>();
|
| | | // Boolean[] values10 = { false, true };
|
| | | List<String> addresses10 = new ArrayList<>();
|
| | |
|
| | | addresses10.add("DB104.9.0");
|
| | | addresses10.add("DB104.9.1");
|
| | | List<Boolean> arraylist10 = S7control.getinstance().readBits(addresses10);
|
| | | short[] params3 = new short[arraylist10.size()];
|
| | | for (int i = 0; i < arraylist10.size(); i++) {
|
| | | boolean value = arraylist10.get(i);
|
| | | params3[i] = value ? (short) 1 : (short) 0;
|
| | | }
|
| | | addresses10.add("DB104.9.0");
|
| | | addresses10.add("DB104.9.1");
|
| | | List<Boolean> arraylist10 = S7control.getinstance().readBits(addresses10);
|
| | | short[] params3 = new short[arraylist10.size()];
|
| | | for (int i = 0; i < arraylist10.size(); i++) {
|
| | | boolean value = arraylist10.get(i);
|
| | | params3[i] = value ? (short) 1 : (short) 0;
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | //A01启动地址
|
| | | List<String> A01start = Arrays.asList(config.getProperty("mlp2.A01start"));
|
| | | //A02启动地址
|
| | | List<String> A02start = Arrays.asList(config.getProperty("mlp2.A02start"));
|
| | | //A01启动地址
|
| | | List<String> A01start = Arrays.asList(config.getProperty("mlp2.A01start"));
|
| | | //A02启动地址
|
| | | List<String> A02start = Arrays.asList(config.getProperty("mlp2.A02start"));
|
| | |
|
| | |
|
| | |
|
| | | List<Boolean> A01readstart = S7control.getinstance().readBits(A01start);
|
| | | List<Boolean> A02readstart = S7control.getinstance().readBits(A02start);
|
| | | List<Boolean> A01readstart = S7control.getinstance().readBits(A01start);
|
| | | List<Boolean> A02readstart = S7control.getinstance().readBits(A02start);
|
| | |
|
| | |
|
| | | short[] combinedBinaryShortArray = PLCBooleanConverter.convertListsToBinaryShortArray(
|
| | | A01readstart, A02readstart
|
| | | );
|
| | | short[] combinedBinaryShortArray = PLCBooleanConverter.convertListsToBinaryShortArray(
|
| | | A01readstart, A02readstart
|
| | | );
|
| | |
|
| | | JSONObject jsonObject = new JSONObject();
|
| | | JSONObject jsonObject = new JSONObject();
|
| | |
|
| | | jsonObject.append("zuhe1", arraylist);
|
| | | jsonObject.append("zuhe2", arraylist2);
|
| | | jsonObject.append("guzhang", params2);
|
| | | jsonObject.append("weihuiling", params3);
|
| | | jsonObject.append("qidong", combinedBinaryShortArray);
|
| | | // System.out.println(jsonObject);
|
| | | jsonObject.append("zuhe1", arraylist);
|
| | | jsonObject.append("zuhe2", arraylist2);
|
| | | jsonObject.append("guzhang", params2);
|
| | | jsonObject.append("weihuiling", params3);
|
| | | jsonObject.append("qidong", combinedBinaryShortArray);
|
| | | // System.out.println(jsonObject);
|
| | | // WebSocketServer sendwServer = WebSocketServer.sessionMap.get("ManualonePosition2");
|
| | | // if (sendwServer != null) {
|
| | | // sendwServer.sendMessage(jsonObject.toString());
|
| | | // }
|
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("ManualonePosition2");
|
| | | if (sendwServer != null) {
|
| | | for (WebSocketServer webserver : sendwServer) {
|
| | | webserver.sendMessage(jsonObject.toString());
|
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("ManualonePosition2");
|
| | | if (sendwServer != null) {
|
| | | for (WebSocketServer webserver : sendwServer) {
|
| | | webserver.sendMessage(jsonObject.toString());
|
| | |
|
| | | // WebSocketServer webSocketServer = WebSocketServer.sessionMap.get("ManualonePosition2");
|
| | | if (webserver != null) {
|
| | | List<String> messages = webserver.getMessages();
|
| | | List<String> waddresses1 = new ArrayList<>();
|
| | | waddresses1.add("DB100.116");
|
| | | waddresses1.add("DB100.16");
|
| | | if (webserver != null) {
|
| | | List<String> messages = webserver.getMessages();
|
| | | List<String> waddresses1 = new ArrayList<>();
|
| | | waddresses1.add("DB100.116");
|
| | | waddresses1.add("DB100.16");
|
| | |
|
| | |
|
| | | List<String> waddresses2 = new ArrayList<>();
|
| | | waddresses2.add("DB100.118");
|
| | | waddresses2.add("DB100.192");
|
| | | List<String> waddresses2 = new ArrayList<>();
|
| | | waddresses2.add("DB100.118");
|
| | | waddresses2.add("DB100.192");
|
| | |
|
| | |
|
| | | // 故障地址
|
| | | List<String> waddresses3 = new ArrayList<>();
|
| | | waddresses3.add("DB103.242");
|
| | | waddresses3.add("DB103.248");
|
| | | // 故障地址
|
| | | List<String> waddresses3 = new ArrayList<>();
|
| | | waddresses3.add("DB103.242");
|
| | | waddresses3.add("DB103.248");
|
| | |
|
| | | // 复位地址
|
| | | List<String> waddresses4 = new ArrayList<>();
|
| | | waddresses4.add("DB101.3.6");
|
| | | waddresses4.add("DB101.4.1");
|
| | | // 复位地址
|
| | | List<String> waddresses4 = new ArrayList<>();
|
| | | waddresses4.add("DB101.3.6");
|
| | | waddresses4.add("DB101.4.1");
|
| | |
|
| | | // 回零地址
|
| | | List<String> waddresses5 = new ArrayList<>();
|
| | | waddresses5.add("DB101.3.7");
|
| | | waddresses5.add("DB101.4.2");
|
| | | // 回零地址
|
| | | List<String> waddresses5 = new ArrayList<>();
|
| | | waddresses5.add("DB101.3.7");
|
| | | waddresses5.add("DB101.4.2");
|
| | |
|
| | | if (!messages.isEmpty()) {
|
| | | // 将最后一个消息转换为 short 类型的列表
|
| | | String lastMessage = messages.get(messages.size() - 1);
|
| | | // System.out.println("lastMessage:" + lastMessage);
|
| | | JSONArray messageArray = new JSONArray(lastMessage);
|
| | | if (!messages.isEmpty()) {
|
| | | // 将最后一个消息转换为 short 类型的列表
|
| | | String lastMessage = messages.get(messages.size() - 1);
|
| | | // System.out.println("lastMessage:" + lastMessage);
|
| | | JSONArray messageArray = new JSONArray(lastMessage);
|
| | |
|
| | | // A01下发
|
| | | if (messageArray.getJSONArray(0).size() > 0) {
|
| | | JSONArray jsonArray = messageArray.getJSONArray(0);
|
| | | List<Short> sValue = new ArrayList<>();
|
| | | for (int i = 0; i < jsonArray.size(); i++) {
|
| | | Object value = jsonArray.get(i);
|
| | | if (value != null && !value.toString().equals("null")) {
|
| | | try {
|
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", "");
|
| | | short val = Short.parseShort(cleanedValue.trim());
|
| | | sValue.add(val);
|
| | | System.out.println("messageValue:" + Arrays.asList(val) + " added to the list");
|
| | | } catch (NumberFormatException e) {
|
| | | // 如果无法解析为 short 类型,则忽略该部分
|
| | | System.err.println("Could not parse value: " + value);
|
| | | // A01下发
|
| | | customS7Control.WriteWordToPLC(messageArray, waddresses1, 0);
|
| | |
|
| | |
|
| | | // A02下发
|
| | | customS7Control.WriteWordToPLC(messageArray, waddresses2, 1);
|
| | |
|
| | |
|
| | | // 写入故障地址
|
| | | customS7Control.WriteWordToPLC(messageArray, waddresses3, 2);
|
| | |
|
| | |
|
| | | // 写入复位地址
|
| | | customS7Control.writeBitToPLC(messageArray, waddresses4, 3);
|
| | |
|
| | |
|
| | | // 写入回零地址
|
| | | customS7Control.writeBitToPLC(messageArray, waddresses5, 4);
|
| | |
|
| | | customS7Control.writeBitToPLC(messageArray, A01start, 5);
|
| | | customS7Control.writeBitToPLC(messageArray, A02start, 6);
|
| | |
|
| | | // 清空消息列表
|
| | | webserver.clearMessages();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | if (!sValue.isEmpty()) {
|
| | | S7control.getinstance().WriteWord(waddresses1, sValue);
|
| | |
|
| | | System.out.println("Values " + sValue + " written to PLC at address " + waddresses1);
|
| | | }
|
| | | }
|
| | |
|
| | | // A02下发
|
| | | if (messageArray.getJSONArray(1).size() > 0) {
|
| | | JSONArray jsonArray = messageArray.getJSONArray(1);
|
| | | List<Short> sValue2 = new ArrayList<>();
|
| | | for (int i = 0; i < jsonArray.size(); i++) {
|
| | | Object value = jsonArray.get(i);
|
| | | if (value != null && !value.toString().equals("null")) {
|
| | | try {
|
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", "");
|
| | | short val = Short.parseShort(cleanedValue.trim());
|
| | | sValue2.add(val);
|
| | | System.out.println("messageValue:" + Arrays.asList(val) + " added to the list");
|
| | | } catch (NumberFormatException e) {
|
| | | // 如果无法解析为 short 类型,则忽略该部分
|
| | | System.err.println("Could not parse value: " + value);
|
| | | }
|
| | | }
|
| | | }
|
| | | if (!sValue2.isEmpty()) {
|
| | | S7control.getinstance().WriteWord(waddresses2, sValue2);
|
| | |
|
| | | System.out.println("Values " + sValue2 + " written to PLC at address " + waddresses2);
|
| | | }
|
| | | }
|
| | |
|
| | | // 写入故障地址
|
| | | if (messageArray.getJSONArray(2).size() > 0) {
|
| | | JSONArray jsonArray = messageArray.getJSONArray(2);
|
| | | List<Short> sValue2 = new ArrayList<>();
|
| | | for (int i = 0; i < jsonArray.size(); i++) {
|
| | | Object value = jsonArray.get(i);
|
| | | if (value != null && !value.toString().equals("null")) {
|
| | | try {
|
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", "");
|
| | | short val = Short.parseShort(cleanedValue.trim());
|
| | | sValue2.add(val);
|
| | | System.out.println("messageValue:" + Arrays.asList(val) + " added to the list");
|
| | | } catch (NumberFormatException e) {
|
| | | // 如果无法解析为 short 类型,则忽略该部分
|
| | | System.err.println("Could not parse value: " + value);
|
| | | }
|
| | | }
|
| | | }
|
| | | if (!sValue2.isEmpty()) {
|
| | | S7control.getinstance().WriteWord(waddresses3, sValue2);
|
| | | System.out.println("Values " + sValue2 + " written to PLC at address " + waddresses3);
|
| | | }
|
| | | }
|
| | |
|
| | | // 写入复位地址
|
| | | if (messageArray.getJSONArray(3).size() > 0) {
|
| | | JSONArray jsonArray3 = messageArray.getJSONArray(3);
|
| | | List<Boolean> sValue3 = new ArrayList<>();
|
| | | for (int i = 0; i < jsonArray3.size(); i++) {
|
| | | Object value = jsonArray3.get(i);
|
| | | if (value != null && !value.toString().equals("null")) {
|
| | | try {
|
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", "");
|
| | | boolean val = "1".equals(cleanedValue.trim());
|
| | | sValue3.add(val);
|
| | | System.out.println("messageValue: " + Arrays.asList(val) + " added to the list");
|
| | | } catch (NumberFormatException e) {
|
| | | // 如果无法解析为 boolean 类型,则忽略该部分
|
| | | System.err.println("Could not parse value: " + value);
|
| | | }
|
| | | }
|
| | | }
|
| | | if (!sValue3.isEmpty()) {
|
| | | S7control.getinstance().WriteBit(waddresses4, sValue3);
|
| | | System.out.println("Values " + sValue3 + " written to PLC at address " + waddresses4);
|
| | | }
|
| | | }
|
| | |
|
| | | // 写入回零地址
|
| | | if (messageArray.getJSONArray(4).size() > 0) {
|
| | | JSONArray jsonArray3 = messageArray.getJSONArray(4);
|
| | | List<Boolean> sValue3 = new ArrayList<>();
|
| | | for (int i = 0; i < jsonArray3.size(); i++) {
|
| | | Object value = jsonArray3.get(i);
|
| | | if (value != null && !value.toString().equals("null")) {
|
| | | try {
|
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", "");
|
| | | boolean val = "1".equals(cleanedValue.trim());
|
| | | sValue3.add(val);
|
| | | System.out.println("messageValue: " + Arrays.asList(val) + " added to the list");
|
| | | } catch (NumberFormatException e) {
|
| | | // 如果无法解析为 boolean 类型,则忽略该部分
|
| | | System.err.println("Could not parse value: " + value);
|
| | | }
|
| | | }
|
| | | }
|
| | | if (!sValue3.isEmpty()) {
|
| | | S7control.getinstance().WriteBit(waddresses5, sValue3);
|
| | | System.out.println("Values " + sValue3 + " written to PLC at address " + waddresses5);
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | customS7Control.writeBitToPLC( messageArray, A01start,5);
|
| | | customS7Control.writeBitToPLC( messageArray, A02start,6);
|
| | |
|
| | | // 清空消息列表
|
| | | webserver.clearMessages();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | import java.util.List; |
| | | |
| | | public class PlcParameter1 extends Thread { |
| | | String name = ""; |
| | | Integer count = 0; |
| | | |
| | | public static String readFileToString(String filePath) throws IOException { |
| | | File file = new File(filePath); |
| | | return FileUtils.readFileToString(file, "UTF-8"); |
| | | } |
| | | MessageHandler customS7Control = new MessageHandler(); |
| | | |
| | | public void readValue() { |
| | | String str = ""; |
| | | BufferedReader bufferedReader = null; |
| | | FileInputStream fileInputStream; |
| | | try { |
| | | // 从文件中读取字节数据存入 fileInputStream |
| | | fileInputStream = new FileInputStream("CanadaMes-ui/src/configuration/address.json"); |
| | | // 读取 fileInputStream 中字节并将其解码为字符 |
| | | InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "utf-8"); |
| | | // 提高读取效率,在 BufferedReader 内包装 InputStreamReader |
| | | bufferedReader = new BufferedReader(inputStreamReader); |
| | | String line = null; |
| | | // 将 bufferedReader 内容一行一行赋值给str |
| | | while ((line = bufferedReader.readLine()) != null) { |
| | | str += line; |
| | | } |
| | | @Override |
| | | public void run() { |
| | | while (this != null) { |
| | | try { |
| | | Thread.sleep(1000); |
| | | |
| | | // 将str字符串格式转为json |
| | | JSONObject jsonObject = new JSONObject(str); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | // 获取json中的值 |
| | | JSONArray address = jsonObject.getJSONArray("address"); |
| | | for (int i = 0; i < address.size(); i++) { |
| | | JSONObject ress = (JSONObject) address.get(i); |
| | | |
| | | this.name = ress.getStr("name"); |
| | | this.count = ress.getInt("count"); |
| | | |
| | | } |
| | | |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } catch (UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void run() { |
| | | while (this != null) { |
| | | try { |
| | | Thread.sleep(1000); |
| | | |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | // this.readValue(); |
| | | // String PlcAddress = this.name; |
| | | // Integer Plccount = this.count; |
| | | |
| | | // System.out.println(stt); |
| | | List<String> addresses = new ArrayList<>(); |
| | | addresses.add("DB100.0"); |
| | | addresses.add("DB100.2"); |
| | | addresses.add("DB100.4"); |
| | | addresses.add("DB100.6"); |
| | | addresses.add("DB100.26"); |
| | | addresses.add("DB100.28"); |
| | | addresses.add("DB100.30"); |
| | | addresses.add("DB100.32"); |
| | | addresses.add("DB100.34"); |
| | | addresses.add("DB100.36"); |
| | | addresses.add("DB100.38"); |
| | | addresses.add("DB100.40"); |
| | | List<Short> arraylist = S7control.getinstance().readWords(addresses); |
| | | // System.out.println(stt); |
| | | List<String> addresses = new ArrayList<>(); |
| | | addresses.add("DB100.0"); |
| | | addresses.add("DB100.2"); |
| | | addresses.add("DB100.4"); |
| | | addresses.add("DB100.6"); |
| | | addresses.add("DB100.26"); |
| | | addresses.add("DB100.28"); |
| | | addresses.add("DB100.30"); |
| | | addresses.add("DB100.32"); |
| | | addresses.add("DB100.34"); |
| | | addresses.add("DB100.36"); |
| | | addresses.add("DB100.38"); |
| | | addresses.add("DB100.40"); |
| | | List<Short> arraylist = S7control.getinstance().readWords(addresses); |
| | | //翻转 |
| | | List<Short> fanzhuan1 = S7control.getinstance().ReadWord("DB100.8", 1); |
| | | List<Short> xiaoche1 = S7control.getinstance().ReadWord("DB100.12", 1); |
| | | // Short[] values1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; |
| | | // List<Short> arraylist = new ArrayList<>(Arrays.asList(values1)); |
| | | // Short[] fanzhuan = { 4 }; |
| | | // List<Short> fanzhuan1 = new ArrayList<>(Arrays.asList(fanzhuan)); |
| | | // Short[] xiaoche = {5}; |
| | | // List<Short> xiaoche1 = new ArrayList<>(Arrays.asList(xiaoche)); |
| | | List<Short> fanzhuan1 = S7control.getinstance().ReadWord("DB100.8", 1); |
| | | List<Short> xiaoche1 = S7control.getinstance().ReadWord("DB100.12", 1); |
| | | // Short[] values1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; |
| | | // List<Short> arraylist = new ArrayList<>(Arrays.asList(values1)); |
| | | // Short[] fanzhuan = { 4 }; |
| | | // List<Short> fanzhuan1 = new ArrayList<>(Arrays.asList(fanzhuan)); |
| | | // Short[] xiaoche = {5}; |
| | | // List<Short> xiaoche1 = new ArrayList<>(Arrays.asList(xiaoche)); |
| | | |
| | | JSONObject jsonObject = new JSONObject(); |
| | | // new short[]{1,1, 1, 1, 1, 1, 2, 33, 2,3, 4, 5} |
| | | // new short[]{0,0, 0, 0, 0, 0, 0, 0, 0, 0} |
| | | JSONObject jsonObject = new JSONObject(); |
| | | // new short[]{1,1, 1, 1, 1, 1, 2, 33, 2,3, 4, 5} |
| | | // new short[]{0,0, 0, 0, 0, 0, 0, 0, 0, 0} |
| | | |
| | | jsonObject.append("params", arraylist); |
| | | jsonObject.append("fanzhuan", fanzhuan1); |
| | | jsonObject.append("xiaoche", xiaoche1); |
| | | jsonObject.append("params", arraylist); |
| | | jsonObject.append("fanzhuan", fanzhuan1); |
| | | jsonObject.append("xiaoche", xiaoche1); |
| | | |
| | | // WebSocketServer sendwServer = WebSocketServer.sessionMap.get("Parameter1"); |
| | | // if (sendwServer != null) { |
| | | // sendwServer.sendMessage(jsonObject.toString()); |
| | | // } |
| | | |
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("Parameter1"); |
| | | if (sendwServer != null) { |
| | | for (WebSocketServer webserver : sendwServer) { |
| | | webserver.sendMessage(jsonObject.toString()); |
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("Parameter1"); |
| | | if (sendwServer != null) { |
| | | for (WebSocketServer webserver : sendwServer) { |
| | | webserver.sendMessage(jsonObject.toString()); |
| | | |
| | | |
| | | if (webserver != null) { |
| | | List<String> messages = webserver.getMessages(); |
| | | List<String> waddresses1 = new ArrayList<>(); |
| | | waddresses1.add("DB100.0"); |
| | | waddresses1.add("DB100.2"); |
| | | waddresses1.add("DB100.4"); |
| | | waddresses1.add("DB100.6"); |
| | | waddresses1.add("DB100.26"); |
| | | waddresses1.add("DB100.28"); |
| | | waddresses1.add("DB100.30"); |
| | | waddresses1.add("DB100.32"); |
| | | waddresses1.add("DB100.34"); |
| | | waddresses1.add("DB100.36"); |
| | | waddresses1.add("DB100.38"); |
| | | waddresses1.add("DB100.40"); |
| | | if (webserver != null) { |
| | | List<String> messages = webserver.getMessages(); |
| | | List<String> waddresses1 = new ArrayList<>(); |
| | | waddresses1.add("DB100.0"); |
| | | waddresses1.add("DB100.2"); |
| | | waddresses1.add("DB100.4"); |
| | | waddresses1.add("DB100.6"); |
| | | waddresses1.add("DB100.26"); |
| | | waddresses1.add("DB100.28"); |
| | | waddresses1.add("DB100.30"); |
| | | waddresses1.add("DB100.32"); |
| | | waddresses1.add("DB100.34"); |
| | | waddresses1.add("DB100.36"); |
| | | waddresses1.add("DB100.38"); |
| | | waddresses1.add("DB100.40"); |
| | | |
| | | String addressList2 = "DB100.8"; |
| | | String addressList3 = "DB100.12"; |
| | | String addressList2 = "DB100.8"; |
| | | String addressList3 = "DB100.12"; |
| | | |
| | | if (!messages.isEmpty()) { |
| | | // 将最后一个消息转换为 short 类型的列表 |
| | | String lastMessage = messages.get(messages.size() - 1); |
| | | // System.out.println("lastMessage:" + lastMessage); |
| | | JSONArray messageArray = new JSONArray(lastMessage); |
| | | if (!messages.isEmpty()) { |
| | | // 将最后一个消息转换为 short 类型的列表 |
| | | String lastMessage = messages.get(messages.size() - 1); |
| | | // System.out.println("lastMessage:" + lastMessage); |
| | | JSONArray messageArray = new JSONArray(lastMessage); |
| | | |
| | | // 整合第 1 到 3 个数组并去掉 null 元素 |
| | | List<Short> mergedList = new ArrayList<>(); |
| | | for (int i = 0; i < 3; i++) { |
| | | JSONArray sublist = messageArray.getJSONArray(i); |
| | | for (int j = 0; j < sublist.size(); j++) { |
| | | Object value = sublist.get(j); |
| | | if (value != null && !value.toString().equals("null")) { |
| | | try { |
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", ""); |
| | | short sValue = Short.parseShort(cleanedValue.trim()); |
| | | mergedList.add(sValue); |
| | | } catch (NumberFormatException e) { |
| | | // 如果无法解析为 short 类型,则忽略该部分 |
| | | System.err.println("Could not parse value: " + value); |
| | | // 整合第 1 到 3 个数组并去掉 null 元素 |
| | | List<Short> mergedList = new ArrayList<>(); |
| | | for (int i = 0; i < 3; i++) { |
| | | JSONArray sublist = messageArray.getJSONArray(i); |
| | | for (int j = 0; j < sublist.size(); j++) { |
| | | Object value = sublist.get(j); |
| | | if (value != null && !value.toString().equals("null")) { |
| | | try { |
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", ""); |
| | | short sValue = Short.parseShort(cleanedValue.trim()); |
| | | mergedList.add(sValue); |
| | | } catch (NumberFormatException e) { |
| | | // 如果无法解析为 short 类型,则忽略该部分 |
| | | System.err.println("Could not parse value: " + value); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 写入第一个地址 |
| | | customS7Control.WriteWordsToPLC(messageArray, addressList2, 3); |
| | | |
| | | |
| | | // 写入第二个地址 |
| | | customS7Control.WriteWordsToPLC(messageArray, addressList3, 4); |
| | | |
| | | |
| | | // 写入第三个地址 |
| | | if (!mergedList.isEmpty()) { |
| | | S7control.getinstance().WriteWord(waddresses1, mergedList); |
| | | System.out.println("messageValue:" + mergedList + " written to PLC at address " + waddresses1); |
| | | } |
| | | |
| | | // 清空消息列表 |
| | | webserver.clearMessages(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 写入第一个地址 |
| | | if (messageArray.getJSONArray(3).size() > 0) { |
| | | Object value = messageArray.getJSONArray(3).get(0); |
| | | if (value != null && !value.toString().equals("null")) { |
| | | try { |
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", ""); |
| | | short sValue = Short.parseShort(cleanedValue.trim()); |
| | | S7control.getinstance().WriteWord(addressList2, Arrays.asList(sValue)); |
| | | System.out |
| | | .println("messageValue:" + Arrays.asList(sValue) + " written to PLC at address " + addressList2); |
| | | } catch (NumberFormatException e) { |
| | | // 如果无法解析为 short 类型,则忽略该部分 |
| | | System.err.println("Could not parse value: " + value); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 写入第二个地址 |
| | | if (messageArray.getJSONArray(4).size() > 0) { |
| | | Object value = messageArray.getJSONArray(4).get(0); |
| | | if (value != null && !value.toString().equals("null")) { |
| | | try { |
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", ""); |
| | | short sValue = Short.parseShort(cleanedValue.trim()); |
| | | S7control.getinstance().WriteWord(addressList3, Arrays.asList(sValue)); |
| | | System.out |
| | | .println("messageValue:" + Arrays.asList(sValue) + " written to PLC at address " + addressList3); |
| | | } catch (NumberFormatException e) { |
| | | // 如果无法解析为 short 类型,则忽略该部分 |
| | | System.err.println("Could not parse value: " + value); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 写入第三个地址 |
| | | if (!mergedList.isEmpty()) { |
| | | S7control.getinstance().WriteWord(waddresses1, mergedList); |
| | | System.out.println("messageValue:" + mergedList + " written to PLC at address " + waddresses1); |
| | | } |
| | | |
| | | // 清空消息列表 |
| | | webserver.clearMessages(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | public class PlcParameter2 extends Thread { |
| | | String name = ""; |
| | | Integer count = 0; |
| | | |
| | | public static String readFileToString(String filePath) throws IOException { |
| | | File file = new File(filePath); |
| | | return FileUtils.readFileToString(file, "UTF-8"); |
| | | } |
| | | // 用于存储应用程序的配置信息 |
| | | private Configuration config; |
| | | |
| | | public void readValue() { |
| | | String str = ""; |
| | | BufferedReader bufferedReader = null; |
| | | FileInputStream fileInputStream; |
| | | try { |
| | | // 从文件中读取字节数据存入 fileInputStream |
| | | fileInputStream = new FileInputStream("CanadaMes-ui/src/configuration/address.json"); |
| | | // 读取 fileInputStream 中字节并将其解码为字符 |
| | | InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "utf-8"); |
| | | // 提高读取效率,在 BufferedReader 内包装 InputStreamReader |
| | | bufferedReader = new BufferedReader(inputStreamReader); |
| | | String line = null; |
| | | // 将 bufferedReader 内容一行一行赋值给str |
| | | while ((line = bufferedReader.readLine()) != null) { |
| | | str += line; |
| | | } |
| | | // 创建一个自定义的 S7 控制器消息处理器对象 |
| | | MessageHandler customS7Control = new MessageHandler(); |
| | | |
| | | // 将str字符串格式转为json |
| | | JSONObject jsonObject = new JSONObject(str); |
| | | |
| | | // 获取json中的值 |
| | | JSONArray address = jsonObject.getJSONArray("Positioning1"); |
| | | for (int i = 0; i < address.size(); i++) { |
| | | JSONObject ress = (JSONObject) address.get(i); |
| | | |
| | | this.name = ress.getStr("name"); |
| | | this.count = ress.getInt("count"); |
| | | |
| | | } |
| | | |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } catch (UnsupportedEncodingException e) { |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | public PlcParameter2() throws IOException { |
| | | config = new Configuration("config.properties"); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void run() { |
| | | while (this != null) { |
| | | try { |
| | | Thread.sleep(1000); |
| | | @Override |
| | | public void run() { |
| | | while (this != null) { |
| | | try { |
| | | Thread.sleep(1000); |
| | | |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | // 手动状态地址 |
| | | List<String> addressList1 = new ArrayList<>(); |
| | | // id |
| | | List<String> addressList1 = Arrays.asList(config.getProperty("Parameter2.id").split(",")); |
| | | |
| | | addressList1.add("DB103.44");//D01 |
| | | addressList1.add("DB103.58");//D02 |
| | | addressList1.add("DB103.72");//D03 |
| | | addressList1.add("DB103.86");//D04 |
| | | addressList1.add("DB103.100");//D05 |
| | | addressList1.add("DB103.114");//D06 |
| | | addressList1.add("DB103.128");//A01 |
| | | addressList1.add("DB103.142");//A01 2 |
| | | addressList1.add("DB103.156");//A02 |
| | | addressList1.add("DB103.184");//B01 |
| | | addressList1.add("DB103.212");//B02 |
| | | List<String> paramlist = S7control.getinstance().readStrings(addressList1); |
| | | |
| | | |
| | | List<String> paramlist = S7control.getinstance().readStrings(addressList1); |
| | | //手动状态 |
| | | List<String> addresses = Arrays.asList(config.getProperty("Parameter2.state").split(",")); |
| | | |
| | | List<Short> data = S7control.getinstance().readWords(addresses); |
| | | |
| | | |
| | | //清除ID地址 |
| | | List<String> addresses = new ArrayList<>(); |
| | | addresses.add("DB103.0"); |
| | | addresses.add("DB103.2"); |
| | | addresses.add("DB103.12"); |
| | | addresses.add("DB103.14"); |
| | | addresses.add("DB103.16"); |
| | | addresses.add("DB103.18"); |
| | | addresses.add("DB103.8"); |
| | | addresses.add("DB103.10"); |
| | | addresses.add("DB103.4"); |
| | | addresses.add("DB103.6"); |
| | | List<Short> data = S7control.getinstance().readWords(addresses); |
| | | //清除id |
| | | List<String> addressList0 = Arrays.asList(config.getProperty("Parameter2.cleanid").split(",")); |
| | | |
| | | |
| | | //id |
| | | List<String> addressList0 = new ArrayList<>(); |
| | | // 扫码枪 |
| | | List<Boolean> data2 = S7control.getinstance().readBits(addressList0); |
| | | List<String> addressList3 = Arrays.asList(config.getProperty("Parameter2.scanner").split(",")); |
| | | |
| | | addressList0.add("DB101.9.2"); |
| | | addressList0.add("DB101.9.3"); |
| | | addressList0.add("DB101.9.4"); |
| | | addressList0.add("DB101.9.5"); |
| | | addressList0.add("DB101.9.6"); |
| | | addressList0.add("DB101.9.7"); |
| | | //急停按钮 |
| | | List<String> niuanaddressList3 = Arrays.asList(config.getProperty("Parameter2.stop").split(",")); |
| | | |
| | | addressList0.add("DB101.10.0"); |
| | | addressList0.add("DB101.10.1"); |
| | | addressList0.add("DB101.10.2"); |
| | | addressList0.add("DB101.10.3"); |
| | | |
| | | // 扫码枪 |
| | | List<Boolean> data2 = S7control.getinstance().readBits(addressList0); |
| | | List<String> addressList3 = new ArrayList<>(); |
| | | addressList3.add("DB103.256"); |
| | | addressList3.add("DB103.270"); |
| | | List<Boolean> anniuread = S7control.getinstance().readBits(niuanaddressList3); |
| | | |
| | | |
| | | |
| | | |
| | | List<String> niuanaddressList3 = new ArrayList<>(); |
| | | |
| | | niuanaddressList3.add("DB101.10.4"); |
| | | List<Boolean> anniuread = S7control.getinstance().readBits(niuanaddressList3); |
| | | |
| | | |
| | | |
| | | List<String> data3 = S7control.getinstance().readStrings(addressList3); |
| | | List<String> data3 = S7control.getinstance().readStrings(addressList3); |
| | | // A01 A02 B01 B02 |
| | | List<String> addresses4 = new ArrayList<>(); |
| | | addresses4.add("DB103.32"); |
| | | addresses4.add("DB103.34"); |
| | | addresses4.add("DB103.36"); |
| | | addresses4.add("DB103.40"); |
| | | |
| | | List<Short> data4 = S7control.getinstance().readWords(addresses4); |
| | | List<String> addresses4 = Arrays.asList(config.getProperty("Parameter2.Currentcell").split(",")); |
| | | |
| | | |
| | | List<Short> data4 = S7control.getinstance().readWords(addresses4); |
| | | |
| | | // List<Long> TIME2 = Collections.singletonList(S7control.getinstance().readtime("DB100.194")); |
| | | // System.out.println("addressList:" + TIME2); |
| | | |
| | | |
| | | // |
| | | |
| | | // |
| | | |
| | | |
| | | // |
| | |
| | | // List<Short> data4 = new ArrayList<>(Arrays.asList(values4)); |
| | | // |
| | | // |
| | | JSONObject jsonObject = new JSONObject(); |
| | | short[] params = new short[data2.size()]; |
| | | for (int i = 0; i < data2.size(); i++) { |
| | | boolean value = data2.get(i); |
| | | params[i] = value ? (short) 1 : (short) 0; |
| | | } |
| | | JSONObject jsonObject = new JSONObject(); |
| | | short[] params = new short[data2.size()]; |
| | | for (int i = 0; i < data2.size(); i++) { |
| | | boolean value = data2.get(i); |
| | | params[i] = value ? (short) 1 : (short) 0; |
| | | } |
| | | // |
| | | short[] anniuparams = new short[anniuread.size()]; |
| | | for (int i = 0; i < anniuread.size(); i++) { |
| | | boolean value = anniuread.get(i); |
| | | anniuparams[i] = value ? (short) 1 : (short) 0; |
| | | } |
| | | short[] anniuparams = new short[anniuread.size()]; |
| | | for (int i = 0; i < anniuread.size(); i++) { |
| | | boolean value = anniuread.get(i); |
| | | anniuparams[i] = value ? (short) 1 : (short) 0; |
| | | } |
| | | |
| | | jsonObject.append("params", params); |
| | | jsonObject.append("params", paramlist); |
| | | jsonObject.append("params", data); |
| | | jsonObject.append("params", data3); |
| | | jsonObject.append("params", data4); |
| | | jsonObject.append("jiting", anniuparams); |
| | | jsonObject.append("params", params); |
| | | jsonObject.append("params", paramlist); |
| | | jsonObject.append("params", data); |
| | | jsonObject.append("params", data3); |
| | | jsonObject.append("params", data4); |
| | | jsonObject.append("jiting", anniuparams); |
| | | |
| | | |
| | | // WebSocketServer sendwServer = WebSocketServer.getWebSocketServer("Parameter2"); |
| | |
| | | // sendwServer.sendMessage(jsonObject.toString()); |
| | | // } |
| | | |
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("Parameter2"); |
| | | if (sendwServer != null) { |
| | | for (WebSocketServer webserver : sendwServer) { |
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("Parameter2"); |
| | | if (sendwServer != null) { |
| | | for (WebSocketServer webserver : sendwServer) { |
| | | |
| | | webserver.sendMessage(jsonObject.toString()); |
| | | webserver.sendMessage(jsonObject.toString()); |
| | | |
| | | |
| | | if (webserver != null) { |
| | | if (webserver != null) { |
| | | |
| | | |
| | | List<String> messages = webserver.getMessages(); |
| | | List<String> addressList = new ArrayList<>(); |
| | | |
| | | addressList.add("DB101.9.2"); |
| | | addressList.add("DB101.9.3"); |
| | | addressList.add("DB101.9.4"); |
| | | addressList.add("DB101.9.5"); |
| | | addressList.add("DB101.9.6"); |
| | | addressList.add("DB101.9.7"); |
| | | addressList.add("DB101.10.0"); |
| | | addressList.add("DB101.10.1"); |
| | | addressList.add("DB101.10.2"); |
| | | addressList.add("DB101.10.3"); |
| | | List<String> messages = webserver.getMessages(); |
| | | |
| | | |
| | | if (!messages.isEmpty()) { |
| | | // 将最后一个消息转换为整数类型的列表 |
| | | String lastMessage = messages.get(messages.size() - 1); |
| | | if (!messages.isEmpty()) { |
| | | // 将最后一个消息转换为整数类型的列表 |
| | | String lastMessage = messages.get(messages.size() - 1); |
| | | // System.out.println("lastMessage:" + lastMessage); |
| | | JSONArray messageArray = new JSONArray(lastMessage); |
| | | |
| | | if (messageArray.getJSONArray(0).size() > 0) { |
| | | JSONArray jsonArray3 = messageArray.getJSONArray(0); |
| | | List<Boolean> sValue3 = new ArrayList<>(); |
| | | for (int i = 0; i < jsonArray3.size(); i++) { |
| | | Object value = jsonArray3.get(i); |
| | | if (value != null && !value.toString().equals("null")) { |
| | | try { |
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", ""); |
| | | boolean val = "1".equals(cleanedValue.trim()); |
| | | sValue3.add(val); |
| | | System.out.println("messageValue: " + Arrays.asList(val) + " added to the list"); |
| | | } catch (NumberFormatException e) { |
| | | // 如果无法解析为 boolean 类型,则忽略该部分 |
| | | System.err.println("Could not parse value: " + value); |
| | | } |
| | | } |
| | | } |
| | | if (!sValue3.isEmpty()) { |
| | | S7control.getinstance().WriteBit(addressList, sValue3); |
| | | System.out.println("Values " + sValue3 + " written to PLC at address " + addressList); |
| | | } |
| | | } |
| | | // 将布尔列表写入 PLC |
| | | if (messageArray.getJSONArray(1).size() > 0) { |
| | | JSONArray jsonArray3 = messageArray.getJSONArray(1); |
| | | List<Boolean> sValue3 = new ArrayList<>(); |
| | | for (int i = 0; i < jsonArray3.size(); i++) { |
| | | Object value = jsonArray3.get(i); |
| | | if (value != null && !value.toString().equals("null")) { |
| | | try { |
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", ""); |
| | | boolean val = "1".equals(cleanedValue.trim()); |
| | | sValue3.add(val); |
| | | System.out.println("messageValue: " + Arrays.asList(val) + " added to the list"); |
| | | } catch (NumberFormatException e) { |
| | | // 如果无法解析为 boolean 类型,则忽略该部分 |
| | | System.err.println("Could not parse value: " + value); |
| | | } |
| | | } |
| | | } |
| | | if (!sValue3.isEmpty()) { |
| | | S7control.getinstance().WriteBit(niuanaddressList3, sValue3); |
| | | |
| | | System.out.println("Values " + sValue3 + " written to PLC at address " + sValue3); |
| | | } |
| | | } |
| | | |
| | | |
| | | // 清空消息列表 |
| | | webserver.clearMessages(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | JSONArray messageArray = new JSONArray(lastMessage); |
| | | //清除ID |
| | | customS7Control.writeBitToPLC(messageArray, addressList0, 0); |
| | | //急停 |
| | | customS7Control.writeBitToPLC(messageArray, niuanaddressList3, 1); |
| | | // 清空消息列表 |
| | | webserver.clearMessages(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | import org.apache.commons.io.FileUtils;
|
| | |
|
| | | public class PlcPositioning1 extends Thread {
|
| | | String name = "";
|
| | | Integer count = 0;
|
| | |
|
| | | public static String readFileToString(String filePath) throws IOException {
|
| | | File file = new File(filePath);
|
| | | return FileUtils.readFileToString(file, "UTF-8");
|
| | | }
|
| | |
|
| | | public void readValue() {
|
| | | String str = "";
|
| | | BufferedReader bufferedReader = null;
|
| | | FileInputStream fileInputStream;
|
| | | try {
|
| | | // 从文件中读取字节数据存入 fileInputStream
|
| | | fileInputStream = new FileInputStream("CanadaMes-ui/src/configuration/address.json");
|
| | | // 读取 fileInputStream 中字节并将其解码为字符
|
| | | InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "utf-8");
|
| | | // 提高读取效率,在 BufferedReader 内包装 InputStreamReader
|
| | | bufferedReader = new BufferedReader(inputStreamReader);
|
| | | String line = null;
|
| | | // 将 bufferedReader 内容一行一行赋值给str
|
| | | while ((line = bufferedReader.readLine()) != null) {
|
| | | str += line;
|
| | | }
|
| | |
|
| | | // 将str字符串格式转为json
|
| | | JSONObject jsonObject = new JSONObject(str);
|
| | |
|
| | | // 获取json中的值
|
| | | JSONArray address = jsonObject.getJSONArray("Positioning1");
|
| | | for (int i = 0; i < address.size(); i++) {
|
| | | JSONObject ress = (JSONObject) address.get(i);
|
| | |
|
| | | this.name = ress.getStr("name");
|
| | | this.count = ress.getInt("count");
|
| | | System.out.println("messageValues:" + this.name);
|
| | | System.out.println("messageValues:" + this.count);
|
| | | }
|
| | |
|
| | | } catch (FileNotFoundException e) {
|
| | | e.printStackTrace();
|
| | | } catch (UnsupportedEncodingException e) {
|
| | | e.printStackTrace();
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void run() {
|
| | |
| | | } catch (InterruptedException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | // this.readValue();
|
| | | // String PlcAddress = this.name;
|
| | | // Integer Plccount = this.count;
|
| | |
|
| | |
|
| | | // System.out.println(stt);
|
| | | //存片格 出片格读取
|
| | | List<Short> arraylist = S7control.getinstance().ReadWord("DB100.42", 33);
|
| | | List<Short> arraylist = S7control.getinstance().ReadWord("DB100.42", 33);
|
| | | // System.out.println(arraylist);
|
| | | // Short[] 存片 = { 1 };
|
| | | // List<Short> 存片1 = new ArrayList<>(Arrays.asList(存片));
|
| | | // Short[] 接片 = { 1 };
|
| | | // List<Short> 接片1 = new ArrayList<>(Arrays.asList(接片));
|
| | | // Short[] 间距 = { 1 };
|
| | | // List<Short> 间距1 = new ArrayList<>(Arrays.asList(间距));
|
| | | // Short[] values1 = {1,1,1, 1,2, 3, 4, 5, 6, 7, 8, 9, 10,11, 12,13,14,15,16,17,18,19,20 };
|
| | |
|
| | |
|
| | | // Short[] values1 = {1,1,1, 1,2, 3, 4, 5, 6, 7, 8, 9, 10,11, 12,13,14,15,16,17,18,19,20,11, 12,13,14,15,16,17,18,19,20 };
|
| | | // List<Short> arraylist = new ArrayList<>(Arrays.asList(values1));
|
| | |
|
| | |
|
| | |
| | | import java.util.List;
|
| | |
|
| | | public class PlcPositioning2 extends Thread {
|
| | | String name = "";
|
| | | Integer count = 0;
|
| | |
|
| | | public static String readFileToString(String filePath) throws IOException {
|
| | | File file = new File(filePath);
|
| | | return FileUtils.readFileToString(file, "UTF-8");
|
| | | }
|
| | |
|
| | | public void readValue() {
|
| | | String str = "";
|
| | | BufferedReader bufferedReader = null;
|
| | | FileInputStream fileInputStream;
|
| | | try {
|
| | | // 从文件中读取字节数据存入 fileInputStream
|
| | | fileInputStream = new FileInputStream("CanadaMes-ui/src/configuration/address.json");
|
| | | // 读取 fileInputStream 中字节并将其解码为字符
|
| | | InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "utf-8");
|
| | | // 提高读取效率,在 BufferedReader 内包装 InputStreamReader
|
| | | bufferedReader = new BufferedReader(inputStreamReader);
|
| | | String line = null;
|
| | | // 将 bufferedReader 内容一行一行赋值给str
|
| | | while ((line = bufferedReader.readLine()) != null) {
|
| | | str += line;
|
| | | }
|
| | |
|
| | | // 将str字符串格式转为json
|
| | | JSONObject jsonObject = new JSONObject(str);
|
| | |
|
| | | // 获取json中的值
|
| | | JSONArray address = jsonObject.getJSONArray("Positioning2");
|
| | | for (int i = 0; i < address.size(); i++) {
|
| | | JSONObject ress = (JSONObject) address.get(i);
|
| | |
|
| | | this.name = ress.getStr("name");
|
| | | this.count = ress.getInt("count");
|
| | | System.out.println("messageValues:" + this.name);
|
| | | System.out.println("messageValues:" + this.count);
|
| | | }
|
| | |
|
| | | } catch (FileNotFoundException e) {
|
| | | e.printStackTrace();
|
| | | } catch (UnsupportedEncodingException e) {
|
| | | e.printStackTrace();
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void run() {
|
| | |
| | | public class PlcServoManualone extends Thread { |
| | | |
| | | |
| | | // 用于存储应用程序的配置信息 |
| | | private Configuration config; |
| | | // 用于存储应用程序的配置信息 |
| | | private Configuration config; |
| | | |
| | | // 创建一个自定义的 S7 控制器消息处理器对象 |
| | | MessageHandler customS7Control = new MessageHandler(); |
| | | // 创建一个自定义的 S7 控制器消息处理器对象 |
| | | MessageHandler customS7Control = new MessageHandler(); |
| | | |
| | | |
| | | public PlcServoManualone() throws IOException { |
| | | config = new Configuration("config.properties"); |
| | | } |
| | | public PlcServoManualone() throws IOException { |
| | | config = new Configuration("config.properties"); |
| | | } |
| | | |
| | | //将布尔列表转换为二进制的 short 数组 |
| | | public static class PLCBooleanConverter { |
| | | //将布尔列表转换为二进制的 short 数组 |
| | | public static class PLCBooleanConverter { |
| | | |
| | | public static short[] convertListsToBinaryShortArray(List<Boolean>... lists) { |
| | | // 计算所有列表中元素的总数 |
| | | int totalSize = 0; |
| | | for (List<Boolean> list : lists) { |
| | | totalSize += list.size(); |
| | | } |
| | | public static short[] convertListsToBinaryShortArray(List<Boolean>... lists) { |
| | | // 计算所有列表中元素的总数 |
| | | int totalSize = 0; |
| | | for (List<Boolean> list : lists) { |
| | | totalSize += list.size(); |
| | | } |
| | | |
| | | // 创建一个足够大的数组来存放所有的二进制值 |
| | | short[] binaryShortArray = new short[totalSize]; |
| | | // 创建一个足够大的数组来存放所有的二进制值 |
| | | short[] binaryShortArray = new short[totalSize]; |
| | | |
| | | // 当前数组填充位置指针 |
| | | int currentIndex = 0; |
| | | // 当前数组填充位置指针 |
| | | int currentIndex = 0; |
| | | |
| | | // 遍历所有的列表 |
| | | for (List<Boolean> list : lists) { |
| | | // 将每个布尔值转换为 0 或 1 并填入数组 |
| | | for (Boolean value : list) { |
| | | binaryShortArray[currentIndex++] = (short) (value ? 1 : 0); |
| | | // 遍历所有的列表 |
| | | for (List<Boolean> list : lists) { |
| | | // 将每个布尔值转换为 0 或 1 并填入数组 |
| | | for (Boolean value : list) { |
| | | binaryShortArray[currentIndex++] = (short) (value ? 1 : 0); |
| | | } |
| | | } |
| | | |
| | | return binaryShortArray; |
| | | } |
| | | } |
| | | |
| | | return binaryShortArray; |
| | | } |
| | | } |
| | | |
| | | //读取id |
| | | public StringBuilder queGlassid(String address,int count) { |
| | | StringBuilder writedstrIdOut = new StringBuilder(); |
| | | byte[] writedglassidbytesOut = S7control.getinstance().ReadByte(address, count); |
| | | if (writedglassidbytesOut != null) { |
| | | // 获取玻璃id |
| | | for (byte iditem : writedglassidbytesOut) { |
| | | writedstrIdOut.append((char) iditem); |
| | | } |
| | | //读取id |
| | | public StringBuilder queGlassid(String address, int count) { |
| | | StringBuilder writedstrIdOut = new StringBuilder(); |
| | | byte[] writedglassidbytesOut = S7control.getinstance().ReadByte(address, count); |
| | | if (writedglassidbytesOut != null) { |
| | | // 获取玻璃id |
| | | for (byte iditem : writedglassidbytesOut) { |
| | | writedstrIdOut.append((char) iditem); |
| | | } |
| | | } |
| | | return writedstrIdOut; |
| | | } |
| | | return writedstrIdOut; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void run() { |
| | | while (this != null) { |
| | | try { |
| | | Thread.sleep(1000); |
| | | @Override |
| | | public void run() { |
| | | while (this != null) { |
| | | try { |
| | | Thread.sleep(1000); |
| | | |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | |
| | | //A01组合中地址表集合 |
| | | List<String> addresses = Arrays.asList(config.getProperty("A01.addresses").split(",")); |
| | | //System.out.println(addresses); |
| | | List<String> addresses = Arrays.asList(config.getProperty("A01.addresses").split(",")); |
| | | //System.out.println(addresses); |
| | | |
| | | List<Short> arraylist = S7control.getinstance().readWords(addresses); |
| | | List<Short> arraylist = S7control.getinstance().readWords(addresses); |
| | | |
| | | //A02组合中地址表集合 |
| | | List<String> addresses2 = Arrays.asList(config.getProperty("A02.addresses").split(",")); |
| | | List<Short> arraylist2 = S7control.getinstance().readWords(addresses2); |
| | | List<String> addresses2 = Arrays.asList(config.getProperty("A02.addresses").split(",")); |
| | | List<Short> arraylist2 = S7control.getinstance().readWords(addresses2); |
| | | |
| | | //A01翻转地址 |
| | | List<String> addresses3 = Arrays.asList(config.getProperty("A01.flipAddress")); |
| | | List<Short> arraylist3 = S7control.getinstance().readWords(addresses3); |
| | | //A01翻转地址 |
| | | List<String> addresses3 = Arrays.asList(config.getProperty("A01.flipAddress")); |
| | | List<Short> arraylist3 = S7control.getinstance().readWords(addresses3); |
| | | |
| | | //A02翻转地址 |
| | | List<String> addresses4 = Arrays.asList(config.getProperty("A02.flipAddress")); |
| | | //A02翻转地址 |
| | | List<String> addresses4 = Arrays.asList(config.getProperty("A02.flipAddress")); |
| | | |
| | | List<Short> arraylist4 = S7control.getinstance().readWords(addresses4); |
| | | //B01组合中地址 |
| | | String b01Address = config.getProperty("B01.address"); |
| | | List<Short> arraylist5 = S7control.getinstance().ReadWord(b01Address, 2); |
| | | //B02组合地址 |
| | | String b02Address = config.getProperty("B02.address"); |
| | | List<Short> arraylist6 = S7control.getinstance().ReadWord(b02Address, 2); |
| | | List<Short> arraylist4 = S7control.getinstance().readWords(addresses4); |
| | | //B01组合中地址 |
| | | String b01Address = config.getProperty("B01.address"); |
| | | List<Short> arraylist5 = S7control.getinstance().ReadWord(b01Address, 2); |
| | | //B02组合地址 |
| | | String b02Address = config.getProperty("B02.address"); |
| | | List<Short> arraylist6 = S7control.getinstance().ReadWord(b02Address, 2); |
| | | // System.out.println(b02Address); |
| | | // 所有故障按钮地址 |
| | | List<String> addresses7 = Arrays.asList(config.getProperty("faultButtonAddresses").split(",")); |
| | | List<Boolean> arraylist7 = S7control.getinstance().readBits(addresses7); |
| | | // 所有故障按钮地址 |
| | | List<String> addresses7 = Arrays.asList(config.getProperty("faultButtonAddresses").split(",")); |
| | | List<Boolean> arraylist7 = S7control.getinstance().readBits(addresses7); |
| | | |
| | | //A01启动地址 |
| | | List<String> A01start = Arrays.asList(config.getProperty("A01start")); |
| | | //A02启动地址 |
| | | List<String> A02start = Arrays.asList(config.getProperty("A02start")); |
| | | //A01启动地址 |
| | | List<String> A01start = Arrays.asList(config.getProperty("A01start")); |
| | | //A02启动地址 |
| | | List<String> A02start = Arrays.asList(config.getProperty("A02start")); |
| | | //A01半自动地址 |
| | | List<String> A01Bstart = Arrays.asList(config.getProperty("A01Bstart")); |
| | | //A02半自动地址 |
| | | List<String> A02Bstart = Arrays.asList(config.getProperty("A02Bstart")); |
| | | // |
| | | List<String> abortresumeTasks = Arrays.asList(config.getProperty("abortresumeTasks")); |
| | | //回零按钮地址 |
| | | List<String> waddresses4 = Arrays.asList(config.getProperty("HomedButtonAddresses").split(",")); |
| | | // 所有复位按钮地址 |
| | | List<String> Reset = Arrays.asList(config.getProperty("resetButtonAddresses").split(",")); |
| | | List<String> A01Bstart = Arrays.asList(config.getProperty("A01Bstart")); |
| | | //A02半自动地址 |
| | | List<String> A02Bstart = Arrays.asList(config.getProperty("A02Bstart")); |
| | | // |
| | | List<String> abortresumeTasks = Arrays.asList(config.getProperty("abortresumeTasks")); |
| | | //回零按钮地址 |
| | | List<String> waddresses4 = Arrays.asList(config.getProperty("HomedButtonAddresses").split(",")); |
| | | // 所有复位按钮地址 |
| | | List<String> Reset = Arrays.asList(config.getProperty("resetButtonAddresses").split(",")); |
| | | // System.out.println(Reset); |
| | | // 所有未回零按钮地址 |
| | | List<String> addresses8 = Arrays.asList(config.getProperty("notHomedButtonAddresses").split(",")); |
| | | // 进片id地址 |
| | | String inputGlassIdAddress = config.getProperty("inputGlassIdAddress"); |
| | | String outputGlassIdAddress = config.getProperty("outputGlassIdAddress"); |
| | | StringBuilder queueid1 = queGlassid(inputGlassIdAddress, 14); |
| | | // 存片id地址 |
| | | StringBuilder queueid2 = queGlassid(outputGlassIdAddress, 14); |
| | | // 所有未回零按钮地址 |
| | | List<String> addresses8 = Arrays.asList(config.getProperty("notHomedButtonAddresses").split(",")); |
| | | // 进片id地址 |
| | | String inputGlassIdAddress = config.getProperty("inputGlassIdAddress"); |
| | | String outputGlassIdAddress = config.getProperty("outputGlassIdAddress"); |
| | | StringBuilder queueid1 = queGlassid(inputGlassIdAddress, 14); |
| | | // 存片id地址 |
| | | StringBuilder queueid2 = queGlassid(outputGlassIdAddress, 14); |
| | | //A01 A02启动 半自动启动 |
| | | List<Boolean> A01readstart = S7control.getinstance().readBits(A01start); |
| | | List<Boolean> A02readstart = S7control.getinstance().readBits(A02start); |
| | | List<Boolean> A01readBstart = S7control.getinstance().readBits(A01Bstart); |
| | | List<Boolean> A02readsBtart = S7control.getinstance().readBits(A02Bstart); |
| | | List<Boolean> A01readstart = S7control.getinstance().readBits(A01start); |
| | | List<Boolean> A02readstart = S7control.getinstance().readBits(A02start); |
| | | List<Boolean> A01readBstart = S7control.getinstance().readBits(A01Bstart); |
| | | List<Boolean> A02readsBtart = S7control.getinstance().readBits(A02Bstart); |
| | | |
| | | List<Boolean> resumeTasks = S7control.getinstance().readBits(abortresumeTasks); |
| | | List<Boolean> resumeTasks = S7control.getinstance().readBits(abortresumeTasks); |
| | | |
| | | short[] combinedBinaryShortArray = PLCBooleanConverter.convertListsToBinaryShortArray( |
| | | A01readBstart, A01readstart, A02readsBtart,A02readstart |
| | | ); |
| | | short[] combinedBinaryShortArray = PLCBooleanConverter.convertListsToBinaryShortArray( |
| | | A01readBstart, A01readstart, A02readsBtart, A02readstart |
| | | ); |
| | | |
| | | // System.out.println(A01readBstart); |
| | | |
| | | // 所有故障按钮转换为1和0 |
| | | short[] params2 = new short[arraylist7.size()]; |
| | | for (int i = 0; i < arraylist7.size(); i++) { |
| | | boolean value = arraylist7.get(i); |
| | | params2[i] = value ? (short) 1 : (short) 0; |
| | | } |
| | | short[] params2 = new short[arraylist7.size()]; |
| | | for (int i = 0; i < arraylist7.size(); i++) { |
| | | boolean value = arraylist7.get(i); |
| | | params2[i] = value ? (short) 1 : (short) 0; |
| | | } |
| | | |
| | | //急停中止按钮 |
| | | short[] resumeTask = new short[resumeTasks.size()]; |
| | | for (int i = 0; i < resumeTasks.size(); i++) { |
| | | boolean value = resumeTasks.get(i); |
| | | resumeTask[i] = value ? (short) 1 : (short) 0; |
| | | } |
| | | short[] resumeTask = new short[resumeTasks.size()]; |
| | | for (int i = 0; i < resumeTasks.size(); i++) { |
| | | boolean value = resumeTasks.get(i); |
| | | resumeTask[i] = value ? (short) 1 : (short) 0; |
| | | } |
| | | |
| | | List<Boolean> Reset1 = S7control.getinstance().readBits(Reset); |
| | | // System.out.println(Reset1); |
| | | List<Boolean> Reset1 = S7control.getinstance().readBits(Reset); |
| | | // System.out.println(Reset1); |
| | | // 所有故障按钮转换为1和0 |
| | | short[] rReset = new short[Reset1.size()]; |
| | | for (int i = 0; i < Reset1.size(); i++) { |
| | | boolean value = Reset1.get(i); |
| | | rReset[i] = value ? (short) 1 : (short) 0; |
| | | } |
| | | short[] rReset = new short[Reset1.size()]; |
| | | for (int i = 0; i < Reset1.size(); i++) { |
| | | boolean value = Reset1.get(i); |
| | | rReset[i] = value ? (short) 1 : (short) 0; |
| | | } |
| | | |
| | | |
| | | //所有未回零按钮转换为1和0 |
| | | List<Boolean> arraylist8 = S7control.getinstance().readBits(addresses8); |
| | | short[] params = new short[arraylist8.size()]; |
| | | for (int i = 0; i < arraylist8.size(); i++) { |
| | | boolean value = arraylist8.get(i); |
| | | params[i] = value ? (short) 1 : (short) 0; |
| | | } |
| | | |
| | | |
| | | |
| | | List<Boolean> arraylist8 = S7control.getinstance().readBits(addresses8); |
| | | short[] params = new short[arraylist8.size()]; |
| | | for (int i = 0; i < arraylist8.size(); i++) { |
| | | boolean value = arraylist8.get(i); |
| | | params[i] = value ? (short) 1 : (short) 0; |
| | | } |
| | | |
| | | |
| | | // Short[] values1 = { 1, 2, 3, 4, 5, 6, 7}; |
| | |
| | | // params[i] = value ? (short) 1 : (short) 0; |
| | | // } |
| | | |
| | | JSONObject jsonObject = new JSONObject(); |
| | | JSONObject jsonObject = new JSONObject(); |
| | | |
| | | jsonObject.append("zuhe1", arraylist); |
| | | jsonObject.append("zuhe2", arraylist2); |
| | | jsonObject.append("zuhe3", arraylist3); |
| | | jsonObject.append("zuhe4", arraylist4); |
| | | jsonObject.append("zuhe5", arraylist5); |
| | | jsonObject.append("zuhe6", arraylist6); |
| | | jsonObject.append("guzhang", params2); |
| | | jsonObject.append("weihuiling", params); |
| | | jsonObject.append("jinpianid", queueid1); |
| | | jsonObject.append("qupianid", queueid2); |
| | | jsonObject.append("fuwei", rReset); |
| | | jsonObject.append("qidong", combinedBinaryShortArray); |
| | | jsonObject.append("resumeTasks", resumeTask); |
| | | |
| | | jsonObject.append("zuhe1", arraylist); |
| | | jsonObject.append("zuhe2", arraylist2); |
| | | jsonObject.append("zuhe3", arraylist3); |
| | | jsonObject.append("zuhe4", arraylist4); |
| | | jsonObject.append("zuhe5", arraylist5); |
| | | jsonObject.append("zuhe6", arraylist6); |
| | | jsonObject.append("guzhang", params2); |
| | | jsonObject.append("weihuiling", params); |
| | | jsonObject.append("jinpianid", queueid1); |
| | | jsonObject.append("qupianid", queueid2); |
| | | jsonObject.append("fuwei", rReset); |
| | | jsonObject.append("qidong", combinedBinaryShortArray); |
| | | jsonObject.append("resumeTasks", resumeTask); |
| | | |
| | | |
| | | // WebSocketServer sendwServer = WebSocketServer.sessionMap.get("ServoManualone"); |
| | |
| | | // sendwServer.sendMessage(jsonObject.toString()); |
| | | // } |
| | | |
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("ServoManualone"); |
| | | if (sendwServer != null) { |
| | | for (WebSocketServer webserver : sendwServer) { |
| | | webserver.sendMessage(jsonObject.toString()); |
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("ServoManualone"); |
| | | if (sendwServer != null) { |
| | | for (WebSocketServer webserver : sendwServer) { |
| | | webserver.sendMessage(jsonObject.toString()); |
| | | |
| | | |
| | | if (webserver != null) { |
| | | List<String> messages = webserver.getMessages(); |
| | | if (webserver != null) { |
| | | List<String> messages = webserver.getMessages(); |
| | | |
| | | |
| | | if (!messages.isEmpty()) { |
| | | // 将最后一个消息转换为 short 类型的列表 |
| | | String lastMessage = messages.get(messages.size() - 1); |
| | | if (!messages.isEmpty()) { |
| | | // 将最后一个消息转换为 short 类型的列表 |
| | | String lastMessage = messages.get(messages.size() - 1); |
| | | // System.out.println("lastMessage:" + lastMessage); |
| | | JSONArray messageArray = new JSONArray(lastMessage); |
| | | JSONArray messageArray = new JSONArray(lastMessage); |
| | | |
| | | |
| | | // 写入AO1组合 |
| | | customS7Control.WriteWordToPLC(messageArray, addresses,0); |
| | | |
| | | //A01半自动启动 |
| | | customS7Control.writeBitToPLC( messageArray, A01start,8); |
| | | // 写入AO1组合 |
| | | customS7Control.WriteWordToPLC(messageArray, addresses, 0); |
| | | |
| | | |
| | | // 写入AO2组合 |
| | | customS7Control.WriteWordToPLC(messageArray, addresses2,1); |
| | | //A02半自动启动 |
| | | // 写入AO2组合 |
| | | customS7Control.WriteWordToPLC(messageArray, addresses2, 1); |
| | | |
| | | customS7Control.writeBitToPLC( messageArray, A02start,9); |
| | | |
| | | // 复位按钮写入 |
| | | customS7Control.writeBitToPLC(messageArray, Reset, 2); |
| | | |
| | | //回零按钮写入 |
| | | customS7Control.writeBitToPLC(messageArray, waddresses4, 3); |
| | | |
| | | // 进片ID写入 |
| | | customS7Control.writeStringToPLC(messageArray, inputGlassIdAddress, 4); |
| | | //取片ID写入 |
| | | customS7Control.writeStringToPLC(messageArray, outputGlassIdAddress, 5); |
| | | |
| | | //A01半自动 |
| | | customS7Control.writeBitToPLC(messageArray, A01Bstart, 6); |
| | | //A02半自动 |
| | | customS7Control.writeBitToPLC(messageArray, A02Bstart, 7); |
| | | //A01半自动启动 |
| | | customS7Control.writeBitToPLC(messageArray, A01start, 8); |
| | | //A02半自动启动 |
| | | customS7Control.writeBitToPLC(messageArray, A02start, 9); |
| | | |
| | | |
| | | |
| | | // 复位按钮写入 |
| | | customS7Control.writeBitToPLC( messageArray, Reset,2); |
| | | |
| | | //回零按钮写入 |
| | | customS7Control.writeBitToPLC( messageArray, waddresses4,3); |
| | | |
| | | // 进片ID写入 |
| | | customS7Control.writeStringToPLC( messageArray,inputGlassIdAddress,4); |
| | | //取片ID写入 |
| | | customS7Control.writeStringToPLC( messageArray,outputGlassIdAddress,5); |
| | | |
| | | //A01半自动 |
| | | customS7Control.writeBitToPLC( messageArray, A01Bstart,6); |
| | | |
| | | //A02半自动 |
| | | customS7Control.writeBitToPLC( messageArray, A02Bstart,7); |
| | | |
| | | |
| | | |
| | | // 清空消息列表 |
| | | webserver.clearMessages(); |
| | | // 清空消息列表 |
| | | webserver.clearMessages(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | for (WebSocketServer webserver : sendwServer) { |
| | | webserver.sendMessage(jsonObject.toString()); |
| | | |
| | | } |
| | | |
| | | } |
| | | // 将获取的布尔类型转换为整数类型 |
| | | List<Integer> Intlist = new ArrayList<>(); |
| | | for (Boolean value : plclist) { |
| | |
| | | // 查询对应报警信息结束时间为null的条数 |
| | | short result = alarmMapper.selectnullti(array1[i]); |
| | | // 读取到PLC的值为1并且对应报警信息结束时间为null的条数的条数为0 |
| | | // System.out.println(result); |
| | | //System.out.println(result); |
| | | if (shuzu1[i] == 1 && result == 0) { |
| | | // 填加一条报警信息,有开始时间 |
| | | alarmMapper.Insertalarm(array1[i]); |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | package com.example.springboot.component; |
| | | |
| | | import cn.hutool.json.JSONObject; |
| | | |
| | | import java.sql.SQLException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | |
| | | import com.example.springboot.entity.Out_slice; |
| | | import com.example.springboot.entity.Queue; |
| | | import com.example.springboot.entity.StorageCage; |
| | | import com.example.springboot.entity.alarmmg; |
| | | import com.example.springboot.mapper.HomeMapper; |
| | | import com.example.springboot.mapper.SpianMapper; |
| | | import com.example.springboot.service.JdbcConnections; |
| | | import com.example.springboot.service.North_Glass_Buffer1Service; |
| | | import com.example.springboot.service.OutSliceServive; |
| | | import com.example.springboot.service.SpianService; |
| | | |
| | | public class Plchome extends Thread { |
| | | |
| | | @Autowired |
| | | private HomeMapper homeMapper; |
| | | private OutSliceServive outSliceServive; |
| | | private SpianMapper spianMapper; |
| | | private SpianService spianService; |
| | | private North_Glass_Buffer1Service north_Glass_Buffer1Service; |
| | | private JdbcConnections dbserve; |
| | | // 出片队列是否允许出片 |
| | | public static Boolean isAllowQueue = true; |
| | | // 铝框id |
| | | public static String FrameNo; |
| | | // 是否需要手动确认玻璃 |
| | | public static Boolean isConfirm = false; |
| | | |
| | | // public static Map b=new HashMap<>(); |
| | | // b.put() |
| | | @Override |
| | | public void run() { |
| | | while (this != null) { |
| | | try { |
| | | Thread.sleep(1000); |
| | | |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | JSONObject jsonObject = new JSONObject(); |
| | | |
| | | // 注入mapper |
| | | homeMapper = WebSocketServer.applicationContext.getBean(HomeMapper.class); |
| | | spianMapper = WebSocketServer.applicationContext.getBean(SpianMapper.class); |
| | | spianService = WebSocketServer.applicationContext.getBean(SpianService.class); |
| | | outSliceServive = WebSocketServer.applicationContext.getBean(OutSliceServive.class); |
| | | north_Glass_Buffer1Service = WebSocketServer.applicationContext.getBean(North_Glass_Buffer1Service.class); |
| | | // 笼子使用情况 |
| | | List<StorageCage> tableData = homeMapper.selectAll(); |
| | | jsonObject.append("tableData", tableData); |
| | | // 格理片笼格子状态 |
| | | List<StorageCage> cagelist1 = homeMapper.selectRack1(); |
| | | List<StorageCage> cagelist2 = homeMapper.selectRack2(); |
| | | List<StorageCage> cagelist3 = homeMapper.selectRack3(); |
| | | List<StorageCage> cagelist4 = homeMapper.selectRack4(); |
| | | jsonObject.append("cagelist1", cagelist1); |
| | | jsonObject.append("cagelist2", cagelist2); |
| | | jsonObject.append("cagelist3", cagelist3); |
| | | jsonObject.append("cagelist4", cagelist4); |
| | | // 进出片任务 |
| | | List<StorageCage> tasklist1 = homeMapper.selectinout(3); |
| | | List<StorageCage> tasklist2 = homeMapper.selectinout(2); |
| | | jsonObject.append("tasklist1", tasklist1); |
| | | jsonObject.append("tasklist2", tasklist2); |
| | | // 查询报警信息 |
| | | List<alarmmg> alarmmg = homeMapper.SelectAlarmmgInfo(); |
| | | jsonObject.append("alarmmg", alarmmg); |
| | | // 读去Plc进片车与出片车位置W |
| | | List<String> addressList = new ArrayList<String>(); |
| | | addressList.add("DB106.12"); |
| | | addressList.add("DB106.0"); |
| | | List<Short> paramlist = S7control.getinstance().ReadWord(addressList); |
| | | if (paramlist != null) { |
| | | jsonObject.append("params", paramlist); |
| | | } |
| | | // 获取进片车状态 |
| | | List<Short> datas1ListState = S7control.getinstance().ReadWord("DB106.8", |
| | | 1);// 获取进片车状态 |
| | | boolean exist1 = datas1ListState.contains((short) 0); |
| | | jsonObject.append("zhuangtai", exist1); |
| | | // 获取进片玻璃信息 |
| | | List<Short> inglassInfo = S7control.getinstance().ReadWord("DB106.24", 1); |
| | | if (inglassInfo != null) { |
| | | if (inglassInfo.size() > 0) |
| | | jsonObject.append("loadglassheight", inglassInfo.get(0) * 70); |
| | | } |
| | | // 伍 获取进是否有待确认的玻璃id |
| | | String queid = spianMapper.Selectqueueid(); |
| | | int state = spianMapper.Selectqueuestate(); |
| | | jsonObject.append("queid", queid); |
| | | jsonObject.append("state", state); |
| | | // 获取扫码位与上片位玻璃信息 |
| | | Queue form2 = homeMapper.GetQueueInfo(2); |
| | | Queue form3 = homeMapper.GetQueueInfo(1); |
| | | if (form2.getglassId() != null && form2.getglassId() != "") { |
| | | jsonObject.append("form2", form2); |
| | | } |
| | | if (form3.getglassId() != null && form3.getglassId() != "") { |
| | | jsonObject.append("form3", form3); |
| | | } |
| | | // 获取出片队列信息 |
| | | List<Out_slice> listoutslice = outSliceServive.SelectProductionqueue(); |
| | | jsonObject.append("listoutslice", listoutslice); |
| | | // 获取当前出片队列状态 |
| | | jsonObject.append("isAllowQueue", Plchome.isAllowQueue); |
| | | |
| | | // 获取铝框idDB106.DBW64 |
| | | // String frameno=spianService.queGlassid("DB103.270",14).toString(); |
| | | // if(frameno!=Plchome.FrameNo&&frameno!=""){ |
| | | // Plchome.FrameNo=frameno; |
| | | // } |
| | | // try { |
| | | // north_Glass_Buffer1Service.AddOutSliceS(Plchome.FrameNo); |
| | | // } catch (SQLException e) { |
| | | // // TODO Auto-generated catch block |
| | | // e.printStackTrace(); |
| | | // } |
| | | // 是否需要人工确认上片玻璃 |
| | | jsonObject.append("isConfirm", isConfirm); |
| | | |
| | | //获取进片请求状态 |
| | | List<Short> D01Request = S7control.getinstance().ReadWord("DB106.24", 1); |
| | | boolean D01RequestState = D01Request.contains((short) 1); |
| | | // boolean D01RequestState =true; |
| | | jsonObject.append("D01RequestState", D01RequestState); |
| | | |
| | | //复位倒计时 |
| | | // 地址104.9.6 |
| | | List<Boolean> countdown = S7control.getinstance().ReadBits("DB104.9.6", 1); |
| | | for (Boolean countdowns : countdown) { |
| | | jsonObject.append("countdown", countdowns); |
| | | } |
| | | // jsonObject.append("countdown", true); |
| | | // 铝框线交互 |
| | | |
| | | // //铝框id请求字 |
| | | // List<Short> framerequest = S7control.getinstance().ReadWord("铝框id请求字地址", 1); |
| | | // if(framerequest!=null){ |
| | | // //铝框id |
| | | // String franmeno= spianService.queGlassid("铝框id地址", 14).toString(); |
| | | // String position; |
| | | // try { |
| | | // position=dbserve.SelectPositionByFrameBarcode(franmeno); |
| | | // } catch (SQLException e) { |
| | | // // TODO Auto-generated catch block |
| | | // position="0"; |
| | | // e.printStackTrace(); |
| | | // } |
| | | // Short send; |
| | | // if(position=="0"){ |
| | | // send=0; |
| | | // }else{ |
| | | // send=1; |
| | | // } |
| | | // S7control.getinstance().WriteWord("铝框翻转发送地址", (short)send); |
| | | // } |
| | | |
| | | dbserve = WebSocketServer.applicationContext.getBean(JdbcConnections.class); |
| | | boolean dbconnected = false; |
| | | try { |
| | | dbserve.getConn(); |
| | | dbconnected = true; |
| | | } catch (Exception e) { |
| | | // TODO: handle exception |
| | | dbconnected = false; |
| | | } |
| | | jsonObject.append("dbconnected", dbconnected); |
| | | // jsonObject.append("params", new short[] { 30, 40, }); |
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("Home"); |
| | | if (sendwServer != null) { |
| | | for (WebSocketServer webserver : sendwServer) { |
| | | webserver.sendMessage(jsonObject.toString()); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | package com.example.springboot.component;
|
| | |
|
| | | import cn.hutool.json.JSONObject;
|
| | |
|
| | | import java.sql.SQLException;
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | |
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | |
|
| | | import com.example.springboot.entity.Out_slice;
|
| | | import com.example.springboot.entity.Queue;
|
| | | import com.example.springboot.entity.StorageCage;
|
| | | import com.example.springboot.entity.alarmmg;
|
| | | import com.example.springboot.mapper.HomeMapper;
|
| | | import com.example.springboot.mapper.SpianMapper;
|
| | | import com.example.springboot.service.JdbcConnections;
|
| | | import com.example.springboot.service.North_Glass_Buffer1Service;
|
| | | import com.example.springboot.service.OutSliceServive;
|
| | | import com.example.springboot.service.SpianService;
|
| | |
|
| | | public class Plchome extends Thread {
|
| | |
|
| | | @Autowired
|
| | | private HomeMapper homeMapper;
|
| | | private OutSliceServive outSliceServive;
|
| | | private SpianMapper spianMapper;
|
| | | private SpianService spianService;
|
| | | private North_Glass_Buffer1Service north_Glass_Buffer1Service;
|
| | | private JdbcConnections dbserve;
|
| | | // 出片队列是否允许出片
|
| | | public static Boolean isAllowQueue = true;
|
| | | // 铝框id
|
| | | public static String FrameNo;
|
| | | // 是否需要手动确认玻璃
|
| | | public static Boolean isConfirm = false;
|
| | |
|
| | | // public static Map b=new HashMap<>();
|
| | | // b.put()
|
| | | @Override
|
| | | public void run() {
|
| | | while (this != null) {
|
| | | try {
|
| | | Thread.sleep(1000);
|
| | | |
| | | } catch (InterruptedException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | JSONObject jsonObject = new JSONObject();
|
| | |
|
| | | // 注入mapper
|
| | | homeMapper = WebSocketServer.applicationContext.getBean(HomeMapper.class);
|
| | | spianMapper = WebSocketServer.applicationContext.getBean(SpianMapper.class);
|
| | | spianService = WebSocketServer.applicationContext.getBean(SpianService.class);
|
| | | outSliceServive = WebSocketServer.applicationContext.getBean(OutSliceServive.class);
|
| | | north_Glass_Buffer1Service = WebSocketServer.applicationContext.getBean(North_Glass_Buffer1Service.class);
|
| | | // 笼子使用情况
|
| | | List<StorageCage> tableData = homeMapper.selectAll();
|
| | | jsonObject.append("tableData", tableData);
|
| | | // 格理片笼格子状态
|
| | | List<StorageCage> cagelist1 = homeMapper.selectRack1();
|
| | | List<StorageCage> cagelist2 = homeMapper.selectRack2();
|
| | | List<StorageCage> cagelist3 = homeMapper.selectRack3();
|
| | | List<StorageCage> cagelist4 = homeMapper.selectRack4();
|
| | | jsonObject.append("cagelist1", cagelist1);
|
| | | jsonObject.append("cagelist2", cagelist2);
|
| | | jsonObject.append("cagelist3", cagelist3);
|
| | | jsonObject.append("cagelist4", cagelist4);
|
| | | // 进出片任务
|
| | | List<StorageCage> tasklist1 = homeMapper.selectinout(3);
|
| | | List<StorageCage> tasklist2 = homeMapper.selectinout(2);
|
| | | jsonObject.append("tasklist1", tasklist1);
|
| | | jsonObject.append("tasklist2", tasklist2);
|
| | | // 查询报警信息
|
| | | List<alarmmg> alarmmg = homeMapper.SelectAlarmmgInfo();
|
| | | jsonObject.append("alarmmg", alarmmg);
|
| | | // 读去Plc进片车与出片车位置W
|
| | | List<String> addressList = new ArrayList<String>();
|
| | | addressList.add("DB106.12");
|
| | | addressList.add("DB106.0");
|
| | | List<Short> paramlist = S7control.getinstance().ReadWord(addressList);
|
| | | if (paramlist != null) {
|
| | | jsonObject.append("params", paramlist);
|
| | | }
|
| | | // 获取进片车状态
|
| | | List<Short> datas1ListState = S7control.getinstance().ReadWord("DB106.8",
|
| | | 1);// 获取进片车状态
|
| | | boolean exist1 = datas1ListState.contains((short) 0);
|
| | | jsonObject.append("zhuangtai", exist1);
|
| | | // 获取进片玻璃信息
|
| | | List<Short> inglassInfo = S7control.getinstance().ReadWord("DB106.24", 1);
|
| | | if (inglassInfo != null) {
|
| | | if (inglassInfo.size() > 0)
|
| | | jsonObject.append("loadglassheight", inglassInfo.get(0) * 70);
|
| | | }
|
| | | // 伍 获取进是否有待确认的玻璃id
|
| | | String queid = spianMapper.Selectqueueid();
|
| | | int state = spianMapper.Selectqueuestate();
|
| | | jsonObject.append("queid", queid);
|
| | | jsonObject.append("state", state);
|
| | | // 获取扫码位与上片位玻璃信息
|
| | | Queue form2 = homeMapper.GetQueueInfo(2);
|
| | | Queue form3 = homeMapper.GetQueueInfo(1);
|
| | | if (form2.getglassId() != null && form2.getglassId() != "") {
|
| | | jsonObject.append("form2", form2);
|
| | | }
|
| | | if (form3.getglassId() != null && form3.getglassId() != "") {
|
| | | jsonObject.append("form3", form3);
|
| | | }
|
| | | // 获取出片队列信息
|
| | | List<Out_slice> listoutslice = outSliceServive.SelectProductionqueue();
|
| | | jsonObject.append("listoutslice", listoutslice);
|
| | | // 获取当前出片队列状态
|
| | | jsonObject.append("isAllowQueue", Plchome.isAllowQueue);
|
| | |
|
| | | // 获取铝框idDB106.DBW64
|
| | | // String frameno=spianService.queGlassid("DB103.270",14).toString();
|
| | | // if(frameno!=Plchome.FrameNo&&frameno!=""){
|
| | | // Plchome.FrameNo=frameno;
|
| | | // }
|
| | | // try {
|
| | | // north_Glass_Buffer1Service.AddOutSliceS(Plchome.FrameNo);
|
| | | // } catch (SQLException e) {
|
| | | // // TODO Auto-generated catch block
|
| | | // e.printStackTrace();
|
| | | // }
|
| | | // 是否需要人工确认上片玻璃
|
| | | jsonObject.append("isConfirm", isConfirm);
|
| | |
|
| | | //获取进片请求状态
|
| | | List<Short> D01Request = S7control.getinstance().ReadWord("DB106.24", 1);
|
| | | boolean D01RequestState = D01Request.contains((short)1);
|
| | | // boolean D01RequestState =true;
|
| | | jsonObject.append("D01RequestState", D01RequestState);
|
| | |
|
| | | //复位倒计时
|
| | | // 地址104.9.6
|
| | | List<Boolean> countdown = S7control.getinstance().ReadBits("DB104.9.6", 1);
|
| | | for (Boolean countdowns : countdown) {
|
| | | jsonObject.append("countdown", countdowns);
|
| | | }
|
| | | // jsonObject.append("countdown", true);
|
| | |
|
| | | //是否急停
|
| | | List<Boolean> emergencystops = S7control.getinstance().ReadBits("DB104.5.1", 1);
|
| | | for (Boolean emergencystop : emergencystops) {
|
| | | jsonObject.append("emergencystop", emergencystop);
|
| | | }
|
| | |
|
| | | // 铝框线交互
|
| | |
|
| | | // //铝框id请求字
|
| | | // List<Short> framerequest = S7control.getinstance().ReadWord("铝框id请求字地址", 1);
|
| | | // if(framerequest!=null){
|
| | | // //铝框id
|
| | | // String franmeno= spianService.queGlassid("铝框id地址", 14).toString();
|
| | | // String position;
|
| | | // try {
|
| | | // position=dbserve.SelectPositionByFrameBarcode(franmeno);
|
| | | // } catch (SQLException e) {
|
| | | // // TODO Auto-generated catch block
|
| | | // position="0";
|
| | | // e.printStackTrace();
|
| | | // }
|
| | | // Short send;
|
| | | // if(position=="0"){
|
| | | // send=0;
|
| | | // }else{
|
| | | // send=1;
|
| | | // }
|
| | | // S7control.getinstance().WriteWord("铝框翻转发送地址", (short)send);
|
| | | // }
|
| | |
|
| | | dbserve = WebSocketServer.applicationContext.getBean(JdbcConnections.class);
|
| | | boolean dbconnected = false;
|
| | | try {
|
| | | dbserve.getConn();
|
| | | dbconnected = true;
|
| | | } catch (Exception e) {
|
| | | // TODO: handle exception
|
| | | dbconnected = false;
|
| | | }
|
| | | jsonObject.append("dbconnected", dbconnected);
|
| | | // jsonObject.append("params", new short[] { 30, 40, });
|
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("Home");
|
| | | if (sendwServer != null) {
|
| | | for (WebSocketServer webserver : sendwServer) {
|
| | | webserver.sendMessage(jsonObject.toString());
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | // |
| | | System.out.println("启动完成"); |
| | | |
| | | new PlcHold().start(); |
| | | new PlcHold().start(); |
| | | |
| | | new Plchome().start(); |
| | | |
| | | // new Plcalarm().start(); |
| | | // new Plcalarm().start(); |
| | | |
| | | // new Plcsign().start(); |
| | | // new Plcsign().start(); |
| | | |
| | | // new Plcaction().start(); |
| | | // new Plcstate().start(); |
| | | // new PlcPositioning1().start(); |
| | | |
| | | // new Plcstate().start(); |
| | | // new PlcPositioning1().start(); |
| | | |
| | | // new PlcParameter2().start(); |
| | | // new PlcParameter2().start(); |
| | | |
| | | // new PLCAutomaticParameterSetting().start(); |
| | | // new PLCAutomaticParameterSetting().start(); |
| | | |
| | | // new PlcManualonePosition().start(); |
| | | // new PlcManualonePosition2().start(); |
| | | // new PlcServoManualone().start(); |
| | | // new PLCManualJog().start(); |
| | | // new PlcManualonePosition().start(); |
| | | // new PlcManualonePosition2().start(); |
| | | // new PlcServoManualone().start(); |
| | | // new PLCManualJog().start(); |
| | | } |
| | | } |
| | |
| | |
|
| | |
|
| | |
|
| | | #PLCManualJog--------------------------
|
| | |
|
| | |
|
| | |
|
| | | #Parameter2--------------------------
|
| | |
|
| | | #id
|
| | | #addressList1.add("DB103.44");//D01
|
| | | #addressList1.add("DB103.58");//D02
|
| | | #addressList1.add("DB103.72");//D03
|
| | | #addressList1.add("DB103.86");//D04
|
| | | #addressList1.add("DB103.100");//D05
|
| | | #addressList1.add("DB103.114");//D06
|
| | | #addressList1.add("DB103.128");//A01
|
| | | #addressList1.add("DB103.142");//A01 2
|
| | | #addressList1.add("DB103.156");//A02
|
| | | #addressList1.add("DB103.184");//B01
|
| | | #addressList1.add("DB103.212");//B02
|
| | | Parameter2.id=DB103.44,DB103.58,DB103.72,DB103.86,DB103.100,DB103.114,DB103.128,DB103.142,DB103.156,DB103.184,DB103.212
|
| | |
|
| | | #清除id
|
| | | #state
|
| | | #addresses.add("DB103.0");
|
| | | #addresses.add("DB103.2");
|
| | | #addresses.add("DB103.12");
|
| | | #addresses.add("DB103.14");
|
| | | #addresses.add("DB103.16");
|
| | | #addresses.add("DB103.18");
|
| | | #addresses.add("DB103.8");
|
| | | #addresses.add("DB103.10");
|
| | | #addresses.add("DB103.4");
|
| | | #addresses.add("DB103.6");
|
| | | Parameter2.state=DB103.0,DB103.2,DB103.12,DB103.14,DB103.16,DB103.18,DB103.8,DB103.10,DB103.4,DB103.6
|
| | |
|
| | | #清除id
|
| | |
|
| | |
|
| | | #手动状态
|
| | | #addressList0.add("DB101.9.2");
|
| | | #addressList0.add("DB101.9.3");
|
| | | #addressList0.add("DB101.9.4");
|
| | | #addressList0.add("DB101.9.5");
|
| | | #addressList0.add("DB101.9.6");
|
| | | #addressList0.add("DB101.9.7");
|
| | | #
|
| | | #addressList0.add("DB101.10.0");
|
| | | #addressList0.add("DB101.10.1");
|
| | | #addressList0.add("DB101.10.2");
|
| | | #addressList0.add("DB101.10.3");
|
| | | Parameter2.cleanid=DB101.9.2,DB101.9.3,DB101.9.4,DB101.9.5,DB101.9.6,DB101.9.7,DB101.10.0,DB101.10.1,DB101.10.2,DB101.10.3
|
| | | #扫码枪
|
| | | Parameter2.scanner=DB103.256,DB103.270
|
| | |
|
| | | #急停
|
| | | Parameter2.stop=DB101.10.4
|
| | |
|
| | | #当前格子
|
| | | Parameter2.Currentcell=DB103.32,DB103.34,DB103.36,DB103.40
|
| | |
|
| | |
| | | #addressList21.add("DB101.3.1");
|
| | | #addressList21.add("DB101.3.3");
|
| | | #按钮
|
| | | PLCManualJog.button=DB101.0.0,DB101.0.1,DB101.0.2,DB101.0.3,DB101.0.4,DB101.0.5,DB101.0.6,DB101.3.4,DB101.1.4,DB101.1.2,DB101.5.2,DB101.0.7,DB101.3.5,DB101.1.5,DB101.1.3,DB101.5.3,DB101.1.0,DB101.1.6,DB101.2.6,DB101.2.7,DB101.3.2,DB101.1.1,DB101.1.7,DB101.3.0,DB101.3.1,DB101.3.3
|
| | | PLCManualJog.button=DB101.0.0,DB101.0.1,DB101.0.2,DB101.0.3,DB101.0.4,DB101.0.5,DB101.0.6,DB101.3.4,DB101.1.4,DB101.1.2,DB101.5.2,DB101.0.7,DB101.3.5,DB101.1.5,DB101.1.3,DB101.5.3,DB101.1.0,DB101.1.6,DB101.2.6,DB101.2.7,DB101.3.2,DB101.1.1,DB101.1.7,DB101.3.0,DB101.3.1,DB101.3.3,DB101.10.5,DB101.10.6
|
| | |
|
| | |
|
| | |
|
| | | #AUto----------------------------------------------------------------
|
| | | #List<String> addresses = new ArrayList<>();
|
| | | #addresses.add("DB100.0");
|
| | | #addresses.add("DB100.2");
|
| | | #addresses.add("DB100.4");
|
| | | #addresses.add("DB100.6");
|
| | | #addresses.add("DB100.26");
|
| | | #addresses.add("DB100.28");
|
| | | #addresses.add("DB100.30");
|
| | | #addresses.add("DB100.32");
|
| | | #addresses.add("DB100.34");
|
| | | #addresses.add("DB100.36");
|
| | | #addresses.add("DB100.38");
|
| | | #addresses.add("DB100.40");
|
| | | Auto.addresses=DB100.0,DB100.2,DB100.4,DB100.6,DB100.26,DB100.28,DB100.30,DB100.32,DB100.36,DB100.38,DB100.40
|
| | |
|
| | | #List<String> waddresses1 = new ArrayList<>();
|
| | | #waddresses1.add("DB100.0");
|
| | | #waddresses1.add("DB100.2");
|
| | | #waddresses1.add("DB100.4");
|
| | | #waddresses1.add("DB100.6");
|
| | | #waddresses1.add("DB100.26");
|
| | | #waddresses1.add("DB100.28");
|
| | | #waddresses1.add("DB100.30");
|
| | | #waddresses1.add("DB100.32");
|
| | | #waddresses1.add("DB100.34");
|
| | | #waddresses1.add("DB100.36");
|
| | | #waddresses1.add("DB100.38");
|
| | | #waddresses1.add("DB100.40");
|
| | |
|
| | | Auto.shusong=DB100.0,DB100.2,DB100.4,DB100.6,DB100.26,DB100.28,DB100.30,DB100.32,DB100.34,DB100.36,DB100.38,DB100.40 |