From 864068a49c985982577808e49ba2fe0b7a698839 Mon Sep 17 00:00:00 2001 From: lsh <lsh123456> Date: 星期三, 26 十月 2022 11:22:13 +0800 Subject: [PATCH] # --- src/main/java/com/zy/core/thread/SiemensCrnThread.java | 41 +++++++++++++++++++++++++++++++++++------ 1 files changed, 35 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/zy/core/thread/SiemensCrnThread.java b/src/main/java/com/zy/core/thread/SiemensCrnThread.java index 25674d7..a7a25a9 100644 --- a/src/main/java/com/zy/core/thread/SiemensCrnThread.java +++ b/src/main/java/com/zy/core/thread/SiemensCrnThread.java @@ -45,6 +45,7 @@ @Override @SuppressWarnings("InfiniteLoopStatement") public void run() { + initCrnProtocol(); this.connect(); while (true) { try { @@ -89,6 +90,22 @@ } } + } + + /** + * 鍒濆鍖栧爢鍨涙満 + */ + private void initCrnProtocol(){ + crnProtocol = new CrnProtocol(); + crnProtocol.setMode((short) 0); + crnProtocol.setStatus((short) 0); + crnProtocol.setTaskNo((short) 0); + crnProtocol.setTaskFinish((short) 0); + crnProtocol.setValid((short) 0); + crnProtocol.setBay((short) 0); + crnProtocol.setLevel((short) 0); + crnProtocol.setRow((short) 0); + crnProtocol.setLane((short) 0); } @Override @@ -313,6 +330,7 @@ BasCrnpService basCrnpService = SpringUtils.getBean(BasCrnpService.class); BasCrnp basCrnp = new BasCrnp(); basCrnp.setCrnNo(slave.getId()); + basCrnp.setCrnSts((int)crnProtocol.getMode()); if (!basCrnpService.updateById(crnProtocol.toSqlModel(basCrnp))){ log.error("鍫嗗灈鏈簆lc鏁版嵁搴撴洿鏂板け璐� ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()); } @@ -344,23 +362,35 @@ } array[1] = command.getSourcePosZ(); array[2] = command.getSourcePosY(); - array[3] = command.getSourcePosX(); + if (command.getSourcePosX()==(short)3){ + array[3] = (short)1; + }else if (command.getSourcePosX()==(short)4){ + array[3] = (short)2; + }else { + array[3] = command.getSourcePosX(); + } array[4] = command.getDestinationPosZ(); array[5] = command.getDestinationPosY(); - array[6] = command.getDestinationPosX(); + if (command.getDestinationPosX()==(short)3){ + array[6] = (short)1; + }else if (command.getDestinationPosX()==(short)4){ + array[6] = (short)2; + }else { + array[6] = command.getDestinationPosX(); + } array[7] = command.getSourceStaNo(); array[8] = command.getDestinationStaNo(); // 浣滀笟淇℃伅 - OperateResult result = siemensNet.Write("DB1000.0", array); + OperateResult result = siemensNet.Write("DB10.0", array); // 浠诲姟鍙� + 瀹屾垚浣� short[] array2 = new short[2]; array2[0] = command.getTaskNo(); array2[1] = command.getAckFinish(); - OperateResult result1 = siemensNet.Write("DB1000.24", array2); + OperateResult result1 = siemensNet.Write("DB10.24", array2); // 缁撴潫浣� if (command.getAckFinish() == 0) { - OperateResult result2 = siemensNet.Write("DB1000.28.1", true); + OperateResult result2 = siemensNet.Write("DB10.28.1", true); } // 鏃ュ織璁板綍 @@ -389,7 +419,6 @@ } catch (Exception ignore) {} if (result.IsSuccess && result1.IsSuccess) { - log.warn("鍫嗗灈鏈哄懡浠や笅鍙慬id:{},鏃堕棿锛歿}] >>>>> {}", slave.getId(), DateUtils.convert(new Date(), DateUtils.yyyyMMddHHmmsssss_F), JSON.toJSON(command)); OutputQueue.CRN.offer(MessageFormat.format("銆恵0}銆慬id:{1}] >>>>> 鍛戒护涓嬪彂锛� {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command))); return true; -- Gitblit v1.9.1