From 8066494f23f6820d326a4d8e56f579bc3eed6774 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@63.com>
Date: 星期三, 05 一月 2022 13:42:25 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/thread/CrnThread.java | 110 +++++++++++++++++++------------------------------------
1 files changed, 38 insertions(+), 72 deletions(-)
diff --git a/src/main/java/com/zy/core/thread/CrnThread.java b/src/main/java/com/zy/core/thread/CrnThread.java
index f95f4ae..18e9df7 100644
--- a/src/main/java/com/zy/core/thread/CrnThread.java
+++ b/src/main/java/com/zy/core/thread/CrnThread.java
@@ -184,82 +184,48 @@
return;
}
command.setCrnNo(slave.getId());
- /* 鏂规硶 1 */
- do {
- if (command.getDestinationPosZ() != null) {
- if (!melsecMcNet.Write("D2202", command.getDestinationPosZ()).IsSuccess) { break; }
- }
- if (command.getDestinationPosY() != null) {
- if (!melsecMcNet.Write("D2204", command.getDestinationPosY()).IsSuccess) { break; }
- }
- if (command.getDestinationPosX() != null) {
- if (!melsecMcNet.Write("D2208", command.getDestinationPosX()).IsSuccess) { break; }
- }
- if (command.getSourcePosZ() != null) {
- if (!melsecMcNet.Write("D2210", command.getSourcePosZ()).IsSuccess) { break; }
- }
- if (command.getSourcePosY() != null) {
- if (!melsecMcNet.Write("D2212", command.getSourcePosY()).IsSuccess) { break; }
- }
- if (command.getDestinationPosX() != null) {
- if (!melsecMcNet.Write("D2214", command.getSourcePosX()).IsSuccess) { break; }
- }
- if (command.getTaskMode() != null) {
- if (!melsecMcNet.Write("D2216", command.getTaskMode()).IsSuccess) { break; }
- }
- if (command.getTaskNo() != null) {
- if (!melsecMcNet.Write("D2217", command.getTaskNo()).IsSuccess) { break; }
- }
- if (command.getAckFinish() != null) {
- if (!melsecMcNet.Write("D2218", command.getAckFinish()).IsSuccess) { break; }
- }
+ short[] array = new short[9];
+ array[0] = command.getStatus();
+ array[1] = command.getSourceRow(); // 鎺�
+ array[2] = command.getSourceBay(); // 鍒�
+ array[3] = command.getSourceLev(); // 灞�
+ array[4] = command.getSourceSta(); // 绔欏彿
+ array[5] = command.getDestinationPosRow(); // 鎺�
+ array[6] = command.getDestinationPosBay(); // 鍒�
+ array[7] = command.getDestinationPosLev(); // 灞�
+ array[8] = command.getDestinationSta(); // 鐩爣浣嶇疆绔欏彿
- try {
- // 鏃ュ織璁板綍
- BasCrnOptService bean = SpringUtils.getBean(BasCrnOptService.class);
- BasCrnOpt basCrnOpt = new BasCrnOpt(
- command.getTaskNo().intValue(), // 浠诲姟鍙�
- command.getCrnNo(), // 鍫嗗灈鏈篬闈炵┖]
- new Date(), // 涓嬪彂鏃堕棿
- command.getTaskModeType().toString(), // 妯″紡
- command.getSourcePosX().intValue(), // 婧愭帓
- command.getSourcePosY().intValue(), // 婧愬垪
- command.getSourcePosZ().intValue(), // 婧愬眰
- null, // 婧愮珯
- command.getDestinationPosX().intValue(), // 鐩爣鎺�
- command.getDestinationPosY().intValue(), // 鐩爣鍒�
- command.getDestinationPosZ().intValue(), // 鐩爣灞�
- null, // 鐩爣绔�
- null, // 鍝嶅簲缁撴灉
- null, // 淇敼鏃堕棿
- null // 淇敼浜哄憳
- );
- bean.insert(basCrnOpt);
- } catch (Exception ignore) {}
+ try {
+ // 鏃ュ織璁板綍
+ BasCrnOptService bean = SpringUtils.getBean(BasCrnOptService.class);
+ BasCrnOpt basCrnOpt = new BasCrnOpt(
+ command.getTaskNo().intValue(), // 浠诲姟鍙�
+ command.getCrnNo(), // 鍫嗗灈鏈篬闈炵┖]
+ new Date(), // 涓嬪彂鏃堕棿
+ command.getTaskModeType().toString(), // 妯″紡
+ command.getSourcePosX().intValue(), // 婧愭帓
+ command.getSourcePosY().intValue(), // 婧愬垪
+ command.getSourcePosZ().intValue(), // 婧愬眰
+ null, // 婧愮珯
+ command.getDestinationPosX().intValue(), // 鐩爣鎺�
+ command.getDestinationPosY().intValue(), // 鐩爣鍒�
+ command.getDestinationPosZ().intValue(), // 鐩爣灞�
+ null, // 鐩爣绔�
+ null, // 鍝嶅簲缁撴灉
+ null, // 淇敼鏃堕棿
+ null // 淇敼浜哄憳
+ );
+ bean.insert(basCrnOpt);
+ } catch (Exception ignore) {}
+ OperateResult result = melsecMcNet.Write("100", array);
+ if (result.IsSuccess) {
log.info("鍫嗗灈鏈哄懡浠や笅鍙慬id:{}] >>>>> {}", slave.getId(), JSON.toJSON(command));
OutputQueue.CRN.offer(MessageFormat.format("銆恵0}銆慬id:{1}] >>>>> 鍛戒护涓嬪彂锛� {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command)));
-
- return;
- } while (false);
-
-
- System.out.println(MessageFormat.format("銆恵0}銆戝啓鍏ュ爢鍨涙満plc鏁版嵁澶辫触 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));
- OutputQueue.CRN.offer(MessageFormat.format("銆恵0}銆戝啓鍏ュ爢鍨涙満plc鏁版嵁澶辫触 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));
- log.error("鍐欏叆鍫嗗灈鏈簆lc鏁版嵁澶辫触 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
-
-
-
- /* 鏂规硶 2 */
-// melsecMcNet.Write("D2218", command.getAckFinish());
-// melsecMcNet.Write("D2217", command.getTaskNo());
-// melsecMcNet.Write("D2216", command.getTaskMode());
-// melsecMcNet.Write("D2214", command.getSourcePosX());
-// melsecMcNet.Write("D2212", command.getSourcePosY());
-// melsecMcNet.Write("D2210", command.getSourcePosZ());
-// melsecMcNet.Write("D2208", command.getDestinationPosX());
-// melsecMcNet.Write("D2204", command.getDestinationPosY());
-// melsecMcNet.Write("D2202", command.getDestinationPosZ());
+ } else {
+ OutputQueue.CRN.offer(MessageFormat.format("銆恵0}銆戝啓鍏ュ爢鍨涙満plc鏁版嵁澶辫触 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));
+ log.error("鍐欏叆鍫嗗灈鏈簆lc鏁版嵁澶辫触 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
+ }
}
--
Gitblit v1.9.1