From 8076a2a7abb05b4f49544bd95a6083bae0048023 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期三, 13 一月 2021 15:19:38 +0800
Subject: [PATCH] #test
---
src/main/java/com/zy/core/thread/SiemensDevpThread.java | 82 +++++++++++++++++------------------------
1 files changed, 34 insertions(+), 48 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..3cfbbd6 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);
@@ -180,7 +169,7 @@
} else {
OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戣鍙栬緭閫佺嚎plc鐘舵�佷俊鎭け璐� ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()));
- log.error("璇诲彇鍫嗗灈鏈簆lc鐘舵�佷俊鎭け璐� ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot());
+ log.error("璇诲彇杈撻�佺嚎plc鐘舵�佷俊鎭け璐� ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot());
}
}
@@ -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