From 16441fe63adf04e0c434377f7da0fd05ba155eb6 Mon Sep 17 00:00:00 2001
From: zjj <3272660260@qq.com>
Date: 星期二, 21 十一月 2023 17:13:15 +0800
Subject: [PATCH] #联机

---
 src/main/java/com/zy/core/thread/SiemensCrnThread.java |   83 +++++++++++++++++++++++++----------------
 1 files changed, 51 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 ea7b1f4..5d068f5 100644
--- a/src/main/java/com/zy/core/thread/SiemensCrnThread.java
+++ b/src/main/java/com/zy/core/thread/SiemensCrnThread.java
@@ -5,6 +5,7 @@
 import HslCommunication.Profinet.Siemens.SiemensPLCS;
 import HslCommunication.Profinet.Siemens.SiemensS7Net;
 import com.alibaba.fastjson.JSON;
+import com.core.common.Cools;
 import com.core.common.DateUtils;
 import com.core.common.SpringUtils;
 import com.zy.asrs.entity.*;
@@ -38,12 +39,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;
@@ -381,48 +389,59 @@
         }
 
         command.setCrnNo(slave.getId());
-        short[] array = new short[9];
+        short[] array = new short[12];
         if (command.getAckFinish() == 0) {
             array[0] = 5;
         } else {
             array[0] = 0;
         }
-        array[1] = command.getSourcePosZ();
-        array[2] = command.getSourcePosY();
+        array[1] = command.getTaskNo();
+        array[2] = command.getTaskMode();
 
-
-        if (staNoOne.contains(command.getSourcePosX())){
-            array[3] = (short)1;
-        }else if (staNoTwo.contains(command.getSourcePosX())){
-            array[3] = (short)2;
+        array[3] = command.getDestinationPosZ();
+        if (rowOne.contains(command.getSourcePosX())){
+            array[4] = (short)1;
+        }else if (rowTwo.contains(command.getSourcePosX())){
+            array[4] = (short)2;
+        }else if (rowThree.contains(command.getSourcePosX())){
+            array[4] = (short)3;
+        }else if (rowFour.contains(command.getSourcePosX())){
+            array[4] = (short)4;
         }else {
-            array[3] = command.getSourcePosX();
+            array[4] = command.getSourcePosX();
         }
-        array[4] = command.getDestinationPosZ();
         array[5] = command.getDestinationPosY();
 
-        if (staNoOne.contains(command.getDestinationPosX())){
-            array[6] = (short)1;
-        }else if (staNoTwo.contains(command.getDestinationPosX())){
-            array[6] = (short)2;
+        array[6] = command.getDestinationPosZ();
+        if (rowOne.contains(command.getDestinationPosX())){
+            array[7] = (short)1;
+        }else if (rowTwo.contains(command.getDestinationPosX())){
+            array[7] = (short)2;
+        }else if (rowThree.contains(command.getDestinationPosX())){
+            array[7] = (short)3;
+        }else if (rowFour.contains(command.getDestinationPosX())){
+            array[7] = (short)4;
         }else {
-            array[6] = command.getDestinationPosX();
+            array[7] = command.getDestinationPosX();
         }
-        array[7] = command.getSourceStaNo();
-        array[8] = command.getDestinationStaNo();
+        array[8] = command.getDestinationPosY();
+        if (!Cools.isEmpty(command.getAuto())){
+            array[10] = command.getAuto();
+        }
+
 
         // 浣滀笟淇℃伅
         OperateResult result = siemensNet.Write("DB100.0", array);
-        // 浠诲姟鍙� + 瀹屾垚浣�
-        short[] array2 = new short[2];
-        array2[0] = command.getTaskNo();
-        array2[1] = command.getAckFinish();
-        OperateResult result1 = siemensNet.Write("DB10.24", array2);
-
-        // 缁撴潫浣�
-        if (command.getAckFinish() == 0) {
-            OperateResult result2 = siemensNet.Write("DB10.28.1", true);
-        }
+//        // 浠诲姟鍙� + 瀹屾垚浣�
+//        short[] array2 = new short[2];
+//        array2[0] = command.getTaskNo();
+//        array2[1] = command.getAckFinish();
+//        OperateResult result1 = siemensNet.Write("DB10.24", array2);
+//
+//        // 缁撴潫浣�
+//        if (command.getAckFinish() == 0) {
+//            OperateResult result2 = siemensNet.Write("DB10.28.1", true);
+//        }
 
         // 鏃ュ織璁板綍
         try {
@@ -456,7 +475,7 @@
         CommandInfoLog commandInfoLog = JSON.parseObject(JSON.toJSONString(commandInfo), CommandInfoLog.class);
         commandInfoLog.setId(null);
 
-        if (result.IsSuccess && result1.IsSuccess) {
+        if (result.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)));
 

--
Gitblit v1.9.1