From 58bb9d3e0a8d8c385085f8cce3492eccf5448ec4 Mon Sep 17 00:00:00 2001
From: zhang <zc857179121@qq.com>
Date: 星期三, 10 九月 2025 16:20:12 +0800
Subject: [PATCH] 1

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

diff --git a/src/main/java/com/zy/core/thread/SiemensDevpThread.java b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
index 9dc5f37..094fd26 100644
--- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java
+++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -52,6 +52,10 @@
         add(1006);
         add(1007);
 
+    }};
+
+    public static final ArrayList<Integer> staNos2 = new ArrayList<Integer>() {{
+
         add(101);
         add(102);
         add(103);
@@ -117,7 +121,16 @@
                     // 鍐欐暟鎹� ID+鐩爣绔�
                     case 2:
                         write((StaProtocol) task.getData());
-                        log.error("杈撻�佺嚎涓嬪彂鍛戒护锛�" + ((StaProtocol) task.getData()).getWorkNo() + "," + ((StaProtocol) task.getData()).getStaNo());
+                        log.info("杈撻�佺嚎涓嬪彂鍛戒护锛�" + ((StaProtocol) task.getData()).getWorkNo() + "," + ((StaProtocol) task.getData()).getStaNo());
+                        break;
+                    // 鍐欐暟鎹� ID+鐩爣绔�
+                    case 3:
+                        write2((StaProtocol) task.getData());
+                        log.info("杈撻�佺嚎涓嬪彂鍛戒护3锛�");
+                        break;
+                    case 4:
+                        write4((StaProtocol) task.getData());
+                        log.info("杈撻�佺嚎涓嬪彂鍛戒护4锛�");
                         break;
                     default:
                         break;
@@ -216,6 +229,44 @@
                 if (!staProtocol.isPakMk() && !staProtocol.isLoading()) {
                     staProtocol.setPakMk(true);
                 }
+            }
+        }
+        ArrayList<Integer> staNosxx = staNos2;
+        int size = staNosxx.size();
+        OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB101.14", (short) (size * 2));
+        if (result3.IsSuccess) {
+            for (int i = 0; i < size; i++) {
+                Integer siteId = staNosxx.get(i); // 绔欑偣缂栧彿
+                StaProtocol staProtocol = station.get(siteId);
+                if (null == staProtocol) {
+                    staProtocol = new StaProtocol();
+                    staProtocol.setSiteId(siteId);
+                    station.put(siteId, staProtocol);
+                }
+                boolean[] status = null;
+                status = siemensS7Net.getByteTransform().TransBool(result3.Content, i * 2, 2);
+                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);
+                }
+            }
+        }
+
+        OperateResultExOne<byte[]> result4 = siemensS7Net.Read("DB102.0", (short) 2);
+        if (result4.IsSuccess) {
+            boolean[] status = siemensS7Net.getByteTransform().TransBool(result4.Content, 0, 1);
+            if (status[0] && status[1]) {
+                StaProtocol staProtocol = station.get(1007);
+                MessageQueue.offer(SlaveType.Devp, 1, new Task(4, staProtocol));
+                log.info("澶嶄綅1007");
             }
         }
 
@@ -364,6 +415,57 @@
         }
     }
 
+    private void write2(StaProtocol staProtocol) throws InterruptedException {
+        if (null == staProtocol) {
+            return;
+        }
+        OperateResult write = null;
+        boolean[] array = new boolean[1];
+        array[0] = true;
+        //浠诲姟涓嬪彂娆℃暟
+        int writeCount = 0;
+        do {
+            write = siemensS7Net.Write("DB102.0", array);
+            if (write.IsSuccess) {
+                log.error("鍐欏叆杈撻�佺嚎DB102.0鍛戒护鎴愬姛3銆傝緭閫佺嚎plc缂栧彿={}锛岀珯鐐规暟鎹�={},鍐欏叆娆℃暟={}", slave.getId(), JSON.toJSON(staProtocol), writeCount);
+                break;
+            } else {
+                writeCount++;
+                log.error("鍐欏叆杈撻�佺嚎鍛戒护澶辫触銆傝緭閫佺嚎plc缂栧彿={}锛岀珯鐐规暟鎹�={},鍐欏叆娆℃暟={}", slave.getId(), JSON.toJSON(staProtocol), writeCount);
+            }
+        } while (writeCount < 5);
+
+        if (!write.IsSuccess) {
+            News.error("SiemensDevp" + " - 4" + " - 鍐欏叆杈撻�佺嚎绔欑偣鏁版嵁澶辫触銆傝緭閫佺嚎plc缂栧彿={}锛岀珯鐐规暟鎹�={}", slave.getId(), JSON.toJSON(staProtocol));
+        }
+    }
+
+    private void write4(StaProtocol staProtocol) throws InterruptedException {
+        if (null == staProtocol) {
+            return;
+        }
+        OperateResult write = null;
+        boolean[] array = new boolean[2];
+        array[0] = false;
+        array[1] = false;
+        //浠诲姟涓嬪彂娆℃暟
+        int writeCount = 0;
+        do {
+            write = siemensS7Net.Write("DB102.0", array);
+            if (write.IsSuccess) {
+                log.error("44鍐欏叆杈撻�佺嚎DB102.0鍛戒护鎴愬姛3銆傝緭閫佺嚎plc缂栧彿={}锛岀珯鐐规暟鎹�={},鍐欏叆娆℃暟={}", slave.getId(), JSON.toJSON(staProtocol), writeCount);
+                break;
+            } else {
+                writeCount++;
+                log.error("44鍐欏叆杈撻�佺嚎鍛戒护澶辫触銆傝緭閫佺嚎plc缂栧彿={}锛岀珯鐐规暟鎹�={},鍐欏叆娆℃暟={}", slave.getId(), JSON.toJSON(staProtocol), writeCount);
+            }
+        } while (writeCount < 5);
+
+        if (!write.IsSuccess) {
+            News.error("SiemensDevp" + " - 4" + " - 鍐欏叆杈撻�佺嚎绔欑偣鏁版嵁澶辫触銆傝緭閫佺嚎plc缂栧彿={}锛岀珯鐐规暟鎹�={}", slave.getId(), JSON.toJSON(staProtocol));
+        }
+    }
+
     // 鏇存柊鍏ュ嚭搴撴ā寮�
     private void updateIoMode() throws InterruptedException {
         if (this.ioModeOf2F != IoModeType.NONE) {

--
Gitblit v1.9.1