From 2599526586d46212c48eaccba1a8cea97e14176d Mon Sep 17 00:00:00 2001
From: zhang <zc857179121@qq.com>
Date: 星期四, 14 八月 2025 16:41:04 +0800
Subject: [PATCH] 1
---
src/main/java/com/zy/core/thread/SiemensDevpThread.java | 62 +++++++++++++++++++++++++++++++
1 files changed, 62 insertions(+), 0 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..5abe98d 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,6 +121,11 @@
// 鍐欐暟鎹� ID+鐩爣绔�
case 2:
write((StaProtocol) task.getData());
+ log.error("杈撻�佺嚎涓嬪彂鍛戒护锛�" + ((StaProtocol) task.getData()).getWorkNo() + "," + ((StaProtocol) task.getData()).getStaNo());
+ break;
+ // 鍐欐暟鎹� ID+鐩爣绔�
+ case 3:
+ write2((StaProtocol) task.getData());
log.error("杈撻�佺嚎涓嬪彂鍛戒护锛�" + ((StaProtocol) task.getData()).getWorkNo() + "," + ((StaProtocol) task.getData()).getStaNo());
break;
default:
@@ -208,6 +217,34 @@
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);
+ }
+ }
+ }
+ 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]); // 楂樺簱浣�
@@ -364,6 +401,31 @@
}
}
+ 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("鍐欏叆杈撻�佺嚎鍛戒护鎴愬姛銆傝緭閫佺嚎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 updateIoMode() throws InterruptedException {
if (this.ioModeOf2F != IoModeType.NONE) {
--
Gitblit v1.9.1