From 9d82e56ee05e2be1150b98da80b720b4f93f6afd Mon Sep 17 00:00:00 2001
From: zhang <zc857179121@qq.com>
Date: 星期六, 11 四月 2026 09:56:48 +0800
Subject: [PATCH] 1
---
zy-asc-conveyor/src/main/java/com/zy/acs/conveyor/core/thread/SiemensDevpThread.java | 21 ++++++++++++++++-----
1 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/zy-asc-conveyor/src/main/java/com/zy/acs/conveyor/core/thread/SiemensDevpThread.java b/zy-asc-conveyor/src/main/java/com/zy/acs/conveyor/core/thread/SiemensDevpThread.java
index dbc7d9a..0c9d2ee 100644
--- a/zy-asc-conveyor/src/main/java/com/zy/acs/conveyor/core/thread/SiemensDevpThread.java
+++ b/zy-asc-conveyor/src/main/java/com/zy/acs/conveyor/core/thread/SiemensDevpThread.java
@@ -8,6 +8,8 @@
import com.zy.acs.conveyor.core.constant.StationStatusField;
import com.zy.acs.conveyor.core.model.StaProtocol;
import com.zy.acs.conveyor.core.properties.DevpSlave;
+import com.zy.acs.conveyor.core.service.DevpS7Service;
+import com.zy.acs.conveyor.core.service.StationService;
import com.zy.acs.conveyor.entity.Devp;
import com.zy.acs.conveyor.service.DevpService;
import com.zy.acs.conveyor.utils.SpringContextUtil;
@@ -32,8 +34,6 @@
private SiemensS7Net siemensS7Net;
private Map<Integer, StaProtocol> station;
-
- private volatile boolean connected = false;
private static final int WRITE_RETRY_MAX = 5;
@@ -75,8 +75,20 @@
* 璇诲彇鐘舵�� ====> 鏁村潡plc
*/
private void read() throws InterruptedException {
- if (!connected || siemensS7Net == null) {
+ if (siemensS7Net == null) {
+ DevpS7Service devpS7Service = SpringContextUtil.getBean(DevpS7Service.class);
+ if (devpS7Service != null) {
+ siemensS7Net = devpS7Service.get(slave.getId());
+ }
log.warn("PLC鏈繛鎺ワ紝璺宠繃璇诲彇 [id:{}]", slave.getId());
+ return;
+ }
+ if (station == null) {
+ StationService stationService = SpringContextUtil.getBean(StationService.class);
+ if (stationService != null) {
+ station = stationService.getStationMap(slave.getId());
+ }
+ log.warn("绔欑偣鏈繛鎺ワ紝璺宠繃璇诲彇 [id:{}]", slave.getId());
return;
}
@@ -90,7 +102,6 @@
if (!result.IsSuccess) {
log.error("璇诲彇绔欑偣鐘舵�佸け璐� [id:{}] [error:{}]", slave.getId(), result.Message);
- connected = false;
return;
}
@@ -165,7 +176,7 @@
if (!Cools.isEmpty(barcode)) {
StaProtocol staProtocol = station.get(barcodeArr.get(i));
staProtocol.setBarcode(barcode);
- log.info("鏂欑鐮侊細{}", barcode);
+ News.info("鏂欑鐮侊細{}", barcode);
}
}
}
--
Gitblit v1.9.1