From a0c9f738fdebae1f0bcb51d397978f24332a86ea Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期一, 04 一月 2021 16:58:16 +0800
Subject: [PATCH] #

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

diff --git a/src/main/java/com/zy/core/thread/SiemensDevpThread.java b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
index f1da677..5a12873 100644
--- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java
+++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -45,17 +45,6 @@
         add(200);add(201);add(202);add(203);add(204);add(205);
     }};
 
-    public static void main(String[] args) {
-        for (Integer siteId : staNos) {
-            int divides = (int) Arith.divides(0, siteId, 100);
-            int remainder = (int) Arith.remainder(siteId, 100);
-            int index = ((divides - 1) * 50) + remainder;
-            System.out.print(siteId + " 浠诲姟鍦板潃 锛� " + index*2);
-            System.out.print(" 鐩爣鍦板潃 锛� " + (index*2+200) );
-            System.out.println(" 鐘舵�� 锛� " + (index+500) );
-        }
-    }
-
     public SiemensDevpThread(DevpSlave slave) {
         this.slave = slave;
     }
@@ -83,9 +72,8 @@
                     default:
                         break;
                 }
-
                 // 蹇冭烦
-                heartbeat();
+//                heartbeat();
                 Thread.sleep(400);
             } catch (Exception e) {
                 e.printStackTrace();
@@ -141,16 +129,17 @@
                 Integer siteId = staNos.get(i); // 绔欑偣缂栧彿
                 int divides = (int) Arith.divides(0, siteId, 100);
                 int remainder = (int) Arith.remainder(siteId, 100);
-                int index = ((divides - 1) * 50) + remainder;
-
-
-                boolean[] status = siemensS7Net.getByteTransform().TransBool(result1.Content, i-1, 1);
-                StaProtocol staProtocol = station.get(i);
+                int index = ((divides - 1) * 100) + remainder;
+                boolean[] status = siemensS7Net.getByteTransform().TransBool(result1.Content, index, 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);
@@ -191,16 +180,13 @@
         if (null == staProtocol) {
             return;
         }
-        OperateResult write = siemensS7Net.Write("DB100." + (staProtocol.getSiteId() - 1) * 2, staProtocol.getWorkNo());    // 宸ヤ綔鍙�
+        int divides = (int) Arith.divides(0, staProtocol.getSiteId(), 100);
+        int remainder = (int) Arith.remainder(staProtocol.getSiteId(), 100);
+        int index = ((divides - 1) * 50) + remainder;
+
+        OperateResult write = siemensS7Net.Write("DB100." + index*2, staProtocol.getWorkNo());    // 宸ヤ綔鍙�
         Thread.sleep(300);
-        OperateResult write1 = siemensS7Net.Write("DB100." + ((staProtocol.getSiteId() - 1) * 2 + 20), staProtocol.getStaNo());    // 鐩爣绔�
-//        boolean[] status = new boolean[8];
-//        status[0] = staProtocol.isAutoing();
-//        status[1] = staProtocol.isLoading();
-//        status[2] = staProtocol.isInEnable();
-//        status[3] = staProtocol.isOutEnable();
-//        status[4] = staProtocol.isEmptyMk();
-//        OperateResult write2 = siemensS7Net.Write("DB100." + ((staProtocol.getSiteId() - 1) + 40), status);     //  鐘舵��
+        OperateResult write1 = siemensS7Net.Write("DB100." + (index*2 + 200), staProtocol.getStaNo());    // 鐩爣绔�
         if (!write.IsSuccess || !write1.IsSuccess) {
             staProtocol = station.get(staProtocol.getSiteId());
             if (staProtocol.getWorkNo() == 0 && staProtocol.getStaNo() ==0) {
@@ -245,25 +231,25 @@
         siemensS7Net.ConnectClose();
     }
 
-//    public static void main(String[] args) throws Exception {
-//        DevpSlave slave = new DevpSlave();
-//        slave.setIp("192.168.2.125");
-//        SiemensDevpThread devpThread = new SiemensDevpThread(slave);
-//        devpThread.connect();
-//        devpThread.read();
-//        // 鍐�
-//        StaProtocol staProtocol = devpThread.getStation().get(1);
-//        staProtocol.setWorkNo((short) 232);
-//        staProtocol.setStaNo((short) 6);
-//        staProtocol.setAutoing(true);
-//        staProtocol.setEmptyMk(true);
-//        staProtocol.setInEnable(true);
-//        devpThread.write(staProtocol);
-//        System.out.println("----------------------------------------");
-//        // 璇�
-//        devpThread.read();
-//        System.out.println(JSON.toJSONString(devpThread.station));
-//
-//    }
+    public static void main(String[] args) throws Exception {
+        DevpSlave slave = new DevpSlave();
+        slave.setIp("192.168.2.125");
+        SiemensDevpThread devpThread = new SiemensDevpThread(slave);
+        devpThread.connect();
+        devpThread.read();
+        // 鍐�
+        StaProtocol staProtocol = devpThread.getStation().get(1);
+        staProtocol.setWorkNo((short) 232);
+        staProtocol.setStaNo((short) 6);
+        staProtocol.setAutoing(true);
+        staProtocol.setEmptyMk(true);
+        staProtocol.setInEnable(true);
+        devpThread.write(staProtocol);
+        System.out.println("----------------------------------------");
+        // 璇�
+        devpThread.read();
+        System.out.println(JSON.toJSONString(devpThread.station));
+
+    }
 
 }

--
Gitblit v1.9.1