Merge branch 'master' of http://10.153.19.25:10101/r/CanadaMes
| | |
| | | {
|
| | | |
| | | "ip": "192.168.10.21",
|
| | | "systemTitle": "Login System",
|
| | | "usernamePlaceholder": "Please enter username",
|
| | | "passwordPlaceholder": "Please enter password",
|
| | |
| | | "B01手动格子": "B01 Target grid(Manual)",
|
| | | "B01定位速度": "B01 TRAVEL POS Velocity manual",
|
| | | "B01当前格子": "B01 Current Grid",
|
| | | "B01启动": "Start",
|
| | | "B01启动": "B01 Start",
|
| | | "复位": "Reset",
|
| | | "回零": "Zero",
|
| | | "未回零": "NotZero",
|
| | | "B02手动格子": "B02 Target grid(Manual)",
|
| | | "B02定位速度": "B02 TRAVEL POS Velocity manual",
|
| | | "B02当前格子": "B02 Current Grid",
|
| | | "B02启动": "Start",
|
| | | "B02启动": "B02 Start",
|
| | | "复位": "Reset",
|
| | | "A01实时位置": "A01 tavel Actual Position",
|
| | | "A02实时位置": "A02 tavel Actual Position",
|
| | |
| | | {
|
| | | "ip": "192.168.10.21",
|
| | | "systemTitle": "登录系统",
|
| | | "usernamePlaceholder": "请输入用户名",
|
| | | "passwordPlaceholder": "请输入密码",
|
| | |
| | | } else { |
| | | //console.log("您的浏览器支持WebSocket"); |
| | | |
| | | let socketUrl = "ws://" + "localhost:8888" + "/springboot-vue3/api/talk/" + viewname; |
| | | let socketUrl = "ws://" + this.$t('ip')+":8888" + "/springboot-vue3/api/talk/" + viewname; |
| | | if (socket != null) { |
| | | socket.close(); |
| | | socket = null; |
| | |
| | | if (typeof WebSocket === "undefined") { |
| | | console.log("您的浏览器不支持WebSocket"); |
| | | } else { |
| | | let socketUrl = "ws://" + "localhost:8888" + "/springboot-vue3/api/talk/" + viewname; |
| | | let socketUrl = "ws://" + this.$t('ip')+":8888" + "/springboot-vue3/api/talk/" + viewname; |
| | | |
| | | if (socket != null) { |
| | | socket.close(); |
| | |
| | | if (typeof WebSocket === "undefined") { |
| | | console.log("您的浏览器不支持WebSocket"); |
| | | } else { |
| | | let socketUrl = "ws://" + "localhost:8888" + "/springboot-vue3/api/talk/" + viewname; |
| | | let socketUrl = "ws://" + this.$t('ip')+":8888" + "/springboot-vue3/api/talk/" + viewname; |
| | | |
| | | if (socket != null) { |
| | | socket.close(); |
| | |
| | | <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 }"
|
| | | :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 }"
|
| | | @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 }"
|
| | | :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 }"
|
| | | @click="updateButtonValue(dataGroup, itemIndex); submitDataToBackend(item.button.name);">{{
|
| | | item.button.name }}</el-button>
|
| | | </div>
|
| | |
| | | updateButtonValue (dataGroup, itemIndex) {
|
| | | // 将当前按钮的值设为1
|
| | |
|
| | | 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 (typeof WebSocket === "undefined") {
|
| | | console.log("您的浏览器不支持WebSocket");
|
| | | } else {
|
| | | let socketUrl = "ws://" + "localhost:8888" + "/springboot-vue3/api/talk/" + viewname;
|
| | |
|
| | | let socketUrl = "ws://" + this.$t('ip')+":8888" + "/springboot-vue3/api/talk/" + viewname;
|
| | | if (socket != null) {
|
| | | socket.close();
|
| | | socket = null;
|
| | |
| | | .error-button2 {
|
| | | background-color: red;
|
| | | }
|
| | | .greenbutton{
|
| | |
|
| | | background-color: green;
|
| | | }
|
| | | </style> |
| | |
| | | <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 }"
|
| | | :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 }"
|
| | | @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 }"
|
| | | :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 }"
|
| | | @click="updateButtonValue(dataGroup, itemIndex); submitDataToBackend(item.button.name);">{{
|
| | | item.button.name }}</el-button>
|
| | | </div>
|
| | |
| | | updateButtonValue (dataGroup, itemIndex) {
|
| | | // 将当前按钮的值设为1
|
| | |
|
| | | if (dataGroup[itemIndex].button.value === 1) {
|
| | | if (dataGroup[itemIndex].button.value === 0) {
|
| | | // 如果当前按钮的值是 0,将其设为 1
|
| | | this.$set(dataGroup[itemIndex].button, 'value', 0);
|
| | | this.$set(dataGroup[itemIndex].button, 'value', 1);
|
| | | } else {
|
| | | // 否则将其设为 0
|
| | | this.$set(dataGroup[itemIndex].button, 'value', 1);
|
| | | this.$set(dataGroup[itemIndex].button, 'value', 0);
|
| | | }
|
| | |
|
| | |
|
| | |
| | | if (typeof WebSocket === "undefined") {
|
| | | console.log("您的浏览器不支持WebSocket");
|
| | | } else {
|
| | | let socketUrl = "ws://" + "localhost:8888" + "/springboot-vue3/api/talk/" + viewname;
|
| | | let socketUrl = "ws://" + this.$t('ip')+":8888" + "/springboot-vue3/api/talk/" + viewname;
|
| | |
|
| | | if (socket != null) {
|
| | | socket.close();
|
| | |
| | | .error-button2 {
|
| | | background-color: red;
|
| | | }
|
| | | .greenbutton{
|
| | |
|
| | | 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://" + this.$t('ip')+":8888" + "/springboot-vue3/api/talk/" + viewname; |
| | | |
| | | if (socket != null) { |
| | | socket.close(); |
| | |
| | | <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" |
| | | @click="updateButtonValue(dataGroup, itemIndex);submitDataToBackend(item.button.name)" |
| | | :class="{ 'green-button': (item.button.value === 0 && item.button.name !== 'Clear ID' ) ,'red-button': item.button.value === 2 && (item.button.name !== 'Clear ID' ) ,'yellow-button': item.button.value === 1 && (item.button.name !== 'Clear ID' ) }">{{ item.button.name }}</el-button> |
| | | :class="{ 'green-button': (item.button.value === 0 && item.button.name !== 'Clear ID' ) ,'red-button': 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' ) }">{{ 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" |
| | | @click="updateButtonValue(dataGroup, itemIndex);submitDataToBackend(item.button.name)" |
| | | :class="{ 'green-button': (item.button.value === 0 && item.button.name !== '清除ID' ) ,'red-button': item.button.value === 2 && (item.button.name !== '清除ID' ) ,'yellow-button': item.button.value === 1 && (item.button.name !== '清除ID' ) }">{{ item.button.name }}</el-button> |
| | | :class="{ 'green-button': (item.button.value === 0 && item.button.name !== '清除ID' ) ,'red-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' ) }">{{ item.button.name }}</el-button> |
| | | |
| | | </div> |
| | | </div> |
| | |
| | | <script> |
| | | import LanguageMixin from '../../lang/LanguageMixin' |
| | | import data from '../../configuration/parameter2' |
| | | import { throttle } from 'lodash'; |
| | | let socket; |
| | | |
| | | // window.onload=function(){ |
| | |
| | | }, |
| | | |
| | | updateButtonValue(dataGroup, itemIndex) { |
| | | if (dataGroup[itemIndex].button.value === 1) { |
| | | if (dataGroup[itemIndex].button.value === 0) { |
| | | // 如果当前按钮的值是 0,将其设为 1 |
| | | this.$set(dataGroup[itemIndex].button, 'value', 0); |
| | | this.$set(dataGroup[itemIndex].button, 'value', 1); |
| | | } else { |
| | | // 否则将其设为 0 |
| | | this.$set(dataGroup[itemIndex].button, 'value', 1); |
| | | this.$set(dataGroup[itemIndex].button, 'value', 0); |
| | | } |
| | | }, |
| | | submitDataToBackend(currentButtonName) { |
| | |
| | | if (typeof WebSocket === "undefined") { |
| | | console.log("您的浏览器不支持WebSocket"); |
| | | } else { |
| | | let socketUrl = "ws://" + "localhost:8888" + "/springboot-vue3/api/talk/" + viewname; |
| | | let socketUrl = "ws://" + this.$t('ip')+":8888" + "/springboot-vue3/api/talk/" + viewname; |
| | | |
| | | if (socket != null) { |
| | | socket.close(); |
| | |
| | | // const xiaoche = obj.params[3]; |
| | | |
| | | // console.log(obj); |
| | | |
| | | |
| | | |
| | | const handleMouseMove = throttle(function(event) { |
| | | const inputBox = document.querySelectorAll('.action-button'); |
| | | const target = event.target; |
| | | |
| | | if (inputBox && Array.from(inputBox).every(box => !box.contains(target))) { |
| | | //清除id |
| | | for (let i = 0; i < jsonData2.length; i++) { |
| | | let arr = jsonData2[i]; |
| | |
| | | |
| | | |
| | | } |
| | | //改变状态文字 |
| | | 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 === '4' && obj.button.value===1) { |
| | | if ( obj.button.name.includes("状态")&& this.language==="zh-CN") { |
| | | obj.button.name =obj.button.name.replace("手动","自动") ; |
| | | } |
| | | if ( obj.button.name.includes("Status")) { |
| | | obj.button.name =obj.button.name.replace("Manual","Auto") ; |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | //扫描枪扫码的ID |
| | | |
| | | jsonData2.forEach((item) => { |
| | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | // console.log(jsonData2); |
| | | }, 50); |
| | | |
| | | document.addEventListener('mouseover', handleMouseMove); |
| | | |
| | | }; |
| | | |
| | |
| | | .yellow-button{ |
| | | background-color: blue; |
| | | } |
| | | .id{ |
| | | |
| | | 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://" + this.$t('ip')+":8888" + "/springboot-vue3/api/talk/" + viewname; |
| | | |
| | | if (socket != null) { |
| | | socket.close(); |
| | |
| | | if (typeof WebSocket === "undefined") { |
| | | console.log("您的浏览器不支持WebSocket"); |
| | | } else { |
| | | let socketUrl = "ws://" + "localhost:8888" + "/springboot-vue3/api/talk/" + viewname; |
| | | let socketUrl = "ws://" + this.$t('ip')+":8888" + "/springboot-vue3/api/talk/" + viewname; |
| | | |
| | | if (socket != null) { |
| | | socket.close(); |
| | |
| | | </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}" @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}" @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,'fuwei': item.button.name === 'Reset' && 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}" @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,'fuwei': 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 }" @click="updateButtonValue(dataGroup, itemIndex); submitDataToBackend(item.button.name);">{{ item.button.name }}</el-button> |
| | | </div> |
| | | </div> |
| | | </el-card> |
| | |
| | | return { |
| | | jsonData: data , |
| | | language:this.$i18n.locale, |
| | | zhi:"1", |
| | | zhi2:"1" |
| | | // 加载整个data.json文件作为jsonData |
| | | } |
| | | }, |
| | |
| | | |
| | | |
| | | updateButtonValue(dataGroup, itemIndex) { |
| | | // 将当前按钮的值设为1 |
| | | if (dataGroup[itemIndex].button.value === 1) { |
| | | // 如果当前按钮的值是 0,将其设为 1 |
| | | this.$set(dataGroup[itemIndex].button, 'value', 0); |
| | | } else { |
| | | // 否则将其设为 0 |
| | | this.$set(dataGroup[itemIndex].button, 'value', 1); |
| | | |
| | | // 将其他按钮的值设为0 |
| | | // dataGroup.forEach((item, index) => { |
| | | // if (index !== itemIndex && item.button) { |
| | | // this.$set(item.button, 'value', 0); |
| | | // } |
| | | // }); |
| | | } |
| | | }, |
| | | submitDataToBackend(currentButtonName) { |
| | | if (currentButtonName === 'A01半自动启动' ||currentButtonName === 'A01 Semi-Auto Start') { |
| | |
| | | data.push(values); |
| | | |
| | | } |
| | | data.push([]); |
| | | data.push([],[], [],); |
| | | |
| | | |
| | | const jsonObject = { data }; |
| | | |
| | |
| | | } |
| | | data2.unshift([]); |
| | | |
| | | data2.push([], [], []); |
| | | data2.push([], []); |
| | | |
| | | for (let i = 1; i < 2; i++) { |
| | | const inputData = this.jsonData[i].filter(item => item.type === '0' && item.read == 8888).map(item => { |
| | |
| | | const values2 = inputData.map(item => item.value); |
| | | |
| | | data2.push(values2); |
| | | data2.push([], [],[], []); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | const jsonObject = { data:data2 }; |
| | |
| | | |
| | | // 在 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 |
| | | ) |
| | | // setTimeout(()=> |
| | | // window.location.reload(),2000 |
| | | // ) |
| | | |
| | | } |
| | | |
| | |
| | | |
| | | // 在 data3 数组前面添加两个空数组 |
| | | data3.unshift([], [], []); |
| | | data3.push([], [], [], []); |
| | | |
| | | // 创建 jsonObject2 对象,并添加 data3 属性 |
| | | // 创建 jsonObject3 对象,并添加 data3 属性 |
| | | const jsonObject3 = { data: data3 }; |
| | | |
| | | // 提交数据到后端 |
| | | const jsonString3 = JSON.stringify(jsonObject3); |
| | | console.log('回零:', jsonString3); |
| | | socket?.send(jsonString3); |
| | | setTimeout(()=> |
| | | window.location.reload(),2000 |
| | | ) |
| | | // setTimeout(()=> |
| | | // window.location.reload(),2000 |
| | | // ) |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | if (currentButtonName === 'A01半自动' || currentButtonName === 'A01 Semi-Auto' ) { |
| | | const elements = document.getElementsByClassName('special-class'); |
| | | const data = []; |
| | | |
| | | for (let i = 0; i < elements.length; i++) { |
| | | if (elements[i].style.display === 'none') { |
| | | elements[i].style.display = ''; // 显示元素 |
| | | this.zhi=1; |
| | | // if(this.jsonData[0].button.name==='A01半自动' || this.jsonData[0].button.name === 'A01 Semi-Auto'){ |
| | | // this.jsonData[0].button.value=1 |
| | | // } |
| | | |
| | | |
| | | for (let i = 0; i < this.jsonData.length; i++) { |
| | | let arr = this.jsonData[i]; |
| | | for (let j = 0; j < arr.length; j++) { |
| | | let obj2 = arr[j]; |
| | | if (obj2.button && (obj2.button.name === "A01半自动" || obj2.button.name === "A01 Semi-Auto")) { |
| | | obj2.button.value = 1; |
| | | // console.log(obj2.button.value) |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | }else{ |
| | | elements[i].style.display = 'none'; |
| | | this.zhi=0; |
| | | // if(this.jsonData[0].button.name==='A01半自动' || this.jsonData[0].button.name === 'A01 Semi-Auto'){ |
| | | // this.jsonData[0].button.value=0 |
| | | // } |
| | | |
| | | for (let i = 0; i < this.jsonData.length; i++) { |
| | | let arr = this.jsonData[i]; |
| | | for (let j = 0; j < arr.length; j++) { |
| | | let obj2 = arr[j]; |
| | | if (obj2.button && (obj2.button.name === "A01半自动" || obj2.button.name === "A01 Semi-Auto")) { |
| | | obj2.button.value = 0; |
| | | // console.log(obj2.button.value) |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | data.push([this.zhi]); |
| | | |
| | | data.unshift([],[],[],[],[],[]); |
| | | data.push([]); |
| | | |
| | | |
| | | |
| | | |
| | | const jsonObject = { data }; |
| | | |
| | | // 提交数据到后端 |
| | | const jsonString = JSON.stringify(jsonObject); |
| | | console.log('所有Type为0的value:', jsonString); |
| | | socket?.send(jsonString); |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | if (currentButtonName === 'A02半自动' || currentButtonName === 'A02 Semi-Auto' ) { |
| | | const elements = document.getElementsByClassName('special-class2'); |
| | | |
| | | const data = []; |
| | | for (let i = 0; i < elements.length; i++) { |
| | | if (elements[i].style.display === 'none') { |
| | | elements[i].style.display = ''; // 显示元素 |
| | | this.zhi2=1; |
| | | for (let i = 0; i < this.jsonData.length; i++) { |
| | | let arr = this.jsonData[i]; |
| | | for (let j = 0; j < arr.length; j++) { |
| | | let obj2 = arr[j]; |
| | | if (obj2.button && (obj2.button.name === "A02半自动" || obj2.button.name === "A02 Semi-Auto")) { |
| | | obj2.button.value = 1; |
| | | // console.log(obj2.button.value) |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | }else{ |
| | | elements[i].style.display = 'none'; |
| | | this.zhi2=0; |
| | | for (let i = 0; i < this.jsonData.length; i++) { |
| | | let arr = this.jsonData[i]; |
| | | for (let j = 0; j < arr.length; j++) { |
| | | let obj2 = arr[j]; |
| | | if (obj2.button && (obj2.button.name === "A02半自动" || obj2.button.name === "A02 Semi-Auto")) { |
| | | obj2.button.value = 0; |
| | | // console.log(obj2.button.value) |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | data.push([this.zhi2]); |
| | | |
| | | data.unshift([],[],[],[],[],[],[]); |
| | | |
| | | |
| | | const jsonObject = { data }; |
| | | |
| | | // 提交数据到后端 |
| | | const jsonString = JSON.stringify(jsonObject); |
| | | console.log('所有Type为0的value:', jsonString); |
| | | socket?.send(jsonString); |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | if (typeof WebSocket === "undefined") { |
| | | console.log("您的浏览器不支持WebSocket"); |
| | | } else { |
| | | let socketUrl = "ws://" + "localhost:8888" + "/springboot-vue3/api/talk/" + viewname; |
| | | |
| | | let socketUrl = "ws://" +this.$t('ip')+ ":8888" + "/springboot-vue3/api/talk/" + viewname; |
| | | |
| | | if (socket != null) { |
| | | socket.close(); |
| | |
| | | let obj2 = arr[j]; |
| | | if (obj2.button && (obj2.button.name === "故障" || obj2.button.name === "Fault")) { |
| | | obj2.button.value = obj.guzhang[0][i]; |
| | | // console.log(obj2.button.value) |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | for (let i = 0; i < jsonData2.length; i++) { |
| | | let arr = jsonData2[i]; |
| | | for (let j = 0; j < arr.length; j++) { |
| | | let obj2 = arr[j]; |
| | | if (obj2.button && (obj2.button.name === "复位" || obj2.button.name === "Reset")) { |
| | | obj2.button.value = obj.fuwei[0][i]; |
| | | // console.log(obj2.button.value) |
| | | } |
| | | } |
| | |
| | | .error-button2 { |
| | | background-color: red; |
| | | } |
| | | .fuwei { |
| | | background-color: green; |
| | | } |
| | | |
| | | .qidong { |
| | | background-color: green; |
| | | } |
| | | |
| | | .qidong2 { |
| | | background-color: green; |
| | | } |
| | | |
| | | |
| | | </style> |
| | |
| | | } else {
|
| | | //console.log("您的浏览器支持WebSocket");
|
| | |
|
| | | let socketUrl = "ws://" + "localhost:8888" + "/springboot-vue3/api/talk/" + viewname;
|
| | | let socketUrl = "ws://" + this.$t('ip')+":8888" + "/springboot-vue3/api/talk/" + viewname;
|
| | | if (socket != null) {
|
| | | socket.close();
|
| | | socket = null;
|
| | |
| | | } else {
|
| | | //console.log("您的浏览器支持WebSocket");
|
| | |
|
| | | let socketUrl = "ws://" + "localhost:8888" + "/springboot-vue3/api/talk/" + viewname;
|
| | | let socketUrl = "ws://" + this.$t('ip')+":8888" + "/springboot-vue3/api/talk/" + viewname;
|
| | | if (socket != null) {
|
| | | socket.close();
|
| | | socket = null;
|
| | |
| | | } else { |
| | | //console.log("您的浏览器支持WebSocket"); |
| | | |
| | | let socketUrl = "ws://" + "localhost:8888" + "/springboot-vue3/api/talk/" + viewname; |
| | | let socketUrl = "ws://" + this.$t('ip')+":8888" + "/springboot-vue3/api/talk/" + viewname; |
| | | if (socket != null) { |
| | | socket.close(); |
| | | socket = null; |
| | |
| | | console.log("您的浏览器不支持WebSocket");
|
| | | } else {
|
| | | //console.log("您的浏览器支持WebSocket");
|
| | | let socketUrl = "ws://" + "localhost:8888" + "/springboot-vue3/api/talk/" + viewname;
|
| | | let socketUrl = "ws://" + this.$t('ip')+":8888" + "/springboot-vue3/api/talk/" + viewname;
|
| | | if (socket != null) {
|
| | | socket.close();
|
| | | socket = null;
|
| | |
| | | }
|
| | | if (obj.form3 != null && obj.form3 != "" && obj.state[0] == 1) {
|
| | | this.form3 = obj.form3[0];
|
| | |
|
| | | } else {
|
| | | this.form3 = {};
|
| | | }
|
| | |
| | | //判断玻璃是否超出范围
|
| | | Sizerange(Glass) {
|
| | | if ((Glass.glassheight < 380 || Glass.glasswidth < 390 || Glass.glassheight > 1810 || Glass.glasswidth > 2760) || (Glass.glassheight < 390 || Glass.glasswidth < 380 || Glass.glassheight > 2760 || Glass.glasswidth > 1810)) {
|
| | | if (this.disabled == false) {
|
| | | // if (this.disabled == false) {
|
| | | this.disabled = true;
|
| | | this.$message.error(this.$t('The glass size is not within the range'));
|
| | | // this.$message.error(this.$t('The glass size is not within the range'));
|
| | | this.$alert(this.$t('The glass size is not within the range'), this.$t('confirm'), {
|
| | | confirmButtonText: this.$t('Yes'),
|
| | | type:'info',
|
| | | callback: action => {
|
| | | this.$message({
|
| | | type: 'info',
|
| | | message: `action: ${action}`
|
| | | });
|
| | | action: action
|
| | | }).then(
|
| | | this.DeleteBarcodeGlass()
|
| | | );
|
| | | }
|
| | | });
|
| | | }
|
| | | // }
|
| | | // this.$message(this.$t('The glass size is not within the range'), this.$t('confirm'), {
|
| | | // // confirmwidth: 7000,
|
| | | // // height: 8000,
|
| | |
| | | } else {
|
| | | this.disabled1 = false;
|
| | | }
|
| | | },
|
| | | DeleteBarcodeGlass(){
|
| | | this.form5={};
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | loginFormRules: { |
| | | // 验证用户名是否合法 |
| | | username: [ |
| | | {required: true, message: '请输入用户名', trigger: 'blur'}, |
| | | {min: 5, max: 15, message: '长度在 5 到 15 个字符', trigger: 'blur'} |
| | | {required: true, message: this.$t('usernameRequired'), trigger: 'blur'}, |
| | | {min: 5, max: 15, message: this.$t('usernameLength'), trigger: 'blur'} |
| | | ], |
| | | // 验证密码是否合法 |
| | | password: [ |
| | | {required: true, message: '请输入密码', trigger: 'blur'}, |
| | | {min: 5, max: 15, message: '长度在 5 到 15 个字符', trigger: 'blur'} |
| | | {required: true, message: this.$t('passwordRequired'), trigger: 'blur'}, |
| | | {min: 5, max: 15, message: this.$t('passwordLength'), trigger: 'blur'} |
| | | ] |
| | | } |
| | | } |
| | |
| | | registerForm: {}, |
| | | registerRules: { |
| | | username: [ |
| | | {required: true, message: '请输入用户名', trigger: 'blur'}, |
| | | {min: 5, max: 15, message: '长度在 5 到 5 个字符', trigger: 'blur'} |
| | | {required: true, message: this.$t('usernameRequired'), trigger: 'blur'}, |
| | | {min: 5, max: 15, message: this.$t('usernameLength'), trigger: 'blur'} |
| | | ], |
| | | password1: [ |
| | | {required: true, message: '请输入密码', trigger: 'blur'}, |
| | | {min: 5, max: 15, message: '长度在 5 到 15 个字符', trigger: 'blur'}, |
| | | {required: true, message: this.$t('passwordRequired'), trigger: 'blur'}, |
| | | {min: 5, max: 15, message: this.$t('passwordLength'), trigger: 'blur'}, |
| | | {validator: validatePassword, trigger: "blur"} |
| | | ], |
| | | password: [ |
| | | {required: true, message: '请输入密码', trigger: 'blur'}, |
| | | {min: 5, max: 15, message: '长度在 5 到 15 个字符', trigger: 'blur'}, |
| | | {required: true, message: this.$t('passwordRequired'), trigger: 'blur'}, |
| | | {min: 5, max: 15, message: this.$t('passwordLength'), trigger: 'blur'}, |
| | | {validator: validatePassword, trigger: "blur"} |
| | | ], |
| | | email: [ |
| | | {required: false, message: '请输入邮箱', trigger: 'blur'}, |
| | | {type: 'email', message: '请输入正确格式的邮箱地址', trigger: 'blur'} |
| | | {required: false, message: this.$t('langEmailPlaceholder'), trigger: 'blur'}, |
| | | {type: 'email', message: this.$t('langEmailPlaceholder'), trigger: 'blur'} |
| | | ] |
| | | } |
| | | } |
| | |
| | | } |
| | | if (!sValue.isEmpty()) { |
| | | S7control.getinstance().WriteWord(waddresses1, sValue); |
| | | List<String> A01start = new ArrayList<>(); |
| | | A01start.add("DB101.2.2"); |
| | | Boolean[] a01values7 = { true}; |
| | | List<Boolean> a01startval = new ArrayList<>(Arrays.asList(a01values7)); |
| | | S7control.getinstance().WriteBit(A01start, a01startval); |
| | | System.out.println("Values " + sValue + " written to PLC at address " + waddresses1); |
| | | } |
| | | } |
| | |
| | | } |
| | | if (!sValue2.isEmpty()) { |
| | | S7control.getinstance().WriteWord(waddresses2, sValue2); |
| | | List<String> A02start = new ArrayList<>(); |
| | | A02start.add("DB101.2.3"); |
| | | Boolean[] a02values7 = { true}; |
| | | List<Boolean> a01startval = new ArrayList<>(Arrays.asList(a02values7)); |
| | | S7control.getinstance().WriteBit(A02start, a01startval); |
| | | System.out.println("Values " + sValue2 + " written to PLC at address " + waddresses2); |
| | | } |
| | | } |
| | |
| | | } |
| | | if (!sValue2.isEmpty()) { |
| | | S7control.getinstance().WriteWord(waddresses3, sValue2); |
| | | List<String> B01start = new ArrayList<>(); |
| | | B01start.add("DB101.2.4"); |
| | | Boolean[]B01values7 = { true}; |
| | | List<Boolean> B01startval = new ArrayList<>(Arrays.asList(B01values7)); |
| | | S7control.getinstance().WriteBit(B01start, B01startval); |
| | | System.out.println("Values " + sValue2 + " written to PLC at address " + waddresses3); |
| | | } |
| | | } |
| | |
| | | } |
| | | if (!sValue2.isEmpty()) { |
| | | S7control.getinstance().WriteWord(waddresses4, sValue2); |
| | | List<String> B02start = new ArrayList<>(); |
| | | B02start.add("DB101.2.5"); |
| | | Boolean[] B02values7 = { true}; |
| | | List<Boolean> B02startval = new ArrayList<>(Arrays.asList(B02values7)); |
| | | S7control.getinstance().WriteBit(B02start, B02startval); |
| | | System.out.println("Values " + sValue2 + " written to PLC at address " + waddresses4); |
| | | } |
| | | } |
| | |
| | | }
|
| | | if (!sValue.isEmpty()) {
|
| | | S7control.getinstance().WriteWord(waddresses1, sValue);
|
| | | List<String> A01start = new ArrayList<>();
|
| | | A01start.add("DB101.2.0");
|
| | | Boolean[] a01values7 = { true};
|
| | | List<Boolean> a01startval = new ArrayList<>(Arrays.asList(a01values7));
|
| | | S7control.getinstance().WriteBit(A01start, a01startval);
|
| | | System.out.println("Values " + sValue + " written to PLC at address " + waddresses1);
|
| | | }
|
| | | }
|
| | |
| | | }
|
| | | if (!sValue2.isEmpty()) {
|
| | | S7control.getinstance().WriteWord(waddresses2, sValue2);
|
| | | List<String> A02start = new ArrayList<>();
|
| | | A02start.add("DB101.2.1");
|
| | | Boolean[] a02values7 = { true};
|
| | | List<Boolean> a01startval = new ArrayList<>(Arrays.asList(a02values7));
|
| | | S7control.getinstance().WriteBit(A02start, a01startval);
|
| | | System.out.println("Values " + sValue2 + " written to PLC at address " + waddresses2);
|
| | | }
|
| | | }
|
| | |
| | | import java.io.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | public class PlcParameter2 extends Thread { |
| | |
| | | public void run() { |
| | | while (this != null) { |
| | | try { |
| | | Thread.sleep(500); |
| | | Thread.sleep(1000); |
| | | |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | |
| | | // 手动状态地址 |
| | | List<String> addressList1 = new ArrayList<>(); |
| | | |
| | | addressList1.add("DB103.44");//D01 |
| | |
| | | List<String> paramlist = S7control.getinstance().readStrings(addressList1); |
| | | |
| | | |
| | | |
| | | //清除ID地址 |
| | | List<String> addresses = new ArrayList<>(); |
| | | addresses.add("DB103.0"); |
| | | addresses.add("DB103.2"); |
| | |
| | | addresses.add("DB103.6"); |
| | | List<Short> data = S7control.getinstance().readWords(addresses); |
| | | |
| | | |
| | | //id |
| | | List<String> addressList0 = new ArrayList<>(); |
| | | |
| | | addressList0.add("DB101.9.2"); |
| | |
| | | |
| | | List<Short> data4 = S7control.getinstance().readWords(addresses4); |
| | | |
| | | // List<Long> TIME2 = Collections.singletonList(S7control.getinstance().readtime("DB100.194")); |
| | | // System.out.println("addressList:" + TIME2); |
| | | |
| | | |
| | | // |
| | | |
| | | |
| | | |
| | | |
| | | // String[] values6 = { ".x1 ","x2 ","x3",";;x4","x5","x6","x7","x8","x9","x10","x11"}; |
| | | // List<String> paramlist = new ArrayList<>(Arrays.asList(values6)); |
| | | // Short[] values1 = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; |
| | |
| | | } |
| | | |
| | | // 将布尔列表写入 PLC |
| | | S7control.getinstance().WriteBit(addressList, messageBooleans); |
| | | // S7control.getinstance().WriteBit(addressList, messageBooleans); |
| | | System.out.println("messageValues:" + messageBooleans); |
| | | System.out.println("addressList:" + addressList); |
| | | // 清空消息列表 |
| | |
| | | // Integer Plccount = this.count;
|
| | |
|
| | | // System.out.println(stt);
|
| | | //存片格 出片格读取
|
| | | List<Short> arraylist = S7control.getinstance().ReadWord("DB100.42", 23);
|
| | | // System.out.println(arraylist);
|
| | | // Short[] 存片 = { 1 };
|
| | |
| | | WebSocketServer webSocketServer = WebSocketServer.sessionMap.get("Positioning1");
|
| | | if (webSocketServer != null) {
|
| | | List<String> messages = webSocketServer.getMessages();
|
| | |
|
| | | //存片格 出片格地址
|
| | | String addressList3 = "DB100.42";
|
| | |
|
| | | if (!messages.isEmpty()) {
|
| | |
| | | }
|
| | |
|
| | |
|
| | | // 写入第yi个地址
|
| | | // 写入存片格 出片格位置设定数据
|
| | | if (!mergedList.isEmpty()) {
|
| | | S7control.getinstance().WriteWord(addressList3, mergedList);
|
| | | System.out.println("messageValue:" + mergedList + " written to PLC at address " + addressList3);
|
| | |
| | | // Integer Plccount = this.count;
|
| | |
|
| | | // System.out.println(stt);
|
| | | //B01格位置 地址读取
|
| | | List<Short> arraylist = S7control.getinstance().ReadWord("DB100.88", 10);
|
| | |
|
| | | // Short[] values1 = { 1,2, 3, 4, 5 , 11, 12,13,14,15};
|
| | |
| | | WebSocketServer webSocketServer = WebSocketServer.sessionMap.get("Positioning2");
|
| | | if (webSocketServer != null) {
|
| | | List<String> messages = webSocketServer.getMessages();
|
| | |
|
| | | //B01 B02 地址
|
| | | String addressList3 = "DB100.88";
|
| | |
|
| | | if (!messages.isEmpty()) {
|
| | |
| | | }
|
| | |
|
| | |
|
| | | // 写入第yi个地址
|
| | | // 写入b01 b02地址
|
| | | if (!mergedList.isEmpty()) {
|
| | | S7control.getinstance().WriteWord(addressList3, mergedList);
|
| | | System.out.println("messageValue:" + mergedList + " written to PLC at address " + addressList3);
|
| | |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | |
| | | //A01组合中地址表集合 |
| | | List<String> addresses = new ArrayList<>(); |
| | | addresses.add("DB103.32"); |
| | | addresses.add("DB100.144"); |
| | |
| | | // int insertIndex = 2; |
| | | // insertDataToList(arraylist, rangeAddress, insertIndex); |
| | | |
| | | |
| | | //A02组合中地址表集合 |
| | | List<String> addresses2 = new ArrayList<>(); |
| | | addresses2.add("DB103.26"); |
| | | addresses2.add("DB100.188"); |
| | |
| | | // int insertIndex2 = 4; |
| | | // insertDataToList(arraylist2, rangeAddress2, insertIndex2); |
| | | // System.out.println(arraylist2); |
| | | |
| | | //A01翻转地址 |
| | | List<String> addresses3 = new ArrayList<>(); |
| | | addresses3.add("DB103.42"); |
| | | List<Short> arraylist3 = S7control.getinstance().readWords(addresses3); |
| | | |
| | | |
| | | //A02翻转地址 |
| | | List<String> addresses4 = new ArrayList<>(); |
| | | addresses4.add("DB103.46"); |
| | | List<Short> arraylist4 = S7control.getinstance().readWords(addresses4); |
| | | |
| | | //B01组合中地址 |
| | | List<Short> arraylist5 = S7control.getinstance().ReadWord("DB103.27", 2); |
| | | //B02组合地址 |
| | | List<Short> arraylist6 = S7control.getinstance().ReadWord("DB103.29", 2); |
| | | |
| | | // 所有故障按钮地址 |
| | | List<String> addresses7 = new ArrayList<>(); |
| | | addresses7.add("DB104.1.4"); |
| | | addresses7.add("DB104.1.5"); |
| | |
| | | addresses7.add("DB104.1.7"); |
| | | List<Boolean> arraylist7 = S7control.getinstance().readBits(addresses7); |
| | | |
| | | |
| | | // 所有故障按钮转换为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; |
| | | } |
| | | |
| | | |
| | | // 所有复位按钮地址 |
| | | List<String> Reset = new ArrayList<>(); |
| | | Reset.add("DB101.4.0"); |
| | | Reset.add("DB101.4.3"); |
| | | Reset.add("DB101.3.6"); |
| | | Reset.add("DB101.4.1"); |
| | | Reset.add("DB101.4.4"); |
| | | Reset.add("DB101.4.6"); |
| | | List<Boolean> Reset1 = S7control.getinstance().readBits(Reset); |
| | | |
| | | // 所有故障按钮转换为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; |
| | | } |
| | | |
| | | // 所有未回零按钮地址 |
| | | List<String> addresses8 = new ArrayList<>(); |
| | | addresses8.add("DB104.9.0"); |
| | | addresses8.add("DB104.9.1"); |
| | |
| | | params[i] = value ? (short) 1 : (short) 0; |
| | | } |
| | | |
| | | |
| | | // 进片id地址 |
| | | StringBuilder queueid1 = queGlassid("DB100.148", 14); |
| | | // 存片id地址 |
| | | StringBuilder queueid2 = queGlassid("DB100.162", 14); |
| | | |
| | | |
| | |
| | | jsonObject.append("weihuiling", params); |
| | | jsonObject.append("jinpianid", queueid1); |
| | | jsonObject.append("qupianid", queueid2); |
| | | jsonObject.append("fuwei", rReset); |
| | | |
| | | |
| | | |
| | |
| | | WebSocketServer webSocketServer = WebSocketServer.sessionMap.get("ServoManualone"); |
| | | if (webSocketServer != null) { |
| | | List<String> messages = webSocketServer.getMessages(); |
| | | // A01组合地址 |
| | | List<String> waddresses1 = new ArrayList<>(); |
| | | waddresses1.add("DB103.32"); |
| | | waddresses1.add("DB100.144"); |
| | |
| | | waddresses1.add("DB100.180"); |
| | | waddresses1.add("DB100.182"); |
| | | |
| | | // A02组合地址 |
| | | List<String> waddresses2 = new ArrayList<>(); |
| | | waddresses2.add("DB103.26"); |
| | | waddresses2.add("DB100.188"); |
| | |
| | | waddresses2.add("DB100.146"); |
| | | // waddresses2.add("DB100.162-175"); |
| | | |
| | | |
| | | // 复位按钮地址 |
| | | List<String> waddresses3 = new ArrayList<>(); |
| | | waddresses3.add("DB101.4.0"); |
| | | waddresses3.add("DB101.4.3"); |
| | |
| | | waddresses3.add("DB101.4.4"); |
| | | waddresses3.add("DB101.4.6"); |
| | | |
| | | |
| | | //回零按钮地址 |
| | | List<String> waddresses4 = new ArrayList<>(); |
| | | waddresses4.add("DB101.3.7"); |
| | | waddresses4.add("DB101.4.2"); |
| | | waddresses4.add("DB101.4.5"); |
| | | waddresses4.add("DB101.4.7"); |
| | | |
| | | |
| | | |
| | | |
| | | String waddresses5="DB100.148"; |
| | |
| | | |
| | | |
| | | |
| | | // 写入第一个地址 |
| | | // 写入AO1组合 |
| | | if (messageArray.getJSONArray(0).size() > 0) { |
| | | JSONArray jsonArray = messageArray.getJSONArray(0); |
| | | List<Short> sValue = new ArrayList<>(); |
| | |
| | | } |
| | | } |
| | | if (!sValue.isEmpty()) { |
| | | |
| | | |
| | | |
| | | S7control.getinstance().WriteWord(waddresses1, sValue); |
| | | List<String> A01start = new ArrayList<>(); |
| | | A01start.add("DB101.5.0"); |
| | | Boolean[] a01values7 = { true}; |
| | | List<Boolean> a01startval = new ArrayList<>(Arrays.asList(a01values7)); |
| | | S7control.getinstance().WriteBit(A01start, a01startval); |
| | | System.out.println("Values " + sValue + " written to PLC at address " + waddresses1); |
| | | } |
| | | } |
| | | |
| | | |
| | | //// 写入AO2组合 |
| | | if (messageArray.getJSONArray(1).size() > 0) { |
| | | JSONArray jsonArray2 = messageArray.getJSONArray(1); |
| | | List<Short> sValue2 = new ArrayList<>(); |
| | |
| | | } |
| | | if (!sValue2.isEmpty()) { |
| | | S7control.getinstance().WriteWord(waddresses2, sValue2); |
| | | List<String> A02start = new ArrayList<>(); |
| | | A02start.add("DB101.5.1"); |
| | | Boolean[] a02values7 = {true}; |
| | | List<Boolean> a02startval = new ArrayList<>(Arrays.asList(a02values7)); |
| | | S7control.getinstance().WriteBit(A02start, a02startval); |
| | | System.out.println("Values " + sValue2 + " written to PLC at address " + waddresses2); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | // 复位按钮写入 |
| | | if (messageArray.getJSONArray(2).size() > 0) { |
| | | JSONArray jsonArray3 = messageArray.getJSONArray(2); |
| | | List<Boolean> sValue3 = new ArrayList<>(); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | //回零按钮写入 |
| | | if (messageArray.getJSONArray(3).size() > 0) { |
| | | JSONArray jsonArray4 = messageArray.getJSONArray(3); |
| | | List<Boolean> sValue4 = new ArrayList<>(); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | //进片ID写入 |
| | | if (messageArray.getJSONArray(4).size() > 0) { |
| | | // JSONArray jsonArray5 = messageArray.getJSONArray(4); |
| | | String jsonArray5 = String.valueOf(messageArray.getJSONArray(4)); |
| | |
| | | System.out.println("Values " + jsonArray5 + " written to PLC at address " + waddresses5); |
| | | } |
| | | } |
| | | |
| | | // 存片ID写入 |
| | | if (messageArray.getJSONArray(5).size() > 0) { |
| | | JSONArray jsonArray6 = messageArray.getJSONArray(5); |
| | | |
| | |
| | | System.out.println("Values " + value2 + " written to PLC at address " + waddresses6); |
| | | } |
| | | } |
| | | if (messageArray.getJSONArray(6).size() > 0) { |
| | | JSONArray jsonArray4 = messageArray.getJSONArray(6); |
| | | List<Boolean> sValueb4 = new ArrayList<>(); |
| | | for (int i = 0; i < jsonArray4.size(); i++) { |
| | | Object value = jsonArray4.get(i); |
| | | if (value != null && !value.toString().equals("null")) { |
| | | try { |
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", ""); |
| | | boolean val = "1".equals(cleanedValue.trim()); |
| | | sValueb4.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 (!sValueb4.isEmpty()) { |
| | | |
| | | List<String> A01Bstart = new ArrayList<>(); |
| | | A01Bstart.add("DB101.11.0"); |
| | | // Boolean[] a01values7 = {true}; |
| | | // List<Boolean> a01Bstartval = new ArrayList<>(Arrays.asList(a01values7)); |
| | | S7control.getinstance().WriteBit(A01Bstart, sValueb4); |
| | | System.out.println("Values " + sValueb4 + " written to PLC at address " + A01Bstart); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | if (messageArray.getJSONArray(7).size() > 0) { |
| | | JSONArray jsonArray4 = messageArray.getJSONArray(7); |
| | | List<Boolean> sValueb5 = new ArrayList<>(); |
| | | for (int i = 0; i < jsonArray4.size(); i++) { |
| | | Object value = jsonArray4.get(i); |
| | | if (value != null && !value.toString().equals("null")) { |
| | | try { |
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", ""); |
| | | boolean val = "1".equals(cleanedValue.trim()); |
| | | sValueb5.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 (!sValueb5.isEmpty()) { |
| | | |
| | | List<String> A02Bstart = new ArrayList<>(); |
| | | A02Bstart.add("DB101.11.1"); |
| | | // Boolean[] a01values7 = {true}; |
| | | // List<Boolean> a01Bstartval = new ArrayList<>(Arrays.asList(a01values7)); |
| | | S7control.getinstance().WriteBit(A02Bstart, sValueb5); |
| | | System.out.println("Values " + sValueb5 + " written to PLC at address " + A02Bstart); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | // if (messageArray.getJSONArray(6).size() > 0) { |
| | | // JSONArray jsonArray6 = messageArray.getJSONArray(6); |
| | | // |
| | | // if (!jsonArray6.isEmpty()) { |
| | | // String value2 = (String) jsonArray6.get(0); |
| | | // List<String> A01Bstart = new ArrayList<>(); |
| | | // A01Bstart.add("DB101.11.0"); |
| | | // Boolean[] a01values7 = {true}; |
| | | // List<Boolean> a01Bstartval = new ArrayList<>(Arrays.asList(a01values7)); |
| | | // S7control.getinstance().WriteBit(A01Bstart, a01Bstartval); |
| | | // System.out.println("Values " + value2 + " written to PLC at address " + waddresses6); |
| | | // } |
| | | // } |
| | | |
| | | // if (messageArray.getJSONArray(7).size() > 0) { |
| | | // JSONArray jsonArray6 = messageArray.getJSONArray(7); |
| | | // |
| | | // if (!jsonArray6.isEmpty()) { |
| | | // String value2 = (String) jsonArray6.get(0); |
| | | // List<String> A02Bstart = new ArrayList<>(); |
| | | // A02Bstart.add("DB101.11.1"); |
| | | // Boolean[] a02values7 = {true}; |
| | | // List<Boolean> a02Bstartval = new ArrayList<>(Arrays.asList(a02values7)); |
| | | // S7control.getinstance().WriteBit(A02Bstart, a02Bstartval); |
| | | // System.out.println("Values " + value2 + " written to PLC at address " + waddresses6); |
| | | // } |
| | | // } |
| | | |
| | | // 清空消息列表 |
| | | webSocketServer.clearMessages(); |
| | |
| | | // Integer Plccount = this.count; |
| | | // System.out.println(PlcAddress); |
| | | |
| | | //读取状态数据 |
| | | List<Short> plclist = S7control.getinstance().ReadWord("DB103.0", 44); |
| | | // Short[] values = { 0, 1, 1, 0, 1, 0, 1, 0, |
| | | // 1, 0, }; |
| | |
| | | import java.nio.ByteBuffer; |
| | | import java.nio.ByteOrder; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.sql.Time; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | public void outmesid(String data, String addr) { |
| | | // System.out.println("outmesid: " + data); |
| | | List<Byte> glassidlist = new ArrayList<>(); |
| | |
| | | return data; |
| | | } |
| | | |
| | | public Long readtime(String address) { |
| | | if (s7PLC==null) |
| | | return null; |
| | | return s7PLC.readTime(address); |
| | | } |
| | | |
| | | private int extractAddressNumber(String address) { |
| | | String numberStr = address.replaceAll("\\D+", ""); // 使用正则表达式提取数字部分 |
| | | return Integer.parseInt(numberStr); |
| | |
| | | return s7PLC.readBoolean(addresslist); |
| | | } |
| | | |
| | | |
| | | |
| | | private List<String> GetAddressList(String address, int count, int addedbit) { |
| | | List<String> addresslist = new ArrayList<String>(); |
| | | |
| | |
| | | // |
| | | System.out.println("启动完成"); |
| | | |
| | | // new PlcHold().start(); |
| | | |
| | | |
| | | new Plchome().start(); |
| | | new PlcHold().start(); |
| | | // |
| | | // new PlcParameter().start(); |
| | | // |
| | | new Plchome().start(); |
| | | // // |
| | | // // new Plcalarm().start(); |
| | | // // |
| | | // new Plcsign().start(); |
| | | // // |
| | | // new Plcaction().start(); |
| | | // new Plcstate().start(); |
| | | // new PlcPositioning1().start(); |
| | | // new PlcPositioning2().start(); |
| | | // new PlcParameter2().start(); |
| | | // new PlcParameter1().start(); |
| | | // new PLCAutomaticParameterSetting().start(); |
| | | new PlcParameter().start(); |
| | | // |
| | | // new Plcalarm().start(); |
| | | // |
| | | new Plcsign().start(); |
| | | // |
| | | new Plcaction().start(); |
| | | new Plcstate().start(); |
| | | new PlcPositioning1().start(); |
| | | new PlcPositioning2().start(); |
| | | new PlcParameter2().start(); |
| | | new PlcParameter1().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(); |
| | | } |
| | | } |