From 8dfb37b10ffb2fcb41c85b3fa266d1ef2874aebc Mon Sep 17 00:00:00 2001
From: wuyouming666 <2265557248@qq.com>
Date: 星期四, 30 十一月 2023 08:53:27 +0800
Subject: [PATCH] 修改电气管理PLC通讯逻辑
---
CanadaMes-ui/src/views/Electrical/ManualonePosition2.vue | 679 ++++++++++++-----------
springboot-vue3/src/main/java/com/example/springboot/component/PlcManualonePosition2.java | 281 +++++++++
springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter2.java | 24
CanadaMes-ui/src/router/index.js | 27
CanadaMes-ui/src/configuration/Parameter.json | 20
CanadaMes-ui/src/views/Electrical/ManualonePosition.vue | 2
CanadaMes-ui/src/views/Electrical/Parameter2.vue | 6
springboot-vue3/src/main/java/com/example/springboot/component/PLCManualJog.java | 173 +++++
CanadaMes-ui/src/views/Electrical/Parameter.vue | 101 +-
springboot-vue3/src/main/java/com/example/springboot/component/Plcalarm.java | 10
springboot-vue3/src/main/java/com/example/springboot/component/Plcsign.java | 30
springboot-vue3/src/main/java/com/example/springboot/component/PlcServoManualone.java | 166 ++--
CanadaMes-ui/src/configuration/Manualoneposition2.json | 12
springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter.java | 20
springboot-vue3/src/main/java/com/example/springboot/component/Plcstate.java | 8
springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java | 18
CanadaMes-ui/src/views/Electrical/AutomaticParameterSetting.vue | 4
CanadaMes-ui/src/views/Electrical/ServoManualone.vue | 6
springboot-vue3/src/main/java/com/example/springboot/component/PlcManualonePosition.java | 26
CanadaMes-ui/src/configuration/Manualoneposition.json | 32
springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter1.java | 51 +
springboot-vue3/src/main/java/com/example/springboot/component/Plcaction.java | 8
22 files changed, 1,102 insertions(+), 602 deletions(-)
diff --git a/CanadaMes-ui/src/configuration/Manualoneposition.json b/CanadaMes-ui/src/configuration/Manualoneposition.json
index 652a959..69edafb 100644
--- a/CanadaMes-ui/src/configuration/Manualoneposition.json
+++ b/CanadaMes-ui/src/configuration/Manualoneposition.json
@@ -2,7 +2,7 @@
[
{
"name": "A01鎵嬪姩鏍煎瓙",
- "value": 33,
+ "value": 0,
"sending": 0,
"type": "0",
"address": "DB100.0",
@@ -11,7 +11,7 @@
},
{
"name": "A01瀹氫綅閫熷害",
- "value": 11,
+ "value": 0,
"sending": 0,
"address": "DB100.0",
"type": "0",
@@ -19,7 +19,7 @@
},
{
"name": "A01褰撳墠鏍煎瓙",
- "value": 22,
+ "value": 0,
"sending": 0,
"address": "DB100.0",
"type": "0",
@@ -69,7 +69,7 @@
[
{
"name": "A02鎵嬪姩鏍煎瓙",
- "value": 33,
+ "value": 0,
"sending": 0,
"type": "0",
"address": "DB100.0",
@@ -78,7 +78,7 @@
},
{
"name": "A02瀹氫綅閫熷害",
- "value": 11,
+ "value": 0,
"sending": 0,
"address": "DB100.0",
"type": "0",
@@ -86,7 +86,7 @@
},
{
"name": "A02褰撳墠鏍煎瓙",
- "value": 22,
+ "value": 0,
"sending": 0,
"address": "DB100.0",
"type": "0",
@@ -136,7 +136,7 @@
[
{
"name": "B01鎵嬪姩鏍煎瓙",
- "value": 33,
+ "value": 0,
"sending": 0,
"type": "0",
"address": "DB100.0",
@@ -145,7 +145,7 @@
},
{
"name": "B01瀹氫綅閫熷害",
- "value": 11,
+ "value": 0,
"sending": 0,
"address": "DB100.0",
"type": "0",
@@ -153,7 +153,7 @@
},
{
"name": "B01褰撳墠鏍煎瓙",
- "value": 22,
+ "value": 0,
"sending": 0,
"address": "DB100.0",
"type": "0",
@@ -203,7 +203,7 @@
[
{
"name": "B02鎵嬪姩鏍煎瓙",
- "value": 33,
+ "value": 0,
"sending": 0,
"type": "0",
"address": "DB100.0",
@@ -212,7 +212,7 @@
},
{
"name": "B02瀹氫綅閫熷害",
- "value": 11,
+ "value": 0,
"sending": 0,
"address": "DB100.0",
"type": "0",
@@ -220,7 +220,7 @@
},
{
"name": "B02褰撳墠鏍煎瓙",
- "value": 22,
+ "value": 0,
"sending": 0,
"address": "DB100.0",
"type": "0",
@@ -270,7 +270,7 @@
[
{
"name": "A01瀹炴椂浣嶇疆",
- "value": 33,
+ "value": 0,
"sending": 4,
"type": "0",
"address": "DB100.0",
@@ -281,7 +281,7 @@
[
{
"name": "A02瀹炴椂浣嶇疆",
- "value": 33,
+ "value": 0,
"sending": 5,
"type": "0",
"address": "DB100.0",
@@ -292,7 +292,7 @@
[
{
"name": "B01瀹炴椂浣嶇疆",
- "value": 33,
+ "value": 0,
"sending": 6,
"type": "0",
"address": "DB100.0",
@@ -303,7 +303,7 @@
[
{
"name": "B02瀹炴椂浣嶇疆",
- "value": 33,
+ "value": 0,
"sending": 7,
"type": "0",
"address": "DB100.0",
diff --git a/CanadaMes-ui/src/configuration/Manualoneposition2.json b/CanadaMes-ui/src/configuration/Manualoneposition2.json
index 5939f8e..4f43f7c 100644
--- a/CanadaMes-ui/src/configuration/Manualoneposition2.json
+++ b/CanadaMes-ui/src/configuration/Manualoneposition2.json
@@ -2,7 +2,7 @@
[
{
"name": "鎵嬪姩浣嶇疆",
- "value": 33,
+ "value": 0,
"sending": 0,
"type": "0",
"address": "DB100.0",
@@ -10,14 +10,14 @@
},
{
"name": "瀹氫綅閫熷害",
- "value": 11,
+ "value": 0,
"sending": 0,
"address": "DB100.0",
"type": "0"
},
{
"name": "A01缈昏浆瀹炴椂浣嶇疆",
- "value": 22,
+ "value": 0,
"sending": 0,
"address": "DB100.0",
"type": "0"
@@ -66,7 +66,7 @@
[
{
"name": "鎵嬪姩浣嶇疆",
- "value": 33,
+ "value": 0,
"sending": 0,
"type": "0",
"address": "DB100.0",
@@ -74,14 +74,14 @@
},
{
"name": "瀹氫綅閫熷害",
- "value": 11,
+ "value": 0,
"sending": 0,
"address": "DB100.0",
"type": "0"
},
{
"name": "A02缈昏浆瀹炴椂浣嶇疆",
- "value": 22,
+ "value": 0,
"sending": 0,
"address": "DB100.0",
"type": "0"
diff --git a/CanadaMes-ui/src/configuration/Parameter.json b/CanadaMes-ui/src/configuration/Parameter.json
index 193851f..a473bee 100644
--- a/CanadaMes-ui/src/configuration/Parameter.json
+++ b/CanadaMes-ui/src/configuration/Parameter.json
@@ -1,5 +1,4 @@
-{
- "para": [
+ [
{
"name": "D01-D06 conveyor Velocity(Auto FAST)",
"value": 123,
@@ -648,19 +647,4 @@
"type": "1",
"page": "1"
}
- ],
- "address": [
- {
- "name": "DB100.0",
- "count": 72
- },
- {
- "name": "DB101.0",
- "count": 22
- },
- {
- "name": "DB102.0",
- "count": 33
- }
- ]
-}
\ No newline at end of file
+ ]
\ No newline at end of file
diff --git a/CanadaMes-ui/src/router/index.js b/CanadaMes-ui/src/router/index.js
index 5171c05..27246f5 100644
--- a/CanadaMes-ui/src/router/index.js
+++ b/CanadaMes-ui/src/router/index.js
@@ -33,7 +33,7 @@
path: '/home',
component: () => import('../views/home')
},
-
+
{
@@ -49,7 +49,7 @@
component: () => import('../views/device/parameter'),
},
-
+
{
path: '/device/alarm',
component: () => import('../views/device/alarm')
@@ -58,7 +58,7 @@
path: '/device/iostate',
component: () => import('../views/device/iostate')
},
-
+
{
path: '/device/control',
component: () => import('../views/device/control')
@@ -107,23 +107,6 @@
path: '/Electrical/Positioning2',
component: () => import('../views/Electrical/Positioning2')
},
- {
- path: '/Electrical/ManualonePosition',
- component: () => import('../views/Electrical/ManualonePosition')
- },
- {
- path: '/Electrical/ManualonePosition2',
- component: () => import('../views/Electrical/ManualonePosition2')
- },
- {
- path: '/Electrical/AutomaticParameterSetting',
- component: () => import('../views/Electrical/AutomaticParameterSetting')
- },
- {
- path: '/Electrical/ManualJog',
- component: () => import('../views/Electrical/ManualJog')
- }
-
@@ -139,13 +122,15 @@
});
// 璺敱鎺у埗瀹堝崼,瑙e喅闇�瑕佺櫥褰曟墠鍙互璁块棶鐨勯〉闈�
+
+
router.beforeEach((to, from, next) => {
// 濡傛灉璁块棶鐨勬槸鐧诲綍鎴栨敞鍐岄〉闈㈢洿鎺ユ斁琛�
if (to.path === '/login' || to.path === '/register') return next();
// 鑾峰彇token
const hasToken = getToken();
-
+
diff --git a/CanadaMes-ui/src/views/Electrical/AutomaticParameterSetting.vue b/CanadaMes-ui/src/views/Electrical/AutomaticParameterSetting.vue
index 8ea34da..64b71e0 100644
--- a/CanadaMes-ui/src/views/Electrical/AutomaticParameterSetting.vue
+++ b/CanadaMes-ui/src/views/Electrical/AutomaticParameterSetting.vue
@@ -146,7 +146,7 @@
let obj = JSON.parse(msg.data);
const jsonData2 = this.jsonData;
-
+console.log(obj);
const handleMouseMove = throttle(function (event) {
const inputBox = document.querySelectorAll('.el-card__body');
@@ -186,7 +186,7 @@
jsonData2[2][0]['value'] = dache[0][0];
}
}
- }, 50);
+ }, 200);
document.addEventListener('mouseover', handleMouseMove);
};
diff --git a/CanadaMes-ui/src/views/Electrical/ManualonePosition.vue b/CanadaMes-ui/src/views/Electrical/ManualonePosition.vue
index 516bf6c..dbd4dc2 100644
--- a/CanadaMes-ui/src/views/Electrical/ManualonePosition.vue
+++ b/CanadaMes-ui/src/views/Electrical/ManualonePosition.vue
@@ -294,7 +294,7 @@
}
let obj = JSON.parse(msg.data);
- //console.log(obj)
+ // console.log(obj)
const jsonData2 = this.jsonData;
const handleMouseMove = throttle(function (event) {
diff --git a/CanadaMes-ui/src/views/Electrical/ManualonePosition2.vue b/CanadaMes-ui/src/views/Electrical/ManualonePosition2.vue
index 8461e7e..a79506e 100644
--- a/CanadaMes-ui/src/views/Electrical/ManualonePosition2.vue
+++ b/CanadaMes-ui/src/views/Electrical/ManualonePosition2.vue
@@ -1,330 +1,351 @@
-<template>
- <div class="app">
- <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb">
- <router-link to="/Electrical/alarm" tag="el-button" type="text" active-class="blue-button">{{ $t('Alarm')
- }}</router-link>
- <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State')
- }}</router-link>
- <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action')
- }}</router-link>
- <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter')
- }}</router-link>
- <router-link to="/Electrical/Sign" tag="el-button" type="text" active-class="blue-button">{{ $t('Sign')
- }}</router-link>
- <router-link to="/Electrical/Servomanual" tag="el-button" type="text" active-class="blue-button">{{
- $t('ServoManual')
- }}</router-link>
- </el-breadcrumb>
-
- <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb">
-
- <router-link to="/Electrical/Servomanualone" tag="el-button" type="text" active-class="blue-button">{{
- $t('Servomanualone')
- }}</router-link>
- <router-link to="/Electrical/Parameter1" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter1')
- }}</router-link>
- <!-- <router-link to="/Electrical/Parameter2" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter2')
- }}</router-link> -->
- <router-link to="/Electrical/Positioning1" tag="el-button" type="text" active-class="blue-button">{{
- $t('Positioning1')
- }}</router-link>
- <router-link to="/Electrical/Positioning2" tag="el-button" type="text" active-class="blue-button">{{
- $t('Positioning2')
- }}</router-link>
- <router-link to="/Electrical/ManualonePosition" tag="el-button" type="text" active-class="blue-button">{{
- $t('ManualonePosition')
- }}</router-link>
- <router-link to="/Electrical/ManualonePosition2" tag="el-button" type="text" active-class="blue-button">{{
- $t('ManualonePosition2')
- }}</router-link>
- <router-link to="/Electrical/AutomaticParameterSetting" tag="el-button" type="text" active-class="blue-button">{{
- $t('AutomaticParameterSetting')
- }}</router-link>
- <router-link to="/Electrical/ManualJog" tag="el-button" type="text" active-class="blue-button">{{
- $t('ManualJog')
- }}</router-link>
- </el-breadcrumb>
-
- <el-row :gutter="20">
- <el-col :span="12" v-for="(dataGroup, groupIndex) in jsonData" :key="groupIndex">
- <el-card class="json-block" style="width:485px;">
- <div v-for="(item, itemIndex) in dataGroup" :key="itemIndex" class="item-container">
- <div class="item-row">
- <span class="name" style="width:100px;">{{ item.name }}</span>
- <el-input style="width:250px;" v-if="item.state != 0 && item.type === '0'" v-model="item.value"
- class="input-box"></el-input>
- </div>
- </div>
- <div class="button-row" style="display: flex; justify-content: space-between;">
- <div v-for="(item, itemIndex) in dataGroup" :key="itemIndex">
- <el-button v-if="item.button && item.button.state != 0" :name="item.button.name" v-model="item.button.value"
- :class="{ 'action-button': true, 'error-button': item.button.name === '鏁呴殰' && item.button.value === 1 }"
- @click="updateButtonValue(dataGroup, itemIndex); submitDataToBackend(item.button.name);">{{
- item.button.name }}</el-button>
- </div>
- </div>
- </el-card>
- </el-col>
- </el-row>
- <!-- <el-button @click="submitDataToBackend">鎻愪氦鏁版嵁鍒板悗绔�</el-button> -->
- </div>
-</template>
-
-<script>
-import LanguageMixin from '../../lang/LanguageMixin'
-import data from '../../configuration/Manualoneposition2'
-import { throttle } from 'lodash';
-let socket;
-export default {
- name: "ManualonePosition2",
- mixins: [LanguageMixin],
- data () {
- return {
- jsonData: data // 鍔犺浇鏁翠釜data.json鏂囦欢浣滀负jsonData
- }
- },
- created () {
- this.initWebSocket();
- // console.log('jsonData:', this.jsonData);
-
- },
- methods: {
- updateButtonValue (dataGroup, itemIndex) {
- // 灏嗗綋鍓嶆寜閽殑鍊艰涓�1
-
- this.$set(dataGroup[itemIndex].button, 'value', 1);
-
-
-
- },
- submitDataToBackend (currentButtonName) {
- if (currentButtonName === 'A01缈昏浆鍚姩') {
- const data = [];
-
- 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);
-
- data.push(values);
- }
-
-
-
- const jsonObject = { data };
-
- // 鎻愪氦鏁版嵁鍒板悗绔�
- const jsonString = JSON.stringify(jsonObject);
- console.log('鎵�鏈塗ype涓�0鐨剉alue:', jsonString);
- socket?.send(jsonString);
-
- }
-
- if (currentButtonName === 'A02缈昏浆鍚姩') {
- const data = [];
-
- for (let i = 1; i < 2; i++) {
- const inputData = this.jsonData[i].filter(item => item.type === '0').map(item => {
- return { value: item.value };
- });
-
- const values = inputData.map(item => item.value);
- data.unshift([]);
- data.push(values);
- }
-
-
-
- const jsonObject = { data };
-
- // 鎻愪氦鏁版嵁鍒板悗绔�
- const jsonString = JSON.stringify(jsonObject);
- console.log('鎵�鏈塗ype涓�0鐨剉alue:', jsonString);
- socket?.send(jsonString);
-
- }
-
- if (currentButtonName === '鏁呴殰') {
-
- const data2 = [];
- const resetButtonValues = this.jsonData.map(item => {
- const buttonItem = item.find(subItem => subItem.button && subItem.button.name === '鏁呴殰');
- return buttonItem ? buttonItem.button.value : null;
- }).filter(value => value !== null);
-
- // 灏嗗緱鍒扮殑鍊兼坊鍔犲埌 data 鏁扮粍涓�
- data2.push(...resetButtonValues);
- data2.unshift([], []);
- const jsonObject2 = { data2 };
-
- // 鎻愪氦鏁版嵁鍒板悗绔�
- const jsonString2 = JSON.stringify(jsonObject2);
- console.log('鎵�鏈夋晠闅滅殑value:', jsonString2);
- socket?.send(jsonString2);
-
-
- }
-
- if (currentButtonName === '澶嶄綅') {
-
- const data2 = [];
- const resetButtonValues = this.jsonData.map(item => {
- const buttonItem = item.find(subItem => subItem.button && subItem.button.name === '澶嶄綅');
- return buttonItem ? buttonItem.button.value : null;
- }).filter(value => value !== null);
-
- // 灏嗗緱鍒扮殑鍊兼坊鍔犲埌 data 鏁扮粍涓�
- data2.push(...resetButtonValues);
- data2.unshift([], [], []);
- const jsonObject2 = { data2 };
-
- // 鎻愪氦鏁版嵁鍒板悗绔�
- const jsonString2 = JSON.stringify(jsonObject2);
- console.log('鎵�鏈塗ype涓�0鐨剉alue:', jsonString2);
- socket?.send(jsonString2);
-
-
- }
-
-
- },
-
-
- initWebSocket () {
-
- let viewname = "ManualonePosition2";
-
- if (typeof WebSocket === "undefined") {
- console.log("鎮ㄧ殑娴忚鍣ㄤ笉鏀寔WebSocket");
- } else {
- let socketUrl = "ws://" + "localhost:8888" + "/springboot-vue3/api/talk/" + viewname;
-
- if (socket != null) {
- socket.close();
- socket = null;
- }
-
- // 寮�鍚竴涓獁ebsocket鏈嶅姟
- socket = new WebSocket(socketUrl);
-
- // 鎵撳紑浜嬩欢
- socket.onopen = function () {
- console.log("websocket宸叉墦寮�");
- };
-
- // 鏀跺埌娑堟伅
- socket.onmessage = (msg) => {
- if (!msg.data) {
- return; // 濡傛灉鏀跺埌绌烘暟鎹紝鍒欑洿鎺ヨ繑鍥烇紝涓嶆墽琛屽悗缁�昏緫
- }
-
- let obj = JSON.parse(msg.data);
- console.log(obj)
- const jsonData2 = this.jsonData;
-
- const handleMouseMove = throttle(function (event) {
- const inputBox = document.querySelectorAll('.el-card__body');
- const target = event.target;
- if (inputBox && Array.from(inputBox).every(box => !box.contains(target))) {
- // 鎵ц鏇存柊閫昏緫
- for (let i = 0; i < 2; i++) {
- jsonData2[i].forEach((item, index) => {
- if (typeof item.value !== 'undefined' && typeof obj[`zuhe${i + 1}`][0][index] !== 'undefined') {
- item.value = obj[`zuhe${i + 1}`][0][index];
- }
- });
- }
-
- jsonData2.forEach((item) => {
- item.forEach((subItem) => {
- if (subItem.sending === 4) {
- subItem.value = obj.shishi1[0][0];
- }
- if (subItem.sending === 5) {
- subItem.value = obj.shishi1[0][1];
- }
- if (subItem.sending === 6) {
- subItem.value = obj.shishi1[0][2];
- }
- if (subItem.sending === 7) {
- subItem.value = obj.shishi1[0][3];
- }
- });
- });
-
- // 閬嶅巻guzhang鏁扮粍
- for (let i = 0; i < obj.guzhang[0].length; i++) {
- const guzhangValue = obj.guzhang[0][i];
-
- // 鏌ユ壘jsonData2涓甫鏈�"button"鐨勫璞★紝骞朵笖name绛変簬"鏁呴殰"
- for (let j = 0; j < jsonData2.length; j++) {
- const section = jsonData2[j];
-
- for (let k = 0; k < section.length; k++) {
- const item = section[k];
-
- if (item.button && item.button.name === "鏁呴殰") {
- // 鏇存柊value灞炴��
- item.button.value = guzhangValue;
- break;
- }
- }
-
-
- }
- }
-
-
-
-
- }
- }, 200);
-
- document.addEventListener('mouseover', handleMouseMove);
- };
-
-
-
-
- // 鍏抽棴浜嬩欢
- socket.onclose = function () {
- console.log("websocket宸插叧闂�");
- };
-
- // 鍙戠敓閿欒浜嬩欢
- socket.onerror = function () {
- console.log("websocket鍙戠敓浜嗛敊璇�");
- };
-
- }
- },
- send () {
-
-
- socket?.send(JSON.stringify(this.messagepack));
- }
-
- }
-}
-</script>
-
-<style scoped>
-.item-row {
- display: flex;
- align-items: center;
- margin-bottom: 2px;
- /* 璋冩暣姣忎釜椤圭洰涔嬮棿鐨勯棿璺� */
-}
-
-.action-button {
- margin-right: 10px;
- background: #66b1ff;
- color: #FFF;
-}
-
-.blue-button {
- background-color: skyblue;
-}
+<template>
+ <div class="app">
+ <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb">
+ <router-link to="/Electrical/alarm" tag="el-button" type="text" active-class="blue-button">{{ $t('Alarm')
+ }}</router-link>
+ <router-link to="/Electrical/State" tag="el-button" type="text" active-class="blue-button">{{ $t('State')
+ }}</router-link>
+ <router-link to="/Electrical/Action" tag="el-button" type="text" active-class="blue-button">{{ $t('Action')
+ }}</router-link>
+ <router-link to="/Electrical/Parameter" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter')
+ }}</router-link>
+ <router-link to="/Electrical/Sign" tag="el-button" type="text" active-class="blue-button">{{ $t('Sign')
+ }}</router-link>
+ <router-link to="/Electrical/Servomanual" tag="el-button" type="text" active-class="blue-button">{{
+ $t('ServoManual')
+ }}</router-link>
+ </el-breadcrumb>
+
+ <el-breadcrumb separator-class="el-icon-arrow-right" class="el-breadcrumb">
+
+ <router-link to="/Electrical/Servomanualone" tag="el-button" type="text" active-class="blue-button">{{
+ $t('Servomanualone')
+ }}</router-link>
+ <router-link to="/Electrical/Parameter1" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter1')
+ }}</router-link>
+ <!-- <router-link to="/Electrical/Parameter2" tag="el-button" type="text" active-class="blue-button">{{ $t('Parameter2')
+ }}</router-link> -->
+ <router-link to="/Electrical/Positioning1" tag="el-button" type="text" active-class="blue-button">{{
+ $t('Positioning1')
+ }}</router-link>
+ <router-link to="/Electrical/Positioning2" tag="el-button" type="text" active-class="blue-button">{{
+ $t('Positioning2')
+ }}</router-link>
+ <router-link to="/Electrical/ManualonePosition" tag="el-button" type="text" active-class="blue-button">{{
+ $t('ManualonePosition')
+ }}</router-link>
+ <router-link to="/Electrical/ManualonePosition2" tag="el-button" type="text" active-class="blue-button">{{
+ $t('ManualonePosition2')
+ }}</router-link>
+ <router-link to="/Electrical/AutomaticParameterSetting" tag="el-button" type="text" active-class="blue-button">{{
+ $t('AutomaticParameterSetting')
+ }}</router-link>
+ <router-link to="/Electrical/ManualJog" tag="el-button" type="text" active-class="blue-button">{{
+ $t('ManualJog')
+ }}</router-link>
+ </el-breadcrumb>
+
+ <el-row :gutter="20">
+ <el-col :span="12" v-for="(dataGroup, groupIndex) in jsonData" :key="groupIndex">
+ <el-card class="json-block" style="width:485px;">
+ <div v-for="(item, itemIndex) in dataGroup" :key="itemIndex" class="item-container">
+ <div class="item-row">
+ <span class="name" style="width:100px;">{{ item.name }}</span>
+ <el-input style="width:250px;" v-if="item.state != 0 && item.type === '0'" v-model="item.value"
+ class="input-box"></el-input>
+ </div>
+ </div>
+ <div class="button-row" style="display: flex; justify-content: space-between;">
+ <div v-for="(item, itemIndex) in dataGroup" :key="itemIndex">
+ <el-button v-if="item.button && item.button.state != 0" :name="item.button.name" v-model="item.button.value"
+ :class="{ 'action-button': true, 'error-button': item.button.name === '鏁呴殰' && item.button.value === 1 }"
+ @click="updateButtonValue(dataGroup, itemIndex); submitDataToBackend(item.button.name);">{{
+ item.button.name }}</el-button>
+ </div>
+ </div>
+ </el-card>
+ </el-col>
+ </el-row>
+ <!-- <el-button @click="submitDataToBackend">鎻愪氦鏁版嵁鍒板悗绔�</el-button> -->
+ </div>
+</template>
+
+<script>
+import LanguageMixin from '../../lang/LanguageMixin'
+import data from '../../configuration/Manualoneposition2'
+import { throttle } from 'lodash';
+let socket;
+export default {
+ name: "ManualonePosition2",
+ mixins: [LanguageMixin],
+ data () {
+ return {
+ jsonData: data // 鍔犺浇鏁翠釜data.json鏂囦欢浣滀负jsonData
+ }
+ },
+ created () {
+ this.initWebSocket();
+ // console.log('jsonData:', this.jsonData);
+
+ },
+ methods: {
+ updateButtonValue (dataGroup, itemIndex) {
+ // 灏嗗綋鍓嶆寜閽殑鍊艰涓�1
+
+ this.$set(dataGroup[itemIndex].button, 'value', 1);
+
+
+
+ },
+ submitDataToBackend (currentButtonName) {
+ if (currentButtonName === 'A01缈昏浆鍚姩') {
+ const data = [];
+
+ 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);
+
+ data.push(values);
+ }
+
+
+
+ const jsonObject = { data };
+
+ // 鎻愪氦鏁版嵁鍒板悗绔�
+ const jsonString = JSON.stringify(jsonObject);
+ console.log('鎵�鏈塗ype涓�0鐨剉alue:', jsonString);
+ socket?.send(jsonString);
+
+ }
+
+ if (currentButtonName === 'A02缈昏浆鍚姩') {
+ const data = [];
+
+ for (let i = 1; i < 2; i++) {
+ const inputData = this.jsonData[i].filter(item => item.type === '0').map(item => {
+ return { value: item.value };
+ });
+
+ const values = inputData.map(item => item.value);
+ data.unshift([]);
+ data.push(values);
+ }
+
+
+
+ const jsonObject = { data };
+
+ // 鎻愪氦鏁版嵁鍒板悗绔�
+ const jsonString = JSON.stringify(jsonObject);
+ console.log('鎵�鏈塗ype涓�0鐨剉alue:', jsonString);
+ socket?.send(jsonString);
+
+ }
+
+ if (currentButtonName === '鏁呴殰') {
+
+ const data2 = [];
+ const resetButtonValues = this.jsonData.map(item => {
+ const buttonItem = item.find(subItem => subItem.button && subItem.button.name === '鏁呴殰');
+ return buttonItem ? buttonItem.button.value : null;
+ }).filter(value => value !== null);
+
+ // 灏嗗緱鍒扮殑鍊兼坊鍔犲埌 data 鏁扮粍涓�
+ data2.push(...resetButtonValues);
+ data2.unshift([], []);
+ const jsonObject2 = { data2 };
+
+ // 鎻愪氦鏁版嵁鍒板悗绔�
+ const jsonString2 = JSON.stringify(jsonObject2);
+ console.log('鎵�鏈夋晠闅滅殑value:', jsonString2);
+ socket?.send(jsonString2);
+
+
+ }
+
+ if (currentButtonName === '澶嶄綅') {
+
+ const data2 = [];
+ const resetButtonValues = this.jsonData.map(item => {
+ const buttonItem = item.find(subItem => subItem.button && subItem.button.name === '澶嶄綅');
+ return buttonItem ? buttonItem.button.value : null;
+ }).filter(value => value !== null);
+
+ // 灏嗗緱鍒扮殑鍊兼坊鍔犲埌 data 鏁扮粍涓�
+ data2.push(...resetButtonValues);
+ data2.unshift([], [], []);
+ const jsonObject2 = { data2 };
+
+ // 鎻愪氦鏁版嵁鍒板悗绔�
+ const jsonString2 = JSON.stringify(jsonObject2);
+ console.log('鎵�鏈塗ype涓�0鐨剉alue:', jsonString2);
+ socket?.send(jsonString2);
+
+
+ }
+
+ if (currentButtonName === '鍥為浂') {
+
+ const data2 = [];
+ const resetButtonValues = this.jsonData.map(item => {
+ const buttonItem = item.find(subItem => subItem.button && subItem.button.name === '鍥為浂');
+ return buttonItem ? buttonItem.button.value : null;
+ }).filter(value => value !== null);
+
+ // 灏嗗緱鍒扮殑鍊兼坊鍔犲埌 data 鏁扮粍涓�
+ data2.push(...resetButtonValues);
+ data2.unshift([], [], [], []);
+ const jsonObject2 = { data2 };
+
+ // 鎻愪氦鏁版嵁鍒板悗绔�
+ const jsonString2 = JSON.stringify(jsonObject2);
+ console.log('鎵�鏈塗ype涓�0鐨剉alue:', jsonString2);
+ socket?.send(jsonString2);
+
+
+ }
+
+
+ },
+
+
+ initWebSocket () {
+
+ let viewname = "ManualonePosition2";
+
+ if (typeof WebSocket === "undefined") {
+ console.log("鎮ㄧ殑娴忚鍣ㄤ笉鏀寔WebSocket");
+ } else {
+ let socketUrl = "ws://" + "localhost:8888" + "/springboot-vue3/api/talk/" + viewname;
+
+ if (socket != null) {
+ socket.close();
+ socket = null;
+ }
+
+ // 寮�鍚竴涓獁ebsocket鏈嶅姟
+ socket = new WebSocket(socketUrl);
+
+ // 鎵撳紑浜嬩欢
+ socket.onopen = function () {
+ console.log("websocket宸叉墦寮�");
+ };
+
+ // 鏀跺埌娑堟伅
+ socket.onmessage = (msg) => {
+ if (!msg.data) {
+ return; // 濡傛灉鏀跺埌绌烘暟鎹紝鍒欑洿鎺ヨ繑鍥烇紝涓嶆墽琛屽悗缁�昏緫
+ }
+
+ let obj = JSON.parse(msg.data);
+ // console.log(obj)
+ const jsonData2 = this.jsonData;
+
+ const handleMouseMove = throttle(function (event) {
+ const inputBox = document.querySelectorAll('.el-card__body');
+ const target = event.target;
+ if (inputBox && Array.from(inputBox).every(box => !box.contains(target))) {
+ // 鎵ц鏇存柊閫昏緫
+ for (let i = 0; i < 2; i++) {
+ jsonData2[i].forEach((item, index) => {
+ if (typeof item.value !== 'undefined' && typeof obj[`zuhe${i + 1}`][0][index] !== 'undefined') {
+ item.value = obj[`zuhe${i + 1}`][0][index];
+ }
+ });
+ }
+
+ jsonData2.forEach((item) => {
+ item.forEach((subItem) => {
+ if (subItem.sending === 4) {
+ subItem.value = obj.shishi1[0][0];
+ }
+ if (subItem.sending === 5) {
+ subItem.value = obj.shishi1[0][1];
+ }
+ if (subItem.sending === 6) {
+ subItem.value = obj.shishi1[0][2];
+ }
+ if (subItem.sending === 7) {
+ subItem.value = obj.shishi1[0][3];
+ }
+ });
+ });
+
+ // 閬嶅巻guzhang鏁扮粍
+ for (let i = 0; i < obj.guzhang[0].length; i++) {
+ const guzhangValue = obj.guzhang[0][i];
+
+ // 鏌ユ壘jsonData2涓甫鏈�"button"鐨勫璞★紝骞朵笖name绛変簬"鏁呴殰"
+ for (let j = 0; j < jsonData2.length; j++) {
+ const section = jsonData2[j];
+
+ for (let k = 0; k < section.length; k++) {
+ const item = section[k];
+
+ if (item.button && item.button.name === "鏁呴殰") {
+ // 鏇存柊value灞炴��
+ item.button.value = guzhangValue;
+ break;
+ }
+ }
+
+
+ }
+ }
+
+
+
+
+ }
+ }, 200);
+
+ document.addEventListener('mouseover', handleMouseMove);
+ };
+
+
+
+
+ // 鍏抽棴浜嬩欢
+ socket.onclose = function () {
+ console.log("websocket宸插叧闂�");
+ };
+
+ // 鍙戠敓閿欒浜嬩欢
+ socket.onerror = function () {
+ console.log("websocket鍙戠敓浜嗛敊璇�");
+ };
+
+ }
+ },
+ send () {
+
+
+ socket?.send(JSON.stringify(this.messagepack));
+ }
+
+ }
+}
+</script>
+
+<style scoped>
+.item-row {
+ display: flex;
+ align-items: center;
+ margin-bottom: 2px;
+ /* 璋冩暣姣忎釜椤圭洰涔嬮棿鐨勯棿璺� */
+}
+
+.action-button {
+ margin-right: 10px;
+ background: #66b1ff;
+ color: #FFF;
+}
+
+.blue-button {
+ background-color: skyblue;
+}
</style>
\ No newline at end of file
diff --git a/CanadaMes-ui/src/views/Electrical/Parameter.vue b/CanadaMes-ui/src/views/Electrical/Parameter.vue
index 94a34d4..0cbb804 100644
--- a/CanadaMes-ui/src/views/Electrical/Parameter.vue
+++ b/CanadaMes-ui/src/views/Electrical/Parameter.vue
@@ -12,26 +12,26 @@
}}</router-link>
<router-link to="/Electrical/Sign" tag="el-button" type="text" active-class="blue-button">{{ $t('Sign')
}}</router-link>
- <router-link to="/Electrical/Servomanual" tag="el-button" type="text" active-class="blue-button">{{
- $t('ServoManual')
- }}</router-link>
+ <router-link to="/Electrical/Servomanual" tag="el-button" type="text" active-class="blue-button">{{ $t('Servo Manual')
+ }}</router-link>
</el-breadcrumb>
<div>Parameter</div>
<el-form label-width="100px" style="display: flex; flex-wrap: wrap;" :model="messagepack.data">
<div id="btn_div">
- <el-button type="primary" @click="send()" id="xiafa" :disabled="isButtonDisabled">{{ $t('Distribute parameters')
- }}</el-button>
+ <!-- <el-button type="primary" @click="send()" id="xiafa" :disabled="isButtonDisabled">{{ $t('Distribute parameters')
+ }}</el-button> -->
</div>
- <div class="kuai_div" v-for="(item, index) in record.xyData" :key="index">
+ <div class="kuai_div" v-for="(item, index) in jsonData" :key="index">
<el-input style="width: 280px; border:none;" class="in_mc" v-model="item.name" readonly></el-input>
-
- <span style="margin-right: 5px; width: 50px;">{{ item.value }}</span>
- <span style="margin-right: 5px; font-size: 14px;color: red;">|</span>
- <input type="number" style="width: 43px; margin-right: 5px; margin-top: 5px; font-size: 16px;">
- <span style="margin-right: 5px; width: 50px;">{{ item.unit }}</span>
+ <!-- <span style="margin-right: 5px; width: 50px;">{{ item.value }}</span> -->
+ <!-- <span style="margin-right: 5px; font-size: 14px;color: red;">|</span> -->
+ <el-input v-model="item.value" type="number"
+ style="width: 143px; margin-right: 5px; margin-top: 5px; font-size: 16px;border:none" class="input-box"
+ @keyup.enter.native="send"></el-input>
+ <span style="margin-right: 5px; width: 50px;" >{{ item.unit }}</span>
</div>
</el-form>
@@ -47,22 +47,18 @@
let socket;
import LanguageMixin from '../../lang/LanguageMixin'
import data from '../../configuration/Parameter'
+import { throttle } from 'lodash';
export default {
name: "Parameter",
mixins: [LanguageMixin],
data () {
return {
jsonData: data,
+
dialogVisible: true,
password: '',
activeButton: '',
- record: {
- params: [100, 200, 10, 10, 10, 10],
- xyData: [
-
- ],
- canshu: []
- },
+
messagepack: {
data: { taskname: "" }
},
@@ -78,9 +74,12 @@
this.initWebSocket();
this.isButtonDisabled = true;
-
},
methods: {
+ showdata () {
+
+
+ },
setActiveButton (buttonName) {
@@ -114,41 +113,39 @@
}
let obj = JSON.parse(msg.data);
-
-
+ // console.log(obj);
+ const jsonData2=this.jsonData;
+ // console.log(jsonData2);
+ const handleMouseMove = throttle(function (event) {
+ const inputBox = document.querySelectorAll('.input-box');
+ const target = event.target;
+ if (inputBox && Array.from(inputBox).every(box => !box.contains(target))) {
if (obj.params && obj.state) {
-
- this.record.params[0] = obj.params[0];
- this.record.state = obj.state[0];
+
if (obj.state && obj.state.length > 0) {
- let isButtonDisabled = this.record.state.includes(1);
- this.isButtonDisabled = isButtonDisabled;
+
+// console.log( Array.isArray(jsonData2));
+
+
+// 灏� obj 涓殑 params 鍊兼洿鏂板埌 jsonData 涓殑 value 涓�
+for (let i = 0; i < obj.params[0].length; i++) {
+ jsonData2[i].value = obj.params[0][i];
+}
- this.record.xyData = this.jsonData.para;
-
- for (let a = 0; a < this.record.xyData.length; a++) {
- this.record.xyData[a].value = this.record.params[0][a];
-
- }
-
- this.record.xyData = this.jsonData.para.filter(item => {
- return item.state != 0;
- }
-
- );
- const language = this.$i18n.locale;
- if (language === 'en-US') {
- this.replaceChineseWithEnglish();
- } else {
- this.localizedRoles = [...this.record.xyData];
- }
+
+
}
}
- this.$forceUpdate();
- this.replaceChineseWithEnglish();
- };
+ // this.$forceUpdate();
+ // this.replaceChineseWithEnglish();
+ }
+ }, 200);
+
+document.addEventListener('mouseover', handleMouseMove);
+
+};
// 鍏抽棴浜嬩欢
socket.onclose = function () {
@@ -162,8 +159,8 @@
}
},
send () {
- this.messagepack.data = this.record.xyData.map((item) => parseInt(item.value2)); // 杞崲涓烘暣鏁版暟缁�
- //console.log(this.messagepack);
+ this.messagepack.data = this.jsonData.map((item) => parseInt(item.value)); // 杞崲涓烘暣鏁版暟缁�
+ console.log(this.messagepack);
socket?.send(JSON.stringify(this.messagepack));
},
handleChange (index, value) {
@@ -172,7 +169,7 @@
//璇█杞崲
replaceChineseWithEnglish () {
const translation = this.$t('langparameter');
- this.record.xyData = this.record.xyData.map(item => { return { name: translation[item.name] || item.name, value: item.value, unit: item.unit }; });
+ this.jsonData.para = this.jsonData.para.map(item => { return { name: translation[item.name] || item.name, value: item.value, unit: item.unit }; });
//console.log(translation);
},
}
@@ -189,8 +186,10 @@
border: 1px solid black;
border: none;
}
+.special-class{
-.special-class {}
+
+}
.in_mc {
diff --git a/CanadaMes-ui/src/views/Electrical/Parameter2.vue b/CanadaMes-ui/src/views/Electrical/Parameter2.vue
index b067527..8856286 100644
--- a/CanadaMes-ui/src/views/Electrical/Parameter2.vue
+++ b/CanadaMes-ui/src/views/Electrical/Parameter2.vue
@@ -64,6 +64,9 @@
import data from '../../configuration/parameter2'
let socket;
export default {
+ destroyed() {
+ socket.close();
+ },
name: "Parameter2",
mixins: [LanguageMixin],
data() {
@@ -232,6 +235,7 @@
socket.onerror = function () {
console.log("websocket鍙戠敓浜嗛敊璇�");
};
+
}
},
@@ -269,7 +273,7 @@
background-color: red;
}
.yellow-button{
- background-color: yellow;
+ background-color: blue;
}
</style>
\ No newline at end of file
diff --git a/CanadaMes-ui/src/views/Electrical/ServoManualone.vue b/CanadaMes-ui/src/views/Electrical/ServoManualone.vue
index 0029ba5..dbee303 100644
--- a/CanadaMes-ui/src/views/Electrical/ServoManualone.vue
+++ b/CanadaMes-ui/src/views/Electrical/ServoManualone.vue
@@ -60,10 +60,12 @@
import LanguageMixin from '../../lang/LanguageMixin'
import data from '../../configuration/ServoManualone'
import { throttle } from 'lodash';
+
let socket;
export default {
name: "ServoManualone",
mixins: [LanguageMixin],
+
data() {
return {
jsonData: data ,
@@ -76,7 +78,9 @@
// console.log('jsonData:', this.jsonData);
},
+
methods: {
+
updateButtonValue(dataGroup, itemIndex) {
// 灏嗗綋鍓嶆寜閽殑鍊艰涓�1
@@ -238,7 +242,7 @@
}
let obj = JSON.parse(msg.data);
- // console.log(obj)
+ console.log(obj)
const jsonData2 = this.jsonData;
const handleMouseMove = throttle(function(event) {
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
new file mode 100644
index 0000000..23ac20d
--- /dev/null
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/PLCManualJog.java
@@ -0,0 +1,173 @@
+package com.example.springboot.component;
+
+import cn.hutool.json.JSONArray;
+import cn.hutool.json.JSONObject;
+import org.apache.commons.io.FileUtils;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class PLCManualJog extends Thread {
+ String name = "";
+ Integer count = 0;
+
+ public static String readFileToString(String filePath) throws IOException {
+ File file = new File(filePath);
+ return FileUtils.readFileToString(file, "UTF-8");
+ }
+
+ public void readValue() {
+ String str = "";
+ BufferedReader bufferedReader = null;
+ FileInputStream fileInputStream;
+ try {
+ // 浠庢枃浠朵腑璇诲彇瀛楄妭鏁版嵁瀛樺叆 fileInputStream
+ fileInputStream = new FileInputStream("CanadaMes-ui/src/configuration/address.json");
+ // 璇诲彇 fileInputStream 涓瓧鑺傚苟灏嗗叾瑙g爜涓哄瓧绗�
+ InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "utf-8");
+ // 鎻愰珮璇诲彇鏁堢巼锛屽湪 BufferedReader 鍐呭寘瑁� InputStreamReader
+ bufferedReader = new BufferedReader(inputStreamReader);
+ String line = null;
+ // 灏� bufferedReader 鍐呭涓�琛屼竴琛岃祴鍊肩粰str
+ while ((line = bufferedReader.readLine()) != null) {
+ str += line;
+ }
+
+ // 灏唖tr瀛楃涓叉牸寮忚浆涓簀son
+ JSONObject jsonObject = new JSONObject(str);
+
+ // 鑾峰彇json涓殑鍊�
+ JSONArray address = jsonObject.getJSONArray("address");
+ for (int i = 0; i < address.size(); i++) {
+ JSONObject ress = (JSONObject) address.get(i);
+
+ this.name = ress.getStr("name");
+ this.count = ress.getInt("count");
+
+ }
+
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void run() {
+ while (this != null) {
+ try {
+ Thread.sleep(500);
+
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ // this.readValue();
+ // String PlcAddress = this.name;
+ // Integer Plccount = this.count;
+
+ // System.out.println(stt);
+ List<Boolean> arraylist = S7control.getinstance().ReadBits("DB101.0.0", 16);
+ List<Boolean> arraylist2 = S7control.getinstance().ReadBits("DB101.2.6", 8);
+ List<Boolean> arraylist3 = S7control.getinstance().ReadBits("DB101.5.2", 2);
+ // Boolean[] values1 = { false, true, true, true, false, false, true, false,
+ // false, true, true, true, false, false,
+ // true, false };
+ // List<Boolean> arraylist = new ArrayList<>(Arrays.asList(values1));
+ // Boolean[] values2 = { false, true, true, true, false, false, true, false };
+ // List<Boolean> arraylist2 = new ArrayList<>(Arrays.asList(values2));
+ // Boolean[] values3 = { false, false };
+ // List<Boolean> arraylist3 = new ArrayList<>(Arrays.asList(values3));
+
+ arraylist.addAll(arraylist2);
+ arraylist.addAll(arraylist3);
+
+ JSONObject jsonObject = new JSONObject();
+
+ short[] params = new short[arraylist.size()];
+ for (int i = 0; i < arraylist.size(); i++) {
+ boolean value = arraylist.get(i);
+ params[i] = value ? (short) 1 : (short) 0;
+ }
+
+ jsonObject.append("params", params);
+
+ WebSocketServer sendwServer = WebSocketServer.sessionMap.get("ManualJog");
+ if (sendwServer != null) {
+ sendwServer.sendMessage(jsonObject.toString());
+ }
+
+ WebSocketServer webSocketServer = WebSocketServer.sessionMap.get("ManualJog");
+
+ if (webSocketServer != null) {
+ String addressList1 = "DB101.0.0";
+ String addressList2 = "DB101.2.6";
+ String addressList3 = "DB101.5.2";
+
+ List<String> messages = webSocketServer.getMessages();
+ if (!messages.isEmpty()) {
+ // 灏嗘渶鍚庝竴涓秷鎭浆鎹负鏁存暟绫诲瀷鐨勫垪琛�
+ String lastMessage = messages.get(messages.size() - 1);
+ // System.out.println("messages锛�" + messages);
+ String[] parts = lastMessage.split(",");
+ List<Integer> messageValues = new ArrayList<>();
+ for (String part : parts) {
+ try {
+ // 浣跨敤姝e垯琛ㄨ揪寮忔竻闄ら潪鏁板瓧瀛楃
+ String cleanedPart = part.replaceAll("[^0-9-]", "");
+ Integer value = Integer.parseInt(cleanedPart.trim());
+ messageValues.add(value);
+ } catch (NumberFormatException e) {
+ // 濡傛灉鏃犳硶瑙f瀽涓烘暣鏁扮被鍨嬶紝鍒欏拷鐣ヨ閮ㄥ垎
+ // e.printStackTrace();
+ }
+
+ }
+ // 灏嗘秷鎭�艰浆鎹负甯冨皵鍒楄〃
+ List<Boolean> messageBooleans = new ArrayList<>();
+ for (Integer value : messageValues) {
+ messageBooleans.add(value == 1 ? true : false);
+ }
+ // System.out.println(messageBooleans);
+ List<Boolean> bolList = new ArrayList<>();
+ List<Boolean> bolList2 = new ArrayList<>();
+ List<Boolean> bolList3 = new ArrayList<>();
+
+ for (int i = 0; i < 16 && i < messageBooleans.size(); i++) {
+ bolList.add(messageBooleans.get(i));
+ }
+
+ for (int i = 16; i < 24 && i < messageBooleans.size(); i++) {
+ bolList2.add(messageBooleans.get(i));
+ }
+
+ for (int i = 24; i < 26 && i < messageBooleans.size(); i++) {
+ bolList3.add(messageBooleans.get(i));
+ }
+
+ // System.out.println(bolList);
+ // System.out.println(bolList2);
+ // System.out.println(bolList3);
+ if (!bolList.isEmpty()) {
+ S7control.getinstance().WriteBit(addressList1, bolList);
+ System.out.println("messageValue锛�" + bolList + " written to PLC at address " + addressList1);
+ }
+ if (!bolList2.isEmpty()) {
+ S7control.getinstance().WriteBit(addressList2, bolList2);
+ System.out.println("messageValue锛�" + bolList2 + " written to PLC at address " + addressList2);
+ }
+ if (!bolList3.isEmpty()) {
+ S7control.getinstance().WriteBit(addressList3, bolList3);
+ System.out.println("messageValue锛�" + bolList3 + " written to PLC at address " + addressList3);
+ }
+ }
+
+ }
+
+ }
+ }
+}
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 d0351de..49566c2 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
@@ -39,7 +39,7 @@
JSONObject jsonObject = new JSONObject(str);
// 鑾峰彇json涓殑鍊�
- JSONArray address = jsonObject.getJSONArray("ServoManualone");
+ JSONArray address = jsonObject.getJSONArray("ManualonePosition");
for (int i = 0; i < address.size(); i++) {
JSONObject ress = (JSONObject) address.get(i);
@@ -75,7 +75,7 @@
addresses.add("DB100.20");
addresses.add("DB103.52");
List<Short> arraylist = S7control.getinstance().readWords(addresses);
- // System.out.println(arraylist);
+// System.out.println(arraylist);
List<String> addresses2 = new ArrayList<>();
addresses2.add("DB100.110");
@@ -100,13 +100,19 @@
List<Short> arraylist7 = S7control.getinstance().ReadWord("DB103.48", 1);
List<Short> arraylist8 = S7control.getinstance().ReadWord("DB103.50", 1);
List<String> addresses9 = new ArrayList<>();
- addresses9.add("DB104.24");
- addresses9.add("DB104.26");
- addresses9.add("DB104.20");
- addresses9.add("DB104.22");
- addresses9.add("DB104.28");
- addresses9.add("DB104.30");
- List<Short> arraylist9 = S7control.getinstance().readWords(addresses9);
+ addresses9.add("DB104.1.2");
+ addresses9.add("DB104.1.3");
+ addresses9.add("DB104.1.6");
+ addresses9.add("DB104.1.7");
+// addresses9.add("DB104.28");
+// addresses9.add("DB104.30");
+ List<Boolean> arraylist9 = S7control.getinstance().readBits(addresses9);
+ short[] params2 = new short[arraylist9.size()];
+ for (int i = 0; i < arraylist9.size(); i++) {
+ boolean value = arraylist9.get(i);
+ params2[i] = value ? (short) 1 : (short) 0;
+ }
+// List<Short> arraylist9 = S7control.getinstance().readWords(addresses9);
arraylist5.addAll(arraylist6);
arraylist5.addAll(arraylist7);
arraylist5.addAll(arraylist8);
@@ -118,7 +124,7 @@
jsonObject.append("zuhe3", arraylist3);
jsonObject.append("zuhe4", arraylist4);
jsonObject.append("shishi1", arraylist5);
- jsonObject.append("guzhang", arraylist9);
+ jsonObject.append("guzhang", params2);
// jsonObject.append("weihuiling", arraylist8);
WebSocketServer sendwServer = WebSocketServer.sessionMap.get("ManualonePosition");
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
new file mode 100644
index 0000000..f5da68d
--- /dev/null
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/PlcManualonePosition2.java
@@ -0,0 +1,281 @@
+package com.example.springboot.component;
+
+import cn.hutool.json.JSONArray;
+import cn.hutool.json.JSONObject;
+import org.apache.commons.io.FileUtils;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class PlcManualonePosition2 extends Thread {
+ String name = "";
+ Integer count = 0;
+
+ public static String readFileToString(String filePath) throws IOException {
+ File file = new File(filePath);
+ return FileUtils.readFileToString(file, "UTF-8");
+ }
+
+ public void readValue() {
+ String str = "";
+ BufferedReader bufferedReader = null;
+ FileInputStream fileInputStream;
+ try {
+ // 浠庢枃浠朵腑璇诲彇瀛楄妭鏁版嵁瀛樺叆 fileInputStream
+ fileInputStream = new FileInputStream("CanadaMes-ui/src/configuration/address.json");
+ // 璇诲彇 fileInputStream 涓瓧鑺傚苟灏嗗叾瑙g爜涓哄瓧绗�
+ InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "utf-8");
+ // 鎻愰珮璇诲彇鏁堢巼锛屽湪 BufferedReader 鍐呭寘瑁� InputStreamReader
+ bufferedReader = new BufferedReader(inputStreamReader);
+ String line = null;
+ // 灏� bufferedReader 鍐呭涓�琛屼竴琛岃祴鍊肩粰str
+ while ((line = bufferedReader.readLine()) != null) {
+ str += line;
+ }
+
+ // 灏唖tr瀛楃涓叉牸寮忚浆涓簀son
+ JSONObject jsonObject = new JSONObject(str);
+
+ // 鑾峰彇json涓殑鍊�
+ JSONArray address = jsonObject.getJSONArray("ServoManualone");
+ for (int i = 0; i < address.size(); i++) {
+ JSONObject ress = (JSONObject) address.get(i);
+
+ this.name = ress.getStr("name");
+ this.count = ress.getInt("count");
+
+ }
+
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void run() {
+ while (this != null) {
+ try {
+ Thread.sleep(500);
+
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ // this.readValue();
+ // String PlcAddress = this.name;
+ // Integer Plccount = this.count;
+
+ List<String> addresses = new ArrayList<>();
+ addresses.add("DB100.16");
+ addresses.add("DB100.116");
+ addresses.add("DB103.20");
+ List<Short> arraylist = S7control.getinstance().readWords(addresses);
+// System.out.println(arraylist);
+
+ List<String> addresses2 = new ArrayList<>();
+ addresses2.add("DB100.192");
+ addresses2.add("DB100.118");
+ addresses2.add("DB103.22");
+ List<Short> arraylist2 = S7control.getinstance().readWords(addresses2);
+
+ List<String> addresses9 = new ArrayList<>();
+
+
+
+ addresses9.add("DB104.1.2");
+ addresses9.add("DB104.1.3");
+ List<Boolean> arraylist9 = S7control.getinstance().readBits(addresses9);
+ short[] params2 = new short[arraylist9.size()];
+ for (int i = 0; i < arraylist9.size(); i++) {
+ boolean value = arraylist9.get(i);
+ params2[i] = value ? (short) 1 : (short) 0;
+ }
+
+ JSONObject jsonObject = new JSONObject();
+ // System.out.println(arraylist);
+ jsonObject.append("zuhe1", arraylist);
+ jsonObject.append("zuhe2", arraylist2);
+ jsonObject.append("guzhang", params2);
+ // jsonObject.append("weihuiling", arraylist8);
+
+ WebSocketServer sendwServer = WebSocketServer.sessionMap.get("ManualonePosition2");
+ if (sendwServer != null) {
+ sendwServer.sendMessage(jsonObject.toString());
+ }
+
+ WebSocketServer webSocketServer = WebSocketServer.sessionMap.get("ManualonePosition2");
+ if (webSocketServer != null) {
+ List<String> messages = webSocketServer.getMessages();
+ List<String> waddresses1 = new ArrayList<>();
+ waddresses1.add("DB100.108");
+ waddresses1.add("DB100.20");
+ waddresses1.add("DB103.52");
+
+ List<String> waddresses2 = new ArrayList<>();
+ waddresses2.add("DB100.110");
+ waddresses2.add("DB100.176");
+ waddresses2.add("DB103.54");
+
+ // 鏁呴殰鍦板潃
+ List<String> waddresses3 = new ArrayList<>();
+ waddresses3.add("DB103.242");
+ waddresses3.add("DB103.248");
+
+ // 澶嶄綅鍦板潃
+ List<String> waddresses4 = new ArrayList<>();
+ waddresses4.add("DB101.3.6");
+ waddresses4.add("DB101.4.1");
+
+ // 鍥為浂鍦板潃
+ List<String> waddresses5 = new ArrayList<>();
+ waddresses5.add("DB101.3.7");
+ waddresses5.add("DB101.4.2");
+
+ if (!messages.isEmpty()) {
+ // 灏嗘渶鍚庝竴涓秷鎭浆鎹负 short 绫诲瀷鐨勫垪琛�
+ String lastMessage = messages.get(messages.size() - 1);
+ // System.out.println("lastMessage锛�" + lastMessage);
+ JSONArray messageArray = new JSONArray(lastMessage);
+
+ // A01涓嬪彂
+ if (messageArray.getJSONArray(0).size() > 0) {
+ JSONArray jsonArray = messageArray.getJSONArray(0);
+ List<Short> sValue = new ArrayList<>();
+ for (int i = 0; i < jsonArray.size(); i++) {
+ Object value = jsonArray.get(i);
+ if (value != null && !value.toString().equals("null")) {
+ try {
+ String cleanedValue = value.toString().replaceAll("[^0-9-]", "");
+ short val = Short.parseShort(cleanedValue.trim());
+ sValue.add(val);
+ System.out.println("messageValue锛�" + Arrays.asList(val) + " added to the list");
+ } catch (NumberFormatException e) {
+ // 濡傛灉鏃犳硶瑙f瀽涓� short 绫诲瀷锛屽垯蹇界暐璇ラ儴鍒�
+ System.err.println("Could not parse value: " + value);
+ }
+ }
+ }
+ if (!sValue.isEmpty()) {
+ S7control.getinstance().WriteWord(waddresses1, sValue);
+ System.out.println("Values " + sValue + " written to PLC at address " + waddresses1);
+ }
+ }
+
+ // A02涓嬪彂
+ if (messageArray.getJSONArray(1).size() > 0) {
+ JSONArray jsonArray = messageArray.getJSONArray(1);
+ List<Short> sValue2 = new ArrayList<>();
+ for (int i = 0; i < jsonArray.size(); i++) {
+ Object value = jsonArray.get(i);
+ if (value != null && !value.toString().equals("null")) {
+ try {
+ String cleanedValue = value.toString().replaceAll("[^0-9-]", "");
+ short val = Short.parseShort(cleanedValue.trim());
+ sValue2.add(val);
+ System.out.println("messageValue锛�" + Arrays.asList(val) + " added to the list");
+ } catch (NumberFormatException e) {
+ // 濡傛灉鏃犳硶瑙f瀽涓� short 绫诲瀷锛屽垯蹇界暐璇ラ儴鍒�
+ System.err.println("Could not parse value: " + value);
+ }
+ }
+ }
+ if (!sValue2.isEmpty()) {
+ S7control.getinstance().WriteWord(waddresses2, sValue2);
+ System.out.println("Values " + sValue2 + " written to PLC at address " + waddresses2);
+ }
+ }
+
+ // 鍐欏叆鏁呴殰鍦板潃
+ if (messageArray.getJSONArray(2).size() > 0) {
+ JSONArray jsonArray = messageArray.getJSONArray(2);
+ List<Short> sValue2 = new ArrayList<>();
+ for (int i = 0; i < jsonArray.size(); i++) {
+ Object value = jsonArray.get(i);
+ if (value != null && !value.toString().equals("null")) {
+ try {
+ String cleanedValue = value.toString().replaceAll("[^0-9-]", "");
+ short val = Short.parseShort(cleanedValue.trim());
+ sValue2.add(val);
+ System.out.println("messageValue锛�" + Arrays.asList(val) + " added to the list");
+ } catch (NumberFormatException e) {
+ // 濡傛灉鏃犳硶瑙f瀽涓� short 绫诲瀷锛屽垯蹇界暐璇ラ儴鍒�
+ System.err.println("Could not parse value: " + value);
+ }
+ }
+ }
+ if (!sValue2.isEmpty()) {
+ S7control.getinstance().WriteWord(waddresses3, sValue2);
+ System.out.println("Values " + sValue2 + " written to PLC at address " + waddresses3);
+ }
+ }
+
+ // 鍐欏叆澶嶄綅鍦板潃
+ if (messageArray.getJSONArray(3).size() > 0) {
+ JSONArray jsonArray = messageArray.getJSONArray(3);
+ List<Short> sValue2 = new ArrayList<>();
+ List<Boolean> messageBooleans = new ArrayList<>();
+ for (int i = 0; i < jsonArray.size(); i++) {
+ Object value = jsonArray.get(i);
+ if (value != null && !value.toString().equals("null")) {
+ try {
+ String cleanedValue = value.toString().replaceAll("[^0-9-]", "");
+ short val = Short.parseShort(cleanedValue.trim());
+ sValue2.add(val);
+ // 灏嗘秷鎭�艰浆鎹负甯冨皵鍒楄〃
+ for (short values : sValue2) {
+ messageBooleans.add(values == 1 ? true : false);
+ }
+ System.out.println("messageValue锛�" + Arrays.asList(val) + " added to the list");
+ } catch (NumberFormatException e) {
+ // 濡傛灉鏃犳硶瑙f瀽涓� short 绫诲瀷锛屽垯蹇界暐璇ラ儴鍒�
+ System.err.println("Could not parse value: " + value);
+ }
+ }
+ }
+ if (!messageBooleans.isEmpty()) {
+ S7control.getinstance().WriteBit(waddresses4, messageBooleans);
+ System.out.println("Values " + messageBooleans + " written to PLC at address " + waddresses4);
+ }
+ }
+
+ // 鍐欏叆鍥為浂鍦板潃
+ if (messageArray.getJSONArray(4).size() > 0) {
+ JSONArray jsonArray = messageArray.getJSONArray(4);
+ List<Short> sValue2 = new ArrayList<>();
+ List<Boolean> messageBooleans = new ArrayList<>();
+ for (int i = 0; i < jsonArray.size(); i++) {
+ Object value = jsonArray.get(i);
+ if (value != null && !value.toString().equals("null")) {
+ try {
+ String cleanedValue = value.toString().replaceAll("[^0-9-]", "");
+ short val = Short.parseShort(cleanedValue.trim());
+ sValue2.add(val);
+ // 灏嗘秷鎭�艰浆鎹负甯冨皵鍒楄〃
+ for (short values : sValue2) {
+ messageBooleans.add(values == 1 ? true : false);
+ }
+ System.out.println("messageValue锛�" + Arrays.asList(val) + " added to the list");
+ } catch (NumberFormatException e) {
+ // 濡傛灉鏃犳硶瑙f瀽涓� short 绫诲瀷锛屽垯蹇界暐璇ラ儴鍒�
+ System.err.println("Could not parse value: " + value);
+ }
+ }
+ }
+ if (!messageBooleans.isEmpty()) {
+ S7control.getinstance().WriteBit(waddresses5, messageBooleans);
+ System.out.println("Values " + messageBooleans + " written to PLC at address " + waddresses5);
+ }
+ }
+
+ // 娓呯┖娑堟伅鍒楄〃
+ webSocketServer.clearMessages();
+ }
+ }
+ }
+ }
+}
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter.java b/springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter.java
index 08e7f66..0399888 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter.java
@@ -73,18 +73,18 @@
} catch (InterruptedException e) {
e.printStackTrace();
}
- this.readValue();
- String PlcAddress = this.name;
- Integer Plccount = this.count;
+// this.readValue();
+// String PlcAddress = this.name;
+// Integer Plccount = this.count;
// System.out.println(stt);
- // List<Short> arraylist = S7control.getinstance().ReadWord("DB100.0", 12);
- // List<Short> state = S7control.getinstance().ReadWord("DB103.0", 10);
- Short[] values1 = { 1231, 1, 1, 1, 1, 1, 2, 33, 2, 3, 4, 5 };
- List<Short> arraylist = new ArrayList<>(Arrays.asList(values1));
+ List<Short> arraylist = S7control.getinstance().ReadWord("DB100.0", 72);
+ List<Short> state = S7control.getinstance().ReadWord("DB103.0", 10);
+// Short[] values1 = { 1231, 1, 1, 1, 1, 1, 2, 33, 2, 3, 4, 5 ,1231, 1, 1, 1, 1, 1, 2, 33, 2, 3, 4, 5 };
+// List<Short> arraylist = new ArrayList<>(Arrays.asList(values1));
- Short[] values2 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- List<Short> state = new ArrayList<>(Arrays.asList(values2));
+// Short[] values2 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+// List<Short> state = new ArrayList<>(Arrays.asList(values2));
// Boolean[] values = { false, true, true, true, true, true, true, true, true,
// true, true, true, true, true, true, true, true, true, true, true, true, true,
@@ -137,7 +137,7 @@
}
// 灏嗘秷鎭�煎啓鍏� PLC
- // S7control.getinstance().WriteWord(addressList, messageValues);
+ S7control.getinstance().WriteWord(addressList, messageValues);
System.out.println("messageValues锛�" + messageValues);
System.out.println("addressList锛�" + addressList);
// 娓呯┖娑堟伅鍒楄〃
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter1.java b/springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter1.java
index d1518f6..e2fa2b8 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter1.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter1.java
@@ -71,9 +71,23 @@
// Integer Plccount = this.count;
// System.out.println(stt);
- List<Short> arraylist = S7control.getinstance().ReadWord("DB100.0", 12);
- List<Short> fanzhuan1 = S7control.getinstance().ReadWord("DB100.8", 1);
- List<Short> xiaoche1 = S7control.getinstance().ReadWord("DB100.12", 1);
+ List<String> addresses = new ArrayList<>();
+ addresses.add("DB100.0");
+ addresses.add("DB100.2");
+ addresses.add("DB100.4");
+ addresses.add("DB100.6");
+ addresses.add("DB100.26");
+ addresses.add("DB100.28");
+ addresses.add("DB100.30");
+ addresses.add("DB100.32");
+ addresses.add("DB100.34");
+ addresses.add("DB100.36");
+ addresses.add("DB100.38");
+ addresses.add("DB100.40");
+ List<Short> arraylist = S7control.getinstance().readWords(addresses);
+
+ List<Short> fanzhuan1 = S7control.getinstance().ReadWord("DB100.8", 1);
+ List<Short> xiaoche1 = S7control.getinstance().ReadWord("DB100.12", 1);
// Short[] values1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
// List<Short> arraylist = new ArrayList<>(Arrays.asList(values1));
// Short[] fanzhuan = { 4 };
@@ -86,8 +100,8 @@
// new short[]{0,0, 0, 0, 0, 0, 0, 0, 0, 0}
jsonObject.append("params", arraylist);
- jsonObject.append("fanzhuan", fanzhuan1);
- jsonObject.append("xiaoche", xiaoche1);
+ jsonObject.append("fanzhuan", fanzhuan1);
+ jsonObject.append("xiaoche", xiaoche1);
WebSocketServer sendwServer = WebSocketServer.sessionMap.get("Parameter1");
if (sendwServer != null) {
@@ -97,7 +111,20 @@
WebSocketServer webSocketServer = WebSocketServer.sessionMap.get("Parameter1");
if (webSocketServer != null) {
List<String> messages = webSocketServer.getMessages();
- String addressList1 = "DB100.0";
+ List<String> waddresses1 = new ArrayList<>();
+ waddresses1.add("DB100.0");
+ waddresses1.add("DB100.2");
+ waddresses1.add("DB100.4");
+ waddresses1.add("DB100.6");
+ waddresses1.add("DB100.26");
+ waddresses1.add("DB100.28");
+ waddresses1.add("DB100.30");
+ waddresses1.add("DB100.32");
+ waddresses1.add("DB100.34");
+ waddresses1.add("DB100.36");
+ waddresses1.add("DB100.38");
+ waddresses1.add("DB100.40");
+
String addressList2 = "DB100.8";
String addressList3 = "DB100.12";
@@ -133,9 +160,9 @@
try {
String cleanedValue = value.toString().replaceAll("[^0-9-]", "");
short sValue = Short.parseShort(cleanedValue.trim());
- S7control.getinstance().WriteWord(addressList1, Arrays.asList(sValue));
+ S7control.getinstance().WriteWord(addressList2, Arrays.asList(sValue));
System.out
- .println("messageValue锛�" + Arrays.asList(sValue) + " written to PLC at address " + addressList3);
+ .println("messageValue锛�" + Arrays.asList(sValue) + " written to PLC at address " + addressList2);
} catch (NumberFormatException e) {
// 濡傛灉鏃犳硶瑙f瀽涓� short 绫诲瀷锛屽垯蹇界暐璇ラ儴鍒�
System.err.println("Could not parse value: " + value);
@@ -150,9 +177,9 @@
try {
String cleanedValue = value.toString().replaceAll("[^0-9-]", "");
short sValue = Short.parseShort(cleanedValue.trim());
- S7control.getinstance().WriteWord(addressList2, Arrays.asList(sValue));
+ S7control.getinstance().WriteWord(addressList3, Arrays.asList(sValue));
System.out
- .println("messageValue锛�" + Arrays.asList(sValue) + " written to PLC at address " + addressList2);
+ .println("messageValue锛�" + Arrays.asList(sValue) + " written to PLC at address " + addressList3);
} catch (NumberFormatException e) {
// 濡傛灉鏃犳硶瑙f瀽涓� short 绫诲瀷锛屽垯蹇界暐璇ラ儴鍒�
System.err.println("Could not parse value: " + value);
@@ -162,8 +189,8 @@
// 鍐欏叆绗笁涓湴鍧�
if (!mergedList.isEmpty()) {
- S7control.getinstance().WriteWord(addressList3, mergedList);
- System.out.println("messageValue锛�" + mergedList + " written to PLC at address " + addressList1);
+ S7control.getinstance().WriteWord(waddresses1, mergedList);
+ System.out.println("messageValue锛�" + mergedList + " written to PLC at address " + waddresses1);
}
// 娓呯┖娑堟伅鍒楄〃
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 feefee3..59124ce 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
@@ -80,17 +80,19 @@
// addressList1.add("DB103.172~185");
// addressList1.add("DB103.200~213");
// addressList1.add("DB103.228~241");
- addressList1.add("DB103.40");
- addressList1.add("DB103.58");
- addressList1.add("DB103.72");
- addressList1.add("DB103.86");
- addressList1.add("DB103.100");
- addressList1.add("DB103.114");
- addressList1.add("DB103.128");
- addressList1.add("DB103.142");
- addressList1.add("DB103.156");
- addressList1.add("DB103.184");
- addressList1.add("DB103.212");
+ addressList1.add("DB103.44");//D01
+ addressList1.add("DB103.58");//D02
+ addressList1.add("DB103.72");//D03
+ addressList1.add("DB103.86");//D04
+ addressList1.add("DB103.100");//D05
+ addressList1.add("DB103.114");//D06
+ addressList1.add("DB103.128");//A01
+ addressList1.add("DB103.156");//A01 2
+ addressList1.add("DB103.142");//A02
+ addressList1.add("DB103.212");//B01
+ addressList1.add("DB103.184");//B02
+
+
List<String> paramlist = S7control.getinstance().readStrings(addressList1);
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/PlcServoManualone.java b/springboot-vue3/src/main/java/com/example/springboot/component/PlcServoManualone.java
index 4eb6072..9a45abc 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/PlcServoManualone.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/PlcServoManualone.java
@@ -51,85 +51,91 @@
}
- List<String> addresses = new ArrayList<>();
- addresses.add("DB103.25");
- addresses.add("DB100.144");
-
- addresses.add("DB100.184");
- addresses.add("DB100.186");
- addresses.add("DB100.180");
- addresses.add("DB100.182");
-
- List<Short> arraylist = S7control.getinstance().readWords(addresses);
-
-// String rangeAddress = "DB100.148-161";
- String rangeAddress = "DB100.148";
- int insertIndex = 2;
- insertDataToList(arraylist, rangeAddress, insertIndex);
-
-
- List<String> addresses2 = new ArrayList<>();
- addresses2.add("DB103.26");
- addresses2.add("DB100.188");
- addresses2.add("DB100.190");
- addresses2.add("DB100.146");
-// addresses2.add("DB100.162-175");
- List<Short> arraylist2 = S7control.getinstance().readWords(addresses2);
-// String rangeAddress2 = "DB100.148-161";
- String rangeAddress2 = "DB100.162";
- int insertIndex2 = 4;
- insertDataToList(arraylist2, rangeAddress2, insertIndex2);
-// System.out.println(arraylist2);
- List<String> addresses3 = new ArrayList<>();
- addresses3.add("DB103.42");
- List<Short> arraylist3 = S7control.getinstance().readWords(addresses3);
-
- List<String> addresses4 = new ArrayList<>();
- addresses4.add("DB103.46");
- List<Short> arraylist4 = S7control.getinstance().readWords(addresses4);
-
- List<Short> arraylist5 = S7control.getinstance().ReadWord("DB103.27", 2);
- List<Short> arraylist6 = S7control.getinstance().ReadWord("DB103.29", 2);
- List<String> addresses7 = new ArrayList<>();
- addresses7.add("DB104.24");
- addresses7.add("DB104.26");
- addresses7.add("DB104.20");
- addresses7.add("DB104.22");
- addresses7.add("DB104.28");
- addresses7.add("DB104.30");
- List<Short> arraylist7 = S7control.getinstance().readWords(addresses7);
-
-
- List<String> addresses8 = new ArrayList<>();
- addresses8.add("DB101.3.7");
- addresses8.add("DB101.4.2");
- addresses8.add("DB101.4.5");
- addresses8.add("DB101.4.7");
- List<Boolean> arraylist8 = S7control.getinstance().readBits(addresses8);
- short[] params = new short[arraylist8.size()];
- for (int i = 0; i < arraylist8.size(); i++) {
- boolean value = arraylist8.get(i);
- params[i] = value ? (short) 1 : (short) 0;
- }
-
-
-// Short[] values1 = { 1, 2, 3, 4, 5, 6, 7};
-// List<Short> arraylist = new ArrayList<>(Arrays.asList(values1));
-// Short[] values2 = { 1, 2, 3, 4, 5};
-// List<Short> arraylist2 = new ArrayList<>(Arrays.asList(values2));
+// List<String> addresses = new ArrayList<>();
+// addresses.add("DB103.25");
+// addresses.add("DB100.144");
//
-// Short[] values3 = {1};
-// List<Short> arraylist3 = new ArrayList<>(Arrays.asList(values3));
-// Short[] values4 = {2};
-// List<Short> arraylist4 = new ArrayList<>(Arrays.asList(values4));
-// Short[] values5 = {3,3};
-// List<Short> arraylist5 = new ArrayList<>(Arrays.asList(values5));
-// Short[] values6 = { 4,4};
-// List<Short> arraylist6 = new ArrayList<>(Arrays.asList(values6));
-// Short[] values7 = { 1,1,1,1,1,1};
-// List<Short> arraylist7 = new ArrayList<>(Arrays.asList(values7));
-// Short[] values8 = { 1,1,1,1,1,1};
-// List<Short> arraylist8 = new ArrayList<>(Arrays.asList(values8));
+// addresses.add("DB100.184");
+// addresses.add("DB100.186");
+// addresses.add("DB100.180");
+// addresses.add("DB100.182");
+//
+// List<Short> arraylist = S7control.getinstance().readWords(addresses);
+//
+//// String rangeAddress = "DB100.148-161";
+// String rangeAddress = "DB100.148";
+// int insertIndex = 2;
+// insertDataToList(arraylist, rangeAddress, insertIndex);
+//
+//
+// List<String> addresses2 = new ArrayList<>();
+// addresses2.add("DB103.26");
+// addresses2.add("DB100.188");
+// addresses2.add("DB100.190");
+// addresses2.add("DB100.146");
+//// addresses2.add("DB100.162-175");
+// List<Short> arraylist2 = S7control.getinstance().readWords(addresses2);
+//// String rangeAddress2 = "DB100.148-161";
+// String rangeAddress2 = "DB100.162";
+// int insertIndex2 = 4;
+// insertDataToList(arraylist2, rangeAddress2, insertIndex2);
+//// System.out.println(arraylist2);
+// List<String> addresses3 = new ArrayList<>();
+// addresses3.add("DB103.42");
+// List<Short> arraylist3 = S7control.getinstance().readWords(addresses3);
+//
+// List<String> addresses4 = new ArrayList<>();
+// addresses4.add("DB103.46");
+// List<Short> arraylist4 = S7control.getinstance().readWords(addresses4);
+//
+// List<Short> arraylist5 = S7control.getinstance().ReadWord("DB103.27", 2);
+// List<Short> arraylist6 = S7control.getinstance().ReadWord("DB103.29", 2);
+// List<String> addresses7 = new ArrayList<>();
+// addresses7.add("DB104.1.4");
+// addresses7.add("DB104.1.5");
+// addresses7.add("DB104.1.2");
+// addresses7.add("DB104.1.3");
+// addresses7.add("DB104.1.6");
+// addresses7.add("DB104.1.7");
+// List<Boolean> arraylist7 = S7control.getinstance().readBits(addresses7);
+//
+//
+// short[] params2 = new short[arraylist7.size()];
+// for (int i = 0; i < arraylist7.size(); i++) {
+// boolean value = arraylist7.get(i);
+// params2[i] = value ? (short) 1 : (short) 0;
+// }
+//
+// List<String> addresses8 = new ArrayList<>();
+// addresses8.add("DB101.3.7");
+// addresses8.add("DB101.4.2");
+// addresses8.add("DB101.4.5");
+// addresses8.add("DB101.4.7");
+// List<Boolean> arraylist8 = S7control.getinstance().readBits(addresses8);
+// short[] params = new short[arraylist8.size()];
+// for (int i = 0; i < arraylist8.size(); i++) {
+// boolean value = arraylist8.get(i);
+// params[i] = value ? (short) 1 : (short) 0;
+// }
+
+
+ Short[] values1 = { 1, 2, 3, 4, 5, 6, 7};
+ List<Short> arraylist = new ArrayList<>(Arrays.asList(values1));
+ Short[] values2 = { 1, 2, 3, 4, 5};
+ List<Short> arraylist2 = new ArrayList<>(Arrays.asList(values2));
+
+ Short[] values3 = {1};
+ List<Short> arraylist3 = new ArrayList<>(Arrays.asList(values3));
+ Short[] values4 = {2};
+ List<Short> arraylist4 = new ArrayList<>(Arrays.asList(values4));
+ Short[] values5 = {3,3};
+ List<Short> arraylist5 = new ArrayList<>(Arrays.asList(values5));
+ Short[] values6 = { 4,4};
+ List<Short> arraylist6 = new ArrayList<>(Arrays.asList(values6));
+ Short[] values7 = { 1,1,1,1,1,1};
+ List<Short> arraylist7 = new ArrayList<>(Arrays.asList(values7));
+ Short[] values8 = { 1,1,1,1,1,1};
+ List<Short> arraylist8 = new ArrayList<>(Arrays.asList(values8));
JSONObject jsonObject = new JSONObject();
@@ -140,8 +146,8 @@
jsonObject.append("zuhe4", arraylist4);
jsonObject.append("zuhe5", arraylist5);
jsonObject.append("zuhe6", arraylist6);
- jsonObject.append("guzhang", arraylist7);
- jsonObject.append("weihuiling", params);
+// jsonObject.append("guzhang", params2);
+// jsonObject.append("weihuiling", params);
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/Plcaction.java b/springboot-vue3/src/main/java/com/example/springboot/component/Plcaction.java
index 1195ec1..400aefe 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/Plcaction.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/Plcaction.java
@@ -66,12 +66,12 @@
}
// 璋冪敤鏂规硶锛岃繘琛岃祴鍊�
- this.readValue();
- String PlcAddress = this.name;
- Integer Plccount = this.count;
+// this.readValue();
+// String PlcAddress = this.name;
+// Integer Plccount = this.count;
// System.out.println(PlcAddress);
- List<Boolean> paramlist = S7control.getinstance().ReadBits("DB2.0.0", 26);
+ List<Boolean> paramlist = S7control.getinstance().ReadBits("DB2.0.0", 26);
// Boolean[] values = { false, true, true, true, true, true, true, true, true,
// true, true, true, true, true, true, true, true, true, true, true, true, true, true,
// true, false, true };
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/Plcalarm.java b/springboot-vue3/src/main/java/com/example/springboot/component/Plcalarm.java
index 22a103a..54d6a6d 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/Plcalarm.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/Plcalarm.java
@@ -82,13 +82,13 @@
e.printStackTrace();
}
- this.readValue();
- String PlcAddress = this.name;
- Integer Plccount = this.count;
+// this.readValue();
+// String PlcAddress = this.name;
+// Integer Plccount = this.count;
// 鏍规嵁鍦板潃璇诲彇PCL鏁版嵁
- // List<Boolean> plclist = S7control.getinstance().ReadBits("DB104.0.0", 71);
- List<Boolean> plclist = S7control.getinstance().ReadBits(PlcAddress, Plccount);
+ List<Boolean> plclist = S7control.getinstance().ReadBits("DB104.0.0", 71);
+// List<Boolean> plclist = S7control.getinstance().ReadBits(PlcAddress, Plccount);
// System.out.println(plclist);
// Boolean[] values = { false, false, true, false, true, false, true, false,
// true, false, true, false, true, false,
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/Plcsign.java b/springboot-vue3/src/main/java/com/example/springboot/component/Plcsign.java
index ee52f66..89881b8 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/Plcsign.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/Plcsign.java
@@ -65,24 +65,24 @@
e.printStackTrace();
}
- this.readValue();
- String PlcAddress = this.name;
- Integer Plccount = this.count;
+// this.readValue();
+// String PlcAddress = this.name;
+// Integer Plccount = this.count;
// System.out.println(PlcAddress);
- List<Boolean> plclist = S7control.getinstance().ReadBits(PlcAddress, Plccount);
- // List<Boolean> plclist2 = S7control.getinstance().ReadBits("DB102.5.5", 13);
+// List<Boolean> plclist = S7control.getinstance().ReadBits(PlcAddress, Plccount);
+ List<Boolean> plclist = S7control.getinstance().ReadBits("DB102.0.0", 64);
- // Boolean[] values = { true, true, true, true, true, false, true, false,
- // true, false, true, false, true, false,
- // true, false, true, false, true, false, true, false, true, false, true, false,
- // true, false, true, false, true,
- // false, true, false, true, false,
- // true, false, true, false, true, false, true, false, null,
- // true, false,
- // true, false, true, false, true, false,
- // true, false, true, false, true, };
- // List<Boolean> plclist = new ArrayList<>(Arrays.asList(values));
+// Boolean[] values = { true, true, true, true, true, false, true, false,
+// true, false, true, false, true, false,
+// true, false, true, false, true, false, true, false, true, false, true, false,
+// true, false, true, false, true,
+// false, true, false, true, false,
+// true, false, true, false, true, false, true, false, null,
+// true, false,
+// true, false, true, false, true, false,
+// true, false, true, false, true, };
+// List<Boolean> plclist = new ArrayList<>(Arrays.asList(values));
if (plclist != null) {
// 灏嗚幏鍙栫殑甯冨皵绫诲瀷杞崲涓烘暣鏁扮被鍨�
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/Plcstate.java b/springboot-vue3/src/main/java/com/example/springboot/component/Plcstate.java
index 843e685..f644903 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/Plcstate.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/Plcstate.java
@@ -65,12 +65,12 @@
e.printStackTrace();
}
- this.readValue();
- String PlcAddress = this.name;
- Integer Plccount = this.count;
+// this.readValue();
+// String PlcAddress = this.name;
+// Integer Plccount = this.count;
// System.out.println(PlcAddress);
-List<Short> plclist = S7control.getinstance().ReadWord("DB103.0", 10);
+List<Short> plclist = S7control.getinstance().ReadWord("DB103.0", 44);
// Short[] values = { 0, 1, 1, 0, 1, 0, 1, 0,
// 1, 0, };
// List<Short> plclist = new ArrayList<>(Arrays.asList(values));
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 736c35c..ac16929 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
@@ -19,6 +19,10 @@
import com.example.springboot.component.PlcParameter2;
import com.example.springboot.component.PlcParameter1;
import com.example.springboot.component.PlcServoManualone;
+import com.example.springboot.component.PLCAutomaticParameterSetting;
+import com.example.springboot.component.PlcManualonePosition;
+import com.example.springboot.component.PlcManualonePosition2;
+import com.example.springboot.component.PLCManualJog;
@Component
@Order(1)
@@ -33,22 +37,26 @@
// new PlcHold().start();
- // new Plcaction().start();
+ new Plcaction().start();
//
// new Plchome().start();
//
-// new PlcParameter().start();
+ new PlcParameter().start();
//
- // new Plcalarm().start();
+ //new Plcalarm().start();
//
- // new Plcsign().start();
+ new Plcsign().start();
//
- // new Plcstate().start();
+ new Plcstate().start();
new PlcPositioning1().start();
new PlcPositioning2().start();
new PlcParameter2().start();
new PlcParameter1().start();
new PLCAutomaticParameterSetting().start();
+
+ new PlcManualonePosition().start();
+ new PlcManualonePosition2().start();
new PlcServoManualone().start();
+ new PLCManualJog().start();
}
}
\ No newline at end of file
--
Gitblit v1.8.0