From c73329698e53c2642bdd76c829d872a525d33d3f Mon Sep 17 00:00:00 2001
From: sxlktfuq <sxlktfuq>
Date: 星期六, 17 六月 2023 09:48:01 +0800
Subject: [PATCH] #sxlktwcs

---
 src/main/java/com/zy/core/thread/SiemensDevpThread.java |   91 +++++++++++++++++++++++----------------------
 1 files changed, 46 insertions(+), 45 deletions(-)

diff --git a/src/main/java/com/zy/core/thread/SiemensDevpThread.java b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
index afeead4..40fc273 100644
--- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java
+++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -47,8 +47,8 @@
 //
 //    }};
     public static final ArrayList<Integer> staNos1 = new ArrayList<Integer>() {{
-        add(101);add(102);add(103);
-        add(104);add(105);add(106);
+        add(101);add(102);add(103);add(104);
+        add(105);add(106);add(107);add(108);
     }};
 
     public static final ArrayList<Integer> staNos2 = new ArrayList<Integer>() {{
@@ -190,9 +190,9 @@
 //        updateIoMode();
         ArrayList<Integer> staNos = getStaNo();
         int staNoSize = staNos.size();
-        OperateResultExOne<byte[]> result = siemensS7Net.Read("DB100.0", (short) (staNoSize*2));
-        OperateResultExOne<byte[]> result4 = siemensS7Net.Read("DB100.0", (short) (staNoSize*2));
-        if (result.IsSuccess && result4.IsSuccess) {
+        OperateResultExOne<byte[]> result = siemensS7Net.Read("DB100.0", (short) (staNoSize*4));
+//        OperateResultExOne<byte[]> result4 = siemensS7Net.Read("DB100.2", (short) (staNoSize*2));
+        if (result.IsSuccess) {
             for (int i = 0; i < staNoSize; i++) {
                 Integer siteId = staNos.get(i); // 绔欑偣缂栧彿
                 StaProtocol staProtocol = station.get(siteId);
@@ -201,11 +201,41 @@
                     staProtocol.setSiteId(siteId);
                     station.put(siteId, staProtocol);
                 }
-                staProtocol.setWorkNo(siemensS7Net.getByteTransform().TransInt16(result.Content, i*2));     // 宸ヤ綔鍙�
+                staProtocol.setWorkNo(siemensS7Net.getByteTransform().TransInt16(result.Content, i*4));     // 宸ヤ綔鍙�
 
-                staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result4.Content, i*2));   // 鐩爣绔�
+                staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result.Content, i*4 + 2));   // 鐩爣绔�
             }
         }
+
+        Thread.sleep(200);
+        OperateResultExOne<byte[]> result1 = siemensS7Net.Read("DB102.2", (short) (staNoSize * 4));
+        if (result1.IsSuccess) {
+            for (int i = 0; i < staNoSize; i++) {
+                Integer siteId = staNos.get(i); // 绔欑偣缂栧彿
+                boolean[] status = siemensS7Net.getByteTransform().TransBool(result1.Content, i*4, 1);
+                StaProtocol staProtocol = station.get(siteId);
+                staProtocol.setAutoing(status[0]);  // 鑷姩
+                staProtocol.setLoading(status[1]);  // 鏈夌墿
+                staProtocol.setInEnable(status[2]); // 鍙叆
+                staProtocol.setOutEnable(status[3]);// 鍙嚭
+                staProtocol.setEmptyMk(status[4]);  // 绌烘澘淇″彿
+                staProtocol.setFullPlt(status[5]);  // 婊℃墭鐩�
+                staProtocol.setHigh(status[6]);     // 楂樺簱浣�
+                staProtocol.setLow(status[7]);      // 浣庡簱浣�
+
+                if (!staProtocol.isPakMk() && !staProtocol.isLoading()) {
+                    staProtocol.setPakMk(true);
+                }
+
+                if (staProtocol.getStamp()>=2 && !staProtocol.isLoading()){
+                    staProtocol.setStamp(0);
+                }else if (staProtocol.getStamp()<2 && staProtocol.isLoading()){
+                    //lfd鍏ュ簱鍗拌  褰搒tamp>=2鏃舵墠鍏ュ簱
+                    staProtocol.setStamp(staProtocol.getStamp()+1);
+                }
+            }
+        }
+
 //        Thread.sleep(200);
 //        OperateResultExOne<byte[]> result0 = siemensS7Net.Read("DB101.0", (short) 186);
 //        if (result0.IsSuccess) {
@@ -222,7 +252,7 @@
 //        }
         //鏉$爜鎵弿鍣�
         Thread.sleep(200);
-        OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB100.0",(short)(barcodeSize/3*8));
+        OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.0",(short)(barcodeSize*8));
         if (result2.IsSuccess && 1!=1) {
             if (slave.getId()==1){
                 for (int i = 0; i < barcodeSize/3; i++) {
@@ -250,35 +280,6 @@
 //                            && !Cools.isEmpty(barcode) && Cools.isEmpty(barcodeThread.getBarcode())) {
                         barcodeThread.setBarcode(barcode);
                     }
-                }
-            }
-        }
-
-        Thread.sleep(200);
-        OperateResultExOne<byte[]> result1 = siemensS7Net.Read("DB100.0", (short) (staNoSize * 2));
-        if (result1.IsSuccess) {
-            for (int i = 0; i < staNoSize; i++) {
-                Integer siteId = staNos.get(i); // 绔欑偣缂栧彿
-                boolean[] status = siemensS7Net.getByteTransform().TransBool(result1.Content, i*2, 1);
-                StaProtocol staProtocol = station.get(siteId);
-                staProtocol.setAutoing(status[0]);  // 鑷姩
-                staProtocol.setLoading(status[1]);  // 鏈夌墿
-                staProtocol.setInEnable(status[2]); // 鍙叆
-                staProtocol.setOutEnable(status[3]);// 鍙嚭
-                staProtocol.setEmptyMk(status[4]);  // 绌烘澘淇″彿
-                staProtocol.setFullPlt(status[5]);  // 婊℃墭鐩�
-                staProtocol.setHigh(status[6]);     // 楂樺簱浣�
-                staProtocol.setLow(status[7]);      // 浣庡簱浣�
-
-                if (!staProtocol.isPakMk() && !staProtocol.isLoading()) {
-                    staProtocol.setPakMk(true);
-                }
-
-                if (staProtocol.getStamp()>=2 && !staProtocol.isLoading()){
-                    staProtocol.setStamp(0);
-                }else if (staProtocol.getStamp()<2 && staProtocol.isLoading()){
-                    //lfd鍏ュ簱鍗拌  褰搒tamp>=2鏃舵墠鍏ュ簱
-                    staProtocol.setStamp(staProtocol.getStamp()+1);
                 }
             }
         }
@@ -327,17 +328,17 @@
 //        OperateResult write = siemensS7Net.Write("DB100." + index*4, array);
 
         OperateResult write = null;
-        OperateResult write1 = null;
         //浠诲姟涓嬪彂娆℃暟
         int writeCount = 0;
         do {
-            write = siemensS7Net.Write("DB100." + index*2, staProtocol.getWorkNo());    // 宸ヤ綔鍙�
-            Thread.sleep(500);
-            write1 = siemensS7Net.Write("DB101." + index*2, staProtocol.getStaNo());    // 鐩爣绔�
-            if(write.IsSuccess || write1.IsSuccess){
+//            write = siemensS7Net.Write("DB100.0" + index*2, staProtocol.getWorkNo());    // 宸ヤ綔鍙�
+//            Thread.sleep(500);
+//            write1 = siemensS7Net.Write("DB100.0" + index*2+2, staProtocol.getStaNo());    // 鐩爣绔�
+            write = siemensS7Net.Write("DB100." + index*4, array);
+            if(write.IsSuccess){
                 Thread.sleep(200);
-                OperateResultExOne<byte[]> readResult = siemensS7Net.Read("DB100." + index*2, (short) 2);
-                OperateResultExOne<byte[]> readResult1 = siemensS7Net.Read("DB101." + index*2, (short) 2);
+                OperateResultExOne<byte[]> readResult = siemensS7Net.Read("DB100.0" + index*2, (short) 2);
+                OperateResultExOne<byte[]> readResult1 = siemensS7Net.Read("DB100.0" + index*2+2, (short) 2);
                 if(readResult.IsSuccess && readResult1.IsSuccess){
                     short workNo = siemensS7Net.getByteTransform().TransInt16(readResult.Content, 0);
                     short staNo = siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 0);
@@ -360,7 +361,7 @@
             }
         }while (writeCount<5);
 
-        if (!write.IsSuccess || !write1.IsSuccess) {
+        if (!write.IsSuccess) {
             staProtocol = station.get(staProtocol.getSiteId());
             if (staProtocol.getWorkNo() == 0 && staProtocol.getStaNo() ==0) {
                 staProtocol.setPakMk(true);

--
Gitblit v1.9.1