From fb9405a0482b22cd9411ab3e24163f4fb17a5260 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期日, 03 一月 2021 13:46:54 +0800
Subject: [PATCH] #1

---
 src/main/java/com/zy/core/thread/SiemensCrnThread.java |   75 +++++++++++++++++++++----------------
 1 files changed, 43 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 221bf8c..46b2620 100644
--- a/src/main/java/com/zy/core/thread/SiemensCrnThread.java
+++ b/src/main/java/com/zy/core/thread/SiemensCrnThread.java
@@ -73,7 +73,7 @@
                         }
                         command.setCrnNo(slave.getId()); // 鍫嗗灈鏈虹紪鍙�
                         command.setTaskNo((short) 0); // 宸ヤ綔鍙�
-                        command.setAckFinish((short) 1);  // 浠诲姟瀹屾垚纭浣�
+//                        command.setAckFinish((short) 1);  // 浠诲姟瀹屾垚纭浣�
                         command.setTaskMode(CrnTaskModeType.NONE); // 浠诲姟妯″紡
                         command.setSourcePosX((short)0);     // 婧愬簱浣嶆帓
                         command.setSourcePosY((short)0);     // 婧愬簱浣嶅垪
@@ -97,7 +97,7 @@
     @Override
     public boolean connect() {
         boolean result = false;
-        siemensNet = new SiemensS7Net(SiemensPLCS.S300, slave.getIp());
+        siemensNet = new SiemensS7Net(SiemensPLCS.S1200, slave.getIp());
         siemensNet.setRack(slave.getRack().byteValue());
         siemensNet.setSlot(slave.getSlot().byteValue());
         OperateResult connect = siemensNet.ConnectServer();
@@ -117,7 +117,7 @@
      * 璇诲彇鐘舵��
      */
     private void readStatus(){
-        OperateResultExOne<byte[]> result = siemensNet.Read("DB8.18", (short) 62);
+        OperateResultExOne<byte[]> result = siemensNet.Read("DB11.2", (short) 90);
         if (result.IsSuccess) {
             if (null == crnProtocol) {
                 crnProtocol = new CrnProtocol();
@@ -187,38 +187,49 @@
             return false;
         }
         command.setCrnNo(slave.getId());
-        short[] array = new short[9];
-        array[0] = command.getAckFinish();
-        array[1] = command.getTaskNo();
-        array[2] = command.getTaskMode();
+        short[] array = new short[13];
+        if (!command.getTaskModeType().equals(CrnTaskModeType.CLEAR)) {
+            array[0] = 5;
+        } else {
+            array[0] = 7;
+        }
+        array[1] = command.getSourcePosZ();
+        array[2] = command.getSourcePosY();
         array[3] = command.getSourcePosX();
-        array[4] = command.getSourcePosY();
-        array[5] = command.getSourcePosZ();
+        array[4] = command.getDestinationPosZ();
+        array[5] = command.getDestinationPosY();
         array[6] = command.getDestinationPosX();
-        array[7] = command.getDestinationPosY();
-        array[8] = command.getDestinationPosZ();
-        OperateResult result = siemensNet.Write("DB8.0", array);
+        array[7] = command.getSourceStaNo();
+        array[8] = command.getDestinationStaNo();
+        array[9] = command.getSourceLane();
+        array[10] = command.getDestinationLane();
+        array[11] =
+
+        OperateResult result = siemensNet.Write("DB10.0", array);
         if (result.IsSuccess) {
-            // 鏃ュ織璁板綍
-            BasCrnOptService bean = SpringUtils.getBean(BasCrnOptService.class);
-            BasCrnOpt basCrnOpt = new BasCrnOpt(
-                    command.getTaskNo().intValue(),    // 浠诲姟鍙�
-                    command.getCrnNo(),    // 鍫嗗灈鏈篬闈炵┖]
-                    new Date(),    // 涓嬪彂鏃堕棿
-                    command.getTaskModeType().toString(),    // 妯″紡
-                    command.getSourcePosX().intValue(),    // 婧愭帓
-                    command.getSourcePosY().intValue(),    // 婧愬垪
-                    command.getSourcePosZ().intValue(),    // 婧愬眰
-                    null,    // 婧愮珯
-                    command.getDestinationPosX().intValue(),    // 鐩爣鎺�
-                    command.getDestinationPosY().intValue(),    // 鐩爣鍒�
-                    command.getDestinationPosZ().intValue(),    // 鐩爣灞�
-                    null,    // 鐩爣绔�
-                    null,    // 鍝嶅簲缁撴灉
-                    null,    // 淇敼鏃堕棿
-                    null    // 淇敼浜哄憳
-            );
-            bean.insert(basCrnOpt);
+
+            try {
+                // 鏃ュ織璁板綍
+                BasCrnOptService bean = SpringUtils.getBean(BasCrnOptService.class);
+                BasCrnOpt basCrnOpt = new BasCrnOpt(
+                        command.getTaskNo().intValue(),    // 浠诲姟鍙�
+                        command.getCrnNo(),    // 鍫嗗灈鏈篬闈炵┖]
+                        new Date(),    // 涓嬪彂鏃堕棿
+                        command.getTaskModeType().toString(),    // 妯″紡
+                        command.getSourcePosX().intValue(),    // 婧愭帓
+                        command.getSourcePosY().intValue(),    // 婧愬垪
+                        command.getSourcePosZ().intValue(),    // 婧愬眰
+                        null,    // 婧愮珯
+                        command.getDestinationPosX().intValue(),    // 鐩爣鎺�
+                        command.getDestinationPosY().intValue(),    // 鐩爣鍒�
+                        command.getDestinationPosZ().intValue(),    // 鐩爣灞�
+                        null,    // 鐩爣绔�
+                        null,    // 鍝嶅簲缁撴灉
+                        null,    // 淇敼鏃堕棿
+                        null    // 淇敼浜哄憳
+                );
+                bean.insert(basCrnOpt);
+            } catch (Exception ignore) {}
 
             log.info("鍫嗗灈鏈哄懡浠や笅鍙慬id:{}] >>>>> {}", slave.getId(), 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