From 903a5090b1624bc7a95e70ef52c4ccb1ac04d588 Mon Sep 17 00:00:00 2001
From: wu <731351411@qq.com>
Date: 星期三, 20 十二月 2023 14:22:45 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/CanadaMes
---
CanadaMes-ui/src/views/Electrical/ManualonePosition2.vue | 41
springboot-vue3/src/main/java/com/example/springboot/component/PlcManualonePosition2.java | 4
springboot-vue3/src/main/resources/config.properties | 44
springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter2.java | 8
CanadaMes-ui/src/configuration/Positioning1.json | 131 ++
springboot-vue3/src/main/java/com/example/springboot/component/PlcPositioning1.java | 19
springboot-vue3/src/main/java/com/example/springboot/component/S7control.java | 130 +-
CanadaMes-ui/src/views/Electrical/ManualonePosition.vue | 86 +
CanadaMes-ui/src/views/Electrical/Parameter2.vue | 280 ++++--
springboot-vue3/src/main/java/com/example/springboot/component/PLCManualJog.java | 21
CanadaMes-ui/src/configuration/ServoManualone.json | 48
CanadaMes-ui/src/configuration/Manualoneposition2.json | 18
CanadaMes-ui/src/views/Electrical/Positioning1.vue | 74 -
springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java | 26
CanadaMes-ui/src/views/Electrical/AutomaticParameterSetting.vue | 56
springboot-vue3/src/main/java/com/example/springboot/component/MessageHandler.java | 22
springboot-vue3/src/main/java/com/example/springboot/component/PLCAutomaticParameterSetting.java | 2
CanadaMes-ui/src/main.js | 4
CanadaMes-ui/src/lang/locales/en-US.json | 14
CanadaMes-ui/src/views/Electrical/ManualJog.vue | 60
CanadaMes-ui/src/views/Electrical/ServoManualone.vue | 1264 +++++++++++++++++------------
springboot-vue3/src/main/java/com/example/springboot/component/PlcManualonePosition.java | 91 -
CanadaMes-ui/src/configuration/Manualoneposition.json | 33
CanadaMes-ui/src/configuration/parameter2.json | 36
24 files changed, 1,539 insertions(+), 973 deletions(-)
diff --git a/CanadaMes-ui/src/configuration/Manualoneposition.json b/CanadaMes-ui/src/configuration/Manualoneposition.json
index d9b880c..e3c8f32 100644
--- a/CanadaMes-ui/src/configuration/Manualoneposition.json
+++ b/CanadaMes-ui/src/configuration/Manualoneposition.json
@@ -8,6 +8,7 @@
"address": "DB100.0",
"count": 3,
"state": 1
+
},
{
"name": "A01瀹氫綅閫熷害",
@@ -15,7 +16,9 @@
"sending": 0,
"address": "DB100.0",
"type": "0",
- "state": 1
+ "state": 1,
+ "min":0,
+ "max":3000
},
{
"name": "A01褰撳墠鏍煎瓙",
@@ -24,6 +27,7 @@
"address": "DB100.0",
"type": "0",
"state": 1
+
},
{
"button": {
@@ -59,6 +63,8 @@
"address": "DB100.0",
"count": 3,
"state": 1
+
+
},
{
"name": "A02瀹氫綅閫熷害",
@@ -66,7 +72,9 @@
"sending": 0,
"address": "DB100.0",
"type": "0",
- "state": 1
+ "state": 1,
+ "min":0,
+ "max":3000
},
{
"name": "A02褰撳墠鏍煎瓙",
@@ -75,6 +83,7 @@
"address": "DB100.0",
"type": "0",
"state": 1
+
},
{
"button": {
@@ -109,7 +118,9 @@
"type": "0",
"address": "DB100.0",
"count": 3,
- "state": 1
+ "state": 1,
+ "min":1,
+ "max":105
},
{
"name": "B01瀹氫綅閫熷害",
@@ -117,7 +128,9 @@
"sending": 0,
"address": "DB100.0",
"type": "0",
- "state": 1
+ "state": 1,
+ "min":0,
+ "max":2000
},
{
"name": "B01褰撳墠鏍煎瓙",
@@ -126,6 +139,7 @@
"address": "DB100.0",
"type": "0",
"state": 1
+
},
{
"button": {
@@ -171,12 +185,14 @@
[
{
"name": "B02鎵嬪姩鏍煎瓙",
- "value": 0,
+ "value": "",
"sending": 0,
"type": "0",
"address": "DB100.0",
"count": 3,
- "state": 1
+ "state": 1,
+ "min":106,
+ "max":210
},
{
"name": "B02瀹氫綅閫熷害",
@@ -184,7 +200,9 @@
"sending": 0,
"address": "DB100.0",
"type": "0",
- "state": 1
+ "state": 1,
+ "min":0,
+ "max":2000
},
{
"name": "B02褰撳墠鏍煎瓙",
@@ -193,6 +211,7 @@
"address": "DB100.0",
"type": "0",
"state": 1
+
},
{
"button": {
diff --git a/CanadaMes-ui/src/configuration/Manualoneposition2.json b/CanadaMes-ui/src/configuration/Manualoneposition2.json
index 577f1b5..59d1d37 100644
--- a/CanadaMes-ui/src/configuration/Manualoneposition2.json
+++ b/CanadaMes-ui/src/configuration/Manualoneposition2.json
@@ -6,14 +6,18 @@
"sending": 0,
"type": "0",
"address": "DB100.0",
- "count": 3
+ "count": 3,
+ "min":0,
+ "max":99
},
{
"name": "A01瀹氫綅閫熷害",
"value": 0,
"sending": 0,
"address": "DB100.0",
- "type": "0"
+ "type": "0",
+ "min":0,
+ "max":99
},
{
"name": "A01缈昏浆瀹炴椂浣嶇疆",
@@ -21,6 +25,7 @@
"sending": 0,
"address": "DB100.0",
"type": "0"
+
},
{
"button": {
@@ -70,14 +75,18 @@
"sending": 0,
"type": "0",
"address": "DB100.0",
- "count": 3
+ "count": 3,
+ "min":0,
+ "max":99
},
{
"name": "A02瀹氫綅閫熷害",
"value": 0,
"sending": 0,
"address": "DB100.0",
- "type": "0"
+ "type": "0",
+ "min":0,
+ "max":99
},
{
"name": "A02缈昏浆瀹炴椂浣嶇疆",
@@ -85,6 +94,7 @@
"sending": 0,
"address": "DB100.0",
"type": "0"
+
},
{
"button": {
diff --git a/CanadaMes-ui/src/configuration/Positioning1.json b/CanadaMes-ui/src/configuration/Positioning1.json
index c39530e..06a684d 100644
--- a/CanadaMes-ui/src/configuration/Positioning1.json
+++ b/CanadaMes-ui/src/configuration/Positioning1.json
@@ -16,7 +16,9 @@
"sending": 0,
"type": "0",
"unit": "mm",
- "value":"0"
+ "value":"0",
+ "min":0,
+ "max":100
}],
[{
@@ -25,7 +27,9 @@
"sending": 0,
"type": "0",
"unit": "mm",
- "value":"0"
+ "value":"0",
+ "min":0,
+ "max":100
}],
@@ -46,7 +50,9 @@
"unit": "mm",
"value":"0",
"address":"DB100.48",
- "count":10
+ "count":10,
+ "min":0,
+ "max":100
},
{
"name": "22#鏍煎湴鍧�",
@@ -54,7 +60,9 @@
"sending": 0,
"unit": "mm",
"type": "0" ,
- "value":"0"
+ "value":"0",
+ "min":0,
+ "max":100
},
{
"name": "43#鏍煎湴鍧�",
@@ -62,7 +70,9 @@
"sending": 0,
"unit": "mm",
"type": "0" ,
- "value":"0"
+ "value":"0",
+ "min":0,
+ "max":100
},
{
"name": "64#鏍煎湴鍧�",
@@ -70,7 +80,9 @@
"sending": 0,
"unit": "mm",
"type": "0" ,
- "value":"0"
+ "value":"0",
+ "min":0,
+ "max":100
},
{
"name": "85#鏍煎湴鍧�",
@@ -78,7 +90,9 @@
"sending": 0,
"unit": "mm",
"type": "0" ,
- "value":"0"
+ "value":"0",
+ "min":0,
+ "max":100
},
{
"name": "106#鏍煎湴鍧�",
@@ -86,7 +100,9 @@
"sending": 0,
"unit": "mm",
"type": "0" ,
- "value":"0"
+ "value":"0",
+ "min":0,
+ "max":100
},
{
"name": "127#鏍煎湴鍧�",
@@ -94,7 +110,9 @@
"sending": 0,
"unit": "mm",
"type": "0" ,
- "value":"0"
+ "value":"0",
+ "min":0,
+ "max":100
},
{
"name": "148#鏍煎湴鍧�",
@@ -102,7 +120,9 @@
"sending": 0,
"unit": "mm",
"type": "0" ,
- "value":"0"
+ "value":"0",
+ "min":0,
+ "max":100
},
{
"name": "169#鏍煎湴鍧�",
@@ -110,7 +130,9 @@
"sending": 0,
"unit": "mm",
"type": "0" ,
- "value":"0"
+ "value":"0",
+ "min":0,
+ "max":100
},
{
"name": "190#鏍煎湴鍧�",
@@ -118,7 +140,9 @@
"sending": 0,
"unit": "mm",
"type": "0" ,
- "value":"0"
+ "value":"0",
+ "min":0,
+ "max":100
}
@@ -141,7 +165,9 @@
"unit": "mm",
"value":"0",
"address":"DB100.68",
- "count":10
+ "count":10,
+ "min":0,
+ "max":100
},
{
"name": "22#鏍煎湴鍧�",
@@ -149,7 +175,9 @@
"sending": 0,
"unit": "mm",
"type": "0" ,
- "value":"0"
+ "value":"0",
+ "min":0,
+ "max":100
},
{
"name": "43#鏍煎湴鍧�",
@@ -157,7 +185,9 @@
"sending": 0,
"unit": "mm",
"type": "0" ,
- "value":"0"
+ "value":"0",
+ "min":0,
+ "max":100
},
{
"name": "64#鏍煎湴鍧�",
@@ -165,7 +195,9 @@
"sending": 0,
"unit": "mm",
"type": "0" ,
- "value":"0"
+ "value":"0",
+ "min":0,
+ "max":100
},
{
"name": "85#鏍煎湴鍧�",
@@ -173,7 +205,9 @@
"sending": 0,
"unit": "mm",
"type": "0" ,
- "value":"0"
+ "value":"0",
+ "min":0,
+ "max":100
},
{
"name": "106#鏍煎湴鍧�",
@@ -181,7 +215,9 @@
"sending": 0,
"unit": "mm",
"type": "0" ,
- "value":"0"
+ "value":"0",
+ "min":0,
+ "max":100
},
{
"name": "127#鏍煎湴鍧�",
@@ -189,7 +225,9 @@
"sending": 0,
"unit": "mm",
"type": "0" ,
- "value":"0"
+ "value":"0",
+ "min":0,
+ "max":100
},
{
"name": "148#鏍煎湴鍧�",
@@ -197,7 +235,9 @@
"sending": 0,
"unit": "mm",
"type": "0" ,
- "value":"0"
+ "value":"0",
+ "min":0,
+ "max":100
},
{
"name": "169#鏍煎湴鍧�",
@@ -205,7 +245,9 @@
"sending": 0,
"unit": "mm",
"type": "0" ,
- "value":"0"
+ "value":"0",
+ "min":0,
+ "max":100
},
{
"name": "190#鏍煎湴鍧�",
@@ -213,7 +255,9 @@
"sending": 0,
"type": "0" ,
"unit": "mm",
- "value":"0"
+ "value":"0",
+ "min":0,
+ "max":100
}
@@ -234,16 +278,19 @@
"unit": "mm",
"address":"DB100.0",
"count":3,
- "value":"0"
+ "value":"0",
+ "min":0,
+ "max":100
},
{
"name": "22#鏍煎湴鍧�",
"read": 11,
"sending": 0,
"unit": "mm",
- "type": "0"
- ,
- "value":"0"
+ "type": "0",
+ "value":"0",
+ "min":0,
+ "max":100
},
{
"name": "43#鏍煎湴鍧�",
@@ -251,7 +298,9 @@
"sending": 0,
"unit": "mm",
"type": "0",
- "value":"0"
+ "value":"0",
+ "min":0,
+ "max":100
},
{
"name": "64#鏍煎湴鍧�",
@@ -259,7 +308,9 @@
"sending": 0,
"unit": "mm",
"type": "0",
- "value":"0"
+ "value":"0",
+ "min":0,
+ "max":100
},
{
"name": "85#鏍煎湴鍧�",
@@ -267,7 +318,9 @@
"sending": 0,
"unit": "mm",
"type": "0",
- "value":"0"
+ "value":"0",
+ "min":0,
+ "max":100
}
@@ -287,7 +340,9 @@
"sending": 0,
"unit": "mm",
"type": "0",
- "value":"0"
+ "value":"0",
+ "min":0,
+ "max":100
},
{
"name": "127#鏍煎湴鍧�",
@@ -295,7 +350,9 @@
"sending": 0,
"unit": "mm",
"type": "0",
- "value":"0"
+ "value":"0",
+ "min":0,
+ "max":100
},
{
"name": "148#鏍煎湴鍧�",
@@ -303,7 +360,9 @@
"sending": 0,
"unit": "mm",
"type": "0",
- "value":"0"
+ "value":"0",
+ "min":0,
+ "max":100
},
{
"name": "169#鏍煎湴鍧�",
@@ -311,7 +370,9 @@
"sending": 0,
"unit": "mm",
"type": "0",
- "value":"0"
+ "value":"0",
+ "min":0,
+ "max":100
},
{
"name": "190#鏍煎湴鍧�",
@@ -319,7 +380,9 @@
"sending": 0,
"unit": "mm",
"type": "0",
- "value":"0"
+ "value":"0",
+ "min":0,
+ "max":100
}
diff --git a/CanadaMes-ui/src/configuration/ServoManualone.json b/CanadaMes-ui/src/configuration/ServoManualone.json
index 39c014f..91cd5b1 100644
--- a/CanadaMes-ui/src/configuration/ServoManualone.json
+++ b/CanadaMes-ui/src/configuration/ServoManualone.json
@@ -7,7 +7,9 @@
"sending": 0,
"type": "0",
"address":"DB100.0",
- "value":0
+ "value":0,
+ "min":0,
+ "max":100
},
{
@@ -15,7 +17,9 @@
"read": 33,
"sending": 0,
"type": "0",
- "value":0
+ "value":0,
+ "min":0,
+ "max":100
},
@@ -25,7 +29,9 @@
"read": 33,
"sending": 0,
"type": "0",
- "value":0
+ "value":0,
+ "min":0,
+ "max":100
},
@@ -34,7 +40,9 @@
"read": 33,
"sending": 0,
"type": "0",
- "value":0
+ "value":0,
+ "min":0,
+ "max":100
},
@@ -43,21 +51,27 @@
"read": 11,
"sending": 0,
"type": "0",
- "value":0
+ "value":0,
+ "min":0,
+ "max":100
},
{
"name": "瀛樼墖鏍煎瓙",
"read": 22,
"sending": 0,
"type": "0",
- "value":0
+ "value":0,
+ "min":0,
+ "max":100
},
{
"name": "杩涚墖ID",
"read": 9999,
"sending": 0,
"type": "0",
- "value":0
+ "value":0,
+ "min":0,
+ "max":100
},
@@ -100,28 +114,36 @@
"type": "0",
"address":"DB100.1",
"count":3,
- "value":0
+ "value":0,
+ "min":0,
+ "max":100
},
{
"name": "鍙栫墖鏍煎瓙",
"read": 11,
"sending": 0,
"type": "0",
- "value":0
+ "value":0,
+ "min":0,
+ "max":100
},
{
"name": "瀛樼墖鏍煎瓙",
"read": 22,
"sending": 0,
"type": "0",
- "value":0
+ "value":0,
+ "min":0,
+ "max":100
},
{
"name": "鏁伴噺",
"read": 33,
"sending": 0,
"type": "0",
- "value":0
+ "value":0,
+ "min":0,
+ "max":100
},
@@ -130,7 +152,9 @@
"read": 8888,
"sending": 0,
"type": "0",
- "value":0
+ "value":0,
+ "min":0,
+ "max":100
},
diff --git a/CanadaMes-ui/src/configuration/parameter2.json b/CanadaMes-ui/src/configuration/parameter2.json
index a477253..fcc0f7a 100644
--- a/CanadaMes-ui/src/configuration/parameter2.json
+++ b/CanadaMes-ui/src/configuration/parameter2.json
@@ -320,15 +320,41 @@
"value": 0
}
]
- , [
- {
+ ,
+ [
+
+ {
"button": {
- "name": "鎬ュ仠鍚庝腑姝�/缁х画閫夋嫨",
+ "name": "A01缁堟/缁х画",
"value":0,
"address":"DB10.0",
"type":"66"
}
- }
+ }],
+
-]
+ [
+ {
+ "button": {
+ "name": "A02缁堟/缁х画",
+ "value":0,
+ "address":"DB10.0",
+ "type":"66"
+ }
+ }],
+ [
+
+
+
+ {
+ "name": "瀛樼墖绛夊緟寤舵椂",
+ "read": 666,
+ "sending": 0,
+ "type": "0",
+ "value": 0
+ }
+
+
+ ]
+
]
\ No newline at end of file
diff --git a/CanadaMes-ui/src/lang/locales/en-US.json b/CanadaMes-ui/src/lang/locales/en-US.json
index 313dcc4..1024bca 100644
--- a/CanadaMes-ui/src/lang/locales/en-US.json
+++ b/CanadaMes-ui/src/lang/locales/en-US.json
@@ -270,7 +270,7 @@
"There is no glass for this order":"There is no glass for this order",
"There are currently tasks":"There are currently tasks",
"There is no such glass":"There is no such glass",
- "There is no such slot":"There is no such slot",
+ "There is no such grid":"There is no such grid",
"No delete allowed":"No delete allowed",
"No out allowed":"No out allowed",
"Are you sure to perform this operation ?":"Are you sure to perform this operation ?",
@@ -386,7 +386,11 @@
"A02鎵�鍦ㄦ牸瀛�": "A02 Current Grid",
"B01鎵�鍦ㄦ牸瀛�": "B01 Current Grid",
"B02鎵�鍦ㄦ牸瀛�": "B02 Current Grid",
- "鎬ュ仠鍚庝腑姝�/缁х画閫夋嫨": "Abort/ResumeTasks"
+ "鎬ュ仠鍚庝腑姝�/缁х画閫夋嫨": "Abort/ResumeTasks",
+ "A01缁堟/缁х画": "A01Abort/ResumeTasks",
+ "A02缁堟/缁х画": "A02Abort/ResumeTasks",
+ "瀛樼墖绛夊緟寤舵椂": "Storage wait delay"
+
},
"langPositioning1": {
"鏍煎瓙闂磋窛": "GridSpacing",
@@ -533,9 +537,9 @@
"A02娉ㄧ數娉�": "A02 oil pump",
"A01琛岃蛋浼烘湇鍥為浂":"A01 SERVE TRAVEL Home",
"A02琛岃蛋浼烘湇鍥為浂":"A02 SERVE TRAVEL Home"
- }
-
+ },
+ "A01琛岃蛋浼烘湇鍥為浂":"A01 SERVE TRAVEL Home",
+ "A02琛岃蛋浼烘湇鍥為浂":"A02 SERVE TRAVEL Home"
-
}
\ No newline at end of file
diff --git a/CanadaMes-ui/src/main.js b/CanadaMes-ui/src/main.js
index 197ff46..dfacd3c 100644
--- a/CanadaMes-ui/src/main.js
+++ b/CanadaMes-ui/src/main.js
@@ -10,10 +10,14 @@
import VueI18n from 'vue-i18n'
import zhCN from './lang/locales/zh-CN.json' // 涓枃璇█鍖�
import enUS from './lang/locales/en-US.json' // 鑻辨枃璇█鍖�
+import websocketPlugin from './api/websocketPlugin'; // 寮曞叆鎻掍欢鏂囦欢
// import store from './store'
// import store from './store'
Vue.use(VueI18n)
+Vue.use(websocketPlugin, {
+ ip: 'localhost', // 鏇挎崲鎴愪綘鐨� WebSocket 鏈嶅姟鍣� IP 鍦板潃
+});
const i18n = new VueI18n({
locale: 'en-US',
diff --git a/CanadaMes-ui/src/views/Electrical/AutomaticParameterSetting.vue b/CanadaMes-ui/src/views/Electrical/AutomaticParameterSetting.vue
index c9fd7bb..fff23a1 100644
--- a/CanadaMes-ui/src/views/Electrical/AutomaticParameterSetting.vue
+++ b/CanadaMes-ui/src/views/Electrical/AutomaticParameterSetting.vue
@@ -181,7 +181,19 @@
};
// 鏀跺埌娑堟伅
- socket.onmessage = (msg) => {
+ let isMouseInInputBox = false; // 鏍囪榧犳爣鏄惁鍦ㄨ緭鍏ユ鍐�
+
+const inputBox = document.querySelectorAll('.input-box');
+inputBox.forEach(box => {
+ box.addEventListener('mouseenter', () => {
+ isMouseInInputBox = true;
+ });
+ box.addEventListener('mouseleave', () => {
+ isMouseInInputBox = false;
+ });
+});
+
+socket.onmessage = (msg) => {
if (!msg.data) {
return; // 濡傛灉鏀跺埌绌烘暟鎹紝鍒欑洿鎺ヨ繑鍥烇紝涓嶆墽琛屽悗缁�昏緫
}
@@ -189,17 +201,7 @@
let obj = JSON.parse(msg.data);
const jsonData2 = this.jsonData;
- const handleMouseMove = (event) => {
- if (!event || !event.target) {
- return; // 濡傛灉 event 鎴� event.target 涓嶅瓨鍦紝鍒欑洿鎺ヨ繑鍥烇紝涓嶆墽琛屽悗缁�昏緫
- }
-
- const inputBox = document.querySelectorAll('.input-box');
- const target = event.target;
- const isMouseInInput = Array.from(inputBox).some(box => box.contains(target));
-
- if (!isMouseInInput) {
- const parms = obj.params;
+ const parms = obj.params;
const fanzhuan = obj.fanzhuan;
const xiaoche = obj.xiaoche;
const dache = obj.dache1;
@@ -207,6 +209,9 @@
const parms2 = obj.params2;
const fanzhuan2 = obj.fanzhuan2;
const xiaoche2 = obj.xiaoche2;
+
+ if(parms && !isMouseInInputBox){
+
let index = 0;
for (let i = 0; i < jsonData2.length - 1; i++) {
@@ -234,10 +239,10 @@
let index2 = 0;
for (let i = 5; i < jsonData2.length; i++) {
- let arr = jsonData2[i];
+ let arr2 = jsonData2[i];
- for (let j = 0; j < arr.length; j++) {
- let obj2 = arr[j];
+ for (let j = 0; j < arr2.length; j++) {
+ let obj2 = arr2[j];
if (obj2.type === '0' && Object.prototype.hasOwnProperty.call(obj2, 'value')) {
if (Array.isArray(parms2) && Array.isArray(parms2[0]) && parms2[0][index2] !== undefined) {
obj2.value = parms2[0][index2];
@@ -246,18 +251,33 @@
}
}
}
+
+
+ for (let i = 0; i < jsonData2.length; i++) {
+ let arr = jsonData2[i];
+
+ for (let j = 0; j < arr.length; j++) {
+ let obj = arr[j];
+ if (obj.type === '0' && Object.prototype.hasOwnProperty.call(obj, 'value')) {
+ if (Array.isArray(parms) && Array.isArray(parms[0]) && parms[0][index] !== undefined) {
+ obj.value = parms[0][index];
+ index++;
+ }
+ }
+ }
+ }
+
if (Array.isArray(fanzhuan2) && Array.isArray(fanzhuan2[0]) && fanzhuan2[0][0] !== undefined) {
jsonData2[8][0]['value'] = fanzhuan2[0][0];
}
+
if (Array.isArray(xiaoche2) && Array.isArray(xiaoche2[0]) && xiaoche2[0][0] !== undefined) {
jsonData2[9][0]['value'] = xiaoche2[0][0];
}
}
- };
+
- setInterval(() => handleMouseMove(event), 1000); // 姣忛殧 1000ms 妫�娴嬩竴娆¢紶鏍囦綅缃�
-document.addEventListener('mousemove', event => handleMouseMove(event));
};
diff --git a/CanadaMes-ui/src/views/Electrical/ManualJog.vue b/CanadaMes-ui/src/views/Electrical/ManualJog.vue
index dab071b..9897ac8 100644
--- a/CanadaMes-ui/src/views/Electrical/ManualJog.vue
+++ b/CanadaMes-ui/src/views/Electrical/ManualJog.vue
@@ -92,12 +92,10 @@
if (language === 'en-US') {
this.replaceChineseWithEnglish();
}
- // this.$forceUpdate();
- SelectPassword().then(res => {
- this.password = res.data.password;
- console.log(this.password)
- });
+
+this.load();
+
},
methods: {
closeSocket () {
@@ -113,9 +111,25 @@
this.$set(dataGroup[itemIndex].button, 'value2', 0);
}
},
+ load(){
+
+ SelectPassword().then(res => {
+ this.password = res.data.password;
+ console.log(this.password)
+ });
+
+
+
+
+
+console.log(this.jsonData)
+
+
+
+ },
submitDataToBackend (currentButtonName) {
- if (currentButtonName === 'A01 SERVE TRAVEL Home' || currentButtonName === 'A02 SERVE TRAVEL Home' || currentButtonName === 'A01琛岃蛋浼烘湇鍥為浂' || currentButtonName === 'A02琛岃蛋浼烘湇鍥為浂') {
+ if (currentButtonName === 'A01 SERVE TRAVEL Home' || currentButtonName === 'A02 SERVE TRAVEL Home' || currentButtonName === 'A01琛岃蛋浼烘湇鍥為浂' || currentButtonName === 'A02琛岃蛋浼烘湇鍥為浂') {
this.$prompt(
this.$t('Are you sure to perform this operation?'),
this.$t('prompt'),
@@ -177,17 +191,7 @@
socket?.send(jsonString);
}
},
- //鏍规嵁璇诲彇PLC鐨勫�硷紝鏍规嵁鍚嶇О鏀瑰彉棰滆壊1鎵撳紑锛�0鍏抽棴
-// getStatusClass (zhuangtai) {
-// // console.log(zhuangtai);
-// if (zhuangtai === 1) {
-// return "op";
-// }
-// else {
-// return "dow";
-// }
-// },
initWebSocket () {
let viewname = "ManualJog";
@@ -208,7 +212,7 @@
socket.onopen = function () {
console.log("websocket宸叉墦寮�");
};
-
+ let isUpdated = false; // 瀹氫箟鏍囧織鍙橀噺
// 鏀跺埌娑堟伅
socket.onmessage = (msg) => {
if (!msg.data) {
@@ -219,7 +223,7 @@
const jsonData2 = this.jsonData;
const parms = obj.params;
-// console.log(obj)
+// console.log(obj)
//console.log(this.jsonData)
if(parms){
// 濡傛灉榧犳爣涓嶅湪杈撳叆妗嗗唴锛屾洿鏂拌緭鍏ユ鐨勫��
@@ -232,13 +236,26 @@
for (let j = 0; j < arr.length; j++) {
let obj = arr[j];
obj.button.value = parms[0][j];
- obj.button.value2 =obj.button.value;
+ // obj.button.value2 = parms[0][j];
+ // obj.button.value2 =obj.button.value;
}
}
+ jsonData2[1][0].button.value = obj.params[0][26];
+ jsonData2[1][1].button.value = obj.params[0][27];
+
+
+ if (!isUpdated) {
+ for (let i = 0; i < this.jsonData.length; i++) {
+ for (let j = 0; j < this.jsonData[i].length; j++) {
+ this.jsonData[i][j].button.value2 = this.jsonData[i][j].button.value;
+ }
+ }
+ isUpdated = true; // 鏇存柊鏍囧織鍙橀噺鐨勫��
+ }
@@ -248,6 +265,11 @@
};
+
+
+
+
+
// 鍏抽棴浜嬩欢
socket.onclose = function () {
console.log("websocket宸插叧闂�");
diff --git a/CanadaMes-ui/src/views/Electrical/ManualonePosition.vue b/CanadaMes-ui/src/views/Electrical/ManualonePosition.vue
index c9934cd..bb5400c 100644
--- a/CanadaMes-ui/src/views/Electrical/ManualonePosition.vue
+++ b/CanadaMes-ui/src/views/Electrical/ManualonePosition.vue
@@ -56,21 +56,21 @@
<span class="name" style="width:300px;">{{ item.name }}</span>
<el-input style="width:250px;" v-if="item.state != 0 && item.type === '0' && groupIndex === 0 && (itemIndex === 2)" readonly v-model="item.value"
- class="input-box"></el-input>
+ class="input-box" ></el-input>
<el-input style="width:250px;" v-else-if="item.state != 0 && item.type === '0' && groupIndex === 0 " v-model="item.value" @keyup.enter.native="A01start"
- class="input-box"></el-input>
- <el-input style="width: 250px;" v-else-if="(item.state !== 0) && (item.type === '0') && (itemIndex === 2)" v-model="item.value" readonly class="input-box"></el-input>
+ class="input-box" ></el-input>
+ <el-input style="width: 250px;" v-else-if="(item.state !== 0) && (item.type === '0') && (itemIndex === 2)" v-model="item.value" readonly class="input-box" ></el-input>
<el-input style="width:250px;" v-else-if="item.state != 0 && item.type === '0' && groupIndex === 1" v-model="item.value" @keyup.enter.native="A02start"
- class="input-box"></el-input>
+ class="input-box" ></el-input>
<el-input style="width:250px;" v-else-if="item.state != 0 && item.type === '0' && groupIndex === 2" v-model="item.value" @keyup.enter.native="B01start"
- class="input-box"></el-input>
+ class="input-box" ></el-input>
<el-input style="width:250px;" v-else-if="item.state != 0 && item.type === '0' && groupIndex === 3" v-model="item.value" @keyup.enter.native="B02start"
- class="input-box"></el-input>
+ class="input-box" ></el-input>
<el-input style="width:250px;" v-else-if="item.state != 0 && item.type === '0'" v-model="item.value"
- class="input-box"></el-input>
+ class="input-box" ></el-input>
</div>
</div>
<div class="button-row" style="display: flex; justify-content: space-between;">
@@ -106,6 +106,7 @@
import data from '../../configuration/Manualoneposition'
import ManualonePosition2 from './ManualonePosition2.vue';
+// import { createWebSocket } from '../../api/websocket.js';
let socket;
export default {
name: "ManualonePosition",
@@ -156,14 +157,30 @@
for (let i = 0; i < 1; i++) {
const inputData = this.jsonData[i].filter(item => item.type === '0').map(item => {
+
return { value: item.value };
});
const values = inputData.map(item => item.value);
+ console.log(values);
+
+if (values.length > 0) {
+
+ let firstValue = values[0];
+ if (!(firstValue >= "1" && firstValue <= "210") && firstValue !== "888" && firstValue !== "1000") {
+ values.shift();
+ this.$message.error("Out of range");
+
+ return false;
+ }
+}
data.push(values);
+
+
}
data.push([], [], [],[],[],[]);
+
@@ -184,6 +201,15 @@
});
const values = inputData.map(item => item.value);
+ if (values.length > 0) {
+
+let firstValue = values[0];
+if (!(firstValue >= "1" && firstValue <= "210") && firstValue !== "888" && firstValue !== "1000") {
+ values.shift();
+ this.$message.error("Out of range");
+ return false;
+}
+}
data.unshift([]);
data.push(values);
}
@@ -431,31 +457,31 @@
};
// 鏀跺埌娑堟伅
- socket.onmessage = (msg) => {
- if (!msg.data) {
- return; // 濡傛灉鏀跺埌绌烘暟鎹紝鍒欑洿鎺ヨ繑鍥烇紝涓嶆墽琛屽悗缁�昏緫
- }
+ let isMouseInInputBox = false; // 鏍囪榧犳爣鏄惁鍦ㄨ緭鍏ユ鍐�
+
+const inputBox = document.querySelectorAll('.input-box');
+inputBox.forEach(box => {
+ box.addEventListener('mouseenter', () => {
+ isMouseInInputBox = true;
+ });
+ box.addEventListener('mouseleave', () => {
+ isMouseInInputBox = false;
+ });
+});
+
+socket.onmessage = (msg) => {
+ if (!msg.data) {
+ return; // 濡傛灉鏀跺埌绌烘暟鎹紝鍒欑洿鎺ヨ繑鍥烇紝涓嶆墽琛屽悗缁�昏緫
+ }
let obj = JSON.parse(msg.data);
const jsonData2 = this.jsonData;
const weihuiling = obj.weihuiling;
- const handleMouseMove = (event) => {
- if (!event || !event.target) {
- return; // 濡傛灉 event 鎴� event.target 涓嶅瓨鍦紝鍒欑洿鎺ヨ繑鍥烇紝涓嶆墽琛屽悗缁�昏緫
- }
-
- const inputBox = document.querySelectorAll('.input-box');
- const target = event.target;
- // console.log(obj);
-
- const isMouseInInput = Array.from(inputBox).some(box => box.contains(target));
-
- if (!isMouseInInput) {
- if(obj.zuhe1){
+ if(obj.zuhe1&& !isMouseInInputBox){
-
+// console.log(obj);
// 鎵ц鏇存柊閫昏緫
for (let i = 0; i < 4; i++) {
@@ -467,14 +493,8 @@
}
}
- }
- }
-
- // console.log(jsonData2);
- setInterval(() => handleMouseMove(event), 1000); // 姣忛殧 1000ms 妫�娴嬩竴娆¢紶鏍囦綅缃�
-
-document.addEventListener('mousemove', event => handleMouseMove(event));
-
+
+
if(obj.zuhe1){
diff --git a/CanadaMes-ui/src/views/Electrical/ManualonePosition2.vue b/CanadaMes-ui/src/views/Electrical/ManualonePosition2.vue
index c2db6ea..286a5ef 100644
--- a/CanadaMes-ui/src/views/Electrical/ManualonePosition2.vue
+++ b/CanadaMes-ui/src/views/Electrical/ManualonePosition2.vue
@@ -318,10 +318,22 @@
};
// 鏀跺埌娑堟伅
- socket.onmessage = (msg) => {
- if (!msg.data) {
- return; // 濡傛灉鏀跺埌绌烘暟鎹紝鍒欑洿鎺ヨ繑鍥烇紝涓嶆墽琛屽悗缁�昏緫
- }
+ let isMouseInInputBox = false; // 鏍囪榧犳爣鏄惁鍦ㄨ緭鍏ユ鍐�
+
+const inputBox = document.querySelectorAll('.input-box');
+inputBox.forEach(box => {
+ box.addEventListener('mouseenter', () => {
+ isMouseInInputBox = true;
+ });
+ box.addEventListener('mouseleave', () => {
+ isMouseInInputBox = false;
+ });
+});
+
+socket.onmessage = (msg) => {
+ if (!msg.data) {
+ return; // 濡傛灉鏀跺埌绌烘暟鎹紝鍒欑洿鎺ヨ繑鍥烇紝涓嶆墽琛屽悗缁�昏緫
+ }
let obj = JSON.parse(msg.data);
@@ -329,21 +341,11 @@
// console.log(obj)
const jsonData2 = this.jsonData;
const weihuiling = obj.weihuiling;
- const handleMouseMove = (event) => {
- if (!event || !event.target) {
- return; // 濡傛灉 event 鎴� event.target 涓嶅瓨鍦紝鍒欑洿鎺ヨ繑鍥烇紝涓嶆墽琛屽悗缁�昏緫
- }
- const inputBox = document.querySelectorAll('.input-box');
- const target = event.target;
- // console.log(obj);
-
- const isMouseInInput = Array.from(inputBox).some(box => box.contains(target));
-
-if (!isMouseInInput) {
+
- if (obj.zuhe1 ) {
+ if (obj.zuhe1&& !isMouseInInputBox ) {
// 鎵ц鏇存柊閫昏緫
for (let i = 0; i < 2; i++) {
jsonData2[i].forEach((item, index) => {
@@ -378,13 +380,8 @@
}
- }
-
- }
- // console.log(jsonData2);
- setInterval(() => handleMouseMove(event), 1000); // 姣忛殧 1000ms 妫�娴嬩竴娆¢紶鏍囦綅缃�
+
-document.addEventListener('mousemove', event => handleMouseMove(event));
if(obj.zuhe1){
diff --git a/CanadaMes-ui/src/views/Electrical/Parameter2.vue b/CanadaMes-ui/src/views/Electrical/Parameter2.vue
index c8ae4de..95bf82f 100644
--- a/CanadaMes-ui/src/views/Electrical/Parameter2.vue
+++ b/CanadaMes-ui/src/views/Electrical/Parameter2.vue
@@ -21,7 +21,7 @@
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
@@ -102,10 +102,9 @@
:span="6"
v-for="(dataGroup, groupIndex) in jsonData"
:key="groupIndex"
-
- style="margin-bottom: -20px;"
+ style="margin-bottom: -20px"
>
- <el-card class="json-block" style="width: 300px; margin-bottom: 2px">
+ <el-card class="json-block" style="width: 300px; margin-bottom: 2px;height:200px" :height="groupIndex === 12 ? '190px' : '170px'" >
<div
class="button-row"
style="display: flex; justify-content: space-between"
@@ -141,7 +140,8 @@
item.button.value === 2 && item.button.name !== 'Clear ID',
'yellow-button':
item.button.value === 1 && item.button.name !== 'Clear ID',
- 'id': item.button.value === 1 && item.button.name === 'Clear ID',
+ id:
+ item.button.value === 1 && item.button.name === 'Clear ID',
}"
>{{ item.button.name }}</el-button
>
@@ -162,7 +162,7 @@
item.button.value === 2 && item.button.name !== '娓呴櫎ID',
'yellow-button':
item.button.value === 1 && item.button.name !== '娓呴櫎ID',
- 'id': item.button.value === 1 && item.button.name === '娓呴櫎ID',
+ id: item.button.value === 1 && item.button.name === '娓呴櫎ID',
}"
>{{ item.button.name }}</el-button
>
@@ -177,15 +177,21 @@
<span
class="name"
v-if="groupIndex === 12"
- style="width: 250px"
+ style="width: 350px"
>{{ item.name }}</span
>
<span class="name" v-else style="width: 150px">{{
item.name
}}</span>
-
+ <el-input
+ v-if="item.type === '0' && groupIndex==15"
+ v-model="item.value"
+ @keyup.enter.native="timeout"
+ style="width: 300px"
+ class="input-box2"
+ ></el-input>
<el-input
- v-if="item.type === '0'"
+ v-else-if="item.type === '0' "
v-model="item.value"
readonly="readonly"
style="width: 300px"
@@ -260,13 +266,40 @@
updateButtonValue(dataGroup, itemIndex) {
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锛屽皢鍏惰涓� 1
+ this.$set(dataGroup[itemIndex].button, "value", 0);
+ } else {
+ // 鍚﹀垯灏嗗叾璁句负 0
+ this.$set(dataGroup[itemIndex].button, "value", 1);
+ }
+ },
+ //鑼冨洿 0-100
+ timeout(){
+
+
+ const data3 = [];
+ const resetButtonValues3 = [this.jsonData[15][0].value];
+
+ // 灏嗗緱鍒扮殑鍊兼坊鍔犲埌 data 鏁扮粍涓�
+ data3.push(resetButtonValues3.flat());
+ data3.unshift([],[]);
+ // 鍦� data3 鏁扮粍鍓嶉潰娣诲姞涓や釜绌烘暟缁�
+
+ // 鍒涘缓 jsonObject3 瀵硅薄锛屽苟娣诲姞 data3 灞炴��
+ const jsonObject3 = { data: data3 };
+
+ // 鎻愪氦鏁版嵁鍒板悗绔�
+ const jsonString3 = JSON.stringify(jsonObject3);
+ console.log("Storage wait delay:", jsonString3);
+ socket?.send(jsonString3);
+ // setTimeout(()=>
+ // window.location.reload(),2000
+ // )
+
+ },
+
+
+
submitDataToBackend(currentButtonName) {
if (currentButtonName === "娓呴櫎ID" || currentButtonName === "Clear ID") {
const data2 = [];
@@ -297,11 +330,13 @@
}
if (
- currentButtonName === "Abort/ResumeTasks" ||
- currentButtonName === "鎬ュ仠鍚庝腑姝�/缁х画閫夋嫨"
+ currentButtonName === "A01Abort/ResumeTasks" ||
+ currentButtonName === "A01缁堟/缁х画" ||
+ currentButtonName === "A02Abort/ResumeTasks" ||
+ currentButtonName === "A02缁堟/缁х画"
) {
const data3 = [];
- const resetButtonValues3 = [this.jsonData[13][0].button.value];
+ const resetButtonValues3 = [this.jsonData[13][0].button.value,this.jsonData[14][0].button.value];
// 灏嗗緱鍒扮殑鍊兼坊鍔犲埌 data 鏁扮粍涓�
data3.push(resetButtonValues3.flat());
@@ -319,7 +354,11 @@
// window.location.reload(),2000
// )
}
+
+
},
+
+
initWebSocket() {
let viewname = "Parameter2";
@@ -345,7 +384,17 @@
socket.onopen = function () {
console.log("websocket宸叉墦寮�");
};
+ let isMouseInInputBox = false; // 鏍囪榧犳爣鏄惁鍦ㄨ緭鍏ユ鍐�
+const inputBox = document.querySelectorAll('.input-box2');
+inputBox.forEach(box => {
+ box.addEventListener('mouseenter', () => {
+ isMouseInInputBox = true;
+ });
+ box.addEventListener('mouseleave', () => {
+ isMouseInInputBox = false;
+ });
+});
// 鏀跺埌娑堟伅
socket.onmessage = (msg) => {
if (!msg.data) {
@@ -358,122 +407,134 @@
const parms = obj.params;
- // console.log(obj);
+ //console.log(obj);
// const handleMouseMove = throttle(function(event) {
// const inputBox = document.querySelectorAll('.id');
// const target = event.target;
- if (parms ) {
- //鎬ュ仠鎸夐挳
- jsonData2[13][0].button.value = obj.jiting[0][0];
+ if (parms && !isMouseInInputBox) {
+ //鎬ュ仠鎸夐挳
+ jsonData2[13][0].button.value = obj.jiting[0][0];
+ jsonData2[14][0].button.value = obj.jiting[0][1];
+
- //娓呴櫎id
+
+
+
+ //娓呴櫎id
- 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(obj.button.value);
- }
- }
- }
-
- //ID
- const specialChars = /[^\w\s]/g; // 姝e垯琛ㄨ揪寮忓尮閰嶉潪瀛楁瘝銆佹暟瀛椼�佷笅鍒掔嚎鍜岀┖鏍肩殑瀛楃
-
- 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") {
- if (parms[1] && parms[1][i]) {
- obj.value = parms[1][i].replace(specialChars, "");
- // console.log(obj.value);
- }
- if (obj.name === "ID2") {
- obj.value = parms[1][7].replace(specialChars, ""); // 灏咺D2瀵瑰簲鐨勫�艰祴涓簆arms[1][7]
- }
-
- if (obj.name === "A02ID") {
- obj.value = parms[1][8].replace(specialChars, "");
- }
- if (obj.name === "B01ID") {
- obj.value = parms[1][9].replace(specialChars, "");
- }
- if (obj.name === "B02ID") {
- obj.value = parms[1][10].replace(specialChars, "");
+ 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(obj.button.value);
}
}
}
- }
- //鎵嬪姩鐘舵��
- 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 === "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
+ const specialChars = /[^\w\s]/g; // 姝e垯琛ㄨ揪寮忓尮閰嶉潪瀛楁瘝銆佹暟瀛椼�佷笅鍒掔嚎鍜岀┖鏍肩殑瀛楃
+
+ 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") {
+ if (parms[1] && parms[1][i]) {
+ obj.value = parms[1][i].replace(specialChars, "");
+ // console.log(obj.value);
+ }
+ if (obj.name === "ID2") {
+ obj.value = parms[1][7].replace(specialChars, ""); // 灏咺D2瀵瑰簲鐨勫�艰祴涓簆arms[1][7]
+ }
+
+ if (obj.name === "A02ID") {
+ obj.value = parms[1][8].replace(specialChars, "");
+ }
+ if (obj.name === "B01ID") {
+ obj.value = parms[1][9].replace(specialChars, "");
+ }
+ if (obj.name === "B02ID") {
+ obj.value = parms[1][10].replace(specialChars, "");
+ }
}
}
}
- }
- //鎵弿鏋壂鐮佺殑ID
- jsonData2.forEach((item) => {
- item.forEach((subItem) => {
- if (subItem.read === 66) {
- subItem.value = parms[3][0].replace(specialChars, "");
+ //鎵嬪姩鐘舵��
+ 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 === "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) => {
+ item.forEach((subItem) => {
+ if (subItem.read === 66) {
+ subItem.value = parms[3][0].replace(specialChars, "");
+ }
+ });
});
- });
- jsonData2.forEach((item) => {
- item.forEach((subItem) => {
- if (subItem.read === 666) {
- subItem.value = parms[3][1].replace(specialChars, "");
- }
+ jsonData2.forEach((item) => {
+ item.forEach((subItem) => {
+ if (subItem.read === 666) {
+ subItem.value = parms[3][1].replace(specialChars, "");
+ }
+ });
});
- });
- //A01褰撳墠鏍煎瓙
- let lastParmsArray = parms[parms.length - 1];
+ //A01褰撳墠鏍煎瓙
+ let lastParmsArray = parms[parms.length - 1];
- let lastParmsIndex = 0;
+ let lastParmsIndex = 0;
- for (let i = 0; i < jsonData2.length; i++) {
- for (let j = 0; j < jsonData2[i].length; j++) {
- if (jsonData2[i][j].read === 333) {
- jsonData2[i][j].value = lastParmsArray[lastParmsIndex];
- lastParmsIndex++;
- if (lastParmsIndex === lastParmsArray.length) {
- lastParmsIndex = 0;
+ for (let i = 0; i < jsonData2.length; i++) {
+ for (let j = 0; j < jsonData2[i].length; j++) {
+ if (jsonData2[i][j].read === 333) {
+ jsonData2[i][j].value = lastParmsArray[lastParmsIndex];
+ lastParmsIndex++;
+ if (lastParmsIndex === lastParmsArray.length) {
+ lastParmsIndex = 0;
+ }
}
}
}
+
+
+ jsonData2[15][0].value = obj.timeout[0];
+
+
+
+
}
- }
};
// console.log(jsonData2);
@@ -557,5 +618,4 @@
.id {
background-color: green;
}
-
</style>
\ No newline at end of file
diff --git a/CanadaMes-ui/src/views/Electrical/Positioning1.vue b/CanadaMes-ui/src/views/Electrical/Positioning1.vue
index 9862208..a59cccb 100644
--- a/CanadaMes-ui/src/views/Electrical/Positioning1.vue
+++ b/CanadaMes-ui/src/views/Electrical/Positioning1.vue
@@ -236,7 +236,19 @@
};
// 鏀跺埌娑堟伅
- socket.onmessage = (msg) => {
+ let isMouseInInputBox = false; // 鏍囪榧犳爣鏄惁鍦ㄨ緭鍏ユ鍐�
+
+const inputBox = document.querySelectorAll('.input-box');
+inputBox.forEach(box => {
+ box.addEventListener('mouseenter', () => {
+ isMouseInInputBox = true;
+ });
+ box.addEventListener('mouseleave', () => {
+ isMouseInInputBox = false;
+ });
+});
+
+socket.onmessage = (msg) => {
if (!msg.data) {
return; // 濡傛灉鏀跺埌绌烘暟鎹紝鍒欑洿鎺ヨ繑鍥烇紝涓嶆墽琛屽悗缁�昏緫
}
@@ -244,50 +256,26 @@
let obj = JSON.parse(msg.data);
const jsonData2 = this.jsonData;
- const handleMouseMove = (event) => {
- if (!event || !event.target) {
- return; // 濡傛灉 event 鎴� event.target 涓嶅瓨鍦紝鍒欑洿鎺ヨ繑鍥烇紝涓嶆墽琛屽悗缁�昏緫
- }
+ const parms = obj.params;
- const inputBox = document.querySelectorAll('.input-box');
- const target = event.target;
- const isMouseInInput = Array.from(inputBox).some(box => box.contains(target));
-
- if (!isMouseInInput) {
-
-
- const parms = obj.params;
-
- // 濡傛灉榧犳爣涓嶅湪杈撳叆妗嗗唴锛屾洿鏂拌緭鍏ユ鐨勫��
- // this.submitDataToBackend()
-
- // console.log(parms)
-if(parms){
-
-
-
- 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++;
- }
- }
- }
- }
- }
+ if(parms && !isMouseInInputBox){ // 鍙湁鍦ㄩ紶鏍囦笉鍦ㄨ緭鍏ユ鍐呮椂鎵嶆洿鏂版暟鎹�
+ // console.log(parms)
+
+ 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);
- setInterval(() => handleMouseMove(event), 1000); // 姣忛殧 1000ms 妫�娴嬩竴娆¢紶鏍囦綅缃�
-
-document.addEventListener('mousemove', event => handleMouseMove(event));
+ }
+ }
+ }
};
diff --git a/CanadaMes-ui/src/views/Electrical/ServoManualone.vue b/CanadaMes-ui/src/views/Electrical/ServoManualone.vue
index db99576..9e366aa 100644
--- a/CanadaMes-ui/src/views/Electrical/ServoManualone.vue
+++ b/CanadaMes-ui/src/views/Electrical/ServoManualone.vue
@@ -1,416 +1,612 @@
<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
+ 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 to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter')
}}</router-link> -->
- <router-link to="/Electrical/Sign" tag="el-button" type="text" active-class="blue-button">{{ $t('Sign')
- }}</router-link>
- <router-link to="/Electrical/Servomanual" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter')
- }}</router-link>
- </el-breadcrumb>
+ <router-link
+ to="/Electrical/Sign"
+ tag="el-button"
+ type="text"
+ active-class="blue-button"
+ >{{ $t("Sign") }}</router-link
+ >
+ <router-link
+ to="/Electrical/Servomanual"
+ tag="el-button"
+ type="text"
+ active-class="blue-button"
+ >{{ $t("Parameter") }}</router-link
+ >
+ </el-breadcrumb>
- <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb">
- <router-link to="/Electrical/Parameter2" tag="el-button" type="text" active-class="blue-button">{{ $t('Automatic State')
- }}</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>
+ <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb">
+ <router-link
+ to="/Electrical/Parameter2"
+ tag="el-button"
+ type="text"
+ active-class="blue-button"
+ >{{ $t("Automatic State") }}</router-link
+ >
+ <router-link
+ to="/Electrical/ManualJog"
+ tag="el-button"
+ type="text"
+ active-class="blue-button"
+ >{{ $t("ManualJog") }}</router-link
+ >
-<router-link to="/Electrical/Servomanualone" tag="el-button" type="text" active-class="blue-button">{{
- $t('Servomanualone')
- }}</router-link>
+ <router-link
+ to="/Electrical/ManualonePosition"
+ tag="el-button"
+ type="text"
+ active-class="blue-button"
+ >{{ $t("ManualonePosition") }}</router-link
+ >
+
+ <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/Positioning1" tag="el-button" type="text" active-class="blue-button">{{
- $t('Address parameter settings')
- }}</router-link>
+
+ <router-link
+ to="/Electrical/Positioning1"
+ tag="el-button"
+ type="text"
+ active-class="blue-button"
+ >{{ $t("Address parameter settings") }}</router-link
+ >
<!-- <router-link to="/Electrical/Positioning2" tag="el-button" type="text" active-class="blue-button">{{
$t('Positioning2')
}}</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('Speed parameter settings')
- }}</router-link>
-
+ <router-link
+ to="/Electrical/AutomaticParameterSetting"
+ tag="el-button"
+ type="text"
+ active-class="blue-button"
+ >{{ $t("Speed parameter settings") }}</router-link
+ >
</el-breadcrumb>
<el-row :gutter="26">
- <el-col :span="12" v-for="(dataGroup, groupIndex) in jsonData" :key="groupIndex" style="margin-bottom: -20px;">
- <el-card class="json-block" style="width:auto;margin-bottom: 10px;">
- <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' && groupIndex === 0" v-model="item.value" @keyup.enter.native="zuhe1" class='input-box' :class="{ 'special-class': groupIndex === 0,'special-class2': groupIndex === 1 }" v-show="groupIndex !== 0 && groupIndex !== 1" ></el-input>
- <el-input v-else-if="item.type === '0' && groupIndex === 1" v-model="item.value" @keyup.enter.native="zuhe2" class='input-box' :class="{ 'special-class': groupIndex === 0,'special-class2': groupIndex === 1 }" v-show="groupIndex !== 0 && groupIndex !== 1" ></el-input>
- <el-input v-else-if="item.type === '0' && groupIndex === 2" v-model="item.value" readonly class='input-box' ></el-input>
- <el-input v-else-if="item.type === '0' && groupIndex === 3" v-model="item.value" readonly class='input-box' ></el-input>
- <el-input v-else-if="item.type === '0' && groupIndex === 4" v-model="item.value" readonly class='input-box' ></el-input>
- <el-input v-else-if="item.type === '0' && groupIndex === 5" v-model="item.value" readonly class='input-box' ></el-input>
- <el-input v-else-if="item.type === '0' " v-model="item.value" class='input-box' :class="{ 'special-class': groupIndex === 0,'special-class2': groupIndex === 1 }" v-show="groupIndex !== 0 && groupIndex !== 1" ></el-input>
+ <el-col
+ :span="12"
+ v-for="(dataGroup, groupIndex) in jsonData"
+ :key="groupIndex"
+ style="margin-bottom: -20px"
+ >
+ <el-card
+ class="json-block"
+ style="width: auto; margin-bottom: 10px; height: 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' && groupIndex === 0"
+ v-model="item.value"
+ @keyup.enter.native="zuhe1"
+ class="input-box"
+ :class="{
+ 'special-class': groupIndex === 0,
+ 'special-class2': groupIndex === 1,
+ }"
+ v-show="groupIndex !== 0 && groupIndex !== 1"
+ ></el-input>
+ <el-input
+ v-else-if="item.type === '0' && groupIndex === 1"
+ v-model="item.value"
+ @keyup.enter.native="zuhe2"
+ class="input-box"
+ :class="{
+ 'special-class': groupIndex === 0,
+ 'special-class2': groupIndex === 1,
+ }"
+ v-show="groupIndex !== 0 && groupIndex !== 1"
+ ></el-input>
+ <el-input
+ v-else-if="item.type === '0' && groupIndex === 2"
+ v-model="item.value"
+ readonly
+ class="input-box"
+ ></el-input>
+ <el-input
+ v-else-if="item.type === '0' && groupIndex === 3"
+ v-model="item.value"
+ readonly
+ class="input-box"
+ ></el-input>
+ <el-input
+ v-else-if="item.type === '0' && groupIndex === 4"
+ v-model="item.value"
+ readonly
+ class="input-box"
+ ></el-input>
+ <el-input
+ v-else-if="item.type === '0' && groupIndex === 5"
+ v-model="item.value"
+ readonly
+ class="input-box"
+ ></el-input>
+ <el-input
+ v-else-if="item.type === '0'"
+ v-model="item.value"
+ class="input-box"
+ :class="{
+ 'special-class': groupIndex === 0,
+ 'special-class2': groupIndex === 1,
+ }"
+ v-show="groupIndex !== 0 && groupIndex !== 1"
+ ></el-input>
+ </div>
+ </div>
+ </el-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 && language === 'en-US'"
+ :name="item.button.name"
+ v-model="item.button.value"
+ :class="{
+ 'action-button': true,
+ 'error-button':
+ item.button.name === 'Fault' && item.button.value === 1,
+ 'error-button2':
+ item.button.name === 'NotZero' && item.button.value === 0,
+ 'error-button3':
+ item.button.name === 'Zero' && item.button.value === 1,
+ fuwei:
+ item.button.name === 'Reset' && item.button.value === 1,
+ huiling:
+ item.button.name === 'Home' && item.button.value === 1,
+ qidong:
+ item.button.name === 'A01 Semi-Auto' &&
+ item.button.value === 1,
+ qidong2:
+ item.button.name === 'A02 Semi-Auto' &&
+ item.button.value === 1,
+ qidong3:
+ item.button.name === 'A01 Semi-Auto Start' &&
+ item.button.value === 1,
+ qidong4:
+ item.button.name === 'A02 Semi-Auto Start' &&
+ item.button.value === 1,
+ qidong5:
+ item.button.name === 'A02 Semi-Auto' &&
+ item.button.value === 1,
+ jiting:
+ item.button.name === 'Abort/ResumeTasks' &&
+ item.button.value === 1,
+ yihuiling:
+ item.button.name === 'Zero' && item.button.value === 1,
+ }"
+ @click="
+ updateButtonValue(dataGroup, itemIndex);
+ submitDataToBackend(item.button.name);
+ "
+ >{{ item.button.name }}</el-button
+ >
+ <el-button
+ v-if="item.button && language === 'zh-CN'"
+ :name="item.button.name"
+ v-model="item.button.value"
+ :class="{
+ 'action-button': true,
+ 'error-button':
+ item.button.name === '鏁呴殰' && item.button.value === 1,
+ 'error-button3':
+ item.button.name === '宸插洖闆�' && item.button.value === 1,
+ 'error-button2':
+ item.button.name === '鏈洖闆�' && item.button.value === 0,
+ fuwei: item.button.name === '澶嶄綅' && item.button.value === 1,
+ huiling:
+ item.button.name === '鍥為浂' && item.button.value === 1,
+ qidong:
+ item.button.name === 'A01鍗婅嚜鍔�' && item.button.value === 1,
+ qidong2:
+ item.button.name === 'A02鍗婅嚜鍔�' && item.button.value === 1,
+ qidong3:
+ item.button.name === 'A01鍗婅嚜鍔ㄥ惎鍔�' &&
+ item.button.value === 1,
+ qidong4:
+ item.button.name === 'A02鍗婅嚜鍔ㄥ惎鍔�' &&
+ item.button.value === 1,
+ qidong5:
+ item.button.name === 'A02鍗婅嚜鍔�' && item.button.value === 1,
+ jiting:
+ item.button.name === '鎬ュ仠鍚庝腑姝�/缁х画閫夋嫨' &&
+ item.button.value === 1,
+ yihuiling:
+ item.button.name === '宸插洖闆�' && item.button.value === 1,
+ }"
+ @click="
+ updateButtonValue(dataGroup, itemIndex);
+ submitDataToBackend(item.button.name);
+ "
+ >{{ item.button.name }}</el-button
+ >
</div>
</div>
- </el-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 && language === 'en-US' " :name="item.button.name" v-model="item.button.value" :class="{'action-button': true, 'error-button': item.button.name === 'Fault' && item.button.value === 1,'error-button2': item.button.name === 'NotZero' && item.button.value === 0,'error-button3': item.button.name === 'Zero' && item.button.value === 1,'fuwei': item.button.name === 'Reset' && item.button.value === 1,'huiling': item.button.name === 'Home' && item.button.value === 1,'qidong': item.button.name === 'A01 Semi-Auto' && item.button.value === 1,'qidong2': item.button.name === 'A02 Semi-Auto' && item.button.value === 1,'qidong3': item.button.name === 'A01 Semi-Auto Start' && item.button.value === 1,'qidong4': item.button.name === 'A02 Semi-Auto Start' && item.button.value === 1,'qidong5': item.button.name === 'A02 Semi-Auto' && item.button.value === 1,'jiting': item.button.name === 'Abort/ResumeTasks' && item.button.value === 1,'yihuiling': item.button.name === 'Zero' && item.button.value === 1}" @click="updateButtonValue(dataGroup, itemIndex); submitDataToBackend(item.button.name);">{{ item.button.name }}</el-button>
- <el-button v-if="item.button && language === 'zh-CN' " :name="item.button.name" v-model="item.button.value" :class="{'action-button': true, 'error-button': item.button.name === '鏁呴殰' && item.button.value === 1,'error-button3': item.button.name === '宸插洖闆�' && item.button.value === 1,'error-button2': item.button.name === '鏈洖闆�' && item.button.value === 0,'fuwei': item.button.name === '澶嶄綅' && item.button.value === 1,'huiling': item.button.name === '鍥為浂' && item.button.value === 1,'qidong': item.button.name === 'A01鍗婅嚜鍔�' && item.button.value === 1,'qidong2': item.button.name === 'A02鍗婅嚜鍔�' && item.button.value === 1,'qidong3': item.button.name === 'A01鍗婅嚜鍔ㄥ惎鍔�' && item.button.value === 1,'qidong4': item.button.name === 'A02鍗婅嚜鍔ㄥ惎鍔�' && item.button.value === 1,'qidong5': item.button.name === 'A02鍗婅嚜鍔�' && item.button.value === 1,'jiting': item.button.name === '鎬ュ仠鍚庝腑姝�/缁х画閫夋嫨' && item.button.value === 1,'yihuiling': item.button.name === '宸插洖闆�' && item.button.value === 1 }" @click="updateButtonValue(dataGroup, itemIndex); submitDataToBackend(item.button.name);">{{ item.button.name }}</el-button>
- </div>
- </div>
- </el-card>
- </el-col>
-</el-row>
+ </el-card>
+ </el-col>
+ </el-row>
<!-- <el-button @click="submitDataToBackend">鎻愪氦鏁版嵁鍒板悗绔�</el-button> -->
</div>
</template>
<script>
-import LanguageMixin from '../../lang/LanguageMixin'
-import data from '../../configuration/ServoManualone'
+import LanguageMixin from "../../lang/LanguageMixin";
+import data from "../../configuration/ServoManualone";
let socket;
- export default {
+export default {
name: "ServoManualone",
mixins: [LanguageMixin],
-
+
data() {
return {
- jsonData: data ,
-language:this.$i18n.locale,
-zhi:"1",
-zhi2:"1"
+ jsonData: data,
+ language: this.$i18n.locale,
+ zhi: "1",
+ zhi2: "1",
// 鍔犺浇鏁翠釜data.json鏂囦欢浣滀负jsonData
- }
+ };
},
- activated(){
-
+ activated() {
this.initWebSocket();
const language = this.$i18n.locale;
- // console.log(language);
- if (language === 'en-US') {
- this.replaceChineseWithEnglish();
- }
- this.$forceUpdate();
-
-
- },
-// destroyed(){
-// this.close();
-// this.$router.go(0);
-// },
+ // console.log(language);
+ if (language === "en-US") {
+ this.replaceChineseWithEnglish();
+ }
+ this.$forceUpdate();
+ },
+ // destroyed(){
+ // this.close();
+ // this.$router.go(0);
+ // },
methods: {
closeSocket() {
// 鍏抽棴 WebSocket 杩炴帴
socket.close();
},
-
-
+
updateButtonValue(dataGroup, itemIndex) {
if (dataGroup[itemIndex].button.value === 1) {
- // 濡傛灉褰撳墠鎸夐挳鐨勫�兼槸 0锛屽皢鍏惰涓� 1
- this.$set(dataGroup[itemIndex].button, 'value', 0);
- } else {
- // 鍚﹀垯灏嗗叾璁句负 0
- this.$set(dataGroup[itemIndex].button, 'value', 1);
- }
-},
-zuhe1(){
+ // 濡傛灉褰撳墠鎸夐挳鐨勫�兼槸 0锛屽皢鍏惰涓� 1
+ this.$set(dataGroup[itemIndex].button, "value", 0);
+ } else {
+ // 鍚﹀垯灏嗗叾璁句负 0
+ this.$set(dataGroup[itemIndex].button, "value", 1);
+ }
+ },
+ zuhe1() {
+ const data = [];
- const data = [];
+ for (let i = 0; i < 1; i++) {
+ const inputData = this.jsonData[i]
+ .filter((item) => item.type === "0" && item.read !== 9999)
+ .map((item) => {
+ return { value: item.value };
+ });
-for (let i = 0; i < 1; i++) {
- const inputData = this.jsonData[i].filter(item => item.type === '0' && item.read !== 9999).map(item => {
- return { value: item.value };
- });
+ const values = inputData.map((item) => item.value);
- const values = inputData.map(item => item.value);
+ data.push(values);
+ }
- data.push(values);
-
-}
+ data.push([], [], []);
+ for (let i = 0; i < 1; i++) {
+ const inputData = this.jsonData[i]
+ .filter((item) => item.type === "0" && item.read == 9999)
+ .map((item) => {
+ return { value: item.value };
+ });
-data.push([], [], []);
+ const values = inputData.map((item) => item.value);
-for (let i = 0; i < 1; i++) {
- const inputData = this.jsonData[i].filter(item => item.type === '0' && item.read == 9999).map(item => {
- return { value: item.value };
- });
+ data.push(values);
+ }
+ data.push([], [], []);
- const values = inputData.map(item => item.value);
+ const jsonObject = { data };
- data.push(values);
-
-}
-data.push([], [],[]);
+ // 鎻愪氦鏁版嵁鍒板悗绔�
+ const jsonString = JSON.stringify(jsonObject);
+ console.log("鎵�鏈塗ype涓�0鐨剉alue:", jsonString);
+ socket?.send(jsonString);
+ },
+ zuhe2() {
+ const data2 = [];
+ for (let i = 1; i < 2; i++) {
+ const inputData = this.jsonData[i]
+ .filter((item) => item.type === "0" && item.read !== 8888)
+ .map((item) => {
+ return { value: item.value };
+ });
-const jsonObject = { data };
+ const values2 = inputData.map((item) => item.value);
-// 鎻愪氦鏁版嵁鍒板悗绔�
-const jsonString = JSON.stringify(jsonObject);
-console.log('鎵�鏈塗ype涓�0鐨剉alue:', jsonString);
-socket?.send(jsonString);
+ data2.push(values2);
+ }
+ data2.unshift([]);
-},
-zuhe2(){
+ data2.push([], [], []);
- const data2 = [];
+ for (let i = 1; i < 2; i++) {
+ const inputData = this.jsonData[i]
+ .filter((item) => item.type === "0" && item.read == 8888)
+ .map((item) => {
+ return { value: item.value };
+ });
-for (let i = 1; i < 2; i++) {
- const inputData = this.jsonData[i].filter(item => item.type === '0' && item.read !== 8888).map(item => {
- return { value: item.value };
- });
+ const values2 = inputData.map((item) => item.value);
- const values2 = inputData.map(item => item.value);
+ data2.push(values2);
+ data2.push([], [], []);
+ }
- data2.push(values2);
+ const jsonObject = { data: data2 };
-}
-data2.unshift([]);
+ // 鎻愪氦鏁版嵁鍒板悗绔�
+ const jsonString = JSON.stringify(jsonObject);
+ console.log("鎵�鏈塗ype涓�0鐨剉alue:", jsonString);
+ socket?.send(jsonString);
+ },
+ submitDataToBackend(currentButtonName) {
+ const data = [];
+ let jsonObject;
+ if (currentButtonName === "鏁呴殰" || currentButtonName === "Fault") {
+ return false;
+ }
-data2.push([], [],[]);
+ if (
+ currentButtonName === "A01鍗婅嚜鍔ㄥ惎鍔�" ||
+ currentButtonName === "A01 Semi-Auto Start"
+ ) {
+ const values = [this.jsonData[0][10].button.value];
+ data.push(values);
+ data.unshift([], [], [], [], [], [], [], []);
+ jsonObject = { data };
+ }
-for (let i = 1; i < 2; i++) {
- const inputData = this.jsonData[i].filter(item => item.type === '0' && item.read == 8888).map(item => {
- return { value: item.value };
- });
+ if (
+ currentButtonName === "A02鍗婅嚜鍔ㄥ惎鍔�" ||
+ currentButtonName === "A02 Semi-Auto Start"
+ ) {
+ const values2 = [this.jsonData[1][8].button.value];
+ data.push(values2);
+ data.unshift([], [], [], [], [], [], [], [], []);
+ jsonObject = { data };
+ }
- const values2 = inputData.map(item => item.value);
+ if (currentButtonName === "澶嶄綅" || currentButtonName === "Reset") {
+ const resetButtonValues = this.jsonData
+ .map((item) =>
+ item.find(
+ (subItem) =>
+ subItem.button &&
+ ["澶嶄綅", "Reset"].includes(subItem.button.name)
+ )
+ )
+ .filter((value) => value !== null)
+ .map((item) => item.button.value);
- data2.push(values2);
- data2.push( [],[], []);
-
-}
+ data.push(resetButtonValues.flat());
+ data.unshift([], []);
+ data.push([], [], [], [], []);
+ jsonObject = { data };
+ }
+ if (currentButtonName === "鍥為浂" || currentButtonName === "Home") {
+ const data3 = [];
+ const resetButtonValues3 = this.jsonData
+ .map((item) => {
+ const buttonItem3 = item.find(
+ (subItem) =>
+ subItem.button && ["鍥為浂", "Home"].includes(subItem.button.name)
+ );
-const jsonObject = { data:data2 };
+ return buttonItem3 ? buttonItem3.button.value : null;
+ })
+ .filter((value) => value !== null);
-// 鎻愪氦鏁版嵁鍒板悗绔�
-const jsonString = JSON.stringify(jsonObject);
-console.log('鎵�鏈塗ype涓�0鐨剉alue:', jsonString);
-socket?.send(jsonString);
+ // 灏嗗緱鍒扮殑鍊兼坊鍔犲埌 data 鏁扮粍涓�
+ data3.push(resetButtonValues3.flat());
-},
-submitDataToBackend(currentButtonName) {
- const data = [];
- let jsonObject;
- if (currentButtonName === '鏁呴殰' || currentButtonName === 'Fault') {
- return false;
+ // 鍦� data3 鏁扮粍鍓嶉潰娣诲姞涓や釜绌烘暟缁�
+ data3.unshift([], [], []);
+ data3.push([], [], [], []);
- }
+ // 鍒涘缓 jsonObject3 瀵硅薄锛屽苟娣诲姞 data3 灞炴��
+ jsonObject = { data: data3 };
+ }
+ if (
+ currentButtonName === "A01鍗婅嚜鍔�" ||
+ currentButtonName === "A01 Semi-Auto"
+ ) {
+ const elements = document.getElementsByClassName("special-class");
+ const data = [];
- if (currentButtonName === 'A01鍗婅嚜鍔ㄥ惎鍔�' || currentButtonName === 'A01 Semi-Auto Start') {
- const values = [this.jsonData[0][10].button.value];
- data.push(values);
- data.unshift([], [],[],[], [],[],[], []);
- jsonObject = { 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
+ // }
- if (currentButtonName === 'A02鍗婅嚜鍔ㄥ惎鍔�' || currentButtonName === 'A02 Semi-Auto Start') {
- const values2 = [this.jsonData[1][8].button.value];
- data.push(values2);
- data.unshift([],[], [],[],[], [],[],[], []);
- jsonObject = { data };
- }
-
- if (currentButtonName === '澶嶄綅' || currentButtonName === 'Reset') {
- const resetButtonValues = this.jsonData
- .map(item => item.find(subItem => subItem.button && ['澶嶄綅', 'Reset'].includes(subItem.button.name)))
- .filter(value => value !== null)
- .map(item => item.button.value);
-
- data.push(resetButtonValues.flat());
- data.unshift([], []);
- data.push([], [], [], [], []);
- jsonObject = { data };
- }
-
- if (currentButtonName === '鍥為浂' || currentButtonName === 'Home') {
- const data3 = [];
- const resetButtonValues3 = this.jsonData.map(item => {
- const buttonItem3 = item.find(subItem => subItem.button && ['鍥為浂', 'Home'].includes(subItem.button.name));
-
- return buttonItem3 ? buttonItem3.button.value : null;
- }).filter(value => value !== null);
-
- // 灏嗗緱鍒扮殑鍊兼坊鍔犲埌 data 鏁扮粍涓�
- data3.push(resetButtonValues3.flat());
-
- // 鍦� data3 鏁扮粍鍓嶉潰娣诲姞涓や釜绌烘暟缁�
- data3.unshift([], [], []);
- data3.push([], [], [], []);
-
- // 鍒涘缓 jsonObject3 瀵硅薄锛屽苟娣诲姞 data3 灞炴��
- jsonObject = { data: data3 };
-
-
-}
- 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)
- }
+ 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
- // }
+ }
+ } 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;
+ 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.push([this.zhi]);
+ data.unshift([], [], [], [], [], []);
+ data.push([]);
- data.unshift([],[],[],[],[],[]);
-data.push([]);
+ jsonObject = { data };
+ // 鎻愪氦鏁版嵁鍒板悗绔�
+ }
+ if (
+ currentButtonName === "A02鍗婅嚜鍔�" ||
+ currentButtonName === "A02 Semi-Auto"
+ ) {
+ // 鑾峰彇鎵�鏈塩lass涓簊pecial-class2鐨勫厓绱�
+ const elements = document.getElementsByClassName("special-class2");
-
- jsonObject = { data };
-
-// 鎻愪氦鏁版嵁鍒板悗绔�
-
- }
-
-
-
- if (currentButtonName === 'A02鍗婅嚜鍔�' || currentButtonName === 'A02 Semi-Auto' ) {
- // 鑾峰彇鎵�鏈塩lass涓簊pecial-class2鐨勫厓绱�
- 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;
- // 閬嶅巻jsonData
- for (let i = 0; i < this.jsonData.length; i++) {
- let arr = this.jsonData[i];
- // 閬嶅巻arr
- for (let j = 0; j < arr.length; j++) {
- let obj2 = arr[j];
- // 濡傛灉button鐨刵ame涓篈02鍗婅嚜鍔ㄦ垨鑰匒02 Semi-Auto
- if (obj2.button && (obj2.button.name === "A02鍗婅嚜鍔�" || obj2.button.name === "A02 Semi-Auto")) {
- // 璁剧疆button鐨剉alue涓�1
- obj2.button.value = 1;
- // console.log(obj2.button.value)
- }
+ const data = [];
+ // 閬嶅巻鎵�鏈夊厓绱�
+ for (let i = 0; i < elements.length; i++) {
+ // 濡傛灉鍏冪礌闅愯棌
+ if (elements[i].style.display === "none") {
+ // 鏄剧ず鍏冪礌
+ elements[i].style.display = ""; // 鏄剧ず鍏冪礌
+ this.zhi2 = 1;
+ // 閬嶅巻jsonData
+ for (let i = 0; i < this.jsonData.length; i++) {
+ let arr = this.jsonData[i];
+ // 閬嶅巻arr
+ for (let j = 0; j < arr.length; j++) {
+ let obj2 = arr[j];
+ // 濡傛灉button鐨刵ame涓篈02鍗婅嚜鍔ㄦ垨鑰匒02 Semi-Auto
+ if (
+ obj2.button &&
+ (obj2.button.name === "A02鍗婅嚜鍔�" ||
+ obj2.button.name === "A02 Semi-Auto")
+ ) {
+ // 璁剧疆button鐨剉alue涓�1
+ obj2.button.value = 1;
+ // console.log(obj2.button.value)
}
-
-
}
-
- }else{
- // 濡傛灉鍏冪礌鏄剧ず
- elements[i].style.display = 'none';
- this.zhi2=0;
- // 閬嶅巻jsonData
- for (let i = 0; i < this.jsonData.length; i++) {
- let arr = this.jsonData[i];
- // 閬嶅巻arr
- for (let j = 0; j < arr.length; j++) {
- let obj2 = arr[j];
- // 濡傛灉button鐨刵ame涓篈02鍗婅嚜鍔ㄦ垨鑰匒02 Semi-Auto
- if (obj2.button && (obj2.button.name === "A02鍗婅嚜鍔�" || obj2.button.name === "A02 Semi-Auto")) {
- // 璁剧疆button鐨剉alue涓�0
- obj2.button.value = 0;
- // console.log(obj2.button.value)
- }
+ }
+ } else {
+ // 濡傛灉鍏冪礌鏄剧ず
+ elements[i].style.display = "none";
+ this.zhi2 = 0;
+ // 閬嶅巻jsonData
+ for (let i = 0; i < this.jsonData.length; i++) {
+ let arr = this.jsonData[i];
+ // 閬嶅巻arr
+ for (let j = 0; j < arr.length; j++) {
+ let obj2 = arr[j];
+ // 濡傛灉button鐨刵ame涓篈02鍗婅嚜鍔ㄦ垨鑰匒02 Semi-Auto
+ if (
+ obj2.button &&
+ (obj2.button.name === "A02鍗婅嚜鍔�" ||
+ obj2.button.name === "A02 Semi-Auto")
+ ) {
+ // 璁剧疆button鐨剉alue涓�0
+ obj2.button.value = 0;
+ // console.log(obj2.button.value)
}
-
-
}
- }
- }
+ }
+ }
+ }
- // 灏唞hi2娣诲姞鍒癲ata鏁扮粍涓�
- data.push([this.zhi2]);
+ // 灏唞hi2娣诲姞鍒癲ata鏁扮粍涓�
+ data.push([this.zhi2]);
- // 灏哾ata鏁扮粍娣诲姞鍒癹sonObject涓�
- data.unshift([],[],[],[],[],[],[]);
+ // 灏哾ata鏁扮粍娣诲姞鍒癹sonObject涓�
+ data.unshift([], [], [], [], [], [], []);
+ jsonObject = { data };
+ }
- jsonObject = { data };
+ const jsonString = JSON.stringify(jsonObject);
+ console.log("鎵�鏈塗ype涓�0鐨剉alue:", jsonString);
+ socket?.send(jsonString);
+ },
-
-
-
-}
-
-const jsonString = JSON.stringify(jsonObject);
- console.log('鎵�鏈塗ype涓�0鐨剉alue:', jsonString);
- socket?.send(jsonString);
-
-},
-
- initWebSocket () {
-
+ initWebSocket() {
let viewname = "ServoManualone";
if (typeof WebSocket === "undefined") {
console.log("鎮ㄧ殑娴忚鍣ㄤ笉鏀寔WebSocket");
} else {
-
- let socketUrl = "ws://" +this.$t('ip')+ ":8888" + "/springboot-vue3/api/talk/" + viewname;
+ let socketUrl =
+ "ws://" +
+ this.$t("ip") +
+ ":8888" +
+ "/springboot-vue3/api/talk/" +
+ viewname;
if (socket != null) {
socket.close();
@@ -424,180 +620,227 @@
console.log("websocket宸叉墦寮�");
};
- // 鏀跺埌娑堟伅
+ let isMouseInInputBox = false; // 鏍囪榧犳爣鏄惁鍦ㄨ緭鍏ユ鍐�
+
+ const inputBox = document.querySelectorAll(".input-box");
+ inputBox.forEach((box) => {
+ box.addEventListener("mouseenter", () => {
+ isMouseInInputBox = true;
+ });
+ box.addEventListener("mouseleave", () => {
+ isMouseInInputBox = false;
+ });
+ });
+
socket.onmessage = (msg) => {
- if (!msg.data) {
- return; // 濡傛灉鏀跺埌绌烘暟鎹紝鍒欑洿鎺ヨ繑鍥烇紝涓嶆墽琛屽悗缁�昏緫
- }
+ if (!msg.data) {
+ return; // 濡傛灉鏀跺埌绌烘暟鎹紝鍒欑洿鎺ヨ繑鍥烇紝涓嶆墽琛屽悗缁�昏緫
+ }
+ let obj = JSON.parse(msg.data);
- let obj = JSON.parse(msg.data);
+ // console.log(obj)
+ const weihuiling = obj.weihuiling;
+ const jsonData2 = this.jsonData;
+ if (obj.zuhe1 && !isMouseInInputBox) {
+ //鍚姩鎸夐挳
+ // 鎵ц鏇存柊閫昏緫
+ 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.read !== "9999" &&
+ item.read !== "8888"
+ ) {
+ item.value = obj[`zuhe${i + 1}`][0][index];
+ }
+ });
+ }
+ //杩涚墖id
+ jsonData2.forEach((item) => {
+ item.forEach((subItem) => {
+ if (subItem.read === 9999) {
+ subItem.value = obj.jinpianid[0];
+ }
+ });
+ });
+ //鍙栫墖id
+ jsonData2.forEach((item) => {
+ item.forEach((subItem) => {
+ if (subItem.read === 8888) {
+ subItem.value = obj.qupianid[0];
+ }
+ });
+ });
+ }
-// console.log(obj)
-const weihuiling=obj.weihuiling;
- const jsonData2 = this.jsonData;
- const handleMouseMove = (event) => {
- if (!event || !event.target) {
- return; // 濡傛灉 event 鎴� event.target 涓嶅瓨鍦紝鍒欑洿鎺ヨ繑鍥烇紝涓嶆墽琛屽悗缁�昏緫
- }
+ if (obj.qidong) {
+ jsonData2[0][9].button.value = obj.qidong[0][0]; // 绗竴涓瓙鏁扮粍涓涓�涓� type=66 鐨� button
+ jsonData2[0][10].button.value = obj.qidong[0][1]; // 绗竴涓瓙鏁扮粍涓浜屼釜 type=66 鐨� button
+ jsonData2[1][7].button.value = obj.qidong[0][2]; // 绗簩涓瓙鏁扮粍涓涓�涓� type=66 鐨� button
+ jsonData2[1][8].button.value = obj.qidong[0][3];
+ //鏁呴殰鏇存柊
- const inputBox = document.querySelectorAll('.input-box');
- const target = event.target;
- // console.log(obj);
-
- const isMouseInInput = Array.from(inputBox).some(box => box.contains(target));
-
+ 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 === "Fault")
+ ) {
+ obj2.button.value = obj.guzhang[0][i];
+ // console.log(obj2.button.value)
+ }
+ }
+ }
- if (!isMouseInInput) {
+ // 澶嶄綅鏇存柊
+ 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)
+ }
+ }
+ }
- if (obj.zuhe1) {
-
- //鍚姩鎸夐挳
-
+ //鏈洖闆舵洿鏂�
+ jsonData2[2][3].button.value = weihuiling[0][0];
+ jsonData2[3][3].button.value = weihuiling[0][1];
+ jsonData2[4][4].button.value = weihuiling[0][2];
+ jsonData2[5][4].button.value = weihuiling[0][3];
+ // if(jsonData2[2][3].button.value===1){
-
- // 鎵ц鏇存柊閫昏緫
- 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.read !== '9999' && item.read !== '8888') {
- item.value = obj[`zuhe${i+1}`][0][index];
- }
- });
-}
+ // jsonData2[2][3].button.name.replace("鏈洖闆�","鍥為浂") ;
+ // }
-//杩涚墖id
-jsonData2.forEach((item) => {
- item.forEach((subItem) => {
- if (subItem.read === 9999) {
- subItem.value = obj.jinpianid[0];
- }
- });
-});
-//鍙栫墖id
-jsonData2.forEach((item) => {
- item.forEach((subItem) => {
- if (subItem.read === 8888) {
- subItem.value = obj.qupianid[0];
- }
- });
-});
+ // console.log(jsonData2[5][4].button.value)
+ if (
+ jsonData2[2][3].button.value === 1 &&
+ (jsonData2[2][3].button.name === "NotZero" ||
+ jsonData2[2][3].button.name === "鏈洖闆�")
+ ) {
+ jsonData2[2][3].button.name = jsonData2[2][3].button.name.replace(
+ "鏈洖闆�",
+ "宸插洖闆�"
+ );
+ jsonData2[2][3].button.name = jsonData2[2][3].button.name.replace(
+ "NotZero",
+ "Zero"
+ );
+ }
+ if (
+ jsonData2[3][3].button.value === 1 &&
+ (jsonData2[3][3].button.name === "NotZero" ||
+ jsonData2[3][3].button.name === "鏈洖闆�")
+ ) {
+ jsonData2[3][3].button.name = jsonData2[3][3].button.name.replace(
+ "鏈洖闆�",
+ "宸插洖闆�"
+ );
+ jsonData2[3][3].button.name = jsonData2[3][3].button.name.replace(
+ "NotZero",
+ "Zero"
+ );
+ }
+ if (
+ jsonData2[4][4].button.value === 1 &&
+ (jsonData2[4][4].button.name === "NotZero" ||
+ jsonData2[4][4].button.name === "鏈洖闆�")
+ ) {
+ jsonData2[4][4].button.name = jsonData2[4][4].button.name.replace(
+ "鏈洖闆�",
+ "宸插洖闆�"
+ );
+ jsonData2[4][4].button.name = jsonData2[4][4].button.name.replace(
+ "NotZero",
+ "Zero"
+ );
+ }
+ if (
+ jsonData2[5][4].button.value === 1 &&
+ (jsonData2[5][4].button.name === "NotZero" ||
+ jsonData2[5][4].button.name === "鏈洖闆�")
+ ) {
+ jsonData2[5][4].button.name = jsonData2[5][4].button.name.replace(
+ "鏈洖闆�",
+ "宸插洖闆�"
+ );
+ jsonData2[5][4].button.name = jsonData2[5][4].button.name.replace(
+ "NotZero",
+ "Zero"
+ );
+ }
-
-
-
-
-
- }
-
-}
-
- }
- // console.log(jsonData2);
- setInterval(() => handleMouseMove(event), 1000); // 姣忛殧 1000ms 妫�娴嬩竴娆¢紶鏍囦綅缃�
-
-document.addEventListener('mousemove', event => handleMouseMove(event));
-
- if (obj.qidong){
-
-
-
-
- jsonData2[0][9].button.value = obj.qidong[0][0]; // 绗竴涓瓙鏁扮粍涓涓�涓� type=66 鐨� button
-jsonData2[0][10].button.value = obj.qidong[0][1]; // 绗竴涓瓙鏁扮粍涓浜屼釜 type=66 鐨� button
-jsonData2[1][7].button.value = obj.qidong[0][2]; // 绗簩涓瓙鏁扮粍涓涓�涓� type=66 鐨� button
-jsonData2[1][8].button.value = obj.qidong[0][3];
- //鏁呴殰鏇存柊
-
-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 === "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)
- }
- }
-
-
-}
-
-
-//鏈洖闆舵洿鏂�
-
-jsonData2[2][3].button.value = weihuiling[0][0];
-jsonData2[3][3].button.value = weihuiling[0][1];
-jsonData2[4][4].button.value = weihuiling[0][2];
-jsonData2[5][4].button.value = weihuiling[0][3];
-
-
-// if(jsonData2[2][3].button.value===1){
-
-// jsonData2[2][3].button.name.replace("鏈洖闆�","鍥為浂") ;
-// }
-
-// console.log(jsonData2[5][4].button.value)
-if(jsonData2[2][3].button.value===1 && (jsonData2[2][3].button.name==="NotZero" ||jsonData2[2][3].button.name==="鏈洖闆�")){
- jsonData2[2][3].button.name=jsonData2[2][3].button.name.replace("鏈洖闆�","宸插洖闆�") ;
- jsonData2[2][3].button.name=jsonData2[2][3].button.name.replace("NotZero","Zero") ;
-}
-if(jsonData2[3][3].button.value===1 && (jsonData2[3][3].button.name==="NotZero" ||jsonData2[3][3].button.name==="鏈洖闆�")){
- jsonData2[3][3].button.name=jsonData2[3][3].button.name.replace("鏈洖闆�","宸插洖闆�") ;
- jsonData2[3][3].button.name=jsonData2[3][3].button.name.replace("NotZero","Zero") ;
-}
-if(jsonData2[4][4].button.value===1 && (jsonData2[4][4].button.name==="NotZero" ||jsonData2[4][4].button.name==="鏈洖闆�")){
- jsonData2[4][4].button.name=jsonData2[4][4].button.name.replace("鏈洖闆�","宸插洖闆�") ;
- jsonData2[4][4].button.name=jsonData2[4][4].button.name.replace("NotZero","Zero") ;
-}
-if(jsonData2[5][4].button.value===1 && (jsonData2[5][4].button.name==="NotZero" ||jsonData2[5][4].button.name==="鏈洖闆�")){
- jsonData2[5][4].button.name=jsonData2[5][4].button.name.replace("鏈洖闆�","宸插洖闆�") ;
- jsonData2[5][4].button.name=jsonData2[5][4].button.name.replace("NotZero","Zero") ;
-}
-
-
-
-
-if(jsonData2[2][3].button.value===0 && (jsonData2[2][3].button.name==="Zero" ||jsonData2[2][3].button.name==="宸插洖闆�")){
- jsonData2[2][3].button.name=jsonData2[2][3].button.name.replace("宸插洖闆�","鏈洖闆�") ;
- jsonData2[2][3].button.name=jsonData2[2][3].button.name.replace("Zero","NotZero") ;
-}
-if(jsonData2[3][3].button.value===0 && (jsonData2[3][3].button.name==="Zero" ||jsonData2[3][3].button.name==="宸插洖闆�")){
- jsonData2[3][3].button.name=jsonData2[3][3].button.name.replace("宸插洖闆�","鏈洖闆�") ;
- jsonData2[3][3].button.name=jsonData2[3][3].button.name.replace("Zero","NotZero") ;
-}
-if(jsonData2[4][4].button.value===0 && (jsonData2[4][4].button.name==="Zero" ||jsonData2[4][4].button.name==="宸插洖闆�")){
- jsonData2[4][4].button.name=jsonData2[4][4].button.name.replace("宸插洖闆�","鏈洖闆�") ;
- jsonData2[4][4].button.name=jsonData2[4][4].button.name.replace("Zero","NotZero") ;
-}
-if(jsonData2[5][4].button.value===0 && (jsonData2[5][4].button.name==="Zero" ||jsonData2[5][4].button.name==="宸插洖闆�")){
- jsonData2[5][4].button.name=jsonData2[5][4].button.name.replace("宸插洖闆�","鏈洖闆�") ;
- jsonData2[5][4].button.name=jsonData2[5][4].button.name.replace("Zero","NotZero") ;
-}
-
-}
-
-
-};
-
-
-
+ if (
+ jsonData2[2][3].button.value === 0 &&
+ (jsonData2[2][3].button.name === "Zero" ||
+ jsonData2[2][3].button.name === "宸插洖闆�")
+ ) {
+ jsonData2[2][3].button.name = jsonData2[2][3].button.name.replace(
+ "宸插洖闆�",
+ "鏈洖闆�"
+ );
+ jsonData2[2][3].button.name = jsonData2[2][3].button.name.replace(
+ "Zero",
+ "NotZero"
+ );
+ }
+ if (
+ jsonData2[3][3].button.value === 0 &&
+ (jsonData2[3][3].button.name === "Zero" ||
+ jsonData2[3][3].button.name === "宸插洖闆�")
+ ) {
+ jsonData2[3][3].button.name = jsonData2[3][3].button.name.replace(
+ "宸插洖闆�",
+ "鏈洖闆�"
+ );
+ jsonData2[3][3].button.name = jsonData2[3][3].button.name.replace(
+ "Zero",
+ "NotZero"
+ );
+ }
+ if (
+ jsonData2[4][4].button.value === 0 &&
+ (jsonData2[4][4].button.name === "Zero" ||
+ jsonData2[4][4].button.name === "宸插洖闆�")
+ ) {
+ jsonData2[4][4].button.name = jsonData2[4][4].button.name.replace(
+ "宸插洖闆�",
+ "鏈洖闆�"
+ );
+ jsonData2[4][4].button.name = jsonData2[4][4].button.name.replace(
+ "Zero",
+ "NotZero"
+ );
+ }
+ if (
+ jsonData2[5][4].button.value === 0 &&
+ (jsonData2[5][4].button.name === "Zero" ||
+ jsonData2[5][4].button.name === "宸插洖闆�")
+ ) {
+ jsonData2[5][4].button.name = jsonData2[5][4].button.name.replace(
+ "宸插洖闆�",
+ "鏈洖闆�"
+ );
+ jsonData2[5][4].button.name = jsonData2[5][4].button.name.replace(
+ "Zero",
+ "NotZero"
+ );
+ }
+ }
+ };
// 鍏抽棴浜嬩欢
socket.onclose = function () {
@@ -608,53 +851,45 @@
socket.onerror = function () {
console.log("websocket鍙戠敓浜嗛敊璇�");
};
- this.$router.afterEach(function(){
+ this.$router.afterEach(function () {
socket.close();
- })
-
+ });
}
},
- send () {
-
-
+ send() {
socket?.send(JSON.stringify(this.messagepack));
},
//鏇挎崲璇█
replaceChineseWithEnglish() {
-
-
- const nameMap= this.$t('ServoManualone')
+ const nameMap = this.$t("ServoManualone");
this.jsonData = this.jsonData.map((item) => {
- return item.map((obj) => {
- if (obj.name) {
- const newName = nameMap[obj.name] || obj.name;
- return { ...obj, name: newName };
- } else if (obj.button && obj.button.name) {
- const newName = nameMap[obj.button.name] || obj.button.name;
- return { ...obj, button: { ...obj.button, name: newName } };
- } else if (obj.title && obj.title.name) {
- const newName = nameMap[obj.title.name] || obj.title.name;
- return { ...obj, title: { ...obj.title, name: newName } };
- } else {
- return obj;
- }
- });
-});
+ return item.map((obj) => {
+ if (obj.name) {
+ const newName = nameMap[obj.name] || obj.name;
+ return { ...obj, name: newName };
+ } else if (obj.button && obj.button.name) {
+ const newName = nameMap[obj.button.name] || obj.button.name;
+ return { ...obj, button: { ...obj.button, name: newName } };
+ } else if (obj.title && obj.title.name) {
+ const newName = nameMap[obj.title.name] || obj.title.name;
+ return { ...obj, title: { ...obj.title, name: newName } };
+ } else {
+ return obj;
+ }
+ });
+ });
-
-// console.log(this.jsonData)
-
+ // console.log(this.jsonData)
},
-
- }
- }
+ },
+};
</script>
<style scoped>
-html,body{
-width:100%;
-height:85%;
-
+html,
+body {
+ width: 100%;
+ height: 85%;
}
.item-row {
@@ -666,7 +901,7 @@
.action-button {
margin-right: 10px;
background: #66b1ff;
- color: #FFF;
+ color: #fff;
}
.blue-button {
background-color: skyblue;
@@ -697,7 +932,6 @@
background-color: green;
}
-
.qidong5 {
background-color: green;
}
@@ -705,17 +939,15 @@
.huiling {
background-color: green;
}
-.jiting{
+.jiting {
background-color: green;
}
-.error-button3{
+.error-button3 {
background-color: green;
-
}
-.yihuiling{
-
+.yihuiling {
background-color: green;
}
</style>
\ No newline at end of file
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/MessageHandler.java b/springboot-vue3/src/main/java/com/example/springboot/component/MessageHandler.java
index ae39320..efcf9b6 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/MessageHandler.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/MessageHandler.java
@@ -97,6 +97,10 @@
+
+
+
+
public void WriteWordsToPLC(JSONArray jsonArray, String address,int index) {
if (jsonArray.getJSONArray(index).size() > 0) {
Object value = jsonArray.getJSONArray(index).get(0);
@@ -115,6 +119,24 @@
}
+ public void Writetime(JSONArray jsonArray, String address,int index) {
+ if (jsonArray.getJSONArray(index).size() > 0) {
+ Object value = jsonArray.getJSONArray(index).get(0);
+ if (value != null && !value.toString().equals("null")) {
+ try {
+ long cleanedValue = Long.parseLong(value.toString().replaceAll("[^0-9-]", ""));
+
+ S7control.getinstance().writetime(address, cleanedValue);
+ System.out.println("messageValue锛�" + Arrays.asList(cleanedValue) + " written to PLC at address " + address);
+ } catch (NumberFormatException e) {
+ // 濡傛灉鏃犳硶瑙f瀽涓� short 绫诲瀷锛屽垯蹇界暐璇ラ儴鍒�
+ System.err.println("Could not parse value: " + value);
+ }
+ }
+ }
+ }
+
+
//鍐欏叆String
public void writeStringToPLC(JSONArray messageArray, String addresses, int index) {
try {
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/PLCAutomaticParameterSetting.java b/springboot-vue3/src/main/java/com/example/springboot/component/PLCAutomaticParameterSetting.java
index 7ae28fc..3532c83 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/PLCAutomaticParameterSetting.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/PLCAutomaticParameterSetting.java
@@ -42,6 +42,8 @@
List<String> addresses = Arrays.asList(config.getProperty("Auto.addresses").split(","));
List<Short> arraylist2 = S7control.getinstance().readWords(addresses);
+ //System.out.println("lastMessage锛�" + arraylist2);
+
//缈昏浆
List<Short> fanzhuan2 = S7control.getinstance().ReadWord("DB100.8", 1);
List<Short> xiaoche2 = S7control.getinstance().ReadWord("DB100.12", 1);
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/PLCManualJog.java b/springboot-vue3/src/main/java/com/example/springboot/component/PLCManualJog.java
index 16fa085..07d6e7f 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/PLCManualJog.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/PLCManualJog.java
@@ -22,7 +22,11 @@
public PLCManualJog() throws IOException {
config = new Configuration("config.properties");
}
-
+// Boolean[] values1 = { false, true, true, true, false, false, true, false,
+// false, true, true, true, false, false,
+// true, false,false, true, true, true, false, false, true, false,
+// false, true, false, true };
+// List<Boolean> arraylist = new ArrayList<>(Arrays.asList(values1));
@Override
public void run() {
@@ -37,13 +41,9 @@
List<String> addressList21 = Arrays.asList(config.getProperty("PLCManualJog.button").split(","));
- List<Boolean> arraylist = S7control.getinstance().readBits(addressList21);
+ List<Boolean> arraylist = S7control.getinstance().readBits(addressList21);
-// Boolean[] values1 = { false, true, true, true, false, false, true, false,
-// false, true, true, true, false, false,
-// true, false,false, true, true, true, false, false, true, false,
-// false, true, false, true };
-// List<Boolean> arraylist = new ArrayList<>(Arrays.asList(values1));
+
@@ -54,7 +54,7 @@
boolean value = arraylist.get(i);
params[i] = value ? (short) 1 : (short) 0;
}
-
+ // System.out.println("messageValue锛�"+ arraylist );
jsonObject.append("params", params);
// System.out.println("messageValue锛�" + arraylist +"messageValue2锛�" + arraylist2 );
@@ -107,7 +107,10 @@
if (!bolList.isEmpty()) {
- S7control.getinstance().WriteBit(addressList21, bolList);
+ S7control.getinstance().WriteBit(addressList21, bolList);
+// arraylist.clear();
+// arraylist.addAll(bolList);
+
System.out.println("messageValue锛�" + bolList + " written to PLC at address " + addressList21);
}
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/PlcManualonePosition.java b/springboot-vue3/src/main/java/com/example/springboot/component/PlcManualonePosition.java
index 741e727..3284110 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/PlcManualonePosition.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/PlcManualonePosition.java
@@ -62,47 +62,41 @@
// String PlcAddress = this.name;
// Integer Plccount = this.count;
- List<String> addresses = new ArrayList<>();
- addresses.add("DB100.108");
- addresses.add("DB100.20");
- addresses.add("DB103.32");
+
+ //B01缁勫悎涓湴鍧�
+ // String b01Address = config.getProperty("B01.address");
+ List<String> addresses = Arrays.asList(config.getProperty("PlcManualonePosition.addresses").split(","));
+
List<Short> arraylist = S7control.getinstance().readWords(addresses);
// System.out.println(arraylist);
+ List<String> addresses2 = Arrays.asList(config.getProperty("PlcManualonePosition.addresses2").split(","));
- List<String> addresses2 = new ArrayList<>();
- addresses2.add("DB100.110");
- addresses2.add("DB100.176");
- addresses2.add("DB103.34");
List<Short> arraylist2 = S7control.getinstance().readWords(addresses2);
- List<String> addresses3 = new ArrayList<>();
- addresses3.add("DB100.112");
- addresses3.add("DB100.24");
- addresses3.add("DB103.36");
+ List<String> addresses3 = Arrays.asList(config.getProperty("PlcManualonePosition.addresses3").split(","));
+
List<Short> arraylist3 = S7control.getinstance().readWords(addresses3);
- List<String> addresses4 = new ArrayList<>();
- addresses4.add("DB100.114");
- addresses4.add("DB100.178");
- addresses4.add("DB103.40");
+
+ List<String> addresses4 = Arrays.asList(config.getProperty("PlcManualonePosition.addresses4").split(","));
+
List<Short> arraylist4 = S7control.getinstance().readWords(addresses4);
+
List<Short> arraylist5 = S7control.getinstance().ReadWord("DB106.0", 1);
List<Short> arraylist6 = S7control.getinstance().ReadWord("DB106.12", 1);
List<Short> arraylist7 = S7control.getinstance().ReadWord("DB106.40", 1);
List<Short> arraylist8 = S7control.getinstance().ReadWord("DB106.50", 1);
- List<String> addresses9 = new ArrayList<>();
- addresses9.add("DB104.1.2");
- addresses9.add("DB104.1.3");
- addresses9.add("DB104.1.6");
- addresses9.add("DB104.1.7");
+ //鏁呴殰
+
+ List<String> addresses9 = Arrays.asList(config.getProperty("PlcManualonePosition.fault").split(","));
+
List<Boolean> arraylist9 = S7control.getinstance().readBits(addresses9);
- List<String> addresses10 = new ArrayList<>();
- addresses10.add("DB104.9.4");
- addresses10.add("DB104.9.5");
- addresses10.add("DB104.9.4");
- addresses10.add("DB104.9.5");
+ //鏈洖闆�
+
+ List<String> addresses10 = Arrays.asList(config.getProperty("PlcManualonePosition.Notzero").split(","));
+
List<Boolean> arraylist10 = S7control.getinstance().readBits(addresses10);
//A01鍚姩鍦板潃
@@ -183,45 +177,20 @@
// WebSocketServer webSocketServer = WebSocketServer.sessionMap.get("ManualonePosition");
if (webserver != null) {
List<String> messages = webserver.getMessages();
- List<String> waddresses1 = new ArrayList<>();
- waddresses1.add("DB100.108");
- waddresses1.add("DB100.20");
- waddresses1.add("DB103.32");
- List<String> waddresses2 = new ArrayList<>();
- waddresses2.add("DB100.110");
- waddresses2.add("DB100.176");
- waddresses2.add("DB103.34");
-
- List<String> waddresses3 = new ArrayList<>();
- waddresses3.add("DB100.112");
- waddresses3.add("DB100.24");
- waddresses3.add("DB103.36");
-
- List<String> waddresses4 = new ArrayList<>();
- waddresses4.add("DB100.114");
- waddresses4.add("DB100.178");
- waddresses4.add("DB103.40");
// 鏁呴殰鍦板潃
- List<String> waddresses5 = new ArrayList<>();
- // waddresses5.add("DB103.244");
- // waddresses5.add("DB103.250");
- waddresses5.add("DB103.252");
- waddresses5.add("DB103.254");
+ List<String> waddresses5 = Arrays.asList(config.getProperty("PlcManualonePosition.fault2").split(","));
+
// 澶嶄綅鍦板潃
- List<String> waddresses6 = new ArrayList<>();
- waddresses6.add("DB101.4.0");
- waddresses6.add("DB101.4.3");
- waddresses6.add("DB101.4.4");
- waddresses6.add("DB101.4.6");
+ List<String> waddresses6 = Arrays.asList(config.getProperty("PlcManualonePosition.Reset").split(","));
+
// 鍥為浂鍦板潃
- List<String> waddresses7 = new ArrayList<>();
+ List<String> waddresses7 = Arrays.asList(config.getProperty("PlcManualonePosition.Zero").split(","));
- waddresses7.add("DB101.4.5");
- waddresses7.add("DB101.4.7");
+
// System.out.println(messages.isEmpty());
@@ -231,18 +200,18 @@
// System.out.println("lastMessage锛�" + lastMessage);
JSONArray messageArray = new JSONArray(lastMessage);
// 鍐欏叆A01
- customS7Control.WriteWordToPLC(messageArray, waddresses1, 0);
+ customS7Control.WriteWordToPLC(messageArray, addresses, 0);
// 鍐欏叆A02
- customS7Control.WriteWordToPLC(messageArray, waddresses2, 1);
+ customS7Control.WriteWordToPLC(messageArray, addresses2, 1);
// 鍐欏叆B01
- customS7Control.WriteWordToPLC(messageArray, waddresses3, 2);
+ customS7Control.WriteWordToPLC(messageArray, addresses3, 2);
// 鍐欏叆B02
- customS7Control.WriteWordToPLC(messageArray, waddresses4, 3);
+ customS7Control.WriteWordToPLC(messageArray, addresses4, 3);
// 鍐欏叆鏁呴殰鍦板潃
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/PlcManualonePosition2.java b/springboot-vue3/src/main/java/com/example/springboot/component/PlcManualonePosition2.java
index 4d24906..0d5816b 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/PlcManualonePosition2.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/PlcManualonePosition2.java
@@ -179,18 +179,14 @@
// A01涓嬪彂
customS7Control.WriteWordToPLC(messageArray, waddresses1, 0);
-
// A02涓嬪彂
customS7Control.WriteWordToPLC(messageArray, waddresses2, 1);
-
// 鍐欏叆鏁呴殰鍦板潃
customS7Control.WriteWordToPLC(messageArray, waddresses3, 2);
-
// 鍐欏叆澶嶄綅鍦板潃
customS7Control.writeBitToPLC(messageArray, waddresses4, 3);
-
// 鍐欏叆鍥為浂鍦板潃
customS7Control.writeBitToPLC(messageArray, waddresses5, 4);
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter2.java b/springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter2.java
index 89f1811..9f0a790 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter2.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter2.java
@@ -56,7 +56,11 @@
//鎬ュ仠鎸夐挳
List<String> niuanaddressList3 = Arrays.asList(config.getProperty("Parameter2.stop").split(","));
+ List<String> timeout = Arrays.asList(config.getProperty("Parameter2.timeout").split(","));
+ String timeout2 = config.getProperty("Parameter2.timeout");
+
+ Long readtimeout = S7control.getinstance().readtime(timeout2);
List<Boolean> anniuread = S7control.getinstance().readBits(niuanaddressList3);
@@ -108,6 +112,7 @@
jsonObject.append("params", data3);
jsonObject.append("params", data4);
jsonObject.append("jiting", anniuparams);
+ jsonObject.append("timeout", readtimeout);
// WebSocketServer sendwServer = WebSocketServer.getWebSocketServer("Parameter2");
@@ -139,6 +144,9 @@
customS7Control.writeBitToPLC(messageArray, addressList0, 0);
//鎬ュ仠
customS7Control.writeBitToPLC(messageArray, niuanaddressList3, 1);
+ //瀛樼墖绛夊緟寤惰繜
+ customS7Control.Writetime(messageArray, timeout2, 2);
+
// 娓呯┖娑堟伅鍒楄〃
webserver.clearMessages();
}
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/PlcPositioning1.java b/springboot-vue3/src/main/java/com/example/springboot/component/PlcPositioning1.java
index 67956dd..e62345d 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/PlcPositioning1.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/PlcPositioning1.java
@@ -18,7 +18,16 @@
public class PlcPositioning1 extends Thread {
+ // 鐢ㄤ簬瀛樺偍搴旂敤绋嬪簭鐨勯厤缃俊鎭�
+ private Configuration config;
+ // 鍒涘缓涓�涓嚜瀹氫箟鐨� S7 鎺у埗鍣ㄦ秷鎭鐞嗗櫒瀵硅薄
+ MessageHandler customS7Control = new MessageHandler();
+
+
+ public PlcPositioning1() throws IOException {
+ config = new Configuration("config.properties");
+ }
@Override
public void run() {
while (this != null) {
@@ -32,7 +41,9 @@
// System.out.println(stt);
//瀛樼墖鏍� 鍑虹墖鏍艰鍙�
- List<Short> arraylist = S7control.getinstance().ReadWord("DB100.42", 33);
+
+ String address = config.getProperty("PlcPositioning1.address");
+ List<Short> arraylist = S7control.getinstance().ReadWord(address, 33);
// System.out.println(arraylist);
@@ -60,7 +71,7 @@
if (webserver != null) {
List<String> messages = webserver.getMessages();
//瀛樼墖鏍� 鍑虹墖鏍煎湴鍧�
- String addressList3 = "DB100.42";
+
if (!messages.isEmpty()) {
// 灏嗘渶鍚庝竴涓秷鎭浆鎹负 short 绫诲瀷鐨勫垪琛�
@@ -90,8 +101,8 @@
// 鍐欏叆瀛樼墖鏍� 鍑虹墖鏍间綅缃瀹氭暟鎹�
if (!mergedList.isEmpty()) {
- S7control.getinstance().WriteWord(addressList3, mergedList);
- System.out.println("messageValue锛�" + mergedList + " written to PLC at address " + addressList3);
+ S7control.getinstance().WriteWord(address, mergedList);
+ System.out.println("messageValue锛�" + mergedList + " written to PLC at address " + address);
}
// 娓呯┖娑堟伅鍒楄〃
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/S7control.java b/springboot-vue3/src/main/java/com/example/springboot/component/S7control.java
index 36f2afb..a73f176 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/S7control.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/S7control.java
@@ -157,10 +157,17 @@
* @return 缁撴灉
*/
public List<Short> ReadWord(List<String> address) {
- if (s7PLC==null)
- return null;
- return s7PLC.readInt16(address);
+ if (s7PLC == null)
+ return null;
+
+ try {
+ return s7PLC.readInt16(address);
+ } catch (Exception e) {
+ System.out.println("璇诲彇 " + address + " 澶辫触锛�" + e.getMessage());
+ return null;
+ }
}
+
@@ -184,12 +191,19 @@
* @return 缁撴灉
*/
public List<Short> ReadWord(String address, int count) {
- if (s7PLC==null)
- return null;
+ if (s7PLC == null)
+ return null;
List<String> addresslist = GetAddressList(address, count, 16);
- return s7PLC.readInt16(addresslist);
+ try {
+ return s7PLC.readInt16(addresslist);
+ } catch (Exception e) {
+ System.out.println("璇诲彇 " + address + " 澶辫触锛�" + e.getMessage());
+
+ return null;
+ }
}
+
/**
* 鎸夋寚瀹氱殑鍦板潃 璇诲彇byte缁撴灉闆�
*
@@ -216,53 +230,48 @@
return s7PLC.readBoolean(addresslist);
}
//璇诲彇涓嶈繛缁湴鍧�bit
- public List<Boolean> readBits(List<String> addressList) {
- if (s7PLC == null || addressList.isEmpty()) {
- return null;
- }
+public List<Boolean> readBits(List<String> addressList) {
+ if (s7PLC == null || addressList.isEmpty()) {
+ return null;
+ }
- List<Boolean> values = new ArrayList<>();
- for (String address : addressList) {
+ List<Boolean> values = new ArrayList<>();
+ for (String address : addressList) {
+ try {
boolean value = s7PLC.readBoolean(address);
values.add(value);
+ } catch (Exception e) {
+ // 澶勭悊寮傚父
+ System.out.println("璇诲彇 " + address + " 澶辫触锛�" + e.getMessage());
}
-
- return values;
}
+
+ return values;
+}
+
//璇诲彇String
- public List<String> readStrings(List<String> addressList) {
- if (s7PLC == null) {
- return null;
- }
-
- List<String> result = new ArrayList<>();
-
- for (String address : addressList) {
+public List<String> readStrings(List<String> addressList) {
+ if (s7PLC == null) {
+ return null;
+ }
+ List<String> result = new ArrayList<>();
+ for (String address : addressList) {
+ try {
byte[] bytes = s7PLC.readByte(address, 14);
-// System.out.println(bytes.toString());
- if (bytes != null) {
- String str = new String(bytes, StandardCharsets.UTF_8);
-// System.out.println(str);
-// if(str == null ){
-// str = "";
-// }
+ if (bytes != null) {
+ String str = new String(bytes, StandardCharsets.UTF_8);
result.add(str);
}
-// if ( bytes.toString().contains("@")) {
-// String str = "";
-//
-// result.add(str);
-// }else{
-//
-// String str = new String(bytes, StandardCharsets.US_ASCII);
-// result.add(str);
-// }
-// System.out.println(bytes.toString());
+ } catch (Exception e) {
+ System.out.println("璇诲彇 " + address + " 澶辫触锛�" + e.getMessage());
+ result.add(null);
}
-
- return result;
}
+
+ return result;
+}
+
//涓嶈繛缁湴鍧�鍐欏叆Word
public void WriteWord(List<String> address, List<Short> datas) {
@@ -298,7 +307,7 @@
S7control.getinstance().WriteByte(addr, bytes);
}
-
+//璇诲彇涓嶈繛缁瓀ord
public List<Short> readWords(List<String> addresses) {
if (s7PLC == null) {
return null;
@@ -307,21 +316,38 @@
List<Short> data = new ArrayList<>();
for (String address : addresses) {
+ try {
- // 鍗曚釜鍦板潃
- Short value = s7PLC.readInt16(address);
- data.add(value);
+ // 鍗曚釜鍦板潃
+ Short value = s7PLC.readInt16(address);
+ data.add(value);
+ } catch (Exception e) {
+ System.out.println("璇诲彇 " + address + " 澶辫触锛�" + e.getMessage());
+
+ }
}
-
return data;
}
+
//璇诲彇鏃堕棿
public Long readtime(String address) {
if (s7PLC==null)
return null;
return s7PLC.readTime(address);
}
+
+ public void writetime(String address, long datas) {
+ if (s7PLC == null)
+ return;
+
+
+ s7PLC.writeTime(address, datas); // 灏嗘暟鎹啓鍏ュ崟涓湴鍧�
+ }
+
+
+
+
private int extractAddressNumber(String address) {
String numberStr = address.replaceAll("\\D+", ""); // 浣跨敤姝e垯琛ㄨ揪寮忔彁鍙栨暟瀛楅儴鍒�
@@ -337,11 +363,17 @@
* @return Boolean缁撴灉
*/
public List<Boolean> ReadBits(String address, int count) {
- if (s7PLC==null)
+ if (s7PLC == null)
return null;
List<String> addresslist = GetAddressList(address, count, 1);
- return s7PLC.readBoolean(addresslist);
- }
+ try {
+ return s7PLC.readBoolean(addresslist);
+ } catch (Exception e) {
+ System.out.println("璇诲彇 " + address + " 澶辫触锛�" + e.getMessage());
+ return null;
+ }
+
+ };
diff --git a/springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java b/springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java
index 873d9b1..38115b2 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java
@@ -17,29 +17,25 @@
//
System.out.println("鍚姩瀹屾垚");
- // new Plclog().start();
-
- // new PlcHold().start();
+ new PlcHold().start();
new Plchome().start();
-
+ new Plcalarm().start();
- // new Plcalarm().start();
+ new Plcsign().start();
- // new Plcsign().start();
-
- // new Plcstate().start();
- // new PlcPositioning1().start();
+ new Plcstate().start();
+ new PlcPositioning1().start();
- // new PlcParameter2().start();
+ new PlcParameter2().start();
- // new PLCAutomaticParameterSetting().start();
+ new PLCAutomaticParameterSetting().start();
- // new PlcManualonePosition().start();
- // new PlcManualonePosition2().start();
- // new PlcServoManualone().start();
- // new PLCManualJog().start();
+ new PlcManualonePosition().start();
+ new PlcManualonePosition2().start();
+ new PlcServoManualone().start();
+ new PLCManualJog().start();
}
}
\ No newline at end of file
diff --git a/springboot-vue3/src/main/resources/config.properties b/springboot-vue3/src/main/resources/config.properties
index 1037320..4e420c3 100644
--- a/springboot-vue3/src/main/resources/config.properties
+++ b/springboot-vue3/src/main/resources/config.properties
@@ -100,7 +100,9 @@
#鎵爜鏋�
Parameter2.scanner=DB103.256,DB103.270
#鎬ュ仠
-Parameter2.stop=DB101.10.4
+Parameter2.stop=DB101.10.4,DB101.11.2
+
+Parameter2.timeout=DB100.194
#褰撳墠鏍煎瓙
Parameter2.Currentcell=DB103.32,DB103.34,DB103.36,DB103.40
@@ -153,7 +155,7 @@
#addresses.add("DB100.36");
#addresses.add("DB100.38");
#addresses.add("DB100.40");
-Auto.addresses=DB100.0,DB100.2,DB100.4,DB100.6,DB100.26,DB100.28,DB100.30,DB100.32,DB100.36,DB100.38,DB100.40
+Auto.addresses=DB100.0,DB100.2,DB100.4,DB100.6,DB100.26,DB100.28,DB100.30,DB100.32,DB100.34,DB100.36,DB100.38,DB100.40
#List<String> waddresses1 = new ArrayList<>();
#waddresses1.add("DB100.0");
@@ -169,4 +171,40 @@
#waddresses1.add("DB100.38");
#waddresses1.add("DB100.40");
-Auto.shusong=DB100.0,DB100.2,DB100.4,DB100.6,DB100.26,DB100.28,DB100.30,DB100.32,DB100.34,DB100.36,DB100.38,DB100.40
\ No newline at end of file
+Auto.shusong=DB100.0,DB100.2,DB100.4,DB100.6,DB100.26,DB100.28,DB100.30,DB100.32,DB100.34,DB100.36,DB100.38,DB100.40
+
+
+#-----PlcPositioning1-------------------------
+PlcPositioning1.address=DB100.42
+
+#----------------PlcManualonePosition-----
+
+PlcManualonePosition.addresses=DB100.108,DB100.20,DB103.32
+
+PlcManualonePosition.addresses2=DB100.110,DB100.176,DB103.34
+
+PlcManualonePosition.addresses3=DB100.112,DB100.24,DB103.36
+
+PlcManualonePosition.addresses4=DB100.114,DB100.178,DB103.40
+
+
+#鏁呴殰
+PlcManualonePosition.fault=DB104.1.2,DB104.1.3,DB104.1.6,DB104.1.7
+
+#鏈洖闆�
+PlcManualonePosition.Notzero=DB104.9.4,DB104.9.5,DB104.9.4,DB104.9.5
+
+#鏁呴殰2
+PlcManualonePosition.fault2=DB103.252,DB103.254
+
+#澶嶄綅
+PlcManualonePosition.Reset=DB101.4.0,DB101.4.3,DB101.4.4,DB101.4.6
+#鍥為浂
+PlcManualonePosition.Zero=DB101.4.5,DB101.4.7
+
+
+
+
+
+
+
--
Gitblit v1.8.0