From c301a5be2ee3d7c846b56b3385b3b6c1bd9d2ba0 Mon Sep 17 00:00:00 2001
From: lsh <lsh@163.com>
Date: 星期四, 05 六月 2025 20:50:25 +0800
Subject: [PATCH] *
---
src/main/java/com/zy/core/thread/RgvThread.java | 71 ++++++++++++++++++++++++++++-------
1 files changed, 56 insertions(+), 15 deletions(-)
diff --git a/src/main/java/com/zy/core/thread/RgvThread.java b/src/main/java/com/zy/core/thread/RgvThread.java
index ece3eeb..b05440d 100644
--- a/src/main/java/com/zy/core/thread/RgvThread.java
+++ b/src/main/java/com/zy/core/thread/RgvThread.java
@@ -84,6 +84,14 @@
private void taskIssued() {
while (true) {
try {
+ if(!connectRgv){
+ try {
+ Thread.sleep(1000L);
+ } catch (Exception e){
+
+ }
+ continue;
+ }
int step = 1;
Task task = MessageQueue.poll(SlaveType.Rgv, slave.getId());
if (task != null) {
@@ -112,10 +120,28 @@
command.setDestinationStaNo1((short)0); // 鐩爣绔�
write3(command);
break;
+ // 澶嶄綅
+ case 4:
+ RgvCommand command4 = (RgvCommand) task.getData();
+ if (null == command4) {
+ command4 = new RgvCommand();
+ }
+ command4.setRgvNo(slave.getId()); // RGV缂栧彿
+ command4.setTaskNo1((short) 0); // 宸ヤ綔鍙�
+ command4.setAckFinish1((short) 1); // 浠诲姟瀹屾垚纭浣�
+ command4.setTaskMode1(RgvTaskModeType.X_MOVE); // 浠诲姟妯″紡
+ command4.setSourceStaNo1((short)0); // 婧愮珯
+ command4.setDestinationStaNo1((short)0); // 鐩爣绔�
+ write3(command4);
+ break;
+ // 婕父
+ case 5:
+ write5((Long) task.getData());
+ break;
default:
break;
}
- Thread.sleep(100);
+ Thread.sleep(50);
} catch (Exception e) {
log.error("RGV鍐欑嚎绋嬪紓甯�"+e.getMessage());
// e.printStackTrace();
@@ -148,6 +174,15 @@
private void readStatusRgv() {
while (true) {
try {
+ if(!connectRgv){
+ try {
+ Thread.sleep(1000L);
+ } catch (Exception e){
+
+ }
+ initRgv();
+ continue;
+ }
Thread.sleep(40);
readStatus();
@@ -215,7 +250,7 @@
OperateResultExOne<byte[]> result = siemensNet.Read("DB100.0", (short) 20);
OperateResultExOne<byte[]> resultV = siemensNet.Read("DB20.16", (short) 2);
OperateResultExOne<byte[]> resultE = siemensNet.Read("DB20.26", (short) 2);
- if (result.IsSuccess) {
+ if (result.IsSuccess && resultV.IsSuccess && resultE.IsSuccess) {
if (null == rgvProtocol) {
rgvProtocol = new RgvProtocol();
rgvProtocol.setRgvNo(slave.getId());
@@ -326,6 +361,12 @@
return false;
}
}
+ private void write5(Long devperimeter){
+ try {
+ siemensNet.Write("DB24.10.0", false);
+ siemensNet.Write("DB24.10.0", devperimeter.intValue());
+ } catch (Exception ignore) {}
+ }
private boolean write3(RgvCommand command) throws InterruptedException {
if (null == command) {
log.error("RGV鍐欏叆鍛戒护涓虹┖");
@@ -393,18 +434,18 @@
/******************************************************************************************/
/**************************************** 娴嬭瘯涓撶敤 *****************************************/
/*****************************************************************************************/
- public static void main(String[] args) throws InterruptedException {
- RgvSlave slave = new RgvSlave();
- slave.setId(1);
- slave.setIp("192.168.6.9");
- slave.setRack(0);
- slave.setSlot(0);
- RgvThread rgvThread = new RgvThread(slave);
- rgvThread.connect();
- rgvThread.readStatus();
- System.out.println(JSON.toJSONString(rgvThread.rgvProtocol));
- Thread.sleep(3000L);
-
- }
+// public static void main(String[] args) throws InterruptedException {
+// RgvSlave slave = new RgvSlave();
+// slave.setId(1);
+// slave.setIp("192.168.6.9");
+// slave.setRack(0);
+// slave.setSlot(0);
+// RgvThread rgvThread = new RgvThread(slave);
+// rgvThread.connect();
+// rgvThread.readStatus();
+// System.out.println(JSON.toJSONString(rgvThread.rgvProtocol));
+// Thread.sleep(3000L);
+//
+// }
}
--
Gitblit v1.9.1