From 2aeea7b010e96f74a52bc4ed5873c41c177a5953 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <xltys1995>
Date: 星期四, 27 八月 2020 14:09:57 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/thread/DevpThread.java | 24 ++++++++++++++----------
1 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/src/main/java/com/zy/core/thread/DevpThread.java b/src/main/java/com/zy/core/thread/DevpThread.java
index 3b57b24..b418f79 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++) {
@@ -230,24 +231,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.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