From 78e0773dba0613bf4fb18a20e0cef5086e1b834f Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期四, 24 十二月 2020 10:37:21 +0800
Subject: [PATCH] #newVersion

---
 src/main/java/com/zy/core/thread/MelsecDevpThread.java |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/zy/core/thread/MelsecDevpThread.java b/src/main/java/com/zy/core/thread/MelsecDevpThread.java
index d2565ca..36a4017 100644
--- a/src/main/java/com/zy/core/thread/MelsecDevpThread.java
+++ b/src/main/java/com/zy/core/thread/MelsecDevpThread.java
@@ -37,6 +37,9 @@
     private MelsecMcNet melsecMcNet;
     private Map<Integer, StaProtocol> station = new ConcurrentHashMap<>();
     private short heartBeatVal = 1;
+    public static final ArrayList<Integer> staNos = new ArrayList<Integer>() {{
+        add(101);add(102);add(103);add(104);add(105);add(106);add(107);
+    }};
 
     public MelsecDevpThread(DevpSlave slave) {
         this.slave = slave;
@@ -99,13 +102,15 @@
     private void read() throws InterruptedException {
         OperateResultExOne<byte[]> result = melsecMcNet.Read("DB100.0", (short) 40);
         if (result.IsSuccess) {
-            for (int i = 1; i <= 8; i++) {
-                StaProtocol staProtocol = station.get(i);
+            for (int i = 1; i <= 7; i++) {
+                Integer siteId = staNos.get(i); // 绔欑偣缂栧彿
+                StaProtocol staProtocol = station.get(siteId);
                 if (null == staProtocol) {
                     staProtocol = new StaProtocol();
-                    staProtocol.setSiteId(i);
-                    station.put(i, staProtocol);
+                    staProtocol.setSiteId(siteId);
+                    station.put(siteId, staProtocol);
                 }
+
                 staProtocol.setWorkNo(melsecMcNet.getByteTransform().TransInt16(result.Content, (i-1)*2));     // 宸ヤ綔鍙�
                 staProtocol.setStaNo(melsecMcNet.getByteTransform().TransInt16(result.Content, (i-1)*2+20));   // 鐩爣绔�
             }

--
Gitblit v1.9.1