From 45213eb52bf46d8734802f6d64ddf31ab8192946 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <xltys1995>
Date: 星期四, 27 八月 2020 15:33:01 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/thread/DevpThread.java |   30 ++++++++++++++++++------------
 1 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/src/main/java/com/zy/core/thread/DevpThread.java b/src/main/java/com/zy/core/thread/DevpThread.java
index 0352ad7..6fcc130 100644
--- a/src/main/java/com/zy/core/thread/DevpThread.java
+++ b/src/main/java/com/zy/core/thread/DevpThread.java
@@ -104,7 +104,7 @@
     /**
      * 璇诲彇鐘舵�� ====> 鏁村潡plc
      */
-    private void read(){
+    private void read() throws InterruptedException {
         OperateResultExOne<byte[]> result = melsecMcNet.Read("D101", (short) 30);
         if (result.IsSuccess) {
             for (int i = 1; i <= 8; i++) {
@@ -118,6 +118,7 @@
                 staProtocol.setStaNo(melsecMcNet.getByteTransform().TransInt16(result.Content, (i-1)*2+40));   // 鐩爣绔�
             }
         }
+        Thread.sleep(100);
         OperateResultExOne<boolean[]> result1 = melsecMcNet.ReadBool("M800", (short) 64);
         if (result1.IsSuccess) {
             for (int i = 1; i <= 8; i++) {
@@ -157,11 +158,12 @@
     /**
      * 鍐欏叆 ID+鐩爣绔� =====> 鍗曠珯鐐瑰啓鍏�
      */
-    private void write(StaProtocol staProtocol){
+    private void write(StaProtocol staProtocol) throws InterruptedException {
         if (null == staProtocol) {
             return;
         }
         OperateResult write = melsecMcNet.Write("D10" + staProtocol.getSiteId(), staProtocol.getWorkNo());    // 宸ヤ綔鍙�
+        Thread.sleep(100);
         OperateResult write1 = melsecMcNet.Write("D12" + staProtocol.getSiteId(), staProtocol.getStaNo());    // 鐩爣绔�
 //        boolean[] status = new boolean[8];
 //        status[0] = staProtocol.isAutoing();
@@ -230,23 +232,27 @@
         melsecMcNet.ConnectClose();
     }
 
-    public static void main(String[] args) {
+    public static void main(String[] args) throws Exception {
         DevpSlave slave = new DevpSlave();
-        slave.setIp("192.168.2.125");
+        slave.setIp("192.168.3.65");
+        slave.setPort(6000);
         DevpThread devpThread = new DevpThread(slave);
         devpThread.connect();
         devpThread.read();
+        System.out.println("绗竴娆¤");
         // 鍐�
-        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("----------------------------------------");
+//        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("----------------------------------------");
+        Thread.sleep(400);
         // 璇�
         devpThread.read();
+        System.out.println("绗簩娆¤");
         System.out.println(JSON.toJSONString(devpThread.station));
 
     }

--
Gitblit v1.9.1