From 64cad8c9b74d1450e873ce378110a7ed8c1aef56 Mon Sep 17 00:00:00 2001
From: wuyouming666 <2265557248@qq.com>
Date: 星期一, 22 一月 2024 09:04:34 +0800
Subject: [PATCH] 增加xlsx转换为json 工具类
---
springboot-vue3/src/main/java/com/example/springboot/component/PlcManualonePosition2.java | 43 +
springboot-vue3/.idea/libraries/Maven__com_google_code_gson_gson_2_8_9.xml | 13
springboot-vue3/src/main/java/com/example/springboot/component/ExcelToJsonConverter.java | 86 ++++
springboot-vue3/src/main/java/com/example/springboot/component/PlcServoManualone.java | 8
springboot-vue3/springboot-vue3.iml | 1
/dev/null | 507 --------------------------
springboot-vue3/JsonFile/PlcSign.json | 10
springboot-vue3/JsonFile/state.json | 227 +++++++++++
springboot-vue3/src/main/java/com/example/springboot/config/AppRunnerConfig.java | 2
springboot-vue3/pom.xml | 6
springboot-vue3/src/main/java/com/example/springboot/component/PLCAutomaticParameterSettingReview.java | 176 ++++----
springboot-vue3/src/main/java/com/example/springboot/entity/device/PlcParameterObject.java | 19
springboot-vue3/JsonFile/state.xlsx | 0
CanadaMes-ui/src/views/Electrical/ServoManualone.vue | 17
springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter1Review.java | 17
15 files changed, 494 insertions(+), 638 deletions(-)
diff --git a/CanadaMes-ui/src/views/Electrical/ServoManualone.vue b/CanadaMes-ui/src/views/Electrical/ServoManualone.vue
index 956ea14..3eae7c3 100644
--- a/CanadaMes-ui/src/views/Electrical/ServoManualone.vue
+++ b/CanadaMes-ui/src/views/Electrical/ServoManualone.vue
@@ -801,6 +801,23 @@
}
}
+
+ 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 === "Home")
+ ) {
+ obj2.button.value = obj.huiling[0][i];
+ // console.log(obj2.button.value)
+ }
+ }
+ }
+
+
+
//鏈洖闆舵洿鏂�
jsonData2[2][3].button.value = weihuiling[0][0];
diff --git a/springboot-vue3/.idea/libraries/Maven__com_google_code_gson_gson_2_8_9.xml b/springboot-vue3/.idea/libraries/Maven__com_google_code_gson_gson_2_8_9.xml
new file mode 100644
index 0000000..f93f971
--- /dev/null
+++ b/springboot-vue3/.idea/libraries/Maven__com_google_code_gson_gson_2_8_9.xml
@@ -0,0 +1,13 @@
+<component name="libraryTable">
+ <library name="Maven: com.google.code.gson:gson:2.8.9">
+ <CLASSES>
+ <root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.8.9/gson-2.8.9.jar!/" />
+ </CLASSES>
+ <JAVADOC>
+ <root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.8.9/gson-2.8.9-javadoc.jar!/" />
+ </JAVADOC>
+ <SOURCES>
+ <root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.8.9/gson-2.8.9-sources.jar!/" />
+ </SOURCES>
+ </library>
+</component>
\ No newline at end of file
diff --git a/springboot-vue3/JsonFile/PlcSign.json b/springboot-vue3/JsonFile/PlcSign.json
index 6a40941..3d1bc04 100644
--- a/springboot-vue3/JsonFile/PlcSign.json
+++ b/springboot-vue3/JsonFile/PlcSign.json
@@ -1,6 +1,6 @@
{
"plcAddressBegin":"DB100.0.0",
- "plcAddressLenght":"20",
+ "plcAddressLenght":"10",
"dataType":"bit",
"parameteInfor":[
{
@@ -29,19 +29,19 @@
},
{
"codeId": "A01A02TURNPOSVelocityAUTO",
- "addressIndex":"12"
+ "addressIndex":"7"
},
{
"codeId": "A01A02TURNPOSVelocitymanual",
- "addressIndex":"14"
+ "addressIndex":"8"
},
{
"codeId": "A01A02TRAVELPOSVelocityAUTO",
- "addressIndex":"16"
+ "addressIndex":"9"
},
{
"codeId": "DO1id",
- "addressIndex":"18"
+ "addressIndex":"10"
}
]
}
diff --git a/springboot-vue3/JsonFile/state.json b/springboot-vue3/JsonFile/state.json
new file mode 100644
index 0000000..4f5fb1e
--- /dev/null
+++ b/springboot-vue3/JsonFile/state.json
@@ -0,0 +1,227 @@
+[
+ {
+ "codeId": "D01.State",
+ "unit": "",
+ "addressIndex": "0"
+ },
+ {
+ "codeId": "D02.State",
+ "unit": "",
+ "addressIndex": "2"
+ },
+ {
+ "codeId": "B01.State",
+ "unit": "",
+ "addressIndex": "4"
+ },
+ {
+ "codeId": "B02.State",
+ "unit": "",
+ "addressIndex": "6"
+ },
+ {
+ "codeId": "A01.State",
+ "unit": "",
+ "addressIndex": "8"
+ },
+ {
+ "codeId": "A02.State",
+ "unit": "",
+ "addressIndex": "10"
+ },
+ {
+ "codeId": "D03.State",
+ "unit": "",
+ "addressIndex": "12"
+ },
+ {
+ "codeId": "D04.State",
+ "unit": "",
+ "addressIndex": "14"
+ },
+ {
+ "codeId": "D05.State",
+ "unit": "",
+ "addressIndex": "16"
+ },
+ {
+ "codeId": "D06.State",
+ "unit": "",
+ "addressIndex": "18"
+ },
+ {
+ "codeId": "A01tavelActualPosition",
+ "unit": "",
+ "addressIndex": "20"
+ },
+ {
+ "codeId": "A01turnActualangle",
+ "unit": "",
+ "addressIndex": "22"
+ },
+ {
+ "codeId": "A02tavelActualPosition",
+ "unit": "",
+ "addressIndex": "24"
+ },
+ {
+ "codeId": "A02turnActualangle",
+ "unit": "",
+ "addressIndex": "26"
+ },
+ {
+ "codeId": "B01tavelActualPosition",
+ "unit": "",
+ "addressIndex": "28"
+ },
+ {
+ "codeId": "B02tavelActualPosition",
+ "unit": "",
+ "addressIndex": "30"
+ },
+ {
+ "codeId": "A01CurrentGrid",
+ "unit": "",
+ "addressIndex": "32"
+ },
+ {
+ "codeId": "A02CurrentGrid",
+ "unit": "",
+ "addressIndex": "34"
+ },
+ {
+ "codeId": "B01CurrentGrid",
+ "unit": "",
+ "addressIndex": "36"
+ },
+ {
+ "codeId": "B01TargetGrid",
+ "unit": "",
+ "addressIndex": "38"
+ },
+ {
+ "codeId": "B02CurrentGrid",
+ "unit": "",
+ "addressIndex": "40"
+ },
+ {
+ "codeId": "B02TargetGrid",
+ "unit": "",
+ "addressIndex": "42"
+ },
+ {
+ "codeId": "D01ID",
+ "unit": "",
+ "addressIndex": "44"
+ },
+ {
+ "codeId": "D02ID",
+ "unit": "",
+ "addressIndex": "58"
+ },
+ {
+ "codeId": "D03ID",
+ "unit": "",
+ "addressIndex": "72"
+ },
+ {
+ "codeId": "D04ID",
+ "unit": "",
+ "addressIndex": "86"
+ },
+ {
+ "codeId": "D05ID",
+ "unit": "",
+ "addressIndex": "100"
+ },
+ {
+ "codeId": "D06ID",
+ "unit": "",
+ "addressIndex": "114"
+ },
+ {
+ "codeId": "A01ID1",
+ "unit": "",
+ "addressIndex": "128"
+ },
+ {
+ "codeId": "A01ID2",
+ "unit": "",
+ "addressIndex": "142"
+ },
+ {
+ "codeId": "A02ID1",
+ "unit": "",
+ "addressIndex": "156"
+ },
+ {
+ "codeId": "A02ID2",
+ "unit": "",
+ "addressIndex": "170"
+ },
+ {
+ "codeId": "B01ID1",
+ "unit": "",
+ "addressIndex": "184"
+ },
+ {
+ "codeId": "B01ID2",
+ "unit": "",
+ "addressIndex": "198"
+ },
+ {
+ "codeId": "B02ID1",
+ "unit": "",
+ "addressIndex": "212"
+ },
+ {
+ "codeId": "B02ID2",
+ "unit": "",
+ "addressIndex": "226"
+ },
+ {
+ "codeId": "A01conveyorFaultcodes",
+ "unit": "",
+ "addressIndex": "240"
+ },
+ {
+ "codeId": "A01turnservoFaultcodes",
+ "unit": "",
+ "addressIndex": "242"
+ },
+ {
+ "codeId": "A01travelservoFaultcodes",
+ "unit": "",
+ "addressIndex": "244"
+ },
+ {
+ "codeId": "A02conveyorFaultcodes",
+ "unit": "",
+ "addressIndex": "246"
+ },
+ {
+ "codeId": "A02turnservoFaultcodes",
+ "unit": "",
+ "addressIndex": "248"
+ },
+ {
+ "codeId": "A02travelservoFaultcodes",
+ "unit": "",
+ "addressIndex": "250"
+ },
+ {
+ "codeId": "B01travelservoFaultcodes",
+ "unit": "",
+ "addressIndex": "252"
+ },
+ {
+ "codeId": "B02travelservoFaultcodes",
+ "unit": "",
+ "addressIndex": "254"
+ },
+ {
+ "codeId": "",
+ "unit": "",
+ "addressIndex": ""
+ }
+]
\ No newline at end of file
diff --git a/springboot-vue3/JsonFile/state.xlsx b/springboot-vue3/JsonFile/state.xlsx
new file mode 100644
index 0000000..d52d6a6
--- /dev/null
+++ b/springboot-vue3/JsonFile/state.xlsx
Binary files differ
diff --git a/springboot-vue3/pom.xml b/springboot-vue3/pom.xml
index c4a06f2..04328bd 100644
--- a/springboot-vue3/pom.xml
+++ b/springboot-vue3/pom.xml
@@ -138,6 +138,12 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>2.8.9</version>
+ </dependency>
</dependencies>
<build>
diff --git a/springboot-vue3/springboot-vue3.iml b/springboot-vue3/springboot-vue3.iml
index 1581352..473e79f 100644
--- a/springboot-vue3/springboot-vue3.iml
+++ b/springboot-vue3/springboot-vue3.iml
@@ -182,5 +182,6 @@
<orderEntry type="library" name="Maven: org.springframework:spring-messaging:5.2.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-websocket:5.2.8.RELEASE" level="project" />
<orderEntry type="library" name="Maven: com.github.xingshuangs:iot-communication:1.4.2" level="project" />
+ <orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.9" level="project" />
</component>
</module>
\ No newline at end of file
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/ExcelToJsonConverter.java b/springboot-vue3/src/main/java/com/example/springboot/component/ExcelToJsonConverter.java
new file mode 100644
index 0000000..d1098ba
--- /dev/null
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/ExcelToJsonConverter.java
@@ -0,0 +1,86 @@
+package com.example.springboot.component;
+
+import cn.hutool.json.JSONObject;
+import com.google.gson.Gson;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public class ExcelToJsonConverter {
+ public static void main(String[] args) {
+ String excelFilePath = "JsonFile/state.xlsx";
+ String sheetName = "Sheet1";
+ int addressColumnIndex = 0;
+ int nameColumnIndex = 1;
+
+ int unitColumnIndex = 2;
+ String outputFilePath = "JsonFile/state.json";
+
+ try (Workbook workbook = new HSSFWorkbook(new FileInputStream(excelFilePath))) {
+ Sheet sheet = workbook.getSheet(sheetName);
+
+ List<JSONObject> jsonList = new ArrayList<>();
+
+ Iterator<Row> rowIterator = sheet.iterator();
+ // Skip the header row
+ if (rowIterator.hasNext()) {
+ rowIterator.next();
+ }
+
+ while (rowIterator.hasNext()) {
+ Row row = rowIterator.next();
+
+ Cell nameCell = row.getCell(nameColumnIndex);
+ Cell addressCell = row.getCell(addressColumnIndex);
+ Cell unitCell = row.getCell(unitColumnIndex);
+
+ String name = nameCell.getStringCellValue();
+ String address = addressCell.getStringCellValue();
+ String unit = unitCell.getStringCellValue();
+
+ String addressIndex = extractAddressIndex(address);
+
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("codeId", name);
+ jsonObject.put("addressIndex", addressIndex);
+
+ jsonObject.put("unit", unit);
+
+ jsonList.add(jsonObject);
+ }
+
+ Gson gson = new Gson();
+ String jsonOutput = gson.toJson(jsonList);
+
+ try (FileWriter fileWriter = new FileWriter(outputFilePath)) {
+ fileWriter.write(jsonOutput);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private static String extractAddressIndex(String address) {
+ // Assuming the address format is "DB103.DBW0" or "DB103.DBB100~DBB113"
+ if (address.startsWith("DB") && address.contains(".DBW")) {
+ int startIndex = address.indexOf(".DBW") + 4;
+ int endIndex = address.length();
+ return address.substring(startIndex, endIndex);
+ } else if (address.startsWith("DB") && address.contains(".DBB")) {
+ int startIndex2 = address.indexOf(".DBB") + 4;
+ int endIndex2 = address.indexOf("~");
+ return address.substring(startIndex2, endIndex2);
+ }
+ return "";
+ }
+
+
+}
\ No newline at end of file
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/PLCAutomaticParameterSettingReview.java b/springboot-vue3/src/main/java/com/example/springboot/component/PLCAutomaticParameterSettingReview.java
index 31a404a..19d4b56 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/PLCAutomaticParameterSettingReview.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/PLCAutomaticParameterSettingReview.java
@@ -89,7 +89,7 @@
String addressList2 = "DB100.18";
String addressList3 = "DB100.22";
String addressList4 = "DB100.14";
-
+System.out.println(plcParameterObject.getPlcParameterValues(Autoaddresses));
@@ -108,7 +108,7 @@
JSONObject jsonObject = new JSONObject();
// new short[]{1,1, 1, 1, 1, 1, 2, 33, 2,3, 4, 5}
// new short[]{0,0, 0, 0, 0, 0, 0, 0, 0, 0}
-System.out.println(plcParameterObject.getPlcParameterValues(addresses));
+//System.out.println(plcParameterObject.getPlcParameterValues(addresses));
jsonObject.append("params", plcParameterObject.getPlcParameterValues(addresses));
jsonObject.append("dache1", plcParameterObject.getPlcParameter("A01A02TRAVELPOSVelocityAUTO").getValue());
jsonObject.append("xiaoche", plcParameterObject.getPlcParameter("B01B02TRAVELPOSVelocityAUTO").getValue());
@@ -118,94 +118,94 @@
jsonObject.append("xiaoche2", plcParameterObject.getPlcParameter("B01B02TRAVELJOGVelocity").getValue());
ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("AutomaticParameterSetting");
- if (sendwServer != null) {
- for (WebSocketServer webserver : sendwServer) {
- webserver.sendMessage(jsonObject.toString());
+// if (sendwServer != null) {
+// for (WebSocketServer webserver : sendwServer) {
+// webserver.sendMessage(jsonObject.toString());
// WebSocketServer webSocketServer = WebSocketServer.sessionMap.get("AutomaticParameterSetting");
- if (webserver != null) {
- List<String> messages = webserver.getMessages();
-
-
- if (!messages.isEmpty()) {
- // 灏嗘渶鍚庝竴涓秷鎭浆鎹负 short 绫诲瀷鐨勫垪琛�
- String lastMessage = messages.get(messages.size() - 1);
- // System.out.println("lastMessage锛�" + lastMessage);
- JSONArray messageArray = new JSONArray(lastMessage);
-
- // 鏁村悎绗� 1 鍒� 2 涓暟缁勫苟鍘绘帀 null 鍏冪礌
- List<Short> mergedList = new ArrayList<>();
- for (int i = 0; i < 2; i++) {
- JSONArray sublist = messageArray.getJSONArray(i);
- for (int j = 0; j < sublist.size(); j++) {
- Object value = sublist.get(j);
- if (value != null && !value.toString().equals("null")) {
- try {
- String cleanedValue = value.toString().replaceAll("[^0-9-]", "");
- short sValue = Short.parseShort(cleanedValue.trim());
- mergedList.add(sValue);
- } catch (NumberFormatException e) {
- // 濡傛灉鏃犳硶瑙f瀽涓� short 绫诲瀷锛屽垯蹇界暐璇ラ儴鍒�
- System.err.println("Could not parse value: " + value);
- }
- }
- }
- }
- System.out.println(messageArray);
- // 鍐欏叆绗竴涓湴鍧�
- customS7Control.WriteWordsToPLC(messageArray, addressList2,2);
- // 鍐欏叆绗簩涓湴鍧�
- customS7Control.WriteWordsToPLC(messageArray, addressList3,3);
- // 鍐欏叆绗笁涓湴鍧�
- customS7Control.WriteWordsToPLC(messageArray, addressList4,4);
- // 鍐欏叆绗洓涓湴鍧�
- if (!mergedList.isEmpty()) {
- S7control.getinstance().WriteWord(addressList1, mergedList);
- System.out.println("messageValue锛�" + mergedList + " written to PLC at address " + addressList1);
- }
-
- //List<String> waddresses1 = Arrays.asList(config.getProperty("Auto.shusong").split(","));
- String addressList22 = "DB100.8";
- String addressList33 = "DB100.12";
- if (!messages.isEmpty()) {
- // 灏嗘渶鍚庝竴涓秷鎭浆鎹负 short 绫诲瀷鐨勫垪琛�
- // 鏁村悎绗� 1 鍒� 3 涓暟缁勫苟鍘绘帀 null 鍏冪礌
- List<Short> mergedList2 = new ArrayList<>();
- for (int i = 5; i < 8; i++) {
- JSONArray sublist = messageArray.getJSONArray(i);
- for (int j = 0; j < sublist.size(); j++) {
- Object value = sublist.get(j);
- if (value != null && !value.toString().equals("null")) {
- try {
- String cleanedValue = value.toString().replaceAll("[^0-9-]", "");
- short sValue = Short.parseShort(cleanedValue.trim());
- mergedList2.add(sValue);
- } catch (NumberFormatException e) {
- // 濡傛灉鏃犳硶瑙f瀽涓� short 绫诲瀷锛屽垯蹇界暐璇ラ儴鍒�
- System.err.println("Could not parse value: " + value);
- }
- }
- }
- }
-
- // 鍐欏叆绗紞涓湴鍧�
- customS7Control.WriteWordsToPLC(messageArray, addressList22,8);
- // 鍐欏叆绗叚涓湴鍧�
- customS7Control.WriteWordsToPLC(messageArray, addressList33,9);
- // 鍐欏叆绗竷涓湴鍧�
- // plcParameterObject.getPlcParameter("conveyorVelocity(AutoFAST)").getAddress(index)
- if (!mergedList2.isEmpty()) {
- //S7control.getinstance().WriteWord(plcParameterObject.getPlcParameter(Autoaddresses), mergedList2);
- // System.out.println("messageValue锛�" + mergedList2 + " written to PLC at address " + waddresses1);
- }
- // 娓呯┖娑堟伅鍒楄〃
- webserver.clearMessages();
- }
- }
- }
-
- }
- }
+// if (webserver != null) {
+// List<String> messages = webserver.getMessages();
+//
+//
+// if (!messages.isEmpty()) {
+// // 灏嗘渶鍚庝竴涓秷鎭浆鎹负 short 绫诲瀷鐨勫垪琛�
+// String lastMessage = messages.get(messages.size() - 1);
+// // System.out.println("lastMessage锛�" + lastMessage);
+// JSONArray messageArray = new JSONArray(lastMessage);
+//
+// // 鏁村悎绗� 1 鍒� 2 涓暟缁勫苟鍘绘帀 null 鍏冪礌
+// List<Short> mergedList = new ArrayList<>();
+// for (int i = 0; i < 2; i++) {
+// JSONArray sublist = messageArray.getJSONArray(i);
+// for (int j = 0; j < sublist.size(); j++) {
+// Object value = sublist.get(j);
+// if (value != null && !value.toString().equals("null")) {
+// try {
+// String cleanedValue = value.toString().replaceAll("[^0-9-]", "");
+// short sValue = Short.parseShort(cleanedValue.trim());
+// mergedList.add(sValue);
+// } catch (NumberFormatException e) {
+// // 濡傛灉鏃犳硶瑙f瀽涓� short 绫诲瀷锛屽垯蹇界暐璇ラ儴鍒�
+// System.err.println("Could not parse value: " + value);
+// }
+// }
+// }
+// }
+// System.out.println(messageArray);
+// // 鍐欏叆绗竴涓湴鍧�
+// customS7Control.WriteWordsToPLC(messageArray, addressList2,2);
+// // 鍐欏叆绗簩涓湴鍧�
+// customS7Control.WriteWordsToPLC(messageArray, addressList3,3);
+// // 鍐欏叆绗笁涓湴鍧�
+// customS7Control.WriteWordsToPLC(messageArray, addressList4,4);
+// // 鍐欏叆绗洓涓湴鍧�
+// if (!mergedList.isEmpty()) {
+// S7control.getinstance().WriteWord(addressList1, mergedList);
+// System.out.println("messageValue锛�" + mergedList + " written to PLC at address " + addressList1);
+// }
+//
+// //List<String> waddresses1 = Arrays.asList(config.getProperty("Auto.shusong").split(","));
+// String addressList22 = "DB100.8";
+// String addressList33 = "DB100.12";
+// if (!messages.isEmpty()) {
+// // 灏嗘渶鍚庝竴涓秷鎭浆鎹负 short 绫诲瀷鐨勫垪琛�
+// // 鏁村悎绗� 1 鍒� 3 涓暟缁勫苟鍘绘帀 null 鍏冪礌
+// List<Short> mergedList2 = new ArrayList<>();
+// for (int i = 5; i < 8; i++) {
+// JSONArray sublist = messageArray.getJSONArray(i);
+// for (int j = 0; j < sublist.size(); j++) {
+// Object value = sublist.get(j);
+// if (value != null && !value.toString().equals("null")) {
+// try {
+// String cleanedValue = value.toString().replaceAll("[^0-9-]", "");
+// short sValue = Short.parseShort(cleanedValue.trim());
+// mergedList2.add(sValue);
+// } catch (NumberFormatException e) {
+// // 濡傛灉鏃犳硶瑙f瀽涓� short 绫诲瀷锛屽垯蹇界暐璇ラ儴鍒�
+// System.err.println("Could not parse value: " + value);
+// }
+// }
+// }
+// }
+//
+// // 鍐欏叆绗紞涓湴鍧�
+// customS7Control.WriteWordsToPLC(messageArray, addressList22,8);
+// // 鍐欏叆绗叚涓湴鍧�
+// customS7Control.WriteWordsToPLC(messageArray, addressList33,9);
+// // 鍐欏叆绗竷涓湴鍧�
+// // plcParameterObject.getPlcParameter("conveyorVelocity(AutoFAST)").getAddress(index)
+// if (!mergedList2.isEmpty()) {
+// //S7control.getinstance().WriteWord(plcParameterObject.getPlcParameter(Autoaddresses), mergedList2);
+// // System.out.println("messageValue锛�" + mergedList2 + " written to PLC at address " + waddresses1);
+// }
+// // 娓呯┖娑堟伅鍒楄〃
+// webserver.clearMessages();
+// }
+// }
+// }
+//
+// }
+// }
}
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 458ccf8..72d225b 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
@@ -124,6 +124,32 @@
short[] combinedBinaryShortArray = PLCBooleanConverter.convertListsToBinaryShortArray(
A01readstart, A02readstart
);
+ // 鏁呴殰鍦板潃
+ 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");
+
+
+
+ List<Boolean> readreast = S7control.getinstance().readBits(waddresses4);
+ short[] reast6 = PlcManualonePosition.PLCBooleanConverter.convertListsToBinaryShortArray(readreast);
+
+
+
+ List<Boolean> readhuiling = S7control.getinstance().readBits(waddresses5);
+ short[] huiling7 = PlcManualonePosition.PLCBooleanConverter.convertListsToBinaryShortArray(readhuiling);
+
+
JSONObject jsonObject = new JSONObject();
@@ -132,6 +158,9 @@
jsonObject.append("guzhang", params2);
jsonObject.append("weihuiling", params3);
jsonObject.append("qidong", combinedBinaryShortArray);
+ jsonObject.append("fuwei", reast6);
+ jsonObject.append("huiling", huiling7);
+
// System.out.println(jsonObject);
// WebSocketServer sendwServer = WebSocketServer.sessionMap.get("ManualonePosition2");
// if (sendwServer != null) {
@@ -155,20 +184,6 @@
waddresses2.add("DB100.192");
- // 鏁呴殰鍦板潃
- 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 绫诲瀷鐨勫垪琛�
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter1Review.java b/springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter1Review.java
index fbfba3c..787b0d2 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter1Review.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/PlcParameter1Review.java
@@ -93,17 +93,20 @@
} catch (InterruptedException e) {
e.printStackTrace();
}
- byte[] getplcvlues = S7control.getinstance().ReadByte(plcParameterObject.getPlcAddressBegin(), plcParameterObject.getPlcAddressLength());
- plcParameterObject.setPlcParameterList(getplcvlues);
+ // byte[] getplcvlues = S7control.getinstance().ReadByte(plcParameterObject.getPlcAddressBegin(), plcParameterObject.getPlcAddressLength());
+
+ byte[] getplcvlues = {0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02, 0x03, 0x04,0x01, 0x02};
+
+ plcParameterObject.setPlcParameterList(getplcvlues);
// int index = plcParameterObject.getPlcParameter("conveyorVelocity(AutoFAST)").getAddressIndex();
// S7control.getinstance().WriteWord(plcParameterObject.getPlcParameter("conveyorVelocity(AutoFAST)").getAddress(index), (short) 100);
List<String> addresses = new ArrayList<>();
- addresses.add("conveyorVelocity(AutoFAST)");
- addresses.add("conveyorVelocity(AutoSLOW)");
- addresses.add("conveyorVelocity(Manual)");
- addresses.add("A01A02TURNJOGVelocity");
- addresses.add("A01A02TRAVELJOGVelocity");
+ addresses.add("A01A02TURNPOSVelocityAUTO");
+// addresses.add("conveyorVelocity(AutoSLOW)");
+// addresses.add("conveyorVelocity(Manual)");
+// addresses.add("A01A02TURNJOGVelocity");
+// addresses.add("A01A02TRAVELJOGVelocity");
System.out.println(plcParameterObject.getPlcParameterValues(addresses));
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 1388c26..e393f1c 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
@@ -141,6 +141,12 @@
A01readBstart, A01readstart, A02readsBtart, A02readstart
);
+
+ // 鍥為浂鍦板潃
+
+ List<Boolean> readhuiling = S7control.getinstance().readBits(waddresses4);
+ short[] huiling7 = PlcManualonePosition.PLCBooleanConverter.convertListsToBinaryShortArray(readhuiling);
+
// System.out.println(A01readBstart);
// 鎵�鏈夋晠闅滄寜閽浆鎹负1鍜�0
@@ -224,6 +230,8 @@
jsonObject.append("qupianid", queueid2);
jsonObject.append("fuwei", rReset);
jsonObject.append("qidong", combinedBinaryShortArray);
+ jsonObject.append("huiling", huiling7);
+
jsonObject.append("resumeTasks", resumeTask);
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 bbc83de..994ed85 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
@@ -36,7 +36,7 @@
new PlcManualonePosition2().start();
new PlcServoManualone().start();
new PLCManualJog().start();
- //new Plclog().start();
+ new Plclog().start();
new PlcInteractionState().start();
//new PlcParameter1Review().start();
diff --git a/springboot-vue3/src/main/java/com/example/springboot/entity/device/PlcParameterObject.java b/springboot-vue3/src/main/java/com/example/springboot/entity/device/PlcParameterObject.java
index 56a0230..5e5abc9 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/entity/device/PlcParameterObject.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/entity/device/PlcParameterObject.java
@@ -69,14 +69,14 @@
/**
* 鏍规嵁鍙傛暟鏍囪瘑 鑾峰彇鏌愪釜鍙傛暟瀹炰緥
*
- * @param codeid 鍙傛暟鏍囪瘑
+ * @param codeids 鍙傛暟鏍囪瘑
* @return 鑾峰彇鏌愪釜鍙傛暟瀹炰緥
*/
public List<String> getPlcParameterValues(List<String> codeids) {
List<String> arrayList = new ArrayList();
if (plcParameterList != null) {
for (PlcParameterInfo plcParameterInfo : plcParameterList) {
- if (codeids.contains(plcParameterInfo.getCodeId().toString()))
+ if (codeids.contains(plcParameterInfo.getCodeId()))
arrayList.add(plcParameterInfo.getValue());
}
}
@@ -84,20 +84,7 @@
}
- public List<String> getPlcAddressList(String codeid) {
- List<String> addressList = new ArrayList<>();
- if (plcParameterList != null) {
- for (PlcParameterInfo plcParameterInfo : plcParameterList) {
- if (plcParameterInfo.getCodeId().equals(codeid)) {
- int plcAddress = plcParameterInfo.getPlcAddress();
- if (!addressList.contains(plcAddress)) {
- addressList.add(String.valueOf(plcAddress));
- }
- }
- }
- }
- return addressList;
- }
+
diff --git a/springboot-vue3/src/main/resources/Alarm.json b/springboot-vue3/src/main/resources/Alarm.json
deleted file mode 100644
index 89bf615..0000000
--- a/springboot-vue3/src/main/resources/Alarm.json
+++ /dev/null
@@ -1,507 +0,0 @@
-{
- "content": [
- {
- "name": "D01 VFD error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "D02 VFD error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "D03 VFD error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "D04 VFD error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "D05 VFD error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "D06 VFD error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "B01 VFD error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "B02 VFD error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "A01 VFD error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "A02 VFD error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "A01 servo turn error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "A02 servo turn error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "A01 servo travel error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "A02 servo travel error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "B01 servo travel error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "B02 servo travel error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "D01 DEC error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "D01 pos error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "D02 DEC error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "D02 pos error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "D03 DEC error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "D03 pos error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "D04 DEC error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "D04 pos error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "D05 DEC error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "D05 pos error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "D06 DEC error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "D06 pos error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "A01 DEC error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "A01 pos error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "A02 DEC error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "A02 pos error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "B01 IN DEC error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "B01 IN pos error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "B01 OUT DEC error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "B01 OUT pos error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "B02 IN DEC error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "B02 IN pos error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "B02 OUT DEC error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "B02 OUT pos error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "D01 Scan glass exceeding limit",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "emergency stop alarm",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "More glass than known",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "less glass than known",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "D01 conveyor timeout alarm",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "D02 conveyor timeout alarm",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "D03 conveyor timeout alarm",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "D04 conveyor timeout alarm",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "D05 conveyor timeout alarm",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "D06 conveyor timeout alarm",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "A01 conveyor timeout alarm",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "A02 conveyor timeout alarm",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "B01 conveyor timeout alarm",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "B02 conveyor timeout alarm",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "A01 conveyor Left safety alarm",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "A01 conveyor right safety alarm",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "A02 conveyor Left safety alarm",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "A02 conveyor right safety alarm",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "1# buffer safety alarm",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "2# buffer safety alarm",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "3# buffer safety alarm",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "4# buffer safety alarm",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "A01.SR right in pos error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "A02.SR left in pos error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "B01.SR left in pos error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "B01.SR left dec error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "B01.SR right dec error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "B01.SR right in pos error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "B02.SR left in pos error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "B02.SR left dec error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- },
- {
- "name": "B02.SR right dec error",
- "value": "1",
- "state": "1",
- "type": "3",
- "page": "1"
- }
- ],
- "address": [
- {
- "name": "DB104.0.0",
- "count": 71
- }
- ]
-}
\ No newline at end of file
--
Gitblit v1.8.0