From 3854c389aff6b26941fd352a1b02aa1e21e64a04 Mon Sep 17 00:00:00 2001
From: ZengTao <2773468879@qq.com>
Date: 星期日, 17 九月 2023 16:44:21 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/CanadaMes

---
 springboot-vue3/src/main/java/com/example/springboot/component/S7control.java |   26 ++++++++++++++++++++++++++
 springboot-vue3/src/main/java/com/example/springboot/component/Plcalarm.java  |    9 +++++++--
 springboot-vue3/src/main/java/com/example/springboot/component/Plcsign.java   |   15 ++++++++++++---
 3 files changed, 45 insertions(+), 5 deletions(-)

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 00d1d4b..ca035a8 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
@@ -19,7 +19,7 @@
       } catch (InterruptedException e) {
         e.printStackTrace();
       }
-
+      // 鏍规嵁鍦板潃璇诲彇PCL鏁版嵁
       List<Boolean> plclist = S7control.getinstance().ReadBits("DB104.0.0", 40);
       // Boolean[] values = { true, false, true, false, true, false, true, false,
       // true, false, true, false, true, false,
@@ -31,7 +31,6 @@
       if (plclist != null) {
 
         JSONObject jsonObject = new JSONObject();
-
         jsonObject.append("params", plclist);
         WebSocketServer sendwServer = WebSocketServer.sessionMap.get("alarm");
         if (sendwServer != null) {
@@ -44,9 +43,11 @@
           Intlist.add(value == true ? 1 : 0);
 
         }
+
         // 灏咺ntlist杞崲涓烘暟缁�
         Integer[] shuzu1 = Intlist.toArray(new Integer[0]);
 
+        // 瀹氫箟鐨勬姤璀﹀唴瀹规暟缁�
         String[] shuzu = {
             "D01 VFD error",
             "D02 VFD error",
@@ -91,10 +92,14 @@
         };
         alarmMapper = WebSocketServer.applicationContext.getBean(AlarmMapper.class);
         for (short i = 0; i < shuzu.length; i++) {
+          // 鏌ヨ瀵瑰簲鎶ヨ淇℃伅缁撴潫鏃堕棿涓簄ull鐨勬潯鏁�
           short result = alarmMapper.selectnullti(shuzu[i]);
+          // 璇诲彇鍒癙LC鐨勫�间负1骞朵笖瀵瑰簲鎶ヨ淇℃伅缁撴潫鏃堕棿涓簄ull鐨勬潯鏁扮殑鏉℃暟涓�0
           if (shuzu1[i] == 1 && result == 0) {
+            // 濉姞涓�鏉℃姤璀︿俊鎭�,鏈夊紑濮嬫椂闂�
             alarmMapper.Insertalarm(shuzu[i]);
           } else if (shuzu1[i] == 0 && result > 0) {
+            // 淇敼璇ユ潯鎶ヨ淇℃伅鐨勭粨鏉熸椂闂�
             alarmMapper.updatealarm(shuzu[i]);
           }
         }
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 ce46de1..8ec4b48 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
@@ -16,16 +16,25 @@
         e.printStackTrace();
       }
 
-      List<Boolean> plclist = S7control.getinstance().ReadBits("DB102.0.0", 58);
+      List<Boolean> plclist = S7control.getinstance().ReadBits("DB102.0.0", 44);
+      List<Boolean> plclist2 = S7control.getinstance().ReadBits("DB102.5.5", 13);
+
       // Boolean[] values = { 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, true, false, true, false, true, false,
+      // true, false, true, false, true, false, true, false, };
+      // List<Boolean> plclist = new ArrayList<>(Arrays.asList(values));
+
+      // Boolean[] values2 = { true, false,
       // true, false, true, false, true, false,
       // true, false, true, false, true, };
-      // List<Boolean> plclist = new ArrayList<>(Arrays.asList(values));
+      // List<Boolean> plclist2 = new ArrayList<>(Arrays.asList(values2));
+
+      // 灏唒lclist2鐨勫厓绱犳坊鍔犲埌plclist涓�
+      plclist.addAll(plclist2);
+      // System.out.println(plclist);
       if (plclist != null) {
         // 灏嗚幏鍙栫殑甯冨皵绫诲瀷杞崲涓烘暣鏁扮被鍨�
         List<Integer> Intlist = new ArrayList<>();
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 3ae24aa..593a8b9 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
@@ -137,6 +137,18 @@
         }
         s7PLC.writeMultiData(addressWrite);
     }
+     /**
+     * 鎸夋寚瀹氱殑鍦板潃 鍐欏叆澶氫釜byte
+     * 
+     * @param address 鍦板潃
+     * @param datas   byte鐨勫��
+     */
+    public void WriteByte(String address, byte[] datas) {
+        if (s7PLC==null)
+            return;
+        // s7PLC.write(address, data); 
+        s7PLC.writeByte(address, datas);
+    }
 
     /**
      * 鎸夋寚瀹氱殑鍦板潃 璇诲彇word缁撴灉闆�
@@ -164,6 +176,20 @@
         List<String> addresslist = GetAddressList(address, count, 16);
         return s7PLC.readInt16(addresslist);
     }
+    /**
+     * 鎸夋寚瀹氱殑鍦板潃 璇诲彇byte缁撴灉闆�
+     * 
+     * @param address 鍦板潃
+     * @param count   杩炵画璇诲灏戜釜byte
+     * @return 缁撴灉
+     */
+    public byte[] ReadByte(String address, int count) {
+        if (s7PLC==null)
+             return null;
+
+       // List<String> addresslist = GetAddressList(address, count, 16);
+        return s7PLC.readByte(address,count);
+    }
 
     /**
      * 鎸夋寚瀹氱殑鍦板潃 鎸塨it浣� 0 flase 1 true 璇诲彇缁撴灉

--
Gitblit v1.8.0