From 608775c2431d9a8eab45fab90f8df31a4ca7873f Mon Sep 17 00:00:00 2001
From: L <L@132>
Date: 星期四, 17 七月 2025 14:15:02 +0800
Subject: [PATCH] *
---
src/main/java/com/zy/core/thread/RgvThread.java | 89 +++++++++++++++++++++++++++++++++++++++-----
1 files changed, 78 insertions(+), 11 deletions(-)
diff --git a/src/main/java/com/zy/core/thread/RgvThread.java b/src/main/java/com/zy/core/thread/RgvThread.java
index 6f98c45..32a4060 100644
--- a/src/main/java/com/zy/core/thread/RgvThread.java
+++ b/src/main/java/com/zy/core/thread/RgvThread.java
@@ -74,17 +74,6 @@
// 鍚姩浠诲姟涓嬪彂绾跨▼
new Thread(this::taskIssued).start();
-
-
- while (true) {
- try {
-
- Thread.sleep(500);
- } catch (Exception e) {
-// e.printStackTrace();
- }
-
- }
}
@@ -184,6 +173,10 @@
commandAvoidanceXY.setCommand((short)0);
write(commandAvoidanceXY);
break;
+ // 宸ヤ綅1瀹屾垚銆�2鍐欏叆鏁版嵁
+ case 10:
+ write10((RgvCommand) task.getData());
+ break;
default:
break;
}
@@ -264,6 +257,17 @@
rgvProtocol.setxSpeed((short) 0);
rgvProtocol.setxDistance((short) 0);
rgvProtocol.setxDuration((short) 0);
+ try {
+ // 鏍规嵁瀹炴椂淇℃伅鏇存柊鏁版嵁搴�
+ BasRgvService basRgvService = SpringUtils.getBean(BasRgvService.class);
+ BasRgv basRgv = new BasRgv();
+ basRgv.setRgvNo(slave.getId());
+ basRgv.setRgvSts((int)rgvProtocol.getMode());
+ basRgv.setLoaded2(rgvProtocol.getLoaded2().intValue());
+ if (!basRgvService.updateById(rgvProtocol.toSqlModel(basRgv))){
+ log.error("RGV plc鏁版嵁搴撴洿鏂板け璐� ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot());
+ }
+ } catch (Exception ignore){}
}
@Override
@@ -432,6 +436,69 @@
}
}
+
+ /**
+ * 宸ヤ綅1瀹屾垚銆�2鍚屾椂鍐欏叆鏁版嵁
+ */
+ private boolean write10(RgvCommand command) throws InterruptedException {
+ if (null == command) {
+ log.error("RGV鍐欏叆鍛戒护涓虹┖");
+ return false;
+ }
+// convertRow(command);
+ command.setRgvNo(slave.getId());
+ short[] array = new short[11];
+ array[0] = command.getAckFinish1();
+ array[1] = command.getTaskNo1();
+ array[2] = command.getTaskMode1();
+ array[3] = command.getSourceStaNo1();
+ array[4] = command.getDestinationStaNo1();
+ array[5] = command.getAckFinish2();
+ array[6] = command.getTaskNo2();
+ array[7] = command.getTaskMode2();
+ array[8] = command.getSourceStaNo2();
+ array[9] = command.getDestinationStaNo2();
+ array[10] = command.getCommand();
+ OperateResult result = siemensNet.Write("DB100.0", array);
+
+ if (command.getAckFinish2() == 0) {
+ short commandFinish = 2; //宸ヤ綅2浠诲姟鍚屾椂鍐欏叆
+ Thread.sleep(100L);
+ result = siemensNet.Write("DB100.20", commandFinish);
+ }
+
+ try {
+ // 鏃ュ織璁板綍
+ BasRgvOptService bean = SpringUtils.getBean(BasRgvOptService.class);
+ BasRgvOpt basRgvOpt = new BasRgvOpt(
+ command.getTaskNo1().intValue(),
+ command.getTaskNo2().intValue(),
+ command.getRgvNo(),
+ new Date(),
+ command.getTaskModeType1().toString(),
+ command.getSourceStaNo1().intValue(),
+ command.getDestinationStaNo1().intValue(),
+ command.getSourceStaNo2().intValue(),
+ command.getDestinationStaNo2().intValue(),
+ null,
+ new Date(),
+ null
+ );
+ bean.insert(basRgvOpt);
+ } catch (Exception ignore) {}
+
+ if (result != null && result.IsSuccess) {
+ Thread.sleep(200);
+ this.readStatus();
+ log.info("RGV 鍛戒护涓嬪彂[id:{}] >>>>> {}", slave.getId(), JSON.toJSON(command));
+ OutputQueue.RGV.offer(MessageFormat.format("銆恵0}銆慬id:{1}] >>>>> 鍛戒护涓嬪彂锛� {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command)));
+ return true;
+ } else {
+ OutputQueue.RGV.offer(MessageFormat.format("銆恵0}銆戝啓鍏GV plc鏁版嵁澶辫触 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));
+ log.error("鍐欏叆RGV plc鏁版嵁澶辫触 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
+ return false;
+ }
+ }
/**
* 宸ヤ綅1鍐欏叆鏁版嵁
*/
--
Gitblit v1.9.1