From bc4a9c7700fbda51a57207fd445a02ad21e85911 Mon Sep 17 00:00:00 2001
From: ZengTao <2773468879@qq.com>
Date: 星期四, 25 一月 2024 08:08:13 +0800
Subject: [PATCH] 自动确认状态下改为从后台直接发送进片任务

---
 springboot-vue3/src/main/java/com/example/springboot/component/S7control.java |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/springboot-vue3/src/main/java/com/example/springboot/component/S7control.java b/springboot-vue3/src/main/java/com/example/springboot/component/S7control.java
index e0a5353..ce4f674 100644
--- a/springboot-vue3/src/main/java/com/example/springboot/component/S7control.java
+++ b/springboot-vue3/src/main/java/com/example/springboot/component/S7control.java
@@ -289,6 +289,41 @@
 }
 
 
+
+
+
+    public List<String> readStringsandword(List<String> addressList) {
+        if (s7PLC == null) {
+            return null;
+        }
+        List<String> result = new ArrayList<>();
+        for (String address : addressList) {
+            try {
+                if (address.contains("-")) {
+                    address = address.substring(0, address.indexOf("-"));
+
+                    byte[] bytes = s7PLC.readByte(address, 14);
+                    if (bytes != null) {
+                        String str = new String(bytes, StandardCharsets.UTF_8);
+                        result.add(str);
+                    }
+
+                } else {
+                    Short value = s7PLC.readInt16(address);
+                    result.add(value.toString());
+
+                }
+            } catch (Exception e) {
+                System.out.println("璇诲彇 " + address + " 澶辫触锛�" + e.getMessage());
+                result.add(null);
+            }
+        }
+
+        return result;
+    }
+
+
+
 //涓嶈繛缁湴鍧�鍐欏叆Word
     public void WriteWord(List<String> address, List<Short> datas) {
         if (s7PLC == null)

--
Gitblit v1.8.0