From 5f9ca1634f6a0ba288048556e29fe2b3e7784682 Mon Sep 17 00:00:00 2001
From: ZengTao <2773468879@qq.com>
Date: 星期五, 15 十二月 2023 09:59:56 +0800
Subject: [PATCH] 调整提示框
---
springboot-vue3/src/main/java/com/example/springboot/component/MessageHandler.java | 22 +++++++++++++++++++++-
1 files changed, 21 insertions(+), 1 deletions(-)
diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/MessageHandler.java b/springboot-vue3/src/main/java/com/example/springboot/component/MessageHandler.java
index c380a42..ae39320 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/MessageHandler.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/MessageHandler.java
@@ -66,7 +66,7 @@
}
}
- //鍐欏叆Word
+ //涓嶈繛缁湴鍧� 鍐欏叆Word
public void WriteWordToPLC(JSONArray messageArray, List<String> addresses, int index) {
try {
if (messageArray.getJSONArray(index).size() > 0) {
@@ -95,6 +95,26 @@
}
}
+
+
+ public void WriteWordsToPLC(JSONArray jsonArray, String address,int index) {
+ if (jsonArray.getJSONArray(index).size() > 0) {
+ Object value = jsonArray.getJSONArray(index).get(0);
+ if (value != null && !value.toString().equals("null")) {
+ try {
+ String cleanedValue = value.toString().replaceAll("[^0-9-]", "");
+ short sValue = Short.parseShort(cleanedValue.trim());
+ S7control.getinstance().WriteWord(address, Arrays.asList(sValue));
+ System.out.println("messageValue锛�" + Arrays.asList(sValue) + " written to PLC at address " + address);
+ } catch (NumberFormatException e) {
+ // 濡傛灉鏃犳硶瑙f瀽涓� short 绫诲瀷锛屽垯蹇界暐璇ラ儴鍒�
+ System.err.println("Could not parse value: " + value);
+ }
+ }
+ }
+ }
+
+
//鍐欏叆String
public void writeStringToPLC(JSONArray messageArray, String addresses, int index) {
try {
--
Gitblit v1.8.0