From 56b2eb4d4f458ecf0586551df044f3caede0db97 Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期三, 29 十一月 2023 15:55:12 +0800
Subject: [PATCH] #指令更新
---
src/main/java/com/zy/core/thread/SiemensDevpThread.java | 80 +++++++++++++++++++++++++++-------------
1 files changed, 54 insertions(+), 26 deletions(-)
diff --git a/src/main/java/com/zy/core/thread/SiemensDevpThread.java b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
index d258bd5..619b4d1 100644
--- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java
+++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -19,6 +19,7 @@
import com.zy.core.cache.MessageQueue;
import com.zy.core.cache.OutputQueue;
import com.zy.core.cache.SlaveConnection;
+import com.zy.core.enums.CommandStatusType;
import com.zy.core.enums.IoModeType;
import com.zy.core.enums.SlaveType;
import com.zy.core.model.DevpSlave;
@@ -73,7 +74,7 @@
/**
* 鏉$爜鏁伴噺
*/
- private int barcodeSize = 3;
+ private int barcodeSize = 7;
/**
* 鍏ュ嚭搴撴ā寮�
@@ -223,7 +224,7 @@
staProtocol.setOutEnable(status[3]);// 鍙嚭
staProtocol.setEmptyMk(status[4]); // 绌烘澘淇″彿
staProtocol.setFullPlt(status[5]); // 婊℃墭鐩�
- staProtocol.setHigh(status[6]); // 楂樺簱浣�
+ staProtocol.setCar(status[6]); // 鏄惁鏈夎溅
staProtocol.setLow(status[7]); // 浣庡簱浣�
if (!staProtocol.isPakMk() && !staProtocol.isLoading()) {
@@ -232,20 +233,21 @@
}
}
+
+ if (slave.getId() == 1){
//鏉$爜
Thread.sleep(200);
- OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.100",(short)31);
+ OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.102",(short)60);
if (result2.IsSuccess) {
- for (int i = 0; i < barcodeSize; i++) {
- String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,i*8,8, "UTF-8");
+ for (int i = 0; i < 6; i++) {
+ String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,i*10,8, "UTF-8");
BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, i + 1);
if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) {
barcodeThread.setBarcode(barcode);
}
}
-
}
- if (slave.getId() == 1){
+
// 澶栧舰妫�娴� - 102
Thread.sleep(100);
OperateResultExOne<byte[]> result4 = siemensS7Net.Read("DB101.150", (short)1);
@@ -422,22 +424,24 @@
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("鎵嬪姩鍛戒护");
- }
+ CommandInfoLog commandInfoLog = JSON.parseObject(JSON.toJSONString(commandInfo), CommandInfoLog.class);
+ commandInfoLog.setId(null);
+// 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;
//浠诲姟涓嬪彂娆℃暟
@@ -446,9 +450,6 @@
boolean writeFlag = false;
while(writeCount < 5){
writeResult = siemensS7Net.Write("DB100." + index*4, array); // 宸ヤ綔鍙枫�佺洰鏍囩珯
- //鏇存柊鎸囦护鏃ュ織
- commandInfoLog.setDeviceLog("鎸囦护涓嬪彂鎴愬姛");
- commandInfoLogService.insert(commandInfoLog);
if(writeResult.IsSuccess){
Thread.sleep(200);
@@ -460,12 +461,39 @@
//浠诲姟鍛戒护鍐欏叆鎴愬姛
writeFlag = true;
log.info("鍐欏叆杈撻�佺嚎鍛戒护鍚庤繑鍥炴垚鍔燂紝骞朵笖鍥炶鎴愬姛銆傝緭閫佺嚎plc缂栧彿={}锛寋}锛屽啓鍏ユ鏁�={}", slave.getId(), JSON.toJSON(staProtocol), writeCount);
+
+ Date now = new Date();
+
+ //鏇存柊鎸囦护鐘舵��
+ commandInfo.setCommandStatus(CommandStatusType.COMPLETE.id);//杈撻�佺嚎鐩存帴瀹屾垚鐘舵��
+ commandInfo.setExecuteTime(now);
+ commandInfo.setCompleteTime(now);
+ commandInfoService.updateById(commandInfo);
+
+ //鏇存柊鎸囦护鏃ュ織
+ commandInfoLog.setDeviceLog("鎸囦护涓嬪彂鎴愬姛");
+ commandInfoLog.setCommandStatus(CommandStatusType.COMPLETE.id);//杈撻�佺嚎鐩存帴瀹屾垚鐘舵��
+ commandInfoLog.setExecuteTime(now);
+ commandInfoLog.setCompleteTime(now);
+ commandInfoLogService.insert(commandInfoLog);
+
+ //鏇存柊浠诲姟姝ュ簭
+ TaskWrkService taskWrkService = SpringUtils.getBean(TaskWrkService.class);
+ TaskWrk taskWrk = taskWrkService.selectByWrkNo(staProtocol.getWorkNo().intValue());
+ if (taskWrk != null) {
+ taskWrk.setCommandStep(taskWrk.getCommandStep() + 1);//鏇存柊鎸囦护姝ュ簭
+ taskWrkService.updateById(taskWrk);
+ }
+
break;
} else {//杩斿洖缁撴灉鏄垚鍔熶簡锛屼絾鏄湡瀹炲�间笉鐩稿悓
writeCount++;
OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戝啓鍏ヨ緭閫佺嚎鍛戒护鍚庤繑鍥炴垚鍔燂紝浣嗘槸璇诲彇浠诲姟鍊间笉涓�鑷淬�傝緭閫佺嚎plc缂栧彿={1}锛岀珯鐐规暟鎹�={2},鍐欏叆娆℃暟={3}",
slave.getId(), JSON.toJSON(staProtocol),writeCount));
log.error("鍐欏叆杈撻�佺嚎鍛戒护鍚庤繑鍥炴垚鍔燂紝浣嗘槸璇诲彇浠诲姟鍊间笉涓�鑷淬�傝緭閫佺嚎plc缂栧彿={}锛寋}锛屽啓鍏ユ鏁�={}", slave.getId(), JSON.toJSON(staProtocol), writeCount);
+ //鏇存柊鎸囦护鏃ュ織
+ commandInfoLog.setDeviceLog("鎸囦护涓嬪彂澶辫触");
+ commandInfoLogService.insert(commandInfoLog);
}
} else {
writeCount++;
--
Gitblit v1.9.1