From b791daa70e38b4e426d2b065da5bd317fe8c91f3 Mon Sep 17 00:00:00 2001
From: 野心家 <1051256694@qq.com>
Date: 星期二, 27 五月 2025 11:18:46 +0800
Subject: [PATCH] #ZH

---
 src/main/java/com/zy/core/thread/SiemensCrnThread.java |   52 +++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 47 insertions(+), 5 deletions(-)

diff --git a/src/main/java/com/zy/core/thread/SiemensCrnThread.java b/src/main/java/com/zy/core/thread/SiemensCrnThread.java
index 40592be..676afa7 100644
--- a/src/main/java/com/zy/core/thread/SiemensCrnThread.java
+++ b/src/main/java/com/zy/core/thread/SiemensCrnThread.java
@@ -155,12 +155,12 @@
      */
     private void readStatus(){
         try {
-            OperateResultExOne<byte[]> result = siemensNet.Read("DB101.0", (short) 56);
+            OperateResultExOne<byte[]> result = siemensNet.Read("DB101.0", (short) 58);
             if (result.IsSuccess) {
                 if (null == crnProtocol) {
                     crnProtocol = new CrnProtocol();
-                    crnProtocol.setCrnNo(slave.getId());
                 }
+                crnProtocol.setCrnNo(slave.getId());
                 crnProtocol.setMode(siemensNet.getByteTransform().TransInt16(result.Content, 0));
                 crnProtocol.setTaskNo(siemensNet.getByteTransform().TransInt16(result.Content, 2));
                 crnProtocol.setStatus(siemensNet.getByteTransform().TransInt16(result.Content, 4));
@@ -182,6 +182,7 @@
                 crnProtocol.setyDistance(siemensNet.getByteTransform().TransInt16(result.Content, 44));
                 crnProtocol.setxDuration(siemensNet.getByteTransform().TransInt16(result.Content, 48));
                 crnProtocol.setyDuration(siemensNet.getByteTransform().TransInt16(result.Content, 52));
+                crnProtocol.setLaneNo((int)siemensNet.getByteTransform().TransInt16(result.Content, 56));//宸烽亾鍙�
 
                 OutputQueue.CRN.offer(MessageFormat.format("銆恵0}銆慬id:{1}] <<<<< 瀹炴椂鏁版嵁鏇存柊鎴愬姛",DateUtils.convert(new Date()), slave.getId()));
 
@@ -254,15 +255,56 @@
         array[6] = command.getDestinationPosX();
         array[7] = command.getDestinationPosY();
         array[8] = command.getDestinationPosZ();
-//        array[9] = command.getSourceStaNo();
-//        array[10] = command.getDestinationStaNo();
         array[9] = command.getCommand();
+        OperateResult result18 = siemensNet.Write("DB100.18", (short)0);
+        try{
+            Thread.sleep(50L);
+        } catch (Exception e){}
+
         OperateResult result = siemensNet.Write("DB100.0", array);
+
+        int i=0;
+        do{
+            //鍫嗗灈鏈轰换鍔″啓鍏ュ悗锛屽洖璇讳竴娆★紝鐪嬫槸鍚︽垚鍔�
+            try{
+                Thread.sleep(100L);
+            } catch (Exception e){}
+            OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB101.0", (short) 4);
+            if (resultRead.IsSuccess) {
+                CrnCommand one = new CrnCommand();
+                one.setTaskNo(siemensNet.getByteTransform().TransInt16(resultRead.Content, 2));
+                if (!command.getTaskNo().equals(one.getTaskNo())
+                ){
+                    i++;
+                    log.error("鍫嗗灈鏈哄懡浠ゅ湴鍧�鍐欏叆鍚庡洖璇诲け璐id:{}]>>>>閲嶅啓[{}] >>>>> 鍐欏叆[{}],===>>鍥炶[{}]", slave.getId(), i,JSON.toJSON(command),JSON.toJSON(one));
+                    result = siemensNet.Write("DB100.0", array);
+                }else{
+                    break;
+                }
+            }
+        }while(i<5);
 
         if (command.getAckFinish() == 0) {
             short commandFinish = 1;
-            Thread.sleep(100L);
+            try{
+                Thread.sleep(100L);
+            } catch (Exception e){}
             result = siemensNet.Write("DB100.18", commandFinish);
+            int signFinish = 1;
+            while (signFinish<5){
+                OperateResultExOne<byte[]> result10018 = siemensNet.Read("DB100.18", (short) 2);
+                short transInt16 = siemensNet.getByteTransform().TransInt16(result10018.Content, 0);
+                if (transInt16 != commandFinish){
+                    log.info("涓嬪彂DB100.18  鍥炶澶辫触" + "commandFinish:"+commandFinish);
+                    log.info("涓嬪彂DB100.18  鍥炶澶辫触" + "array:"+ JSON.toJSONString(array));
+                    result = siemensNet.Write("DB100.18", commandFinish);
+                    signFinish++;
+                }else {
+                    log.info("涓嬪彂DB100.18" + "commandFinish:"+commandFinish);
+                    log.info("涓嬪彂DB100.18" + "array:"+ JSON.toJSONString(array));
+                    break;
+                }
+            }
         }
 
         try {

--
Gitblit v1.9.1