From d6969a2d987d798aadd7be32c53492704c6c1d26 Mon Sep 17 00:00:00 2001
From: 野心家 <1051256694@qq.com>
Date: 星期二, 27 五月 2025 12:44:54 +0800
Subject: [PATCH] #ZH
---
src/main/java/com/zy/core/thread/SiemensDevpThread.java | 47 +++++++++++++++++++++++++++++++++++++++--------
1 files changed, 39 insertions(+), 8 deletions(-)
diff --git a/src/main/java/com/zy/core/thread/SiemensDevpThread.java b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
index f59ff6d..fdf1b1c 100644
--- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java
+++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -213,14 +213,37 @@
//鏉$爜
Thread.sleep(200);
- OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.840.0",(short) (barcodeSize*8));
+ OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB400.100.0",(short) (barcodeSize*8));
if (result2.IsSuccess) {
for (int i = 0; i < barcodeSize; i++) {
- String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,i*8,8, "UTF-8");
+ String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,i*8,6, "UTF-8");
BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, i + 1);
if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) {
barcodeThread.setBarcode(barcode);
}
+ }
+ }
+
+ //鏉$爜
+ Thread.sleep(200);
+ int[] staW = new int[]{1004,1014,1020};
+
+ OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB400.148.0",(short) (staW.length*4));
+ if (result3.IsSuccess) {
+ for (int i = 0; i < staW.length; i++) {
+ Integer siteId = staW[i]; // 绔欑偣缂栧彿
+ StaProtocol staProtocol = station.get(siteId);
+ if (null == staProtocol) {
+ staProtocol = new StaProtocol();
+ station.put(siteId, staProtocol);
+ }
+ staProtocol.setSiteId(siteId);
+ boolean[] status = siemensS7Net.getByteTransform().TransBool(result3.Content, i*4 + 2, 2);
+ staProtocol.setFrontErr(status[0]); // 鍓嶈秴闄�
+ staProtocol.setBackErr(status[1]); // 鍚庤秴闄�
+ staProtocol.setHighErr(status[2]); // 楂樿秴闄�
+ staProtocol.setLeftErr(status[3]); // 宸﹁秴闄�
+ staProtocol.setRightErr(status[4]); // 鍙宠秴闄�
}
}
@@ -235,19 +258,27 @@
StaProtocol staProtocol = station.get(siteId);
basDevps.add(staProtocol.toSqlModel());
}
-
- BasDevpService basDevpService = SpringUtils.getBean(BasDevpService.class);
- if (null != basDevpService && !basDevpService.updateBatchById(basDevps)) {
- throw new Exception("鏇存柊鏁版嵁搴撴暟鎹け璐�");
+ try{
+ BasDevpService basDevpService = SpringUtils.getBean(BasDevpService.class);
+ if (null != basDevpService && !basDevpService.updateBatchById(basDevps)) {
+ throw new Exception("鏇存柊鏁版嵁搴撴暟鎹け璐�");
+ }
+ } catch (Exception e){
+ log.error("e:"+e.getMessage());
}
+
} catch (Exception e) {
e.printStackTrace();
OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戞洿鏂版暟鎹簱鏁版嵁澶辫触 ===>> [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("鏇存柊鏁版嵁搴撴暟鎹け璐� ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot());
}
- DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
- deviceErrorService.deleteDeviceError("devp", slave.getId());
+ try{
+ DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class);
+ deviceErrorService.deleteDeviceError("devp", slave.getId());
+ } catch (Exception e){
+ log.error("e:"+e.getMessage());
+ }
} 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("璇诲彇杈撻�佺嚎plc鐘舵�佷俊鎭け璐� ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot());
--
Gitblit v1.9.1