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 | 59 ++++++++++++++++++++++++++++++-----------------------------
1 files changed, 30 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 56f40a1..f59ff6d 100644
--- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java
+++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -54,7 +54,7 @@
/**
* 鏉$爜鏁伴噺
*/
- private int barcodeSize = 2;
+ private int barcodeSize = 3;
/**
* 鍏ュ嚭搴撴ā寮�
@@ -191,11 +191,12 @@
staProtocol.setInEnable(status[2]); // 鍙叆
// staProtocol.setInEnable(true); // 鍙叆
staProtocol.setOutEnable(status[3]);// 鍙嚭
-// staProtocol.setOutEnable(true);// 鍙嚭
+ staProtocol.setOutEnable(true);// 鍙嚭
staProtocol.setEmptyMk(status[4]); // 绌烘澘淇″彿
staProtocol.setFullPlt(status[5]); // 婊℃墭鐩�
staProtocol.setHigh(status[6]); // 楂樺簱浣�
staProtocol.setLow(status[7]); // 浣庡簱浣�
+ staProtocol.setStaOk(status[8]); // 灏辩华
@@ -212,7 +213,7 @@
//鏉$爜
Thread.sleep(200);
- OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.100.0",(short) (barcodeSize*8));
+ OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.840.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");
@@ -266,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;
//浠诲姟涓嬪彂娆℃暟
@@ -293,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);
@@ -330,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);
}
--
Gitblit v1.9.1