From ccca62c3c22a67373a6f25b3786973b3fb114d4d Mon Sep 17 00:00:00 2001
From: Administrator <1051256694@qq.com>
Date: 星期一, 16 三月 2026 16:17:54 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/network/real/ZyCrnRealConnect.java |  143 +++++++++++++++++++++++++++++++++--------------
 1 files changed, 99 insertions(+), 44 deletions(-)

diff --git a/src/main/java/com/zy/core/network/real/ZyCrnRealConnect.java b/src/main/java/com/zy/core/network/real/ZyCrnRealConnect.java
index 9e12fc1..9985da3 100644
--- a/src/main/java/com/zy/core/network/real/ZyCrnRealConnect.java
+++ b/src/main/java/com/zy/core/network/real/ZyCrnRealConnect.java
@@ -133,54 +133,109 @@
                 return response;
             }
 
-            Integer commandTaskNo = command.getTaskNo();
             Integer commandTaskMode = command.getTaskMode();
             if (commandTaskMode.equals(CrnTaskModeType.RESET.id)) {
-                commandTaskNo = 0;
-                commandTaskMode = 0;
-            }
+                short[] array = new short[9];
+                array[0] = command.getAckFinish().shortValue();
+                array[1] = (short) 0;
+                array[2] = (short) 0;
+                array[3] = (short) 0;
+                array[4] = (short) 0;
+                array[5] = (short) 0;
+                array[6] = (short) 0;
+                array[7] = (short) 0;
+                array[8] = (short) 0;
 
-            short[] array = new short[9];
-            array[0] = command.getAckFinish().shortValue();
-            array[1] = commandTaskNo.shortValue();
-            array[2] = commandTaskMode.shortValue();
-            array[3] = command.getSourcePosX().shortValue();
-            array[4] = command.getSourcePosY().shortValue();
-            array[5] = command.getSourcePosZ().shortValue();
-            array[6] = command.getDestinationPosX().shortValue();
-            array[7] = command.getDestinationPosY().shortValue();
-            array[8] = command.getDestinationPosZ().shortValue();
-
-            int idx = 0;
-            boolean commandDataResult = false;
-            do {
-                OperateResult result = siemensNet.Write("DB100.0", array);
-                if (result.IsSuccess) {
-                    OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB100.0", (short) 20);
-                    if (resultRead.IsSuccess) {
-                        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("DB100.0", array);
-                        } else {
-                            commandDataResult = true;
-                            break;
+                int idx = 0;
+                boolean commandDataResult = false;
+                do {
+                    OperateResult result = siemensNet.Write("DB100.0", array);
+                    if (result.IsSuccess) {
+                        OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB100.0", (short) 20);
+                        if (resultRead.IsSuccess) {
+                            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("DB100.0", array);
+                            } else {
+                                commandDataResult = true;
+                                break;
+                            }
                         }
                     }
-                }
-                idx++;
-                Thread.sleep(200);
-            } while (idx < 5);
+                    idx++;
+                    Thread.sleep(200);
+                } while (idx < 5);
 
-            if (!commandDataResult) {
-                response.setMessage("鍫嗗灈鏈哄懡浠や笅鍙慬id:{}] >>>>> {}" + command.getCrnNo() + "鍫嗗灈鏈哄啓鍏ヤ换鍔℃暟鎹け璐�");
-                return response;
+                if (!commandDataResult) {
+                    response.setMessage("鍫嗗灈鏈哄懡浠や笅鍙慬id:{}] >>>>> {}" + command.getCrnNo() + "鍫嗗灈鏈哄啓鍏ヤ换鍔℃暟鎹け璐�");
+                    return response;
+                }
+
+                if (!Cools.isEmpty(command.getLocNo())){
+                    OperateResult resultAck = siemensNet.Write("DB110." + command.getIndex() * 2, command.getValue());
+                    if (resultAck.IsSuccess) {
+                        Integer index = command.getIndex()*2 + 200;
+                        OperateResult resultAck1 = siemensNet.Write("DB110." + index, command.getValue());
+                        if (resultAck1.IsSuccess) {
+                            News.info("搴撲綅姗欒壊鎸夐挳鍛戒护涓嬪彂[locNo:{}] >>>>> {}", command.getLocNo(), command.getValue());
+                        } else {
+                            News.error("搴撲綅鐧借壊鐏懡浠や笅鍙戝け璐locNo:{}] >>>>> {}", command.getLocNo(), command.getValue());
+                        }
+                        News.info("搴撲綅鐧借壊鐏懡浠や笅鍙慬locNo:{}] >>>>> {}", command.getLocNo(), command.getValue());
+                    } else {
+                        News.error("搴撲綅鐧借壊鐏懡浠や笅鍙戝け璐locNo:{}] >>>>> {}", command.getLocNo(), command.getValue());
+                    }
+                }
+            }else {
+                short[] array = new short[9];
+                array[0] = command.getAckFinish().shortValue();
+                array[1] = command.getTaskNo().shortValue();
+                array[2] = command.getTaskMode().shortValue();
+                array[3] = command.getSourcePosX().shortValue();
+                array[4] = command.getSourcePosY().shortValue();
+                array[5] = command.getSourcePosZ().shortValue();
+                array[6] = command.getDestinationPosX().shortValue();
+                array[7] = command.getDestinationPosY().shortValue();
+                array[8] = command.getDestinationPosZ().shortValue();
+
+                int idx = 0;
+                boolean commandDataResult = false;
+                do {
+                    OperateResult result = siemensNet.Write("DB100.0", array);
+                    if (result.IsSuccess) {
+                        OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB100.0", (short) 20);
+                        if (resultRead.IsSuccess) {
+                            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("DB100.0", array);
+                            } else {
+                                commandDataResult = true;
+                                break;
+                            }
+                        }
+                    }
+                    idx++;
+                    Thread.sleep(200);
+                } while (idx < 5);
+
+                if (!commandDataResult) {
+                    response.setMessage("鍫嗗灈鏈哄懡浠や笅鍙慬id:{}] >>>>> {}" + command.getCrnNo() + "鍫嗗灈鏈哄啓鍏ヤ换鍔℃暟鎹け璐�");
+                    return response;
+                }
             }
 
             int writeConfirmIdx = 0;
@@ -201,7 +256,7 @@
                 }
                 writeConfirmIdx++;
                 Thread.sleep(200);
-            } while (writeConfirmIdx < 5);
+            } while (writeConfirmIdx < 1);
 
             if (!commandConfirmResult) {
                 News.error("鍫嗗灈鏈哄啓鍏ョ‘璁ゆ暟鎹け璐� ===>> [id:{}]", command.getCrnNo());
@@ -258,7 +313,7 @@
             if (resultAck.IsSuccess) {
                 News.info("搴撲綅姗欒壊鎸夐挳鍛戒护涓嬪彂[locNo:{}] >>>>> {}", command.getLocNo(), command.getValue());
             } else {
-                News.error("搴撲綅鐧借壊鐏懡浠や笅鍙戝け璐locNo:{}] >>>>> {}", command.getLocNo(), command.getValue());
+                News.error("搴撲綅姗欒壊鎸夐挳鍛戒护涓嬪彂澶辫触[locNo:{}] >>>>> {}", command.getLocNo(), command.getValue());
             }
             return response;
         } catch (Exception e) {

--
Gitblit v1.9.1