From 922a5f471a735a0ea231d30e45312f61d583e58d Mon Sep 17 00:00:00 2001 From: zhangchao <zc857179121@qq.com> Date: 星期日, 01 九月 2024 16:12:49 +0800 Subject: [PATCH] 对照协议调整 --- src/main/java/com/zy/core/thread/SiemensCrnThread.java | 86 +++++++++++++++++++++++++++---------------- 1 files changed, 54 insertions(+), 32 deletions(-) diff --git a/src/main/java/com/zy/core/thread/SiemensCrnThread.java b/src/main/java/com/zy/core/thread/SiemensCrnThread.java index 5139256..f3c77e2 100644 --- a/src/main/java/com/zy/core/thread/SiemensCrnThread.java +++ b/src/main/java/com/zy/core/thread/SiemensCrnThread.java @@ -39,6 +39,7 @@ private CrnSlave slave; private CrnProtocol crnProtocol; private boolean resetFlag = false; + private boolean resetFlagTwo = false; /** * 鍫嗗灈鏈烘槸鍚﹀湪鍥炲師鐐硅繍鍔ㄤ腑鏍囪 @@ -186,11 +187,9 @@ OutputQueue.CRN.offer(MessageFormat.format("銆恵0}銆慬id:{1}] <<<<< 瀹炴椂鏁版嵁鏇存柊鎴愬姛", DateUtils.convert(new Date()), slave.getId())); - if (crnProtocol.getMode() == 1) { // 澶嶄綅淇″彿 if (!Cools.isEmpty(crnProtocol.getStatusType()) && crnProtocol.getStatusType().equals(CrnStatusType.WAITING)) { - System.out.println(crnProtocol); if (resetFlag) { if (crnProtocol.getTaskNo() == 9999) { backHpFlag = false; @@ -205,8 +204,7 @@ } else if (crnProtocol.getMode() == 2) { // 澶嶄綅淇″彿 if (!Cools.isEmpty(crnProtocol.getStatusTypeTwo()) && crnProtocol.getStatusTypeTwo().equals(CrnStatusType.WAITING)) { - - if (resetFlag) { + if (resetFlagTwo) { if (crnProtocol.getTaskNo() == 9999) { backHpFlag = false; } @@ -220,8 +218,7 @@ } else if (crnProtocol.getMode() == 3) { // 澶嶄綅淇″彿 if (!Cools.isEmpty(crnProtocol.getStatusType()) && crnProtocol.getStatusType().equals(CrnStatusType.WAITING) && !Cools.isEmpty(crnProtocol.getStatusTypeTwo()) && crnProtocol.getStatusTypeTwo().equals(CrnStatusType.WAITING)) { - System.out.println(crnProtocol); - if (resetFlag) { + if (resetFlag && resetFlagTwo) { if (crnProtocol.getTaskNo() == 9999) { backHpFlag = false; } @@ -334,37 +331,62 @@ one.setDestinationPosXTwo(siemensNet.getByteTransform().TransInt16(resultRead.Content, 22)); one.setDestinationPosYTwo(siemensNet.getByteTransform().TransInt16(resultRead.Content, 24)); one.setDestinationPosZTwo(siemensNet.getByteTransform().TransInt16(resultRead.Content, 26)); - if (!command.getTaskNo().equals(one.getTaskNo()) || !command.getTaskMode().equals(one.getTaskMode()) - || !command.getSourcePosX().equals(one.getSourcePosX()) || !command.getSourcePosY().equals(one.getSourcePosY()) - || !command.getSourcePosZ().equals(one.getSourcePosZ()) || !command.getDestinationPosX().equals(one.getDestinationPosX()) - || !command.getDestinationPosY().equals(one.getDestinationPosY()) || !command.getDestinationPosZ().equals(one.getDestinationPosZ()) - || !command.getSourcePosXTwo().equals(one.getSourcePosXTwo()) || !command.getSourcePosYTwo().equals(one.getSourcePosYTwo()) - || !command.getSourcePosZTwo().equals(one.getSourcePosZTwo()) || !command.getDestinationPosXTwo().equals(one.getDestinationPosXTwo()) - || !command.getDestinationPosYTwo().equals(one.getDestinationPosYTwo()) || !command.getDestinationPosZTwo().equals(one.getDestinationPosZTwo()) - ) { - System.out.println(command.getTaskNo().equals(one.getTaskNo())); - System.out.println(one); - try { - log.error("鍫嗗灈鏈哄懡浠ゅ湴鍧�鍐欏叆鍚庡洖璇诲け璐�==>涓嶄竴鑷碵id:{}] >>>>> 鍐欏叆[{}],===>>鍥炶[{}]", slave.getId(), JSON.toJSONString(command), JSON.toJSONString(one)); - } catch (Exception e) { + if (command.getTaskMode() != 2) { + if (!command.getTaskNo().equals(one.getTaskNo()) || !command.getTaskMode().equals(one.getTaskMode()) + || !command.getSourcePosX().equals(one.getSourcePosX()) || !command.getSourcePosY().equals(one.getSourcePosY()) + || !command.getSourcePosZ().equals(one.getSourcePosZ()) || !command.getDestinationPosX().equals(one.getDestinationPosX()) + || !command.getDestinationPosY().equals(one.getDestinationPosY()) || !command.getDestinationPosZ().equals(one.getDestinationPosZ()) + ) { try { - log.error("鏃ュ織鎵撳嵃澶辫触锛�===>>鍙傛暟one鎶ラ敊 [id:{}],{}", slave.getId(), JSON.toJSONString(command), JSON.toJSONString(resultRead)); - } catch (Exception e1) { - log.error("鏃ュ織鎵撳嵃澶辫触锛�===>> [id:{}],{}", slave.getId(), JSON.toJSONString(command)); + log.error("鍫嗗灈鏈哄懡浠ゅ湴鍧�鍐欏叆鍚庡洖璇诲け璐�==>涓嶄竴鑷碵id:{}] >>>>> 鍐欏叆[{}],===>>鍥炶[{}]", slave.getId(), JSON.toJSONString(command), JSON.toJSONString(one)); + } catch (Exception e) { + try { + log.error("鏃ュ織鎵撳嵃澶辫触锛�===>>鍙傛暟one鎶ラ敊 [id:{}],{}", slave.getId(), JSON.toJSONString(command), JSON.toJSONString(resultRead)); + } catch (Exception e1) { + log.error("鏃ュ織鎵撳嵃澶辫触锛�===>> [id:{}],{}", slave.getId(), JSON.toJSONString(command)); + } } - } - try { - Thread.sleep(100); - } catch (Exception e) { + try { + Thread.sleep(100); + } catch (Exception e) { + } + log.error("鍐欏叆鍫嗗灈鏈簆lc鏁版嵁澶辫触锛岄噸鏂颁笅鍙戜换鍔� 鍥炶涓嶄竴鑷� ===>> [id:{}],{},[鍐欏叆娆℃暟:{}]", slave.getId(), JSON.toJSONString(command), writeCount); + result = siemensNet.Write("DB100.0", array); + writeCount++; + continue; + } else { + log.info("鍫嗗灈鏈哄懡浠ゅ湴鍧�鍐欏叆鍚庡洖璇绘垚鍔焄id:{}] >>>>> 鍐欏叆[{}],===>>鍥炶[{}]", slave.getId(), JSON.toJSONString(command), JSON.toJSONString(one)); + break; } - log.error("鍐欏叆鍫嗗灈鏈簆lc鏁版嵁澶辫触锛岄噸鏂颁笅鍙戜换鍔� 鍥炶涓嶄竴鑷� ===>> [id:{}],{},[鍐欏叆娆℃暟:{}]", slave.getId(), JSON.toJSONString(command), writeCount); - result = siemensNet.Write("DB100.0", array); - writeCount++; - continue; } else { - log.info("鍫嗗灈鏈哄懡浠ゅ湴鍧�鍐欏叆鍚庡洖璇绘垚鍔焄id:{}] >>>>> 鍐欏叆[{}],===>>鍥炶[{}]", slave.getId(), JSON.toJSONString(command), JSON.toJSONString(one)); - break; + if (!command.getTaskNo().equals(one.getTaskNo()) || !command.getTaskMode().equals(one.getTaskMode()) + || !command.getSourcePosXTwo().equals(one.getSourcePosXTwo()) || !command.getSourcePosYTwo().equals(one.getSourcePosYTwo()) + || !command.getSourcePosZTwo().equals(one.getSourcePosZTwo()) || !command.getDestinationPosXTwo().equals(one.getDestinationPosXTwo()) + || !command.getDestinationPosYTwo().equals(one.getDestinationPosYTwo()) || !command.getDestinationPosZTwo().equals(one.getDestinationPosZTwo()) + ) { + try { + log.error("鍫嗗灈鏈哄懡浠ゅ湴鍧�鍐欏叆鍚庡洖璇诲け璐�==>涓嶄竴鑷碵id:{}] >>>>> 鍐欏叆[{}],===>>鍥炶[{}]", slave.getId(), JSON.toJSONString(command), JSON.toJSONString(one)); + } catch (Exception e) { + try { + log.error("鏃ュ織鎵撳嵃澶辫触锛�===>>鍙傛暟one鎶ラ敊 [id:{}],{}", slave.getId(), JSON.toJSONString(command), JSON.toJSONString(resultRead)); + } catch (Exception e1) { + log.error("鏃ュ織鎵撳嵃澶辫触锛�===>> [id:{}],{}", slave.getId(), JSON.toJSONString(command)); + } + } + try { + Thread.sleep(100); + } catch (Exception e) { + + } + log.error("鍐欏叆鍫嗗灈鏈簆lc鏁版嵁澶辫触锛岄噸鏂颁笅鍙戜换鍔� 鍥炶涓嶄竴鑷� ===>> [id:{}],{},[鍐欏叆娆℃暟:{}]", slave.getId(), JSON.toJSONString(command), writeCount); + result = siemensNet.Write("DB100.0", array); + writeCount++; + continue; + } else { + log.info("鍫嗗灈鏈哄懡浠ゅ湴鍧�鍐欏叆鍚庡洖璇绘垚鍔焄id:{}] >>>>> 鍐欏叆[{}],===>>鍥炶[{}]", slave.getId(), JSON.toJSONString(command), JSON.toJSONString(one)); + break; + } } } } catch (Exception e) { -- Gitblit v1.9.1