From e4c910e1d145803f506d69688555d4ff2a86a45e Mon Sep 17 00:00:00 2001
From: 1 <1@123>
Date: 星期五, 09 五月 2025 11:29:04 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/thread/SiemensDevpThread.java | 75 +++++++++++++++++++++++--------------
1 files changed, 46 insertions(+), 29 deletions(-)
diff --git a/src/main/java/com/zy/core/thread/SiemensDevpThread.java b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
index a7ddb53..f59ff6d 100644
--- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java
+++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -46,13 +46,15 @@
private Map<Integer, StaProtocol> station = new ConcurrentHashMap<>();
private short heartBeatVal = 1;
public static final ArrayList<Integer> staNos1 = new ArrayList<Integer>() {{
- add(100);add(101);add(102);add(103);add(104);add(105);add(106);add(107);
+ add(1001);add(1002);add(1003);add(1004);add(1005);add(1006);add(1007);
+ add(1008);add(1009);add(1010);add(1011);add(1012);add(1013);add(1014);add(1015);
+ add(1016);add(1017);add(1018);add(1019);add(1020);add(1021);add(1022);add(1023);
}};
/**
* 鏉$爜鏁伴噺
*/
- private int barcodeSize = 4;
+ private int barcodeSize = 3;
/**
* 鍏ュ嚭搴撴ā寮�
@@ -183,13 +185,18 @@
boolean[] status = siemensS7Net.getByteTransform().TransBool(result.Content, i*8 + 6, 2);
staProtocol.setAutoing(status[0]); // 鑷姩
+// staProtocol.setAutoing(true); // 鑷姩
staProtocol.setLoading(status[1]); // 鏈夌墿
+// staProtocol.setLoading(true); // 鏈夌墿
staProtocol.setInEnable(status[2]); // 鍙叆
+// staProtocol.setInEnable(true); // 鍙叆
staProtocol.setOutEnable(status[3]);// 鍙嚭
+ staProtocol.setOutEnable(true);// 鍙嚭
staProtocol.setEmptyMk(status[4]); // 绌烘澘淇″彿
staProtocol.setFullPlt(status[5]); // 婊℃墭鐩�
staProtocol.setHigh(status[6]); // 楂樺簱浣�
staProtocol.setLow(status[7]); // 浣庡簱浣�
+ staProtocol.setStaOk(status[8]); // 灏辩华
@@ -215,7 +222,6 @@
barcodeThread.setBarcode(barcode);
}
}
-
}
if (result.IsSuccess) {
@@ -261,26 +267,26 @@
int index = staNos.indexOf(staProtocol.getSiteId());
- //鏇存柊鍛戒护鏃ュ織
- CommandInfoLogService commandInfoLogService = SpringUtils.getBean(CommandInfoLogService.class);
- CommandInfoService commandInfoService = SpringUtils.getBean(CommandInfoService.class);
- CommandInfo commandInfo = commandInfoService.selectById(staProtocol.getCommandId());
- CommandInfoLog commandInfoLog = new CommandInfoLog();
- if (commandInfo != null) {
- commandInfoLog = JSON.parseObject(JSON.toJSONString(commandInfo), CommandInfoLog.class);
- commandInfoLog.setId(null);
- }else {
- Date now = new Date();
- commandInfoLog.setCommand(JSON.toJSONString(staProtocol));
- commandInfoLog.setCommandStatus(3);
- commandInfoLog.setStartTime(now);
- commandInfoLog.setExecuteTime(now);
- commandInfoLog.setCompleteTime(now);
- commandInfoLog.setDevice(SlaveType.Devp.toString());
- commandInfoLog.setWrkNo(9999);
- commandInfoLog.setTaskNo("9999");
- commandInfoLog.setCommandDesc("鎵嬪姩鍛戒护");
- }
+// //鏇存柊鍛戒护鏃ュ織
+// CommandInfoLogService commandInfoLogService = SpringUtils.getBean(CommandInfoLogService.class);
+// CommandInfoService commandInfoService = SpringUtils.getBean(CommandInfoService.class);
+// CommandInfo commandInfo = commandInfoService.selectById(staProtocol.getCommandId());
+// CommandInfoLog commandInfoLog = new CommandInfoLog();
+// if (commandInfo != null) {
+// commandInfoLog = JSON.parseObject(JSON.toJSONString(commandInfo), CommandInfoLog.class);
+// commandInfoLog.setId(null);
+// }else {
+// Date now = new Date();
+// commandInfoLog.setCommand(JSON.toJSONString(staProtocol));
+// commandInfoLog.setCommandStatus(3);
+// commandInfoLog.setStartTime(now);
+// commandInfoLog.setExecuteTime(now);
+// commandInfoLog.setCompleteTime(now);
+// commandInfoLog.setDevice(SlaveType.Devp.toString());
+// commandInfoLog.setWrkNo(9999);
+// commandInfoLog.setTaskNo("9999");
+// commandInfoLog.setCommandDesc("鎵嬪姩鍛戒护");
+// }
OperateResult writeResult;
//浠诲姟涓嬪彂娆℃暟
@@ -288,15 +294,15 @@
//浠诲姟涓嬪彂鎴愬姛鏍囪瘑
boolean writeFlag = false;
while(writeCount < 5){
- OperateResult writeResult1 = siemensS7Net.Write("DB100." + index*6, staProtocol.getWorkNo()); // 宸ヤ綔鍙�
- OperateResult writeResult2 = siemensS7Net.Write("DB100." + (index*6+4), staProtocol.getStaNo()); // 鐩爣绔�
+ OperateResult writeResult1 = siemensS7Net.Write("DB101." + index*8, staProtocol.getWorkNo()); // 宸ヤ綔鍙�
+ OperateResult writeResult2 = siemensS7Net.Write("DB101." + (index*8+4), staProtocol.getStaNo().shortValue()); // 鐩爣绔�
if(writeResult1.IsSuccess && writeResult2.IsSuccess){
Thread.sleep(200);
OperateResultExOne<byte[]> readResult = siemensS7Net.Read("DB101.0" + index*8, (short)4);
//鏇存柊鎸囦护鏃ュ織
- commandInfoLog.setDeviceLog("鎸囦护涓嬪彂鎴愬姛");
- commandInfoLogService.insert(commandInfoLog);
+// commandInfoLog.setDeviceLog("鎸囦护涓嬪彂鎴愬姛");
+// commandInfoLogService.insert(commandInfoLog);
if(readResult.IsSuccess){
Integer workNo = siemensS7Net.getByteTransform().TransInt32(readResult.Content, 0);
@@ -325,8 +331,8 @@
log.error("鍐欏叆杈撻�佺嚎鍛戒护澶辫触銆傝緭閫佺嚎plc缂栧彿={}锛岀珯鐐规暟鎹�={},鍐欏叆娆℃暟={}", slave.getId(), JSON.toJSON(staProtocol), writeCount);
//鏇存柊鎸囦护鏃ュ織
- commandInfoLog.setDeviceLog("鎸囦护涓嬪彂澶辫触");
- commandInfoLogService.insert(commandInfoLog);
+// commandInfoLog.setDeviceLog("鎸囦护涓嬪彂澶辫触");
+// commandInfoLogService.insert(commandInfoLog);
}
Thread.sleep(200);
}
@@ -412,6 +418,17 @@
}
}
+ /**
+ * 璁剧疆鍏ュ簱鏍囪
+ */
+ @Override
+ public void setGrossWt(Integer siteId, Double grossWt) {
+ StaProtocol staProtocol = station.get(siteId);
+ if (null != staProtocol) {
+ staProtocol.setGrossWt(grossWt);
+ }
+ }
+
@Override
public void close() {
siemensS7Net.ConnectClose();
--
Gitblit v1.9.1