From e7dd8396e19f538e5f51ced927e2f62e1f75fa63 Mon Sep 17 00:00:00 2001
From: LSH
Date: 星期五, 29 三月 2024 10:29:54 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/thread/SiemensDevpThread.java |   49 ++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 46 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/zy/core/thread/SiemensDevpThread.java b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
index 52c745a..c96e8a7 100644
--- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java
+++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -262,6 +262,44 @@
             }
         }
 
+        OperateResultExOne<byte[]> resultAgvAndPlcOk = siemensS7Net.Read("DB132.0", (short) 30);
+        if (resultAgvAndPlcOk.IsSuccess) {
+            for (int i = 0; i < staNoSize; i++) {
+                int sign =(i+2)/2-1;
+                if ((i+2)%2!=0){
+                    Integer siteId = staNos.get(i); // 绔欑偣缂栧彿
+                    StaProtocol staProtocol = station.get(siteId);
+                    if (null == staProtocol) {
+                        staProtocol = new StaProtocol();
+                        staProtocol.setSiteId(siteId);
+                        station.put(siteId, staProtocol);
+                    }
+                    staProtocol.setAgvTargetPick(siemensS7Net.getByteTransform().TransInt16(resultAgvAndPlcOk.Content, sign*6+4));     // 鍏佽鍙栬揣
+                    staProtocol.setAgvTargetPlace((short)0);   // 鍏佽鏀捐揣
+                    continue;
+                }
+                Integer siteId = staNos.get(i); // 绔欑偣缂栧彿
+                StaProtocol staProtocol = station.get(siteId);
+                if (null == staProtocol) {
+                    staProtocol = new StaProtocol();
+                    staProtocol.setSiteId(siteId);
+                    station.put(siteId, staProtocol);
+                }
+                try{
+                    staProtocol.setAgvTargetPick(siemensS7Net.getByteTransform().TransInt16(resultAgvAndPlcOk.Content, sign*6));     // 鍙栬揣瀹屾垚
+                    if (staProtocol.getAgvTargetPick()!=0){
+                        System.out.println(staProtocol.getAgvTargetPick());
+                    }
+                    staProtocol.setAgvTargetPlace(siemensS7Net.getByteTransform().TransInt16(resultAgvAndPlcOk.Content, sign*6 + 2));   // 鏀捐揣瀹屾垚
+                    if (staProtocol.getAgvTargetPlace()!=0){
+                        System.out.println(staProtocol.getAgvTargetPlace());
+                    }
+                }catch (Exception e){
+                    log.error(""+e);
+                }
+            }
+        }
+
 
         if (slave.getId() == 1) {
             //鏉$爜
@@ -363,7 +401,7 @@
         }
         ArrayList<Integer> staNos = getStaNo();
         int index = staNos.indexOf(staProtocol.getSiteId());
-        if (staProtocol.getAgvTypeSign()==0){  //0鍙栬揣
+        if (staProtocol.getAgvTypeSign()==0 || staProtocol.getAgvTypeSign()==2 ){  //0鍙栬揣
             switch (staProtocol.getSiteId()){
                 case 100:
                     index=32;
@@ -415,7 +453,11 @@
         //浠诲姟涓嬪彂娆℃暟
         int writeCount = 0;
         do {
-            write = siemensS7Net.Write("DB102." + index, true);    // 浠诲姟瀹屾垚
+            short textWrite = 1;// 浠诲姟瀹屾垚
+            if (staProtocol.getAgvTypeSign()>1){
+                textWrite = 0;// 浠诲姟澶嶄綅
+            }
+            write = siemensS7Net.Write("DB102." + index, textWrite);
             if(write.IsSuccess){
                 writeCount=6;
             }else {
@@ -461,7 +503,8 @@
                 taskWrk.setCommandStep(taskWrk.getCommandStep() + 1);//鏇存柊鎸囦护姝ュ簭
                 taskWrkService.updateById(taskWrk);
             }else{
-                log.error("杈撻�佺嚎鍐欏叆澶辫触"+staProtocol+"++++++++++++++++++++++++++++++++++++++");
+                log.error(staProtocol+"++++++++++++++++++++++++++++++++++++++");
+//                log.error("杈撻�佺嚎鍐欏叆澶辫触"+staProtocol+"++++++++++++++++++++++++++++++++++++++");
             }
         }
 

--
Gitblit v1.9.1