From 67a8ef2767b1980487091e1bfcd3bd17502140e6 Mon Sep 17 00:00:00 2001
From: LSH
Date: 星期二, 21 十一月 2023 14:30:11 +0800
Subject: [PATCH] #

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

diff --git a/src/main/java/com/zy/core/thread/SiemensCrnThread.java b/src/main/java/com/zy/core/thread/SiemensCrnThread.java
index 4c3f48b..63f6e5a 100644
--- a/src/main/java/com/zy/core/thread/SiemensCrnThread.java
+++ b/src/main/java/com/zy/core/thread/SiemensCrnThread.java
@@ -38,12 +38,19 @@
     private CrnSlave slave;
     private CrnProtocol crnProtocol;
     private boolean resetFlag = false;
-    public static final List<Short> staNoOne = new ArrayList<Short>() {{
-        add((short) 2);add((short) 5);add((short) 8);add((short) 12);add((short) 16);add((short) 20);
+    public static final List<Short> rowOne = new ArrayList<Short>() {{
+        add((short) 1);add((short) 5);add((short) 7);add((short) 11);add((short) 15);add((short) 19);
     }};
-    public static final List<Short> staNoTwo = new ArrayList<Short>() {{
-        add((short) 3);add((short) 6);add((short) 9);add((short) 13);add((short) 17);add((short) 21);
+    public static final List<Short> rowTwo = new ArrayList<Short>() {{
+        add((short) 2);add((short) 6);add((short) 8);add((short) 12);add((short) 16);add((short) 20);
     }};
+    public static final List<Short> rowThree = new ArrayList<Short>() {{
+        add((short) 3);add((short) 9);add((short) 13);add((short) 17);add((short) 21);
+    }};
+    public static final List<Short> rowFour = new ArrayList<Short>() {{
+        add((short) 4);add((short) 10);add((short) 14);add((short) 18);
+    }};
+
 
     public SiemensCrnThread(CrnSlave slave) {
         this.slave = slave;
@@ -141,21 +148,33 @@
      * 璇诲彇鐘舵��
      */
     private void readStatus(){
-        OperateResultExOne<byte[]> result = siemensNet.Read("DB11.2", (short) 104);
+
+        OperateResultExOne<byte[]> result = siemensNet.Read("DB101.0", (short) 56);
         if (result.IsSuccess) {
             if (null == crnProtocol) {
                 crnProtocol = new CrnProtocol();
             }
-            crnProtocol.setMode(siemensNet.getByteTransform().TransInt16(result.Content, 0));   // 2
-            crnProtocol.setStatus(siemensNet.getByteTransform().TransInt16(result.Content, 2)); // 4
-            crnProtocol.setTaskNo(siemensNet.getByteTransform().TransInt16(result.Content, 4)); // 6
-            crnProtocol.setTaskFinish(siemensNet.getByteTransform().TransInt16(result.Content, 6)); // 8
-            crnProtocol.setValid(siemensNet.getByteTransform().TransInt16(result.Content, 8));  // 10
-
-            crnProtocol.setLevel(siemensNet.getByteTransform().TransInt16(result.Content, 14)); // 16
-            crnProtocol.setBay(siemensNet.getByteTransform().TransInt16(result.Content, 16));   // 18
-            crnProtocol.setRow(siemensNet.getByteTransform().TransInt16(result.Content, 18));   // 20
-            crnProtocol.setLane(siemensNet.getByteTransform().TransInt16(result.Content, 20));  // 22
+            crnProtocol.setMode(siemensNet.getByteTransform().TransInt16(result.Content, 0));
+            crnProtocol.setTaskNo(siemensNet.getByteTransform().TransInt16(result.Content, 2));
+            crnProtocol.setStatus(siemensNet.getByteTransform().TransInt16(result.Content, 4));
+            crnProtocol.setBay(siemensNet.getByteTransform().TransInt16(result.Content, 6));
+            crnProtocol.setLevel(siemensNet.getByteTransform().TransInt16(result.Content, 8));
+            crnProtocol.setForkPos(siemensNet.getByteTransform().TransInt16(result.Content, 10));
+            crnProtocol.setLiftPos(siemensNet.getByteTransform().TransInt16(result.Content, 12));
+            crnProtocol.setWalkPos(siemensNet.getByteTransform().TransInt16(result.Content, 14));
+            crnProtocol.setLoaded(siemensNet.getByteTransform().TransInt16(result.Content, 16));
+//            crnProtocol.setAlarm(siemensNet.getByteTransform().TransInt16(result.Content, 18));
+//            crnProtocol.setTemp1(siemensNet.getByteTransform().TransInt16(result.Content, 20));
+//            crnProtocol.setTemp2(siemensNet.getByteTransform().TransInt16(result.Content, 22));
+//            crnProtocol.setTemp3(siemensNet.getByteTransform().TransInt16(result.Content, 24));
+//            crnProtocol.setTemp4(siemensNet.getByteTransform().TransInt16(result.Content, 26));
+            crnProtocol.setXSpeed(siemensNet.getByteTransform().TransSingle(result.Content, 28));
+            crnProtocol.setYSpeed(siemensNet.getByteTransform().TransSingle(result.Content, 32));
+            crnProtocol.setZSpeed(siemensNet.getByteTransform().TransSingle(result.Content, 36));
+            crnProtocol.setXDistance(siemensNet.getByteTransform().TransSingle(result.Content, 40));
+            crnProtocol.setYDistance(siemensNet.getByteTransform().TransSingle(result.Content, 44));
+            crnProtocol.setXDuration(siemensNet.getByteTransform().TransSingle(result.Content, 48));
+            crnProtocol.setYDuration(siemensNet.getByteTransform().TransSingle(result.Content, 52));
 
             // 寮傚父
             crnProtocol.setAlarm1(0);
@@ -379,20 +398,28 @@
         array[2] = command.getSourcePosY();
 
 
-        if (staNoOne.contains(command.getSourcePosX())){
+        if (rowOne.contains(command.getSourcePosX())){
             array[3] = (short)1;
-        }else if (staNoTwo.contains(command.getSourcePosX())){
+        }else if (rowTwo.contains(command.getSourcePosX())){
             array[3] = (short)2;
+        }else if (rowThree.contains(command.getSourcePosX())){
+            array[3] = (short)3;
+        }else if (rowFour.contains(command.getSourcePosX())){
+            array[3] = (short)4;
         }else {
             array[3] = command.getSourcePosX();
         }
         array[4] = command.getDestinationPosZ();
         array[5] = command.getDestinationPosY();
 
-        if (staNoOne.contains(command.getDestinationPosX())){
+        if (rowOne.contains(command.getDestinationPosX())){
             array[6] = (short)1;
-        }else if (staNoTwo.contains(command.getDestinationPosX())){
+        }else if (rowTwo.contains(command.getDestinationPosX())){
             array[6] = (short)2;
+        }else if (rowThree.contains(command.getDestinationPosX())){
+            array[6] = (short)3;
+        }else if (rowFour.contains(command.getDestinationPosX())){
+            array[6] = (short)4;
         }else {
             array[6] = command.getDestinationPosX();
         }
@@ -400,7 +427,7 @@
         array[8] = command.getDestinationStaNo();
 
         // 浣滀笟淇℃伅
-        OperateResult result = siemensNet.Write("DB10.0", array);
+        OperateResult result = siemensNet.Write("DB100.0", array);
         // 浠诲姟鍙� + 瀹屾垚浣�
         short[] array2 = new short[2];
         array2[0] = command.getTaskNo();

--
Gitblit v1.9.1