From 730a25580b579ab32e0eae53fa4ae8aaa15c2d14 Mon Sep 17 00:00:00 2001
From: dubin <dubin>
Date: 星期二, 19 八月 2025 16:33:41 +0800
Subject: [PATCH] 联调

---
 src/main/java/com/zy/core/thread/SiemensDevpThread.java |   83 +++++++++++++++++++++++++++++------------
 1 files changed, 59 insertions(+), 24 deletions(-)

diff --git a/src/main/java/com/zy/core/thread/SiemensDevpThread.java b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
index 2bf4d3a..1e2777a 100644
--- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java
+++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -7,12 +7,9 @@
 import com.alibaba.fastjson.JSON;
 import com.core.common.Cools;
 import com.core.common.DateUtils;
-import com.core.common.SpringUtils;
 import com.core.exception.CoolException;
 import com.zy.asrs.entity.BasDevp;
-import com.zy.asrs.entity.BasRgvMap;
 import com.zy.asrs.service.BasDevpService;
-import com.zy.asrs.service.BasRgvMapService;
 import com.zy.common.utils.News;
 import com.zy.core.DevpThread;
 import com.zy.core.cache.MessageQueue;
@@ -28,7 +25,10 @@
 import lombok.extern.slf4j.Slf4j;
 
 import java.text.MessageFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
 /**
@@ -48,15 +48,11 @@
 //
 //    }};
     public static final ArrayList<Integer> staNos1 = new ArrayList<Integer>() {{
-        add(121);add(122);add(123);add(124);add(125);
-        add(126);
-        add(221);add(222);add(223);add(224);add(225);
-        add(226);add(227);add(228);add(229);add(230);
-        add(231);
-        add(411);add(412);add(413);add(414);
+        add(101);add(102);add(103);
+        add(104);add(105);
     }};
 
-    public static final ArrayList<Integer> staNos2 = new ArrayList<Integer>() {{
+    /*public static final ArrayList<Integer> staNos2 = new ArrayList<Integer>() {{
         add(101);add(102);add(103);
         add(104);add(105);add(106);add(107);
         add(108);add(109);
@@ -66,7 +62,7 @@
         add(208);add(209);add(210);add(211);
 
         add(401);add(402);add(403);add(404);
-    }};
+    }};*/
 
     public static final ArrayList<Integer> BarcodeList1 = new ArrayList<Integer>() {{
         add(1); add(2);add(3);add(4);add(5);
@@ -76,14 +72,23 @@
         add(6);add(7);add(8);add(9);
         add(10); add(11); add(12); add(13);
     }};
-    public static final ArrayList<Integer> staNosErrList2 = new ArrayList<Integer>() {{
-        add(101); add(104);add(106);add(108);
-        add(202);add(204);add(207);add(210);
-    }};
+    /*public static final ArrayList<Integer> staNosErrList2 = new ArrayList<Integer>() {{
+        add(102); add(105);add(107);add(109);
+        add(203);add(205);add(208);add(211);
+    }};*/
 
     public static final ArrayList<Integer> staNosErrList1 = new ArrayList<Integer>() {{
-        add(122);
-        add(222);add(224);add(227);add(230);
+        add(101);
+        add(102);add(103);add(104);add(105);
+    }};
+
+    public static final ArrayList<Integer> staNoWeight1 = new ArrayList<Integer>() {{
+        add(223);add(225);add(228);add(231);
+    }};
+
+    public static final ArrayList<Integer> staNoWeight2 = new ArrayList<Integer>() {{
+        add(102);add(105);add(107);add(109);
+        add(203);add(205);add(208);add(211);
     }};
 
     private Integer count=0;
@@ -114,8 +119,19 @@
         switch (slave.getId()) {
             case 1:
                 return staNosErrList1;
+            /*case 2:
+                return staNosErrList2;*/
+            default:
+                throw new CoolException("鏈嶅姟鍣ㄥ紓甯�");
+        }
+    }
+
+    private ArrayList<Integer> getStaNoWeight() {
+        switch (slave.getId()) {
+            case 1:
+                return staNoWeight1;
             case 2:
-                return staNosErrList2;
+                return staNoWeight2;
             default:
                 throw new CoolException("鏈嶅姟鍣ㄥ紓甯�");
         }
@@ -125,8 +141,8 @@
         switch (slave.getId()) {
             case 1:
                 return staNos1;
-            case 2:
-                return staNos2;
+            /*case 2:
+                return staNos2;*/
             default:
                 throw new CoolException("鏈嶅姟鍣ㄥ紓甯�");
         }
@@ -221,7 +237,7 @@
             OutputQueue.DEVP.offer(MessageFormat.format( "銆恵0}銆戣緭閫佺嚎plc杩炴帴澶辫触锛侊紒锛� ===>> [id:{1}] [ip:{2}] [port:{3}]  [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()));
             News.error("SiemensDevp"+" - 2"+" - 杈撻�佺嚎plc杩炴帴澶辫触锛侊紒锛� ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
         }
-        siemensS7Net.ConnectClose();
+//        siemensS7Net.ConnectClose();
         initSite();
         return result;
     }
@@ -246,12 +262,23 @@
     private void read() throws InterruptedException {
 //        // 鏇存柊鍏ュ嚭搴撴ā寮�
 //        updateIoMode();
+
+//        if (slave.getId()==1) return;
         ArrayList<Integer> staNos = getStaNo();
         ArrayList<Integer> staNosErrList = getStaNoErr();
+        ArrayList<Integer> staNoWeight = getStaNoWeight();
         int staNoSize = staNos.size();
         OperateResultExOne<byte[]> result = siemensS7Net.Read("DB101.0", (short) (500 * 8));
+        OperateResultExOne<byte[]> resultWeight = null;
+        if(staNoWeight.size()>4){
+            resultWeight = siemensS7Net.Read("DB102.0", (short)  (8 * 4));
+        }else{
+            resultWeight = siemensS7Net.Read("DB102.0", (short)  (4 * 4));
+        }
+        OperateResultExOne<byte[]> resultWeight2 = siemensS7Net.Read("DB102.0", (short)  (4 * 4));
 
-        if (result.IsSuccess) {
+        if (result.IsSuccess && resultWeight.IsSuccess) {
+            int j = 0;
             for(int i = 0 ; i<staNoSize;i++){
                 Integer siteId = staNos.get(i); // 绔欑偣缂栧彿
                 StaProtocol staProtocol = station.get(siteId);
@@ -264,9 +291,17 @@
                 int offset = getOffsetFromSiteId(siteId);//鍙栦綑鑾峰緱瀵瑰簲db鍧楁暟鎹�
 
                 staProtocol.setWorkNo(siemensS7Net.getByteTransform().TransInt32(result.Content, offset));     // 宸ヤ綔鍙�
+                if (staNoWeight.contains(siteId)) {
+                    if(staNoWeight.size() == 4){
+                        staProtocol.setWeight(siemensS7Net.getByteTransform().TransInt32(resultWeight2.Content, j));
+                        j = j + 4;
+                    }else{
+                        staProtocol.setWeight(siemensS7Net.getByteTransform().TransInt32(resultWeight.Content, j));
+                        j = j + 4;
 
+                    }
+                }
                 staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result.Content, offset+ 4));   // 鐩爣绔�
-
                 status = siemensS7Net.getByteTransform().TransBool(result.Content, offset+ 6, 2);
 
                 staProtocol.setAutoing(status[0]);  // 鑷姩

--
Gitblit v1.9.1