添加新界面,配置新界面json文件,补充IO状态界面地址,添加报警信息界面json
| | |
| | | [ |
| | | [ |
| | | { |
| | | "name": "大车自动速度", |
| | | "read": 33, |
| | | "sending": "", |
| | | "type": "0", |
| | | "address": "DB100.0", |
| | | "count": 3 |
| | | } |
| | | ], |
| | | [ |
| | | { |
| | | "name": "小车自动速度", |
| | | "read": 11, |
| | | "sending": "", |
| | | "address": "DB100.0", |
| | | "type": "0" |
| | | } |
| | | ], |
| | | [ |
| | | { |
| | | "name": "A01行走高速角度", |
| | | "read": 33, |
| | | "sending": "", |
| | | "type": "0", |
| | | "address": "DB100.0", |
| | | "count": 3 |
| | | "count": 3, |
| | | "value": "" |
| | | }, |
| | | { |
| | | "name": "A01行走低速角度", |
| | | "read": 11, |
| | | "sending": "", |
| | | "address": "DB100.0", |
| | | "type": "0" |
| | | "type": "0", |
| | | "value": "" |
| | | }, |
| | | { |
| | | "name": "A01输送接片角度", |
| | | "read": 22, |
| | | "sending": "", |
| | | "address": "DB100.0", |
| | | "type": "0" |
| | | "type": "0", |
| | | "value": "" |
| | | }, |
| | | { |
| | | "name": "A01笼子角度", |
| | | "read": 22, |
| | | "sending": "", |
| | | "address": "DB100.0", |
| | | "type": "0" |
| | | "type": "0", |
| | | "value": "" |
| | | } |
| | | ], |
| | | [ |
| | |
| | | "sending": "", |
| | | "type": "0", |
| | | "address": "DB100.0", |
| | | "count": 3 |
| | | "count": 3, |
| | | "value": "" |
| | | }, |
| | | { |
| | | "name": "A02行走低速角度", |
| | | "read": 11, |
| | | "sending": "", |
| | | "address": "DB100.0", |
| | | "type": "0" |
| | | "type": "0", |
| | | "value": "" |
| | | }, |
| | | { |
| | | "name": "A02输送接片角度", |
| | | "read": 22, |
| | | "sending": "", |
| | | "address": "DB100.0", |
| | | "type": "0" |
| | | "type": "0", |
| | | "value": "" |
| | | }, |
| | | { |
| | | "name": "A02笼子角度", |
| | | "read": 22, |
| | | "sending": "", |
| | | "address": "DB100.0", |
| | | "type": "0" |
| | | "type": "0", |
| | | "value": "" |
| | | } |
| | | ], |
| | | [ |
| | | { |
| | | "name": "大车自动速度", |
| | | "read": 100, |
| | | "sending": "", |
| | | "type": "0", |
| | | "address": "DB100.0", |
| | | "count": 3, |
| | | "value": "" |
| | | } |
| | | ], |
| | | [ |
| | | { |
| | | "name": "小车自动速度", |
| | | "read": 11, |
| | | "sending": "", |
| | | "address": "DB100.0", |
| | | "type": "0", |
| | | "value": "" |
| | | } |
| | | ], |
| | | [ |
| | |
| | | "read": 33, |
| | | "sending": "", |
| | | "address": "DB100.0", |
| | | "type": "0" |
| | | "type": "0", |
| | | "value": "" |
| | | } |
| | | ] |
| | | ] |
| | |
| | | <div v-for="(item, itemIndex) in dataGroup" :key="itemIndex" class="item-container"> |
| | | <div class="item-row" v-if="item.type === '0'"> |
| | | <span class="name" v-if="item.type === '0'" style="width:150px;">{{ item.name }}</span> |
| | | <el-input style="width:150px;" v-if="item.type === '0'" v-model="item.read" class="input-box"></el-input> |
| | | <el-input style="width:150px;" v-if="item.type === '0'" v-model="item.sending" class="input-box"></el-input> |
| | | <el-input style="width:250px;" v-if="item.type === '0'" v-model="item.value" class="input-box" |
| | | @keyup.enter.native="submitDataToBackend"></el-input> |
| | | </div> |
| | | </div> |
| | | </el-card> |
| | |
| | | <script> |
| | | import LanguageMixin from '../../lang/LanguageMixin' |
| | | import data from '../../configuration/AutomaticParameterSetting' |
| | | import { throttle } from 'lodash'; |
| | | let socket; |
| | | |
| | | export default { |
| | | name: "AutomaticParameterSetting", |
| | |
| | | return { |
| | | jsonData: data // 加载整个data.json文件作为jsonData |
| | | } |
| | | }, |
| | | created () { |
| | | this.initWebSocket(); |
| | | // console.log('jsonData:', this.jsonData); |
| | | |
| | | }, |
| | | methods: { |
| | | updateButtonValue (dataGroup, itemIndex) { |
| | |
| | | }); |
| | | }); |
| | | |
| | | // 模拟提交数据到后端的操作,实际情况下需要根据你的后端API进行修改 |
| | | console.log('提交以下数据到后端:', inputData); |
| | | // 将inputData转换为整数数组 |
| | | const integerArray = inputData.map(dataGroup => { |
| | | return dataGroup.map(item => { |
| | | if (item !== null) { |
| | | return item.value; |
| | | } |
| | | return null; |
| | | }); |
| | | }); |
| | | // 构建JSON对象 |
| | | const jsonObject = { data: integerArray }; |
| | | |
| | | } |
| | | // 提交数据到后端 |
| | | const jsonString = JSON.stringify(jsonObject); |
| | | console.log('提交以下数据到后端:', jsonString); |
| | | socket?.send(jsonString); |
| | | |
| | | |
| | | }, |
| | | initWebSocket () { |
| | | |
| | | let viewname = "AutomaticParameterSetting"; |
| | | |
| | | if (typeof WebSocket === "undefined") { |
| | | console.log("您的浏览器不支持WebSocket"); |
| | | } else { |
| | | let socketUrl = "ws://" + "localhost:8888" + "/springboot-vue3/api/talk/" + viewname; |
| | | |
| | | if (socket != null) { |
| | | socket.close(); |
| | | socket = null; |
| | | } |
| | | |
| | | // 开启一个websocket服务 |
| | | socket = new WebSocket(socketUrl); |
| | | |
| | | // 打开事件 |
| | | socket.onopen = function () { |
| | | console.log("websocket已打开"); |
| | | }; |
| | | |
| | | // 收到消息 |
| | | socket.onmessage = (msg) => { |
| | | if (!msg.data) { |
| | | return; // 如果收到空数据,则直接返回,不执行后续逻辑 |
| | | } |
| | | |
| | | let obj = JSON.parse(msg.data); |
| | | const jsonData2 = this.jsonData; |
| | | |
| | | const handleMouseMove = throttle(function (event) { |
| | | |
| | | const inputBox = document.querySelectorAll('.el-card__body'); |
| | | 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; |
| | | |
| | | // console.log('parms:', parms); |
| | | // console.log('fanzhuan:', fanzhuan); |
| | | // console.log('xiaoche:', xiaoche); |
| | | // console.log('dache:', dache); |
| | | |
| | | 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++; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | 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]; |
| | | } |
| | | } |
| | | }, 50); |
| | | |
| | | document.addEventListener('mouseover', handleMouseMove); |
| | | }; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | // 关闭事件 |
| | | socket.onclose = function () { |
| | | console.log("websocket已关闭"); |
| | | }; |
| | | |
| | | // 发生错误事件 |
| | | socket.onerror = function () { |
| | | console.log("websocket发生了错误"); |
| | | }; |
| | | |
| | | |
| | | } |
| | | |
| | | }, |
| | | replaceChineseWithEnglish () { |
| | | const translation = this.$t('AutomaticParameterSetting'); |
| | | this.jsonData = this.jsonData.map(item => { return { name: translation[item.name] || item.name, value: item.value }; }); |
| | | // console.log(translation); |
| | | }, |
| | | send () { |
| | | |
| | | socket?.send(JSON.stringify(this.messagepack)); |
| | | }, |
| | | |
| | | } |
| | | } |
| | | </script> |
| | |
| | | <template> |
| | | <div class="app"> |
| | | <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb"> |
| | | <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb"> |
| | | <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/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('Servo Manual') |
| | | <router-link to="/Electrical/Servomanual" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('ServoManual') |
| | | }}</router-link> |
| | | </el-breadcrumb> |
| | | |
| | | <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb"> |
| | | <router-link to="/Electrical/Servomanualone" tag="el-button" type="text" active-class="blue-button">{{ $t('Servomanualone') |
| | | <router-link to="/Electrical/Servomanualone" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('Servomanualone') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Parameter1" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter1') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Parameter2" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter2') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Positioning1" tag="el-button" type="text" active-class="blue-button">{{ $t('Positioning1') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Positioning2" tag="el-button" type="text" active-class="blue-button">{{ $t('Positioning2') |
| | | }}</router-link> |
| | | </el-breadcrumb> |
| | | <router-link to="/Electrical/Parameter1" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter1') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Parameter2" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter2') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Positioning1" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('Positioning1') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Positioning2" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('Positioning2') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/ManualonePosition" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('ManualonePosition') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/ManualonePosition2" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('ManualonePosition2') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/AutomaticParameterSetting" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('AutomaticParameterSetting') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/ManualJog" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('ManualJog') |
| | | }}</router-link> |
| | | </el-breadcrumb> |
| | | |
| | | <el-row :gutter="18" class="card"> |
| | | <el-col :span="7" v-for="(dataGroup, groupIndex) in jsonData" :key="groupIndex"> |
| | | <el-card class="json-block"> |
| | | <div class="button-row" style="display: flex; justify-content: space-between;"> |
| | | <div v-for="(item, itemIndex) in dataGroup" :key="itemIndex"> |
| | | <span v-if="item.title" :name="item.title.name" class="action-button" >{{ item.title.name }}</span> |
| | | <el-row :gutter="18" class="card"> |
| | | <el-col :span="7" v-for="(dataGroup, groupIndex) in jsonData" :key="groupIndex"> |
| | | <el-card class="json-block"> |
| | | <div class="button-row" style="display: flex; justify-content: space-between;"> |
| | | <div v-for="(item, itemIndex) in dataGroup" :key="itemIndex"> |
| | | <span v-if="item.title" :name="item.title.name" class="action-button">{{ item.title.name }}</span> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <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> |
| | | <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> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | |
| | | </el-card> |
| | | </el-col> |
| | | </el-row> |
| | | <!-- <el-button @click="submitDataToBackend">提交数据到后端</el-button> --> |
| | | </div> |
| | | |
| | | </el-card> |
| | | </el-col> |
| | | </el-row> |
| | | <!-- <el-button @click="submitDataToBackend">提交数据到后端</el-button> --> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | |
| | | import { throttle } from 'lodash'; |
| | | let socket; |
| | | export default { |
| | | name: "Parameter1", |
| | | mixins: [LanguageMixin], |
| | | data() { |
| | | return { |
| | | jsonData: data // 加载整个data.json文件作为jsonData |
| | | } |
| | | }, created () { |
| | | name: "Parameter1", |
| | | mixins: [LanguageMixin], |
| | | data () { |
| | | return { |
| | | jsonData: data // 加载整个data.json文件作为jsonData |
| | | } |
| | | }, created () { |
| | | this.initWebSocket(); |
| | | // console.log('jsonData:', this.jsonData); |
| | | |
| | | }, |
| | | methods: { |
| | | updateButtonValue(dataGroup, itemIndex) { |
| | | updateButtonValue (dataGroup, itemIndex) { |
| | | this.$set(dataGroup[itemIndex].button, 'value', 1); // 点击按钮后将值改为1 |
| | | }, |
| | | submitDataToBackend() { |
| | | const inputData = this.jsonData.map(dataGroup => { |
| | | return dataGroup.map(item => { |
| | | if (item.type === '0') { |
| | | return { value: parseInt(item.value) }; |
| | | } else if (item.button) { |
| | | return { value: parseInt(item.button.value) }; |
| | | } |
| | | return null; |
| | | }); |
| | | }); |
| | | submitDataToBackend () { |
| | | const inputData = this.jsonData.map(dataGroup => { |
| | | return dataGroup.map(item => { |
| | | if (item.type === '0') { |
| | | return { value: parseInt(item.value) }; |
| | | } else if (item.button) { |
| | | return { value: parseInt(item.button.value) }; |
| | | } |
| | | return null; |
| | | }); |
| | | }); |
| | | |
| | | // 将inputData转换为整数数组 |
| | | const integerArray = inputData.map(dataGroup => { |
| | | return dataGroup.map(item => { |
| | | if (item !== null) { |
| | | return item.value; |
| | | } |
| | | return null; |
| | | }); |
| | | }); |
| | | // 构建JSON对象 |
| | | const jsonObject = { data: integerArray }; |
| | | |
| | | // 提交数据到后端 |
| | | const jsonString = JSON.stringify(jsonObject); |
| | | console.log('提交以下数据到后端:', jsonString); |
| | | socket?.send(jsonString); |
| | | }, |
| | | // 将inputData转换为整数数组 |
| | | const integerArray = inputData.map(dataGroup => { |
| | | return dataGroup.map(item => { |
| | | if (item !== null) { |
| | | return item.value; |
| | | } |
| | | return null; |
| | | }); |
| | | }); |
| | | // 构建JSON对象 |
| | | const jsonObject = { data: integerArray }; |
| | | |
| | | // 提交数据到后端 |
| | | const jsonString = JSON.stringify(jsonObject); |
| | | console.log('提交以下数据到后端:', jsonString); |
| | | socket?.send(jsonString); |
| | | }, |
| | | initWebSocket () { |
| | | |
| | | |
| | | let viewname = "Parameter1"; |
| | | |
| | | if (typeof WebSocket === "undefined") { |
| | |
| | | |
| | | // 收到消息 |
| | | socket.onmessage = (msg) => { |
| | | if (!msg.data) { |
| | | return; // 如果收到空数据,则直接返回,不执行后续逻辑 |
| | | } |
| | | |
| | | let obj = JSON.parse(msg.data); |
| | | const jsonData2 = this.jsonData; |
| | | |
| | | const handleMouseMove = throttle(function(event) { |
| | | const inputBox = document.querySelectorAll('.el-card__body'); |
| | | 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; |
| | | |
| | | // console.log('parms:', parms); |
| | | // console.log('fanzhuan:', fanzhuan); |
| | | // console.log('xiaoche:', xiaoche); |
| | | |
| | | let index = 0; |
| | | 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 (!msg.data) { |
| | | return; // 如果收到空数据,则直接返回,不执行后续逻辑 |
| | | } |
| | | } |
| | | } |
| | | if (Array.isArray(fanzhuan) && Array.isArray(fanzhuan[0]) && fanzhuan[0][0] !== undefined) { |
| | | jsonData2[3][0]['value'] = fanzhuan[0][0]; |
| | | } |
| | | if (Array.isArray(xiaoche) && Array.isArray(xiaoche[0]) && xiaoche[0][0] !== undefined) { |
| | | jsonData2[4][0]['value'] = xiaoche[0][0]; |
| | | } |
| | | } |
| | | }, 200); |
| | | |
| | | document.addEventListener('mouseover', handleMouseMove); |
| | | }; |
| | | let obj = JSON.parse(msg.data); |
| | | const jsonData2 = this.jsonData; |
| | | |
| | | const handleMouseMove = throttle(function (event) { |
| | | const inputBox = document.querySelectorAll('.el-card__body'); |
| | | 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; |
| | | |
| | | // console.log('parms:', parms); |
| | | // console.log('fanzhuan:', fanzhuan); |
| | | // console.log('xiaoche:', xiaoche); |
| | | |
| | | let index = 0; |
| | | 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(fanzhuan) && Array.isArray(fanzhuan[0]) && fanzhuan[0][0] !== undefined) { |
| | | jsonData2[3][0]['value'] = fanzhuan[0][0]; |
| | | } |
| | | if (Array.isArray(xiaoche) && Array.isArray(xiaoche[0]) && xiaoche[0][0] !== undefined) { |
| | | jsonData2[4][0]['value'] = xiaoche[0][0]; |
| | | } |
| | | } |
| | | }, 200); |
| | | |
| | | document.addEventListener('mouseover', handleMouseMove); |
| | | }; |
| | | |
| | | |
| | | |
| | |
| | | socket.onerror = function () { |
| | | console.log("websocket发生了错误"); |
| | | }; |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | }, |
| | | replaceChineseWithEnglish () { |
| | | const translation = this.$t('Parameter1'); |
| | |
| | | // console.log(translation); |
| | | }, |
| | | send () { |
| | | |
| | | |
| | | |
| | | |
| | | socket?.send(JSON.stringify(this.messagepack)); |
| | | }, |
| | | |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | .item-row { |
| | | display: flex; |
| | | align-items: center; |
| | | margin-bottom: 5px; /* 调整每个项目之间的间距 */ |
| | | display: flex; |
| | | align-items: center; |
| | | margin-bottom: 5px; |
| | | /* 调整每个项目之间的间距 */ |
| | | } |
| | | |
| | | .action-button { |
| | | margin-right: 30px; |
| | | background: #66b1ff; |
| | | color: #FFF; |
| | | margin-right: 30px; |
| | | background: #66b1ff; |
| | | color: #FFF; |
| | | } |
| | | |
| | | .blue-button { |
| | | background-color: skyblue; |
| | | } |
| | |
| | | <template> |
| | | <div class="app"> |
| | | <div class="app"> |
| | | <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb"> |
| | | <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/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('Servo Manual') |
| | | }}</router-link> |
| | | </el-breadcrumb> |
| | | |
| | | <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb"> |
| | | <router-link to="/Electrical/Servomanualone" tag="el-button" type="text" active-class="blue-button">{{ $t('Servomanualone') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Parameter1" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter1') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Parameter2" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter2') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Positioning1" tag="el-button" type="text" active-class="blue-button">{{ $t('Positioning1') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Positioning2" tag="el-button" type="text" active-class="blue-button">{{ $t('Positioning2') |
| | | }}</router-link> |
| | | <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/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('ServoManual') |
| | | }}</router-link> |
| | | </el-breadcrumb> |
| | | |
| | | |
| | | <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb"> |
| | | <router-link to="/Electrical/Servomanualone" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('Servomanualone') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Parameter1" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter1') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Parameter2" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter2') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Positioning1" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('Positioning1') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Positioning2" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('Positioning2') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/ManualonePosition" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('ManualonePosition') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/ManualonePosition2" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('ManualonePosition2') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/AutomaticParameterSetting" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('AutomaticParameterSetting') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/ManualJog" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('ManualJog') |
| | | }}</router-link> |
| | | </el-breadcrumb> |
| | | |
| | | <el-row :gutter="20"> |
| | | <el-col :span="6" v-for="(dataGroup, groupIndex) in jsonData" :key="groupIndex"> |
| | | <el-card class="json-block" style="width:260px;"> |
| | | <el-card class="json-block" style="width:260px;"> |
| | | <div class="button-row" style="display: flex; justify-content: space-between;"> |
| | | <div v-for="(item, itemIndex) in dataGroup" :key="itemIndex"> |
| | | <span v-if="item.title" :name="item.title.name" class="action-button" >{{ item.title.name }}</span> |
| | | <span v-if="item.title" :name="item.title.name" class="action-button">{{ item.title.name }}</span> |
| | | </div> |
| | | </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" :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 === 1 && item.button.name !== '清除ID' }">{{ item.button.name }}</el-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 === 1 && item.button.name !== '清除ID' }">{{ |
| | | item.button.name }}</el-button> |
| | | </div> |
| | | </div> |
| | | <div v-for="(item, itemIndex) in dataGroup" :key="itemIndex" class="item-container"> |
| | | <div class="item-row"> |
| | | |
| | | <span class="name" style="width:150px;">{{ item.name }}</span> |
| | | <el-input v-if="item.type === '0'" v-model="item.value" readonly="readonly" style="width:150px;" class="input-box"></el-input> |
| | | <el-input v-if="item.type === '0'" v-model="item.value" readonly="readonly" style="width:150px;" |
| | | class="input-box"></el-input> |
| | | </div> |
| | | </div> |
| | | |
| | | |
| | | </el-card> |
| | | </el-col> |
| | | </el-row> |
| | | <!-- <el-button @click="submitDataToBackend">提交数据到后端</el-button> --> |
| | | </div> |
| | | </template> |
| | | </template> |
| | | |
| | | <script> |
| | | import LanguageMixin from '../../lang/LanguageMixin' |
| | | import data from '../../configuration/parameter2' |
| | | let socket; |
| | | export default { |
| | | <script> |
| | | import LanguageMixin from '../../lang/LanguageMixin' |
| | | import data from '../../configuration/parameter2' |
| | | let socket; |
| | | export default { |
| | | name: "Parameter2", |
| | | mixins: [LanguageMixin], |
| | | data() { |
| | | data () { |
| | | return { |
| | | jsonData: data , |
| | | jsonData: data, |
| | | |
| | | // 加载整个data.json文件作为jsonData |
| | | } |
| | |
| | | |
| | | }, |
| | | methods: { |
| | | updateButtonValue(dataGroup, itemIndex) { |
| | | // 将当前按钮的值设为1 |
| | | updateButtonValue (dataGroup, itemIndex) { |
| | | // 将当前按钮的值设为1 |
| | | |
| | | this.$set(dataGroup[itemIndex].button, 'value', 1); |
| | | |
| | | this.$set(dataGroup[itemIndex].button, 'value', 1); |
| | | |
| | | // 将其他按钮的值全部设为0 |
| | | |
| | | }, |
| | | submitDataToBackend(currentButtonName) { |
| | | if (currentButtonName === '清除ID') { |
| | | const inputData = this.jsonData.map(dataGroup => { |
| | | return dataGroup.map(item => { |
| | | if (item.type === '3') { |
| | | return { value: item.button.value }; |
| | | } |
| | | return null; |
| | | }); |
| | | }); |
| | | // 将其他按钮的值全部设为0 |
| | | |
| | | const values = inputData.flat().filter(item => item !== null).map(item => item.value); |
| | | }, |
| | | submitDataToBackend (currentButtonName) { |
| | | if (currentButtonName === '清除ID') { |
| | | const inputData = this.jsonData.map(dataGroup => { |
| | | return dataGroup.map(item => { |
| | | if (item.type === '3') { |
| | | return { value: item.button.value }; |
| | | } |
| | | return null; |
| | | }); |
| | | }); |
| | | |
| | | const jsonObject = { data: values }; |
| | | |
| | | // 提交数据到后端 |
| | | const jsonString = JSON.stringify(jsonObject); |
| | | console.log('Type为3的value:', jsonString); |
| | | socket?.send(jsonString); |
| | | } |
| | | }, |
| | | 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); |
| | | } |
| | | }, |
| | | initWebSocket () { |
| | | |
| | | |
| | | let viewname = "Parameter2"; |
| | | |
| | | if (typeof WebSocket === "undefined") { |
| | |
| | | |
| | | // 收到消息 |
| | | socket.onmessage = (msg) => { |
| | | if (!msg.data) { |
| | | return; // 如果收到空数据,则直接返回,不执行后续逻辑 |
| | | } |
| | | if (!msg.data) { |
| | | return; // 如果收到空数据,则直接返回,不执行后续逻辑 |
| | | } |
| | | |
| | | let obj = JSON.parse(msg.data); |
| | | |
| | | const jsonData2 = this.jsonData; |
| | | |
| | | // 如果鼠标不在输入框内,更新输入框的值 |
| | | // this.submitDataToBackend() |
| | | const parms = obj.params; |
| | | // console.log(parms); |
| | | let obj = JSON.parse(msg.data); |
| | | |
| | | 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') { |
| | | obj.value = parms[1][i]; |
| | | } |
| | | } |
| | | const jsonData2 = this.jsonData; |
| | | |
| | | |
| | | } |
| | | // 如果鼠标不在输入框内,更新输入框的值 |
| | | // this.submitDataToBackend() |
| | | const parms = obj.params; |
| | | // console.log(parms); |
| | | |
| | | 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 = parms[2][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 === '0') { |
| | | obj.value = parms[1][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 === '3') { |
| | | obj.button.value = parms[0][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 = parms[2][i]; |
| | | } |
| | | } |
| | | |
| | | // console.log(jsonData2); |
| | | |
| | | |
| | | }; |
| | | } |
| | | |
| | | 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 === '3') { |
| | | obj.button.value = parms[0][i]; |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | // console.log(jsonData2); |
| | | |
| | | |
| | | }; |
| | | |
| | | |
| | | |
| | |
| | | } |
| | | }, |
| | | send () { |
| | | |
| | | |
| | | |
| | | |
| | | socket?.send(JSON.stringify(this.messagepack)); |
| | | } |
| | | |
| | | } |
| | | } |
| | | </script> |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | .item-row { |
| | | <style scoped> |
| | | .item-row { |
| | | display: flex; |
| | | align-items: center; |
| | | margin-bottom: 5px; /* 调整每个项目之间的间距 */ |
| | | } |
| | | |
| | | .action-button { |
| | | margin-bottom: 5px; |
| | | /* 调整每个项目之间的间距 */ |
| | | } |
| | | |
| | | .action-button { |
| | | margin-right: 30px; |
| | | background: #66b1ff; |
| | | color: #FFF; |
| | | } |
| | | .blue-button { |
| | | } |
| | | |
| | | .blue-button { |
| | | background-color: skyblue; |
| | | } |
| | | |
| | |
| | | background-color: green; |
| | | } |
| | | |
| | | .red-button{ |
| | | .red-button { |
| | | background-color: red; |
| | | } |
| | | |
| | | </style> |
| | | </style> |
| | |
| | | <template> |
| | | <div class="app"> |
| | | <div class="app"> |
| | | <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb"> |
| | | <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/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('Servo Manual') |
| | | }}</router-link> |
| | | </el-breadcrumb> |
| | | |
| | | <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb"> |
| | | <router-link to="/Electrical/Servomanualone" tag="el-button" type="text" active-class="blue-button">{{ $t('Servomanualone') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Parameter1" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter1') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Parameter2" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter2') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Positioning1" tag="el-button" type="text" active-class="blue-button">{{ $t('Positioning1') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Positioning2" tag="el-button" type="text" active-class="blue-button">{{ $t('Positioning2') |
| | | }}</router-link> |
| | | <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/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('ServoManual') |
| | | }}</router-link> |
| | | </el-breadcrumb> |
| | | |
| | | |
| | | <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb"> |
| | | <router-link to="/Electrical/Servomanualone" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('Servomanualone') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Parameter1" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter1') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Parameter2" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter2') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Positioning1" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('Positioning1') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Positioning2" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('Positioning2') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/ManualonePosition" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('ManualonePosition') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/ManualonePosition2" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('ManualonePosition2') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/AutomaticParameterSetting" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('AutomaticParameterSetting') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/ManualJog" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('ManualJog') |
| | | }}</router-link> |
| | | </el-breadcrumb> |
| | | |
| | | <el-row :gutter="18" class='card'> |
| | | <el-col :span="7" v-for="(dataGroup, groupIndex) in jsonData" :key="groupIndex" > |
| | | <el-col :span="7" v-for="(dataGroup, groupIndex) in jsonData" :key="groupIndex"> |
| | | <el-card class="json-block"> |
| | | <div class="button-row" style="display: flex; justify-content: space-between;"> |
| | | <div v-for="(item, itemIndex) in dataGroup" :key="itemIndex"> |
| | | <span v-if="item.title" :name="item.title.name" class="action-button" >{{ item.title.name }}</span> |
| | | <span v-if="item.title" :name="item.title.name" class="action-button">{{ item.title.name }}</span> |
| | | </div> |
| | | </div> |
| | | <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"></el-input> |
| | | |
| | | |
| | | |
| | | <el-button v-if="item.type === '0' && item.name !== '格子间距' && item.name !== '出片接片地址' && item.name !== '存片接片地址'" class="input-box" @click="submitDataToBackend();">取地址</el-button> |
| | | |
| | | |
| | | <el-button |
| | | v-if="item.type === '0' && item.name !== '格子间距' && item.name !== '出片接片地址' && item.name !== '存片接片地址'" |
| | | class="input-box" @click="submitDataToBackend();">取地址</el-button> |
| | | </div> |
| | | </div> |
| | | |
| | | |
| | | </el-card> |
| | | </el-col> |
| | | </el-row> |
| | | <!-- <el-button @click="submitDataToBackend">提交数据到后端</el-button> --> |
| | | </div> |
| | | </template> |
| | | </template> |
| | | |
| | | <script> |
| | | let socket; |
| | | import LanguageMixin from '../../lang/LanguageMixin' |
| | | import data from '../../configuration/Positioning1' |
| | | |
| | | export default { |
| | | <script> |
| | | let socket; |
| | | import LanguageMixin from '../../lang/LanguageMixin' |
| | | import data from '../../configuration/Positioning1' |
| | | |
| | | export default { |
| | | name: "Positioning1", |
| | | mixins: [LanguageMixin], |
| | | data() { |
| | | data () { |
| | | return { |
| | | jsonData: data // 加载整个data.json文件作为jsonData |
| | | } |
| | |
| | | |
| | | }, |
| | | methods: { |
| | | updateButtonValue(dataGroup, itemIndex) { |
| | | updateButtonValue (dataGroup, itemIndex) { |
| | | this.$set(dataGroup[itemIndex].button, 'value', 1); // 点击按钮后将值改为1 |
| | | }, |
| | | submitDataToBackend() { |
| | | const inputData = this.jsonData.map(dataGroup => { |
| | | return dataGroup.map(item => { |
| | | if (item.type === '0') { |
| | | return { value: parseInt(item.value) }; |
| | | } else if (item.button) { |
| | | return { value: parseInt(item.title.value) }; |
| | | } |
| | | return null; |
| | | }); |
| | | }); |
| | | submitDataToBackend () { |
| | | const inputData = this.jsonData.map(dataGroup => { |
| | | return dataGroup.map(item => { |
| | | if (item.type === '0') { |
| | | return { value: parseInt(item.value) }; |
| | | } else if (item.button) { |
| | | return { value: parseInt(item.title.value) }; |
| | | } |
| | | return null; |
| | | }); |
| | | }); |
| | | |
| | | // 将inputData转换为整数数组 |
| | | const integerArray = inputData.map(dataGroup => { |
| | | return dataGroup.map(item => { |
| | | if (item !== null) { |
| | | return item.value; |
| | | } |
| | | return null; |
| | | }); |
| | | }); |
| | | // 构建JSON对象 |
| | | const jsonObject = { data: integerArray }; |
| | | |
| | | // 提交数据到后端 |
| | | const jsonString = JSON.stringify(jsonObject); |
| | | // console.log('提交以下数据到后端:', jsonString); |
| | | socket?.send(jsonString); |
| | | }, |
| | | // 将inputData转换为整数数组 |
| | | const integerArray = inputData.map(dataGroup => { |
| | | return dataGroup.map(item => { |
| | | if (item !== null) { |
| | | return item.value; |
| | | } |
| | | return null; |
| | | }); |
| | | }); |
| | | // 构建JSON对象 |
| | | const jsonObject = { data: integerArray }; |
| | | |
| | | // 提交数据到后端 |
| | | const jsonString = JSON.stringify(jsonObject); |
| | | // console.log('提交以下数据到后端:', jsonString); |
| | | socket?.send(jsonString); |
| | | }, |
| | | initWebSocket () { |
| | | |
| | | |
| | | let viewname = "Positioning1"; |
| | | |
| | | if (typeof WebSocket === "undefined") { |
| | |
| | | |
| | | // 收到消息 |
| | | 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('.el-card__body'); |
| | | const target = event.target; |
| | | if (inputBox && Array.from(inputBox).every(box => !box.contains(target))) { |
| | | // 如果鼠标不在输入框内,更新输入框的值 |
| | | // this.submitDataToBackend() |
| | | const parms = obj.params; |
| | | |
| | | let obj = JSON.parse(msg.data); |
| | | const jsonData2 = this.jsonData; |
| | | document.addEventListener('mouseover', function (event) { |
| | | const inputBox = document.querySelectorAll('.el-card__body'); |
| | | const target = event.target; |
| | | if (inputBox && Array.from(inputBox).every(box => !box.contains(target))) { |
| | | // 如果鼠标不在输入框内,更新输入框的值 |
| | | // this.submitDataToBackend() |
| | | const parms = obj.params; |
| | | |
| | | |
| | | let index = 0; |
| | | 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')) { |
| | | obj.value = parms[0][index]; |
| | | index++; |
| | | } |
| | | } |
| | | } |
| | | |
| | | let index = 0; |
| | | 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')) { |
| | | obj.value = parms[0][index]; |
| | | index++; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | // console.log(jsonData2); |
| | | // console.log(jsonData2); |
| | | |
| | | } |
| | | }); |
| | | }; |
| | | } |
| | | }); |
| | | }; |
| | | |
| | | |
| | | |
| | |
| | | } |
| | | }, |
| | | send () { |
| | | |
| | | |
| | | |
| | | |
| | | socket?.send(JSON.stringify(this.messagepack)); |
| | | }, |
| | | |
| | | } |
| | | } |
| | | </script> |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | .item-row { |
| | | <style scoped> |
| | | .item-row { |
| | | display: flex; |
| | | align-items: center; |
| | | margin-bottom: 5px; /* 调整每个项目之间的间距 */ |
| | | } |
| | | |
| | | .action-button { |
| | | margin-bottom: 5px; |
| | | /* 调整每个项目之间的间距 */ |
| | | } |
| | | |
| | | .action-button { |
| | | margin-right: 30px; |
| | | background: #66b1ff; |
| | | color: #FFF; |
| | | } |
| | | .blue-button { |
| | | } |
| | | |
| | | .blue-button { |
| | | background-color: skyblue; |
| | | } |
| | | </style> |
| | | </style> |
| | |
| | | <template> |
| | | <div class="app"> |
| | | <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb"> |
| | | <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb"> |
| | | <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/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('Servo Manual') |
| | | <router-link to="/Electrical/Servomanual" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('ServoManual') |
| | | }}</router-link> |
| | | </el-breadcrumb> |
| | | |
| | | <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb"> |
| | | <router-link to="/Electrical/Servomanualone" tag="el-button" type="text" active-class="blue-button">{{ $t('Servomanualone') |
| | | <router-link to="/Electrical/Servomanualone" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('Servomanualone') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Parameter1" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter1') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Parameter2" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter2') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Positioning1" tag="el-button" type="text" active-class="blue-button">{{ $t('Positioning1') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Positioning2" tag="el-button" type="text" active-class="blue-button">{{ $t('Positioning2') |
| | | }}</router-link> |
| | | </el-breadcrumb> |
| | | <router-link to="/Electrical/Parameter1" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter1') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Parameter2" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter2') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Positioning1" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('Positioning1') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Positioning2" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('Positioning2') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/ManualonePosition" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('ManualonePosition') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/ManualonePosition2" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('ManualonePosition2') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/AutomaticParameterSetting" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('AutomaticParameterSetting') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/ManualJog" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('ManualJog') |
| | | }}</router-link> |
| | | </el-breadcrumb> |
| | | |
| | | <el-row :gutter="18" class='card'> |
| | | <el-col :span="7" v-for="(dataGroup, groupIndex) in jsonData" :key="groupIndex" > |
| | | <el-card class="json-block"> |
| | | <div class="button-row" style="display: flex; justify-content: space-between;"> |
| | | <div v-for="(item, itemIndex) in dataGroup" :key="itemIndex"> |
| | | <span v-if="item.title" :name="item.title.name" class="action-button" >{{ item.title.name }}</span> |
| | | <el-row :gutter="18" class='card'> |
| | | <el-col :span="7" v-for="(dataGroup, groupIndex) in jsonData" :key="groupIndex"> |
| | | <el-card class="json-block"> |
| | | <div class="button-row" style="display: flex; justify-content: space-between;"> |
| | | <div v-for="(item, itemIndex) in dataGroup" :key="itemIndex"> |
| | | <span v-if="item.title" :name="item.title.name" class="action-button">{{ item.title.name }}</span> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <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"></el-input> |
| | | <el-button v-if="item.type === '0'" class="input-box" @click="submitDataToBackend();">取地址</el-button> |
| | | <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"></el-input> |
| | | <el-button v-if="item.type === '0'" class="input-box" @click="submitDataToBackend();">取地址</el-button> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | |
| | | </el-card> |
| | | </el-col> |
| | | </el-row> |
| | | <!-- <el-button @click="submitDataToBackend">提交数据到后端</el-button> --> |
| | | </div> |
| | | |
| | | </el-card> |
| | | </el-col> |
| | | </el-row> |
| | | <!-- <el-button @click="submitDataToBackend">提交数据到后端</el-button> --> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | |
| | | import data from '../../configuration/Positioning2' |
| | | |
| | | export default { |
| | | name: "Positioning2", |
| | | mixins: [LanguageMixin], |
| | | data() { |
| | | return { |
| | | jsonData: data // 加载整个data.json文件作为jsonData |
| | | } |
| | | }, |
| | | created () { |
| | | this.initWebSocket(); |
| | | // console.log('jsonData:', this.jsonData); |
| | | |
| | | }, |
| | | methods: { |
| | | updateButtonValue(dataGroup, itemIndex) { |
| | | this.$set(dataGroup[itemIndex].button, 'value', 1); // 点击按钮后将值改为1 |
| | | name: "Positioning2", |
| | | mixins: [LanguageMixin], |
| | | data () { |
| | | return { |
| | | jsonData: data // 加载整个data.json文件作为jsonData |
| | | } |
| | | }, |
| | | submitDataToBackend() { |
| | | const inputData = this.jsonData.map(dataGroup => { |
| | | return dataGroup.map(item => { |
| | | if (item.type === '0') { |
| | | return { value: parseInt(item.value) }; |
| | | } else if (item.button) { |
| | | return { value: parseInt(item.title.value) }; |
| | | } |
| | | return null; |
| | | }); |
| | | }); |
| | | created () { |
| | | this.initWebSocket(); |
| | | // console.log('jsonData:', this.jsonData); |
| | | |
| | | // 将inputData转换为整数数组 |
| | | const integerArray = inputData.map(dataGroup => { |
| | | return dataGroup.map(item => { |
| | | if (item !== null) { |
| | | return item.value; |
| | | } |
| | | return null; |
| | | }); |
| | | }); |
| | | // 构建JSON对象 |
| | | const jsonObject = { data: integerArray }; |
| | | }, |
| | | methods: { |
| | | updateButtonValue (dataGroup, itemIndex) { |
| | | this.$set(dataGroup[itemIndex].button, 'value', 1); // 点击按钮后将值改为1 |
| | | }, |
| | | submitDataToBackend () { |
| | | const inputData = this.jsonData.map(dataGroup => { |
| | | return dataGroup.map(item => { |
| | | if (item.type === '0') { |
| | | return { value: parseInt(item.value) }; |
| | | } else if (item.button) { |
| | | return { value: parseInt(item.title.value) }; |
| | | } |
| | | return null; |
| | | }); |
| | | }); |
| | | |
| | | // 提交数据到后端 |
| | | const jsonString = JSON.stringify(jsonObject); |
| | | // console.log('提交以下数据到后端:', jsonString); |
| | | socket?.send(jsonString); |
| | | }, |
| | | initWebSocket () { |
| | | // 将inputData转换为整数数组 |
| | | const integerArray = inputData.map(dataGroup => { |
| | | return dataGroup.map(item => { |
| | | if (item !== null) { |
| | | return item.value; |
| | | } |
| | | return null; |
| | | }); |
| | | }); |
| | | // 构建JSON对象 |
| | | const jsonObject = { data: integerArray }; |
| | | |
| | | let viewname = "Positioning2"; |
| | | // 提交数据到后端 |
| | | const jsonString = JSON.stringify(jsonObject); |
| | | // console.log('提交以下数据到后端:', jsonString); |
| | | socket?.send(jsonString); |
| | | }, |
| | | initWebSocket () { |
| | | |
| | | if (typeof WebSocket === "undefined") { |
| | | console.log("您的浏览器不支持WebSocket"); |
| | | } else { |
| | | let socketUrl = "ws://" + "localhost:8888" + "/springboot-vue3/api/talk/" + viewname; |
| | | let viewname = "Positioning2"; |
| | | |
| | | 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; |
| | | |
| | | if (socket != null) { |
| | | socket.close(); |
| | | socket = null; |
| | | } |
| | | |
| | | // 开启一个websocket服务 |
| | | socket = new WebSocket(socketUrl); |
| | | |
| | | // 打开事件 |
| | | socket.onopen = function () { |
| | | console.log("websocket已打开"); |
| | | }; |
| | | |
| | | // 收到消息 |
| | | socket.onmessage = (msg) => { |
| | | if (!msg.data) { |
| | | return; // 如果收到空数据,则直接返回,不执行后续逻辑 |
| | | } |
| | | |
| | | let obj = JSON.parse(msg.data); |
| | | const jsonData2 = this.jsonData; |
| | | document.addEventListener('mouseover', function (event) { |
| | | const inputBox = document.querySelectorAll('.el-card__body'); |
| | | const target = event.target; |
| | | if (inputBox && Array.from(inputBox).every(box => !box.contains(target))) { |
| | | // 如果鼠标不在输入框内,更新输入框的值 |
| | | // this.submitDataToBackend() |
| | | const parms = obj.params; |
| | | |
| | | |
| | | let index = 0; |
| | | 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')) { |
| | | obj.value = parms[0][index]; |
| | | index++; |
| | | } |
| | | } |
| | | } |
| | | // console.log(jsonData2); |
| | | |
| | | } |
| | | }); |
| | | }; |
| | | |
| | | |
| | | |
| | | |
| | | // 关闭事件 |
| | | socket.onclose = function () { |
| | | console.log("websocket已关闭"); |
| | | }; |
| | | |
| | | // 发生错误事件 |
| | | socket.onerror = function () { |
| | | console.log("websocket发生了错误"); |
| | | }; |
| | | |
| | | } |
| | | }, |
| | | send () { |
| | | |
| | | // 开启一个websocket服务 |
| | | socket = new WebSocket(socketUrl); |
| | | |
| | | // 打开事件 |
| | | socket.onopen = function () { |
| | | console.log("websocket已打开"); |
| | | }; |
| | | |
| | | // 收到消息 |
| | | socket.onmessage = (msg) => { |
| | | if (!msg.data) { |
| | | return; // 如果收到空数据,则直接返回,不执行后续逻辑 |
| | | } |
| | | |
| | | let obj = JSON.parse(msg.data); |
| | | const jsonData2 = this.jsonData; |
| | | document.addEventListener('mouseover', function(event) { |
| | | const inputBox = document.querySelectorAll('.el-card__body'); |
| | | const target = event.target; |
| | | if (inputBox && Array.from(inputBox).every(box => !box.contains(target))) { |
| | | // 如果鼠标不在输入框内,更新输入框的值 |
| | | // this.submitDataToBackend() |
| | | const parms = obj.params; |
| | | |
| | | |
| | | let index = 0; |
| | | 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')) { |
| | | obj.value = parms[0][index]; |
| | | index++; |
| | | } |
| | | } |
| | | } |
| | | // console.log(jsonData2); |
| | | socket?.send(JSON.stringify(this.messagepack)); |
| | | }, |
| | | |
| | | } |
| | | }); |
| | | }; |
| | | |
| | | |
| | | |
| | | |
| | | // 关闭事件 |
| | | socket.onclose = function () { |
| | | console.log("websocket已关闭"); |
| | | }; |
| | | |
| | | // 发生错误事件 |
| | | socket.onerror = function () { |
| | | console.log("websocket发生了错误"); |
| | | }; |
| | | |
| | | } |
| | | }, |
| | | send () { |
| | | |
| | | |
| | | socket?.send(JSON.stringify(this.messagepack)); |
| | | }, |
| | | |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | .item-row { |
| | | display: flex; |
| | | align-items: center; |
| | | margin-bottom: 5px; /* 调整每个项目之间的间距 */ |
| | | display: flex; |
| | | align-items: center; |
| | | margin-bottom: 5px; |
| | | /* 调整每个项目之间的间距 */ |
| | | } |
| | | |
| | | .action-button { |
| | | margin-right: 30px; |
| | | background: #66b1ff; |
| | | color: #FFF; |
| | | margin-right: 30px; |
| | | background: #66b1ff; |
| | | color: #FFF; |
| | | } |
| | | |
| | | .blue-button { |
| | | background-color: skyblue; |
| | | background-color: skyblue; |
| | | } |
| | | </style> |
| | |
| | | <template> |
| | | <div class="app"> |
| | | <div class="app"> |
| | | <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb"> |
| | | <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/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('Servo Manual') |
| | | }}</router-link> |
| | | </el-breadcrumb> |
| | | |
| | | <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb"> |
| | | |
| | | <router-link to="/Electrical/Servomanualone" tag="el-button" type="text" active-class="blue-button">{{ $t('Servomanualone') |
| | | <router-link to="/Electrical/alarm" tag="el-button" type="text" active-class="blue-button">{{ $t('Alarm') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Parameter1" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter1') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Parameter2" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter2') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Positioning1" tag="el-button" type="text" active-class="blue-button">{{ $t('Positioning1') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Positioning2" tag="el-button" type="text" active-class="blue-button">{{ $t('Positioning2') |
| | | }}</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/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('ServoManual') |
| | | }}</router-link> |
| | | </el-breadcrumb> |
| | | |
| | | <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb"> |
| | | |
| | | <router-link to="/Electrical/Servomanualone" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('Servomanualone') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Parameter1" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter1') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Parameter2" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter2') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Positioning1" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('Positioning1') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Positioning2" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('Positioning2') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/ManualonePosition" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('ManualonePosition') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/ManualonePosition2" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('ManualonePosition2') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/AutomaticParameterSetting" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('AutomaticParameterSetting') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/ManualJog" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('ManualJog') |
| | | }}</router-link> |
| | | |
| | | <router-link to="/Electrical/ManualonePosition" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('ManualonePosition') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/ManualonePosition2" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('ManualonePosition2') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/AutomaticParameterSetting" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('AutomaticParameterSetting') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/ManualJog" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('ManualJog') |
| | | }}</router-link> |
| | | </el-breadcrumb> |
| | | |
| | | <el-row :gutter="26"> |
| | | <el-col :span="12" v-for="(dataGroup, groupIndex) in jsonData" :key="groupIndex"> |
| | | <el-card class="json-block" style="width:auto;"> |
| | | <el-row > |
| | | <el-col v-for="(item, itemIndex) in dataGroup" :key="itemIndex" :span="12"> |
| | | <div class="item-container"> |
| | | <div class="item-row"> |
| | | <span class="name" style='width:230px;'>{{ item.name }}</span> |
| | | <el-input v-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> |
| | | <el-col :span="12" v-for="(dataGroup, groupIndex) in jsonData" :key="groupIndex"> |
| | | <el-card class="json-block" style="width:auto;"> |
| | | <el-row> |
| | | <el-col v-for="(item, itemIndex) in dataGroup" :key="itemIndex" :span="12"> |
| | | <div class="item-container"> |
| | | <div class="item-row"> |
| | | <span class="name" style='width:230px;'>{{ item.name }}</span> |
| | | <el-input v-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-col> |
| | | </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" :name="item.button.name" v-model="item.button.value" |
| | | :class="{ 'action-button': true, 'error-button': item.button.name === '故障' && item.button.value === 1 }" |
| | | @click="updateButtonValue(dataGroup, itemIndex); submitDataToBackend(item.button.name);">{{ |
| | | item.button.name }}</el-button> |
| | | |
| | | </div> |
| | | </div> |
| | | </el-col> |
| | | </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" :name="item.button.name" v-model="item.button.value" :class="{'action-button': true, 'error-button': item.button.name === '故障' && item.button.value === 1}" @click="updateButtonValue(dataGroup, itemIndex); submitDataToBackend(item.button.name);">{{ item.button.name }}</el-button> |
| | | |
| | | </div> |
| | | </div> |
| | | </el-card> |
| | | </el-col> |
| | | </el-row> |
| | | </el-card> |
| | | </el-col> |
| | | </el-row> |
| | | |
| | | <!-- <el-button @click="submitDataToBackend">提交数据到后端</el-button> --> |
| | | </div> |
| | |
| | | import data from '../../configuration/ServoManualone' |
| | | import { throttle } from 'lodash'; |
| | | let socket; |
| | | export default { |
| | | export default { |
| | | name: "ServoManualone", |
| | | mixins: [LanguageMixin], |
| | | data() { |
| | | data () { |
| | | return { |
| | | jsonData: data , |
| | | jsonData: data, |
| | | |
| | | // 加载整个data.json文件作为jsonData |
| | | } |
| | |
| | | |
| | | }, |
| | | methods: { |
| | | updateButtonValue(dataGroup, itemIndex) { |
| | | // 将当前按钮的值设为1 |
| | | updateButtonValue (dataGroup, itemIndex) { |
| | | // 将当前按钮的值设为1 |
| | | |
| | | this.$set(dataGroup[itemIndex].button, 'value', 1); |
| | | |
| | | |
| | | |
| | | }, |
| | | submitDataToBackend(currentButtonName) { |
| | | if (currentButtonName === '半自动启动') { |
| | | const data = []; |
| | | |
| | | for (let i = 0; i < 2; i++) { |
| | | const inputData = this.jsonData[i].filter(item => item.type === '0').map(item => { |
| | | return { value: item.value }; |
| | | }); |
| | | |
| | | const values = inputData.map(item => item.value); |
| | | |
| | | data.push(values); |
| | | } |
| | | this.$set(dataGroup[itemIndex].button, 'value', 1); |
| | | |
| | | |
| | | |
| | | const jsonObject = { data }; |
| | | }, |
| | | submitDataToBackend (currentButtonName) { |
| | | if (currentButtonName === '半自动启动') { |
| | | const data = []; |
| | | |
| | | // 提交数据到后端 |
| | | const jsonString = JSON.stringify(jsonObject); |
| | | console.log('所有Type为0的value:', jsonString); |
| | | socket?.send(jsonString); |
| | | for (let i = 0; i < 2; i++) { |
| | | const inputData = this.jsonData[i].filter(item => item.type === '0').map(item => { |
| | | return { value: item.value }; |
| | | }); |
| | | |
| | | } |
| | | const values = inputData.map(item => item.value); |
| | | |
| | | if (currentButtonName === '复位') { |
| | | |
| | | const data2 = []; |
| | | const resetButtonValues = this.jsonData.map(item => { |
| | | const buttonItem = item.find(subItem => subItem.button && subItem.button.name === '复位'); |
| | | return buttonItem ? buttonItem.button.value : null; |
| | | }).filter(value => value !== null); |
| | | |
| | | // 将得到的值添加到 data 数组中 |
| | | data2.push(...resetButtonValues); |
| | | const jsonObject2 = { data2 }; |
| | | |
| | | // 提交数据到后端 |
| | | const jsonString2 = JSON.stringify(jsonObject2); |
| | | console.log('所有Type为0的value:', jsonString2); |
| | | socket?.send(jsonString2); |
| | | data.push(values); |
| | | } |
| | | |
| | | |
| | | } |
| | | if (currentButtonName === 'A01半自动') { |
| | | const elements = document.getElementsByClassName('special-class'); |
| | | for (let i = 0; i < elements.length; i++) { |
| | | if (elements[i].style.display === 'none') { |
| | | elements[i].style.display = ''; // 显示元素 |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (currentButtonName === 'A02半自动') { |
| | | const elements = document.getElementsByClassName('special-class2'); |
| | | for (let i = 0; i < elements.length; i++) { |
| | | if (elements[i].style.display === 'none') { |
| | | elements[i].style.display = ''; // 显示元素 |
| | | } |
| | | } |
| | | } |
| | | const jsonObject = { data }; |
| | | |
| | | |
| | | // 提交数据到后端 |
| | | const jsonString = JSON.stringify(jsonObject); |
| | | console.log('所有Type为0的value:', jsonString); |
| | | socket?.send(jsonString); |
| | | |
| | | |
| | | }, |
| | | } |
| | | |
| | | if (currentButtonName === '复位') { |
| | | |
| | | const data2 = []; |
| | | const resetButtonValues = this.jsonData.map(item => { |
| | | const buttonItem = item.find(subItem => subItem.button && subItem.button.name === '复位'); |
| | | return buttonItem ? buttonItem.button.value : null; |
| | | }).filter(value => value !== null); |
| | | |
| | | // 将得到的值添加到 data 数组中 |
| | | data2.push(...resetButtonValues); |
| | | const jsonObject2 = { data2 }; |
| | | |
| | | // 提交数据到后端 |
| | | const jsonString2 = JSON.stringify(jsonObject2); |
| | | console.log('所有Type为0的value:', jsonString2); |
| | | socket?.send(jsonString2); |
| | | |
| | | |
| | | } |
| | | if (currentButtonName === 'A01半自动') { |
| | | const elements = document.getElementsByClassName('special-class'); |
| | | for (let i = 0; i < elements.length; i++) { |
| | | if (elements[i].style.display === 'none') { |
| | | elements[i].style.display = ''; // 显示元素 |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (currentButtonName === 'A02半自动') { |
| | | const elements = document.getElementsByClassName('special-class2'); |
| | | for (let i = 0; i < elements.length; i++) { |
| | | if (elements[i].style.display === 'none') { |
| | | elements[i].style.display = ''; // 显示元素 |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | }, |
| | | |
| | | |
| | | initWebSocket () { |
| | | |
| | | |
| | | let viewname = "ServoManualone"; |
| | | |
| | | if (typeof WebSocket === "undefined") { |
| | |
| | | |
| | | // 收到消息 |
| | | socket.onmessage = (msg) => { |
| | | if (!msg.data) { |
| | | return; // 如果收到空数据,则直接返回,不执行后续逻辑 |
| | | } |
| | | if (!msg.data) { |
| | | return; // 如果收到空数据,则直接返回,不执行后续逻辑 |
| | | } |
| | | |
| | | let obj = JSON.parse(msg.data); |
| | | // console.log(obj) |
| | | const jsonData2 = this.jsonData; |
| | | let obj = JSON.parse(msg.data); |
| | | // console.log(obj) |
| | | const jsonData2 = this.jsonData; |
| | | |
| | | const handleMouseMove = throttle(function(event) { |
| | | const inputBox = document.querySelectorAll('.el-card__body'); |
| | | const target = event.target; |
| | | if (inputBox && Array.from(inputBox).every(box => !box.contains(target))) { |
| | | // 执行更新逻辑 |
| | | for (let i = 0; i < 6; i++) { |
| | | jsonData2[i].forEach((item, index) => { |
| | | if (typeof item.value !== 'undefined' && typeof obj[`zuhe${i+1}`][0][index] !== 'undefined') { |
| | | item.value = obj[`zuhe${i+1}`][0][index]; |
| | | } |
| | | }); |
| | | } |
| | | const handleMouseMove = throttle(function (event) { |
| | | const inputBox = document.querySelectorAll('.el-card__body'); |
| | | const target = event.target; |
| | | if (inputBox && Array.from(inputBox).every(box => !box.contains(target))) { |
| | | // 执行更新逻辑 |
| | | for (let i = 0; i < 6; i++) { |
| | | jsonData2[i].forEach((item, index) => { |
| | | if (typeof item.value !== 'undefined' && typeof obj[`zuhe${i + 1}`][0][index] !== 'undefined') { |
| | | item.value = obj[`zuhe${i + 1}`][0][index]; |
| | | } |
| | | }); |
| | | } |
| | | |
| | | // 遍历guzhang数组 |
| | | for (let i = 0; i < obj.guzhang[0].length; i++) { |
| | | const guzhangValue = obj.guzhang[0][i]; |
| | | |
| | | // 查找jsonData2中带有"button"的对象,并且name等于"故障" |
| | | for (let j = 0; j < jsonData2.length; j++) { |
| | | const section = jsonData2[j]; |
| | | |
| | | for (let k = 0; k < section.length; k++) { |
| | | const item = section[k]; |
| | | |
| | | if (item.button && item.button.name === "故障") { |
| | | // 更新value属性 |
| | | item.button.value = guzhangValue; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | // 遍历guzhang数组 |
| | | for (let i = 0; i < obj.guzhang[0].length; i++) { |
| | | const guzhangValue = obj.guzhang[0][i]; |
| | | |
| | | // 查找jsonData2中带有"button"的对象,并且name等于"故障" |
| | | for (let j = 0; j < jsonData2.length; j++) { |
| | | const section = jsonData2[j]; |
| | | |
| | | for (let k = 0; k < section.length; k++) { |
| | | const item = section[k]; |
| | | |
| | | if (item.button && item.button.name === "故障") { |
| | | // 更新value属性 |
| | | item.button.value = guzhangValue; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | |
| | | |
| | | |
| | | } |
| | | }, 200); |
| | | } |
| | | }, 200); |
| | | |
| | | document.addEventListener('mouseover', handleMouseMove); |
| | | }; |
| | | document.addEventListener('mouseover', handleMouseMove); |
| | | }; |
| | | |
| | | |
| | | |
| | |
| | | } |
| | | }, |
| | | send () { |
| | | |
| | | |
| | | |
| | | |
| | | socket?.send(JSON.stringify(this.messagepack)); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | |
| | | |
| | | .item-row { |
| | | display: flex; |
| | | align-items: center; |
| | | margin-bottom: 2px; /* 调整每个项目之间的间距 */ |
| | | margin-bottom: 2px; |
| | | /* 调整每个项目之间的间距 */ |
| | | } |
| | | |
| | | .action-button { |
| | |
| | | background: #66b1ff; |
| | | color: #FFF; |
| | | } |
| | | |
| | | .blue-button { |
| | | background-color: skyblue; |
| | | } |
| | | |
| | | .error-button { |
| | | background-color: red; |
| | | } |
| | | |
| | | |
| | | </style> |
| | |
| | | <template> |
| | | <div class="app"> |
| | | <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb"> |
| | | <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/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('Servo Manual') |
| | | }}</router-link> |
| | | |
| | | </el-breadcrumb> |
| | | |
| | | <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb"> |
| | | |
| | | <router-link to="/Electrical/Servomanualone" tag="el-button" type="text" active-class="blue-button">{{ $t('Servomanualone') |
| | | <div class="app"> |
| | | <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb"> |
| | | <router-link to="/Electrical/alarm" tag="el-button" type="text" active-class="blue-button">{{ $t('Alarm') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Parameter1" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter1') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Parameter2" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter2') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Positioning1" tag="el-button" type="text" active-class="blue-button">{{ $t('Positioning1') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Positioning2" tag="el-button" type="text" active-class="blue-button">{{ $t('Positioning2') |
| | | }}</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/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('ServoManual') |
| | | }}</router-link> |
| | | |
| | | </el-breadcrumb> |
| | | |
| | | |
| | | </div > |
| | | <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb"> |
| | | |
| | | <router-link to="/Electrical/Servomanualone" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('Servomanualone') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Parameter1" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter1') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Parameter2" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter2') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Positioning1" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('Positioning1') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/Positioning2" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('Positioning2') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/ManualonePosition" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('ManualonePosition') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/ManualonePosition2" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('ManualonePosition2') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/AutomaticParameterSetting" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('AutomaticParameterSetting') |
| | | }}</router-link> |
| | | <router-link to="/Electrical/ManualJog" tag="el-button" type="text" active-class="blue-button">{{ |
| | | $t('ManualJog') |
| | | }}</router-link> |
| | | </el-breadcrumb> |
| | | |
| | | |
| | | </div> |
| | | </template> |
| | | <script> |
| | | import LanguageMixin from '../../lang/LanguageMixin' |
| | |
| | | jsonData: data // 加载整个data.json文件作为jsonData |
| | | } |
| | | }, |
| | | created() { |
| | | created () { |
| | | // 通过路由跳转到/Electrical/Servomanualone页面 |
| | | this.$router.push('/Electrical/Servomanualone'); |
| | | } |
| | |
| | | .item-row { |
| | | display: flex; |
| | | align-items: center; |
| | | margin-bottom: 10px; /* 调整每个项目之间的间距 */ |
| | | margin-bottom: 10px; |
| | | /* 调整每个项目之间的间距 */ |
| | | } |
| | | |
| | | |
| | | .action-button { |
| | | margin-right: 60px; /* 调整按钮之间的间距 */ |
| | | margin-right: 60px; |
| | | /* 调整按钮之间的间距 */ |
| | | } |
| | | |
| | | .blue-button { |
| | | background-color: skyblue; |
| | | } |
| | |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | // this.readValue(); |
| | | // String PlcAddress = this.name; |
| | | // Integer Plccount = this.count; |
| | | // this.readValue(); |
| | | // String PlcAddress = this.name; |
| | | // Integer Plccount = this.count; |
| | | |
| | | // System.out.println(stt); |
| | | // List<Short> arraylist = S7control.getinstance().ReadWord("DB100.0", 12); |
| | |
| | | List<Short> arraylist = new ArrayList<>(Arrays.asList(values1)); |
| | | Short[] fanzhuan = { 4 }; |
| | | List<Short> fanzhuan1 = new ArrayList<>(Arrays.asList(fanzhuan)); |
| | | Short[] xiaoche = {5}; |
| | | 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} |
| | |
| | | jsonObject.append("xiaoche", xiaoche1); |
| | | |
| | | WebSocketServer sendwServer = WebSocketServer.sessionMap.get("Parameter1"); |
| | | // System.out.println(sendwServer); |
| | | if (sendwServer != null) { |
| | | sendwServer.sendMessage(jsonObject.toString()); |
| | | } |
| | | |
| | | WebSocketServer webSocketServer = WebSocketServer.sessionMap.get("Parameter1"); |
| | | |
| | | if (webSocketServer != null) { |
| | | List<String> messages = webSocketServer.getMessages(); |
| | | // System.out.println(messages); |
| | | String addressList1 = "DB100.0"; |
| | | String addressList2 = "DB100.8"; |
| | | String addressList3 = "DB100.12"; |
| | |
| | | if (!messages.isEmpty()) { |
| | | // 将最后一个消息转换为 short 类型的列表 |
| | | String lastMessage = messages.get(messages.size() - 1); |
| | | // System.out.println("lastMessage:" + lastMessage); |
| | | // System.out.println("lastMessage:" + lastMessage); |
| | | JSONArray messageArray = new JSONArray(lastMessage); |
| | | |
| | | // System.out.println(messageArray); |
| | | // 整合第 1 到 3 个数组并去掉 null 元素 |
| | | List<Short> mergedList = new ArrayList<>(); |
| | | for (int i = 0; i < 3; i++) { |
| | |
| | | try { |
| | | String cleanedValue = value.toString().replaceAll("[^0-9-]", ""); |
| | | short sValue = Short.parseShort(cleanedValue.trim()); |
| | | // S7control.getinstance().WriteWord(addressList1, Arrays.asList(sValue)); |
| | | System.out.println("messageValue:" + Arrays.asList(sValue) + " written to PLC at address " + addressList1); |
| | | // S7control.getinstance().WriteWord(addressList1, Arrays.asList(sValue)); |
| | | System.out |
| | | .println("messageValue:" + Arrays.asList(sValue) + " written to PLC at address " + addressList1); |
| | | } catch (NumberFormatException e) { |
| | | // 如果无法解析为 short 类型,则忽略该部分 |
| | | System.err.println("Could not parse value: " + value); |
| | |
| | | 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); |
| | | // 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 (!mergedList.isEmpty()) { |
| | | // S7control.getinstance().WriteWord(addressList3, mergedList); |
| | | // S7control.getinstance().WriteWord(addressList3, mergedList); |
| | | System.out.println("messageValue:" + mergedList + " written to PLC at address " + addressList3); |
| | | } |
| | | |
| | | // 清空消息列表 |
| | | webSocketServer.clearMessages(); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | import org.springframework.core.annotation.Order; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import com.example.springboot.component.PLCAutomaticParameterSetting; |
| | | import com.example.springboot.component.PlcHold; |
| | | import com.example.springboot.component.PlcParameter; |
| | | import com.example.springboot.component.Plcaction; |
| | |
| | | import com.example.springboot.component.PlcPositioning2; |
| | | import com.example.springboot.component.PlcParameter2; |
| | | import com.example.springboot.component.PlcParameter1; |
| | | import com.example.springboot.component.PlcServoManualone; |
| | | //import com.example.springboot.component.PlcServoManualone; |
| | | |
| | | @Component |
| | | @Order(1) |
| | |
| | | |
| | | // new PlcHold().start(); |
| | | |
| | | // new Plcaction().start(); |
| | | // |
| | | // new Plchome().start(); |
| | | // |
| | | // new PlcParameter().start(); |
| | | // |
| | | // new Plcalarm().start(); |
| | | // |
| | | // new Plcsign().start(); |
| | | // |
| | | // new Plcstate().start(); |
| | | new PlcPositioning1().start(); |
| | | new PlcPositioning2().start(); |
| | | new PlcParameter2().start(); |
| | | new PlcParameter1().start(); |
| | | new PlcServoManualone().start(); |
| | | // new Plcaction().start(); |
| | | // |
| | | // new Plchome().start(); |
| | | // |
| | | // new PlcParameter().start(); |
| | | // |
| | | // new Plcalarm().start(); |
| | | // |
| | | // new Plcsign().start(); |
| | | // |
| | | // new Plcstate().start(); |
| | | new PlcPositioning1().start(); |
| | | new PlcPositioning2().start(); |
| | | new PlcParameter2().start(); |
| | | new PlcParameter1().start(); |
| | | new PLCAutomaticParameterSetting().start(); |
| | | // new PlcServoManualone().start(); |
| | | } |
| | | } |