CanadaMes-ui/src/lang/locales/en-US.json
@@ -39,6 +39,9 @@ "exit": "exit", "changePassword": "changePassword", "resetPassword": "resetPassword", "Old password":"Old password", "New password":"New password", "Confirm password":"Confirm password", "home": "Home", "role": "role", "langRoleManagement": "Role Management", @@ -372,9 +375,9 @@ "D01手动状态": "D01 Manual Status", "清除ID": "Clear ID", "ID": "ID", "A02ID": "ID", "B01ID": "ID", "B02ID": "ID", "A02ID": "A02ID", "B01ID": "B01ID", "B02ID": "B02ID", "D02手动状态": "D02 Manual Status", "D03手动状态": "D03 Manual Status", "D04手动状态": "D04 Manual Status", CanadaMes-ui/src/layout/index.vue
@@ -66,23 +66,24 @@ <el-menu-item index="1-1" @click="logout">{{ $t('exit') }}</el-menu-item> <el-menu-item index="1-2" @click="showChangePasswordDialog">{{ $t('changePassword') }}</el-menu-item> </el-submenu> </template> <template> <el-dialog title="修改密码" :visible.sync="dialogVisible" width="30%"> <el-form ref="form" :model="formData" label-width="100px"> <el-form-item label="旧密码"> <el-dialog :title="$t('changePassword')" :visible.sync="dialogVisible" width="30%"> <el-form ref="form" :model="formData" label-width="200px"> <el-form-item :label="$t('Old password')"> <el-input v-model="formData.oldPassword" type="password" show-password></el-input> </el-form-item> <el-form-item label="新密码"> <el-form-item :label="$t('New password')"> <el-input v-model="formData.newPassword" type="password" show-password></el-input> </el-form-item> <el-form-item label="确认新密码"> <el-form-item :label="$t('Confirm password')"> <el-input v-model="formData.confirmPassword" type="password" show-password></el-input> </el-form-item> </el-form> <div slot="footer" class="dialog-footer"> <el-button @click="dialogVisible = false">取消</el-button> <el-button type="primary" @click="savePassword">保存</el-button> <el-button @click="dialogVisible = false">{{ $t('cancel') }}</el-button> <el-button type="primary" @click="savePassword">{{ $t('confirm') }}</el-button> </div> </el-dialog> </template> @@ -101,12 +102,13 @@ <el-table-column prop="timeons" :label="$t('timeon')"></el-table-column> </el-table> </el-dialog> <el-dialog :visible.sync="dialogFormCountDown" :title="$t('Approximately resettable time')" top="5vh"> <div :style="'font-size: ' + PromptSize + 'px;text-align: center;'"> <!-- {{ this.CountDowns }} --> {{ this.CountDowns }} </div> </el-dialog> <el-dialog :visible.sync="dialogFormVisible3" > <el-button :class="{ 'blue-button': receivedData === 1 }" @click="toggleButtonValue(1)">{{ $t('A01Abort/ResumeTasks') }}</el-button> <el-button :class="{ 'blue-button': receivedData2 === 1 }" @click="toggleButtonValue(2)">{{ $t('A02Abort/ResumeTasks') }}</el-button> </el-dialog> </el-container> </template> @@ -115,6 +117,7 @@ import { changePassword } from '../api/user' import { removeToken } from "../utils/auth"; import LanguageMixin from '../lang/LanguageMixin' import { MessageBox } from 'element-ui'; // import { mapState, mapMutations } from 'vuex'; // import Tag from '../layout/tag.vue'; // import store from '../store'; @@ -128,6 +131,8 @@ return { activeTag: '', // 当前激活的标签 dialogVisible: false, receivedData:0, receivedData2:0, formData: { oldPassword: '', newPassword: '', @@ -142,19 +147,18 @@ pageNum: -1 }, dialogFormVisible2: false, dialogFormCountDown:false, dialogFormVisible3: false, alarm: [], alarm2: [], CountDowns: "0", EmergencyStop: false, PromptSize:500, reset:false alarm2: [] } }, // components: { // Tag // }, created() { selectList(this.menuListForm).then(res => { this.menuList = res.data @@ -171,6 +175,48 @@ // ...mapState('tags', ['tags']) }, methods: { toggleButtonValue(buttonNumber) { MessageBox.confirm(this.$t('Are you sure to perform this operation?'), this.$t('prompt'), { confirmButtonText: this.$t('confirm'), cancelButtonText: this.$t('cancel'), type: 'warning' }).then(() => { // 点击确认按钮后执行的操作 if (buttonNumber === 1) { this.receivedData = this.receivedData === 0 ? 1 : 0; } else if (buttonNumber === 2) { this.receivedData2 = this.receivedData2 === 0 ? 1 : 0; } console.log(this.receivedData,this.receivedData2) const data3 = []; const resetButtonValues3 = [this.receivedData,this.receivedData2]; // 将得到的值添加到 data 数组中 data3.push(resetButtonValues3.flat()); // 在 data3 数组前面添加两个空数组 // 创建 jsonObject3 对象,并添加 data3 属性 const jsonObject3 = { data: data3 }; // 提交数据到后端 const jsonString3 = JSON.stringify(jsonObject3); console.log("急停后中止/继续选择:", jsonString3); socket?.send(jsonString3); setTimeout(() => { this.dialogFormVisible3 = false; }, 1000); // 延迟时间为1秒(1000毫秒) }).catch(() => { // 点击取消按钮后执行的操作 }); }, init() { let viewname = "Home"; if (typeof (WebSocket) == "undefined") { @@ -192,10 +238,12 @@ socket.onmessage = function (msg) { //console.log("收到数据====" + msg.data); let obj = JSON.parse(msg.data); if(obj.alarmmg){ if (obj.alarmmg[0].length > 0) { if (this.alarm.length > 0) { if (this.alarm[this.alarm.length - 1].id != obj.alarmmg[0][obj.alarmmg[0].length - 1].id) { if (this.alarm[this.alarm.length - 1].id != obj.alarmmg[0][obj.alarmmg[0].length-1].id) { this.alarm = obj.alarmmg[0]; this.dialogFormVisible2 = true; } @@ -207,24 +255,23 @@ this.alarm = obj.alarmmg[0]; this.dialogFormVisible2 = false; } //是否急停 if (obj.emergencystop != null) { this.EmergencyStop = obj.emergencystop[0]; } } //复位倒计时 if (obj.countdown != null) { if ((obj.countdown[0] == true && this.CountDowns == 0) || this.EmergencyStop == true) { this.CountDown(); } } //复位完成信号 if (obj.reset != null) { this.reset = obj.reset[0]; } this.$forceUpdate(); if(obj.Abort){ if (obj.Abort[0].length > 0) { this.receivedData=obj.Abort[0][0]; this.receivedData2=obj.Abort[0][1]; this.dialogFormVisible3 = true; } } this.$forceUpdate(); }.bind(this); //关闭事件 @@ -236,35 +283,6 @@ console.log("websocket发生了错误"); } } }, //45秒复位倒数计时 CountDown() { let count = 45; let timer = setInterval( () => { if (this.EmergencyStop == true) { this.dialogFormCountDown = false; clearInterval(timer); this.CountDowns = "0"; } else { if (count > 0) { this.PromptSize = 500; this.CountDowns = count; count--; this.dialogFormCountDown = true; } else { this.PromptSize = 200; this.CountDowns = "Waiting for reset"; if (this.reset == true) { clearInterval(timer); this.dialogFormCountDown = false; } } } }, 1000 ); }, logout: function () { removeToken() @@ -286,7 +304,6 @@ // this.$store.commit('tags/addTag', tag); // } }, removeTag() { // this.$store.commit('tags/removeTag', index); // 从 Vuex Store 中移除标签 @@ -419,7 +436,10 @@ margin-left: 10px; } } .blue-button { background-color: green; color: white; } .el-header { background-color: #576574; CanadaMes-ui/src/views/Electrical/AutomaticParameterSetting.vue
@@ -64,7 +64,7 @@ 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"> @keyup.enter.native="submitDataToBackend($event)"> </el-input> <!-- <el-input v-if="item.type === '0'" @@ -114,6 +114,7 @@ }, methods: { closeSocket () { // 关闭 WebSocket 连接 @@ -155,7 +156,7 @@ const jsonString = JSON.stringify(jsonObject); console.log('提交以下数据到后端:', jsonString); socket?.send(jsonString); event.target.blur(); // 取消输入框焦点 }, initWebSocket () { @@ -181,109 +182,117 @@ }; // 收到消息 let isMouseInInputBox = false; // 标记鼠标是否在输入框内 // let isMouseInInputBox = false; // 标记鼠标是否在输入框内 const inputBox = document.querySelectorAll('.input-box'); inputBox.forEach(box => { box.addEventListener('mouseenter', () => { isMouseInInputBox = true; }); box.addEventListener('mouseleave', () => { isMouseInInputBox = false; }); }); // const inputBox = document.querySelectorAll('.input-box'); // inputBox.forEach(box => { // box.addEventListener('mouseenter', () => { // isMouseInInputBox = true; // }); // box.addEventListener('mouseleave', () => { // isMouseInInputBox = false; // }); // }); socket.onmessage = (msg) => { if (!msg.data) { return; // 如果收到空数据,则直接返回,不执行后续逻辑 } // 添加判断条件:如果光标在输入框内,则不执行后续逻辑 if (document.activeElement.tagName.toLowerCase() === 'input') { return; } let obj = JSON.parse(msg.data); const jsonData2 = this.jsonData; const parms = obj.params; const fanzhuan = obj.fanzhuan; const xiaoche = obj.xiaoche; const dache = obj.dache1; const fanzhuan = obj.fanzhuan; const xiaoche = obj.xiaoche; const dache = obj.dache1; const parms2 = obj.params2; const fanzhuan2 = obj.fanzhuan2; const xiaoche2 = obj.xiaoche2; const parms2 = obj.params2; const fanzhuan2 = obj.fanzhuan2; const xiaoche2 = obj.xiaoche2; if(parms && !isMouseInInputBox){ if(parms){ let index = 0; for (let i = 0; i < jsonData2.length - 1; i++) { let arr = jsonData2[i]; let index = 0; for (let i = 0; i < jsonData2.length - 1; i++) { let arr = jsonData2[i]; 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++; } 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 arr2 = jsonData2[i]; for (let j = 0; j < arr2.length; j++) { let obj2 = arr2[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++; } } } } for (let i = 0; i < jsonData2.length; i++) { let arr = jsonData2[i]; 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(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]; } } 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 arr2 = jsonData2[i]; for (let j = 0; j < arr2.length; j++) { let obj2 = arr2[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 (document.activeElement.tagName.toLowerCase() === 'input') { // return; // } for (let i = 0; i < jsonData2.length; i++) { let arr = jsonData2[i]; 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(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]; } } }; // 关闭事件 socket.onclose = function () { console.log("websocket已关闭"); CanadaMes-ui/src/views/Electrical/ManualonePosition.vue
@@ -58,16 +58,16 @@ <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" :oninput="`value=value.replace(/^0|[^0-9]/g,'');if(value<`+item.min+`){value=`+item.value+`}else if(value>`+item.max+`){value=`+item.value+`}`" ></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" <el-input style="width:250px;" v-else-if="item.state != 0 && item.type === '0' && groupIndex === 0 " v-model="item.value" @keyup.enter.native="A01start($event)" 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+`}`" ></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" <el-input style="width:250px;" v-else-if="item.state != 0 && item.type === '0' && groupIndex === 1" v-model="item.value" @keyup.enter.native="A02start($event)" 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+`}`" ></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" <el-input style="width:250px;" v-else-if="item.state != 0 && item.type === '0' && groupIndex === 2" v-model="item.value" @keyup.enter.native="B01start($event)" 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+`}`" ></el-input> <el-input style="width:250px;" v-else-if="item.state != 0 && item.type === '0' && groupIndex === 3" v-model="item.value" @keyup.enter.native="B02start" <el-input style="width:250px;" v-else-if="item.state != 0 && item.type === '0' && groupIndex === 3" v-model="item.value" @keyup.enter.native="B02start($event)" 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+`}`" ></el-input> <el-input style="width:250px;" v-else-if="item.state != 0 && 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+`}`" ></el-input> @@ -151,7 +151,7 @@ }, A01start(){ A01start(event){ const data = []; @@ -190,9 +190,9 @@ const jsonString = JSON.stringify(jsonObject); console.log('所有Type为0的value:', jsonString); socket?.send(jsonString); event.target.blur(); // 取消输入框焦点 }, A02start(){ A02start(event){ const data = []; for (let i = 1; i < 2; i++) { @@ -223,9 +223,9 @@ const jsonString = JSON.stringify(jsonObject); console.log('所有Type为0的value:', jsonString); socket?.send(jsonString); event.target.blur(); // 取消输入框焦点 }, B01start(){ B01start(event){ const data = []; for (let i = 2; i < 3; i++) { @@ -248,9 +248,9 @@ const jsonString = JSON.stringify(jsonObject); console.log('所有Type为0的value:', jsonString); socket?.send(jsonString); event.target.blur(); // 取消输入框焦点 }, B02start(){ B02start(event){ const data = []; for (let i = 3; i < 4; i++) { @@ -283,7 +283,7 @@ const jsonString = JSON.stringify(jsonObject); console.log('所有Type为0的value:', jsonString); socket?.send(jsonString); event.target.blur(); // 取消输入框焦点 }, submitDataToBackend (currentButtonName) { if (currentButtonName === 'A01启动' || currentButtonName === 'A01 Start') { @@ -440,7 +440,7 @@ } }, @@ -467,21 +467,26 @@ }; // 收到消息 let isMouseInInputBox = false; // 标记鼠标是否在输入框内 // let isMouseInInputBox = false; // 标记鼠标是否在输入框内 const inputBox = document.querySelectorAll('.input-box'); inputBox.forEach(box => { box.addEventListener('mouseenter', () => { isMouseInInputBox = true; }); box.addEventListener('mouseleave', () => { isMouseInInputBox = false; }); }); // const inputBox = document.querySelectorAll('.input-box'); // inputBox.forEach(box => { // box.addEventListener('mouseenter', () => { // isMouseInInputBox = true; // }); // box.addEventListener('mouseleave', () => { // isMouseInInputBox = false; // }); // }); socket.onmessage = (msg) => { if (!msg.data) { return; // 如果收到空数据,则直接返回,不执行后续逻辑 } // 添加判断条件:如果光标在输入框内,则不执行后续逻辑 if (document.activeElement.tagName.toLowerCase() === 'input') { return; } let obj = JSON.parse(msg.data); @@ -489,7 +494,7 @@ const weihuiling = obj.weihuiling; if(obj.zuhe1&& !isMouseInInputBox){ if(obj.zuhe1){ // console.log(obj); CanadaMes-ui/src/views/Electrical/ManualonePosition2.vue
@@ -51,11 +51,11 @@ <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" :oninput="`value=value.replace(/^0|[^0-9]/g,'');if(value<`+item.min+`){value=`+item.value+`}else if(value>`+item.max+`){value=`+item.value+`}`"></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" <el-input style="width:250px;" v-else-if="item.state != 0 && item.type === '0' && groupIndex === 0 " v-model="item.value" @keyup.enter.native="A01start($event)" 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+`}`"></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 " v-model="item.value" @keyup.enter.native="A02start($event)" 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+`}`"></el-input> @@ -133,7 +133,7 @@ }, A01start(){ A01start(event){ const data = []; for (let i = 0; i < 1; i++) { @@ -155,10 +155,10 @@ const jsonString = JSON.stringify(jsonObject); console.log('所有Type为0的value:', jsonString); socket?.send(jsonString); event.target.blur(); // 取消输入框焦点 }, A02start(){ A02start(event){ const data = []; @@ -180,6 +180,7 @@ const jsonString = JSON.stringify(jsonObject); console.log('所有Type为0的value:', jsonString); socket?.send(jsonString); event.target.blur(); // 取消输入框焦点 }, //提交方法 submitDataToBackend (currentButtonName) { @@ -318,22 +319,27 @@ }; // 收到消息 let isMouseInInputBox = false; // 标记鼠标是否在输入框内 // let isMouseInInputBox = false; // 标记鼠标是否在输入框内 const inputBox = document.querySelectorAll('.input-box'); inputBox.forEach(box => { box.addEventListener('mouseenter', () => { isMouseInInputBox = true; }); box.addEventListener('mouseleave', () => { isMouseInInputBox = false; }); }); // const inputBox = document.querySelectorAll('.input-box'); // inputBox.forEach(box => { // box.addEventListener('mouseenter', () => { // isMouseInInputBox = true; // }); // box.addEventListener('mouseleave', () => { // isMouseInInputBox = false; // }); // }); socket.onmessage = (msg) => { if (!msg.data) { return; // 如果收到空数据,则直接返回,不执行后续逻辑 } if (document.activeElement.tagName.toLowerCase() === 'input') { return; } let obj = JSON.parse(msg.data); // console.log(obj) @@ -343,7 +349,7 @@ if (obj.zuhe1&& !isMouseInInputBox ) { if (obj.zuhe1 ) { // 执行更新逻辑 for (let i = 0; i < 2; i++) { jsonData2[i].forEach((item, index) => { CanadaMes-ui/src/views/Electrical/Parameter2.vue
@@ -186,7 +186,7 @@ <el-input v-if="item.type === '0' && groupIndex==15" v-model="item.value" @keyup.enter.native="timeout" @keyup.enter.native="timeout($event)" style="width: 300px" class="input-box2" ></el-input> @@ -265,16 +265,16 @@ }, updateButtonValue(dataGroup, itemIndex) { if (dataGroup[itemIndex].button.value === 1) { if (dataGroup[itemIndex].button.value2 === 1) { // 如果当前按钮的值是 0,将其设为 1 this.$set(dataGroup[itemIndex].button, "value", 0); this.$set(dataGroup[itemIndex].button, "value2", 0); } else { // 否则将其设为 0 this.$set(dataGroup[itemIndex].button, "value", 1); this.$set(dataGroup[itemIndex].button, "value2", 1); } }, //范围 0-100 timeout(){ timeout(event){ const data3 = []; @@ -306,7 +306,7 @@ // setTimeout(()=> // window.location.reload(),2000 // ) event.target.blur(); // 取消输入框焦点 }, @@ -322,13 +322,13 @@ ["清除ID", "Clear ID"].includes(subItem.button.name) ); return buttonItem ? buttonItem.button.value : null; return buttonItem ? buttonItem.button.value2 : null; }) .filter((value) => value !== null); .filter((value2) => value2 !== null); // 将得到的值添加到 data 数组中 data2.push(resetButtonValues.flat()); data2.push([]); data2.push([],[]); // 在 data2 数组前面添加两个空数组 // 创建 jsonObject2 对象,并添加 data2 属性 @@ -347,11 +347,12 @@ currentButtonName === "A02终止/继续" ) { const data3 = []; const resetButtonValues3 = [this.jsonData[13][0].button.value,this.jsonData[14][0].button.value]; const resetButtonValues3 = [this.jsonData[13][0].button.value2,this.jsonData[14][0].button.value2]; // 将得到的值添加到 data 数组中 data3.push(resetButtonValues3.flat()); data3.unshift([]); data3.push([]); // 在 data3 数组前面添加两个空数组 // 创建 jsonObject3 对象,并添加 data3 属性 @@ -395,22 +396,25 @@ socket.onopen = function () { console.log("websocket已打开"); }; let isMouseInInputBox = false; // 标记鼠标是否在输入框内 const inputBox = document.querySelectorAll('.input-box2'); inputBox.forEach(box => { box.addEventListener('mouseenter', () => { isMouseInInputBox = true; }); box.addEventListener('mouseleave', () => { isMouseInInputBox = false; }); }); // let isMouseInInputBox = false; // 标记鼠标是否在输入框内 let isUpdated = false; // 定义标志变量 // const inputBox = document.querySelectorAll('.input-box2'); // inputBox.forEach(box => { // box.addEventListener('mouseenter', () => { // isMouseInInputBox = true; // }); // box.addEventListener('mouseleave', () => { // isMouseInInputBox = false; // }); // }); // 收到消息 socket.onmessage = (msg) => { if (!msg.data) { return; // 如果收到空数据,则直接返回,不执行后续逻辑 } if (document.activeElement.tagName.toLowerCase() === 'input') { return; } let obj = JSON.parse(msg.data); @@ -424,7 +428,7 @@ // const inputBox = document.querySelectorAll('.id'); // const target = event.target; if (parms && !isMouseInInputBox) { if (parms ) { //急停按钮 jsonData2[13][0].button.value = obj.jiting[0][0]; jsonData2[14][0].button.value = obj.jiting[0][1]; @@ -504,6 +508,8 @@ } } } this.$forceUpdate(); //扫描枪扫码的ID jsonData2.forEach((item) => { @@ -542,7 +548,18 @@ jsonData2[15][0].value = obj.timeout[0]; if (!isUpdated) { for (let i = 0; i < jsonData2.length; i++) { for (let j = 0; j < jsonData2[i].length; j++) { if(jsonData2[i][j].button){ jsonData2[i][j].button.value2 = jsonData2[i][j].button.value; } } } isUpdated = true; // 更新标志变量的值 } } CanadaMes-ui/src/views/Electrical/Positioning1.vue
@@ -137,7 +137,7 @@ 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" @keyup.enter.native="submitDataToBackend($event)" ></el-input> <span v-if="item.unit" :name="item.unit">{{ item.unit }}</span> @@ -180,7 +180,7 @@ this.$set(dataGroup[itemIndex].button, "value", 1); // 点击按钮后将值改为1 }, //提交数据到后端 submitDataToBackend() { submitDataToBackend(event) { const inputData = this.jsonData.map((dataGroup) => { return dataGroup.map((item) => { if (item.type === "0") { @@ -208,6 +208,7 @@ const jsonString = JSON.stringify(jsonObject); console.log('提交以下数据到后端:', jsonString); socket?.send(jsonString); event.target.blur(); // 取消输入框焦点 }, initWebSocket() { let viewname = "Positioning1"; @@ -236,21 +237,24 @@ }; // 收到消息 let isMouseInInputBox = false; // 标记鼠标是否在输入框内 // let isMouseInInputBox = false; // 标记鼠标是否在输入框内 const inputBox = document.querySelectorAll('.input-box'); inputBox.forEach(box => { box.addEventListener('mouseenter', () => { isMouseInInputBox = true; }); box.addEventListener('mouseleave', () => { isMouseInInputBox = false; }); }); // const inputBox = document.querySelectorAll('.input-box'); // inputBox.forEach(box => { // box.addEventListener('mouseenter', () => { // isMouseInInputBox = true; // }); // box.addEventListener('mouseleave', () => { // isMouseInInputBox = false; // }); // }); socket.onmessage = (msg) => { if (!msg.data) { return; // 如果收到空数据,则直接返回,不执行后续逻辑 } if (document.activeElement.tagName.toLowerCase() === 'input') { return; } let obj = JSON.parse(msg.data); @@ -258,7 +262,7 @@ const parms = obj.params; if(parms && !isMouseInInputBox){ // 只有在鼠标不在输入框内时才更新数据 if(parms ){ // 只有在鼠标不在输入框内时才更新数据 // console.log(parms) let index = 0; CanadaMes-ui/src/views/Electrical/ServoManualone.vue
@@ -116,7 +116,7 @@ <el-input v-if="item.type === '0' && groupIndex === 0" v-model="item.value" @keyup.enter.native="zuhe1" @keyup.enter.native="zuhe1($event)" class="input-box" :class="{ 'special-class': groupIndex === 0, @@ -127,7 +127,7 @@ <el-input v-else-if="item.type === '0' && groupIndex === 1" v-model="item.value" @keyup.enter.native="zuhe2" @keyup.enter.native="zuhe2($event)" class="input-box" :class="{ 'special-class': groupIndex === 0, @@ -317,7 +317,7 @@ this.$set(dataGroup[itemIndex].button, "value", 1); } }, zuhe1() { zuhe1(event) { const data = []; for (let i = 0; i < 1; i++) { @@ -387,8 +387,9 @@ const jsonString = JSON.stringify(jsonObject); console.log("所有Type为0的value:", jsonString); socket?.send(jsonString); event.target.blur(); // 取消输入框焦点 }, zuhe2() { zuhe2(event) { const data2 = []; for (let i = 1; i < 2; i++) { @@ -453,6 +454,7 @@ const jsonString = JSON.stringify(jsonObject); console.log("所有Type为0的value:", jsonString); socket?.send(jsonString); event.target.blur(); // 取消输入框焦点 }, submitDataToBackend(currentButtonName) { const data = []; @@ -682,17 +684,17 @@ console.log("websocket已打开"); }; let isMouseInInputBox = false; // 标记鼠标是否在输入框内 // let isMouseInInputBox = false; // 标记鼠标是否在输入框内 const inputBox = document.querySelectorAll(".input-box"); inputBox.forEach((box) => { box.addEventListener("mouseenter", () => { isMouseInInputBox = true; }); box.addEventListener("mouseleave", () => { isMouseInInputBox = false; }); }); // const inputBox = document.querySelectorAll(".input-box"); // inputBox.forEach((box) => { // box.addEventListener("mouseenter", () => { // isMouseInInputBox = true; // }); // box.addEventListener("mouseleave", () => { // isMouseInInputBox = false; // }); // }); socket.onmessage = (msg) => { if (!msg.data) { @@ -703,8 +705,11 @@ // console.log(obj) const weihuiling = obj.weihuiling; const jsonData2 = this.jsonData; if (document.activeElement.tagName.toLowerCase() === 'input') { return; } if (obj.zuhe1 && !isMouseInInputBox) { if (obj.zuhe1 ) { //启动按钮 // 执行更新逻辑 springboot-vue3/src/main/java/com/example/springboot/component/PlcManualonePosition2.java
@@ -72,7 +72,7 @@ addresses2.add("DB100.118"); addresses2.add("DB100.192"); addresses2.add("DB103.22"); addresses2.add("DB106.14"); List<Short> arraylist2 = S7control.getinstance().readWords(addresses2); List<String> addresses9 = new ArrayList<>(); springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter2.java
@@ -21,7 +21,7 @@ public class PlcParameter2 extends Thread { @Autowired StorageCageService StorageCageService ; StorageCageService storageCageService; // 用于存储应用程序的配置信息 @@ -44,12 +44,12 @@ } catch (InterruptedException e) { e.printStackTrace(); } StorageCageService = WebSocketServer.applicationContext.getBean(StorageCageService .class); storageCageService = WebSocketServer.applicationContext.getBean(StorageCageService .class); // id List<String> addressList1 = Arrays.asList(config.getProperty("Parameter2.id").split(",")); List<String> paramlist = S7control.getinstance().readStrings(addressList1); // System.out.println("addressList:" + paramlist); //手动状态 List<String> addresses = Arrays.asList(config.getProperty("Parameter2.state").split(",")); @@ -188,18 +188,26 @@ } } //完成出片 boolean containsOne = data.stream().anyMatch(number -> number == 1); for (int i = 1; i <= 5; i++) { boolean value = sValue.get(i); if (value) { String id=paramlist.get(i); //判断是否自动状态 if(!containsOne) { //判断id是否包含数字 if(id.matches(".*\\d.*")){ //判断清楚id是否true if (value) { System.out.println(id); switch (i) { case 1: StorageCageService.UpdateTask(2, 0, paramlist.get(i)); storageCageService.UpdateTask(2, 0, paramlist.get(i)); break; case 2: case 3: case 4: case 5: StorageCageService.UpdateTask(3, 0, paramlist.get(i)); storageCageService.UpdateTask(3, 0, paramlist.get(i)); break; default: // 处理索引值不在范围内的情况 @@ -208,12 +216,14 @@ } } } // 检查布尔值列表是否为空 if (!sValue.isEmpty()) { // 调用 S7control.getinstance().WriteBit 方法将布尔值列表写入地址列表 S7control.getinstance().WriteBit(addressList0, sValue); System.out.println("Values " + sValue + " written to PLC at address " + addressList0); } } } } catch (Exception e) { @@ -261,19 +271,19 @@ boolean Value2 = sValue.get(1); if (Value1) { StorageCageService.EndTask(0); storageCageService.EndTask(0); } if (Value2) { StorageCageService.EndTask(1); storageCageService.EndTask(1); } // 检查布尔值列表是否为空 if (!sValue.isEmpty()) { // 调用 S7control.getinstance().WriteBit 方法将布尔值列表写入地址列表 S7control.getinstance().WriteBit(addressList0, sValue); System.out.println("Values " + sValue + " written to PLC at address " + addressList0); S7control.getinstance().WriteBit(niuanaddressList3, sValue); System.out.println("Values " + sValue + " written to PLC at address " + niuanaddressList3); } } } catch (Exception e) { springboot-vue3/src/main/java/com/example/springboot/component/Plcalarm.java
@@ -28,7 +28,7 @@ FileInputStream fileInputStream; try { // 从文件中读取字节数据存入 fileInputStream fileInputStream = new FileInputStream("D:/Code/canadames/Alarm.json"); fileInputStream = new FileInputStream("D:/canadames/Alarm.json"); // 读取 fileInputStream 中字节并将其解码为字符 InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "utf-8"); // 提高读取效率,在 BufferedReader 内包装 InputStreamReader springboot-vue3/src/main/java/com/example/springboot/component/Plchome.java
@@ -1,11 +1,15 @@ package com.example.springboot.component; import cn.hutool.json.JSONArray; import cn.hutool.json.JSONObject; import java.io.IOException; import java.sql.SQLException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import com.example.springboot.service.*; import org.springframework.beans.factory.annotation.Autowired; import com.example.springboot.entity.Out_slice; @@ -14,10 +18,7 @@ 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; import com.example.springboot.service.StorageCageService; public class Plchome extends Thread { @@ -36,6 +37,17 @@ // 是否需要手动确认玻璃 public static Boolean isConfirm = false; private Configuration config; private StorageCageService storageCageService; public Plchome() throws IOException { config = new Configuration("config.properties"); } // public static Map b=new HashMap<>(); // b.put() @Override @@ -50,6 +62,7 @@ JSONObject jsonObject = new JSONObject(); // 注入mapper homeMapper = WebSocketServer.applicationContext.getBean(HomeMapper.class); spianMapper = WebSocketServer.applicationContext.getBean(SpianMapper.class); spianService = WebSocketServer.applicationContext.getBean(SpianService.class); @@ -100,91 +113,120 @@ // 是否需要人工确认上片玻璃 jsonObject.append("isConfirm", isConfirm); if (S7control.getinstance().CheckConnected() == true) { // 读去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) { // 读去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) { } // 获取进片车状态 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); } // 获取铝框idDB106.DBW64 String frameno = spianService.queGlassid("DB103.270", 14).toString(); // String frameno="X12345611002GV"; if (!frameno.equals(Plchome.FrameNo)) { Plchome.FrameNo = frameno; try { north_Glass_Buffer1Service.AddOutSliceS(Plchome.FrameNo); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } // 获取进片请求状态 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> resets = S7control.getinstance().ReadBits("DB103.284", 1); for (Boolean reset : resets) { jsonObject.append("reset", reset); } // 是否急停 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); // } jsonObject.append("loadglassheight", inglassInfo.get(0) * 70); } // 获取铝框idDB106.DBW64 String frameno = spianService.queGlassid("DB103.270", 14).toString(); // String frameno="X12345611002GV"; if (!frameno.equals(Plchome.FrameNo)) { Plchome.FrameNo = frameno; try { north_Glass_Buffer1Service.AddOutSliceS(Plchome.FrameNo); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } } // 获取进片请求状态 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> resets = S7control.getinstance().ReadBits("DB103.284", 1); for (Boolean reset : resets) { jsonObject.append("reset", reset); } // 是否急停 List<Boolean> emergencystops = S7control.getinstance().ReadBits("DB104.5.1", 1); for (Boolean emergencystop : emergencystops) { jsonObject.append("emergencystop", emergencystop); } //终止继续按钮 List<String> niuanaddressList3 = Arrays.asList(config.getProperty("Parameter2.stop").split(",")); List<Boolean> anniuread = S7control.getinstance().readBits(niuanaddressList3); // Boolean[] value4 = { false, false}; // List<Boolean> anniuread = new ArrayList<>(Arrays.asList(value4)); // Boolean[] value5 = { true}; // List<Boolean> resets = new ArrayList<>(Arrays.asList(value5)); 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[] resets2 = new short[resets.size()]; for (int i = 0; i < resets.size(); i++) { boolean value = resets.get(i); resets2[i] = value ? (short) 1 : (short) 0; } System.out.println(resets); for (short number : resets2) { if (number == 1) { System.out.println(resets); jsonObject.append("Abort", anniuparams); } } // 铝框线交互 // //铝框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); // } storageCageService = WebSocketServer.applicationContext.getBean(StorageCageService.class); dbserve = WebSocketServer.applicationContext.getBean(JdbcConnections.class); boolean dbconnected = false; try { @@ -200,9 +242,79 @@ if (sendwServer != null) { for (WebSocketServer webserver : sendwServer) { webserver.sendMessage(jsonObject.toString()); if (webserver != null) { List<String> messages = webserver.getMessages(); if (!messages.isEmpty()) { // 将最后一个消息转换为整数类型的列表 String lastMessage = messages.get(messages.size() - 1); // System.out.println("lastMessage:" + lastMessage); JSONArray messageArray = new JSONArray(lastMessage); try { // 检查索引是否有效 if (messageArray.getJSONArray(0).size() > 0) { // 获取消息数组 JSONArray jsonArray = messageArray.getJSONArray(0); // 创建一个布尔值列表 List<Boolean> 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-]", ""); // 解析为布尔值 boolean val = "1".equals(cleanedValue.trim()); // 将布尔值添加到布尔值列表中 sValue.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); } } } // 终止进片任务 boolean Value1 = sValue.get(0); boolean Value2 = sValue.get(1); if (Value1) { storageCageService.EndTask(0); } if (Value2) { storageCageService.EndTask(1); } // 检查布尔值列表是否为空 if (!sValue.isEmpty()) { // 调用 S7control.getinstance().WriteBit 方法将布尔值列表写入地址列表 S7control.getinstance().WriteBit(niuanaddressList3, sValue); System.out.println("Values " + sValue + " written to PLC at address " + niuanaddressList3); } } } catch (Exception e) { System.err.println("An error occurred while writing bit to PLC: " + e.getMessage()); } webserver.clearMessages(); } } } } } } } springboot-vue3/src/main/java/com/example/springboot/component/S7control.java
@@ -223,7 +223,15 @@ if (s7PLC==null) return null; // List<String> addresslist = GetAddressList(address, count, 16); return s7PLC.readByte(address,count); try { return s7PLC.readByte(address, count); }catch (Exception e) { // 处理异常 System.out.println("读取 " + address + " 失败:" + e.getMessage()); return null; } } /** springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java
@@ -17,24 +17,24 @@ // System.out.println("启动完成"); // new PlcHold().start(); //new PlcHold().start(); new Plchome().start(); // new Plcalarm().start(); // new Plcsign().start(); // new Plcstate().start(); // new PlcPositioning1().start(); // new PlcParameter2().start(); // new PLCAutomaticParameterSetting().start(); // new PlcManualonePosition().start(); // new PlcManualonePosition2().start(); // new PlcServoManualone().start(); // new PLCManualJog().start(); // new Plchome().start(); // // new Plcalarm().start(); // // new Plcsign().start(); // // // new Plcstate().start(); // new PlcPositioning1().start(); // // new PlcParameter2().start(); // // new PLCAutomaticParameterSetting().start(); // new PlcManualonePosition().start(); // new PlcManualonePosition2().start(); // new PlcServoManualone().start(); // new PLCManualJog().start(); } }