From a3d44470b704e81d4f66399bed2f37529ddb31be Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期四, 25 十二月 2025 13:53:32 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/network/real/ZyDualCrnRealConnect.java | 259 +++++++++++++++++++++++++--------------------------
1 files changed, 129 insertions(+), 130 deletions(-)
diff --git a/src/main/java/com/zy/core/network/real/ZyDualCrnRealConnect.java b/src/main/java/com/zy/core/network/real/ZyDualCrnRealConnect.java
index c5d2b06..9a35a44 100644
--- a/src/main/java/com/zy/core/network/real/ZyDualCrnRealConnect.java
+++ b/src/main/java/com/zy/core/network/real/ZyDualCrnRealConnect.java
@@ -108,145 +108,144 @@
@Override
public CommandResponse sendCommand(DualCrnCommand command) {
CommandResponse response = new CommandResponse(false);
- try {
- if (null == command) {
- News.error("鍙屽伐浣嶅爢鍨涙満鍐欏叆鍛戒护涓虹┖");
- response.setMessage("鍙屽伐浣嶅爢鍨涙満鍐欏叆鍛戒护涓虹┖");
- return response;
- }
+ // try {
+ // if (null == command) {
+ // News.error("鍙屽伐浣嶅爢鍨涙満鍐欏叆鍛戒护涓虹┖");
+ // response.setMessage("鍙屽伐浣嶅爢鍨涙満鍐欏叆鍛戒护涓虹┖");
+ // return response;
+ // }
- String address = "DB100.0";
- if (command.getStation() == 1) {
- //宸ヤ綅1
- address = "DB100.0";
- }else {
- //宸ヤ綅2
- address = "DB100.20";
- }
+ // String address = "DB100.0";
+ // if (command.getStation() == 1) {
+ // //宸ヤ綅1
+ // address = "DB100.0";
+ // }else {
+ // //宸ヤ綅2
+ // address = "DB100.20";
+ // }
- int writeAck = 0;
- boolean ackResult = false;
- do {
- OperateResult resultAck = siemensNet.Write(address, (short) 0);
- if (resultAck.IsSuccess) {
- Thread.sleep(200);
- OperateResultExOne<byte[]> resultRead = siemensNet.Read(address, (short) 2);
- short ack = siemensNet.getByteTransform().TransInt16(resultRead.Content, 0);
- if (ack != 0) {
- writeAck++;
- } else {
- News.info("鍙屽伐浣嶅爢鍨涙満鍛戒护涓嬪彂[id:{}] >>>>> {}", command.getCrnNo(), "ack澶嶄綅瀹屾垚");
- ackResult = true;
- break;
- }
- }
- } while (writeAck < 5);
+ // int writeAck = 0;
+ // boolean ackResult = false;
+ // do {
+ // OperateResult resultAck = siemensNet.Write(address, (short) 0);
+ // if (resultAck.IsSuccess) {
+ // Thread.sleep(200);
+ // OperateResultExOne<byte[]> resultRead = siemensNet.Read(address, (short) 2);
+ // short ack = siemensNet.getByteTransform().TransInt16(resultRead.Content, 0);
+ // if (ack != 0) {
+ // writeAck++;
+ // } else {
+ // News.info("鍙屽伐浣嶅爢鍨涙満鍛戒护涓嬪彂[id:{}] >>>>> {}", command.getCrnNo(), "ack澶嶄綅瀹屾垚");
+ // ackResult = true;
+ // break;
+ // }
+ // }
+ // } while (writeAck < 5);
- if (!ackResult) {
- response.setMessage("鍙屽伐浣嶅爢鍨涙満鍛戒护涓嬪彂[id:{}] >>>>> {}" + command.getCrnNo() + "ack澶嶄綅澶辫触");
- return response;
- }
+ // if (!ackResult) {
+ // response.setMessage("鍙屽伐浣嶅爢鍨涙満鍛戒护涓嬪彂[id:{}] >>>>> {}" + command.getCrnNo() + "ack澶嶄綅澶辫触");
+ // return response;
+ // }
- short[] array = new short[10];
- array[0] = command.getAckFinish();
- array[1] = command.getTaskNo();
- array[2] = command.getTaskMode();
- array[3] = command.getSourcePosX();
- array[4] = command.getSourcePosY();
- array[5] = command.getSourcePosZ();
- array[6] = command.getDestinationPosX();
- array[7] = command.getDestinationPosY();
- array[8] = command.getDestinationPosZ();
- array[9] = command.getCommand();
+ // short[] array = new short[10];
+ // array[1] = command.getTaskNo();
+ // array[2] = command.getTaskMode();
+ // array[3] = command.getSourcePosX();
+ // array[4] = command.getSourcePosY();
+ // array[5] = command.getSourcePosZ();
+ // array[6] = command.getDestinationPosX();
+ // array[7] = command.getDestinationPosY();
+ // array[8] = command.getDestinationPosZ();
+ // array[9] = command.getCommand();
- OperateResult result = null;
- int idx = 0;
- do {
- OperateResultExOne<byte[]> resultRead = siemensNet.Read(address, (short) 20);
- if (resultRead.IsSuccess) {
- if (command.getAckFinish() == 0) {
- short taskNo = siemensNet.getByteTransform().TransInt16(resultRead.Content, 2);
- short taskMode = siemensNet.getByteTransform().TransInt16(resultRead.Content, 4);
- short sourcePosX = siemensNet.getByteTransform().TransInt16(resultRead.Content, 6);
- short sourcePosY = siemensNet.getByteTransform().TransInt16(resultRead.Content, 8);
- short sourcePosZ = siemensNet.getByteTransform().TransInt16(resultRead.Content, 10);
- short destinationPosX = siemensNet.getByteTransform().TransInt16(resultRead.Content, 12);
- short destinationPosY = siemensNet.getByteTransform().TransInt16(resultRead.Content, 14);
- short destinationPosZ = siemensNet.getByteTransform().TransInt16(resultRead.Content, 16);
- if (taskNo == 0 || taskMode == 0 || sourcePosX == 0 || sourcePosY == 0 || sourcePosZ == 0 || destinationPosX == 0 || destinationPosY == 0 || destinationPosZ == 0) {
- result = siemensNet.Write(address, array);
- } else {
- break;
- }
- } else {
- short ackFinish = siemensNet.getByteTransform().TransInt16(resultRead.Content, 0);
- if (ackFinish != command.getAckFinish()) {
- result = siemensNet.Write(address, array);
- } else {
- break;
- }
- }
- }
- idx++;
- Thread.sleep(500);
- } while (idx < 5);
+ // OperateResult result = null;
+ // int idx = 0;
+ // do {
+ // OperateResultExOne<byte[]> resultRead = siemensNet.Read(address, (short) 20);
+ // if (resultRead.IsSuccess) {
+ // if (command.getAckFinish() == 0) {
+ // short taskNo = siemensNet.getByteTransform().TransInt16(resultRead.Content, 2);
+ // short taskMode = siemensNet.getByteTransform().TransInt16(resultRead.Content, 4);
+ // short sourcePosX = siemensNet.getByteTransform().TransInt16(resultRead.Content, 6);
+ // short sourcePosY = siemensNet.getByteTransform().TransInt16(resultRead.Content, 8);
+ // short sourcePosZ = siemensNet.getByteTransform().TransInt16(resultRead.Content, 10);
+ // short destinationPosX = siemensNet.getByteTransform().TransInt16(resultRead.Content, 12);
+ // short destinationPosY = siemensNet.getByteTransform().TransInt16(resultRead.Content, 14);
+ // short destinationPosZ = siemensNet.getByteTransform().TransInt16(resultRead.Content, 16);
+ // if (taskNo == 0 || taskMode == 0 || sourcePosX == 0 || sourcePosY == 0 || sourcePosZ == 0 || destinationPosX == 0 || destinationPosY == 0 || destinationPosZ == 0) {
+ // result = siemensNet.Write(address, array);
+ // } else {
+ // break;
+ // }
+ // } else {
+ // short ackFinish = siemensNet.getByteTransform().TransInt16(resultRead.Content, 0);
+ // if (ackFinish != command.getAckFinish()) {
+ // result = siemensNet.Write(address, array);
+ // } else {
+ // break;
+ // }
+ // }
+ // }
+ // idx++;
+ // Thread.sleep(500);
+ // } while (idx < 5);
- if (command.getAckFinish() == 0) {
- short commandFinish = 1;
- int i = 0;
- do {
- OperateResultExOne<byte[]> resultRead = siemensNet.Read(address, (short) 4);
- OperateResultExOne<byte[]> resultReadConfirm = siemensNet.Read(address + 18, (short) 2);
- if (resultRead.IsSuccess && resultReadConfirm.IsSuccess) {
- short taskNo = siemensNet.getByteTransform().TransInt16(resultRead.Content, 2);
- short confirm = siemensNet.getByteTransform().TransInt16(resultReadConfirm.Content, 0);
- if (taskNo != 0 && confirm == 0) {
- result = siemensNet.Write(address + 18, commandFinish);
- }
- }
- i++;
- Thread.sleep(500);
- } while (i < 5);
- }
+ // if (command.getAckFinish() == 0) {
+ // short commandFinish = 1;
+ // int i = 0;
+ // do {
+ // OperateResultExOne<byte[]> resultRead = siemensNet.Read(address, (short) 4);
+ // OperateResultExOne<byte[]> resultReadConfirm = siemensNet.Read(address + 18, (short) 2);
+ // if (resultRead.IsSuccess && resultReadConfirm.IsSuccess) {
+ // short taskNo = siemensNet.getByteTransform().TransInt16(resultRead.Content, 2);
+ // short confirm = siemensNet.getByteTransform().TransInt16(resultReadConfirm.Content, 0);
+ // if (taskNo != 0 && confirm == 0) {
+ // result = siemensNet.Write(address + 18, commandFinish);
+ // }
+ // }
+ // i++;
+ // Thread.sleep(500);
+ // } while (i < 5);
+ // }
- if (result != null && result.IsSuccess) {
- News.info("SiemensDualCrn 鍙屽伐浣嶅爢鍨涙満鍛戒护涓嬪彂[id:{}] >>>>> {}", command.getCrnNo(), JSON.toJSON(command));
- OutputQueue.CRN.offer(MessageFormat.format("銆恵0}銆慬id:{1}] >>>>> 鍛戒护涓嬪彂锛� {2}", DateUtils.convert(new Date()), command.getCrnNo(), JSON.toJSON(command)));
- response.setResult(true);
- response.setMessage("鍛戒护涓嬪彂鎴愬姛");
- } else {
- News.error("SiemensDualCrn 鍙屽伐浣嶅爢鍨涙満鍐欏叆鍫嗗灈鏈簆lc鏁版嵁澶辫触 ===>> [id:{}]", command.getCrnNo());
- OutputQueue.CRN.offer(MessageFormat.format("銆恵0}銆戝啓鍏ュ爢鍨涙満plc鏁版嵁澶辫触 ===>> [id:{1}]", DateUtils.convert(new Date()), command.getCrnNo()));
- response.setResult(false);
- response.setMessage("鍛戒护涓嬪彂澶辫触");
- }
+ // if (result != null && result.IsSuccess) {
+ // News.info("SiemensDualCrn 鍙屽伐浣嶅爢鍨涙満鍛戒护涓嬪彂[id:{}] >>>>> {}", command.getCrnNo(), JSON.toJSON(command));
+ // OutputQueue.CRN.offer(MessageFormat.format("銆恵0}銆慬id:{1}] >>>>> 鍛戒护涓嬪彂锛� {2}", DateUtils.convert(new Date()), command.getCrnNo(), JSON.toJSON(command)));
+ // response.setResult(true);
+ // response.setMessage("鍛戒护涓嬪彂鎴愬姛");
+ // } else {
+ // News.error("SiemensDualCrn 鍙屽伐浣嶅爢鍨涙満鍐欏叆鍫嗗灈鏈簆lc鏁版嵁澶辫触 ===>> [id:{}]", command.getCrnNo());
+ // OutputQueue.CRN.offer(MessageFormat.format("銆恵0}銆戝啓鍏ュ爢鍨涙満plc鏁版嵁澶辫触 ===>> [id:{1}]", DateUtils.convert(new Date()), command.getCrnNo()));
+ // response.setResult(false);
+ // response.setMessage("鍛戒护涓嬪彂澶辫触");
+ // }
- return response;
- } catch (Exception e) {
- e.printStackTrace();
- }finally {
- String sourceLocNo = Utils.getLocNo(command.getSourcePosX(), command.getSourcePosY(), command.getSourcePosZ());
- String targetLocNo = Utils.getLocNo(command.getDestinationPosX(), command.getDestinationPosY(), command.getDestinationPosZ());
+ // return response;
+ // } catch (Exception e) {
+ // e.printStackTrace();
+ // }finally {
+ // String sourceLocNo = Utils.getLocNo(command.getSourcePosX(), command.getSourcePosY(), command.getSourcePosZ());
+ // String targetLocNo = Utils.getLocNo(command.getDestinationPosX(), command.getDestinationPosY(), command.getDestinationPosZ());
- // 鏃ュ織璁板綍
- BasCrnpOptService bean = SpringUtils.getBean(BasCrnpOptService.class);
- BasCrnpOpt basCrnpOpt = new BasCrnpOpt(
- command.getTaskNo().intValue(), // 浠诲姟鍙�
- command.getCrnNo(), // 鍫嗗灈鏈篬闈炵┖]
- new Date(), // 涓嬪彂鏃堕棿
- String.valueOf(command.getTaskMode()), // 妯″紡
- sourceLocNo, //婧愬簱浣�
- targetLocNo, //鐩爣搴撲綅
- null, // 淇敼鏃堕棿
- null, // 淇敼浜哄憳
- null, // 澶囨敞
- JSON.toJSONString(command), // 鎸囦护
- JSON.toJSONString(getStatus()), // 绯荤粺鐘舵��
- 1, // 涓嬪彂鐘舵�亄0:鏈笅鍙�,1:宸蹭笅鍙憓
- JSON.toJSONString(response) // 鍝嶅簲
- );
- bean.insert(basCrnpOpt);
- }
+ // // 鏃ュ織璁板綍
+ // BasCrnpOptService bean = SpringUtils.getBean(BasCrnpOptService.class);
+ // BasCrnpOpt basCrnpOpt = new BasCrnpOpt(
+ // command.getTaskNo().intValue(), // 浠诲姟鍙�
+ // command.getCrnNo(), // 鍫嗗灈鏈篬闈炵┖]
+ // new Date(), // 涓嬪彂鏃堕棿
+ // String.valueOf(command.getTaskMode()), // 妯″紡
+ // sourceLocNo, //婧愬簱浣�
+ // targetLocNo, //鐩爣搴撲綅
+ // null, // 淇敼鏃堕棿
+ // null, // 淇敼浜哄憳
+ // null, // 澶囨敞
+ // JSON.toJSONString(command), // 鎸囦护
+ // JSON.toJSONString(getStatus()), // 绯荤粺鐘舵��
+ // 1, // 涓嬪彂鐘舵�亄0:鏈笅鍙�,1:宸蹭笅鍙憓
+ // JSON.toJSONString(response) // 鍝嶅簲
+ // );
+ // bean.insert(basCrnpOpt);
+ // }
return response;
}
}
--
Gitblit v1.9.1