From d014ca67872527703ef949b6874984df0208f17b Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期一, 17 四月 2023 09:42:36 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/thread/SiemensDevpThread.java |   22 +++++++++-------------
 1 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/src/main/java/com/zy/core/thread/SiemensDevpThread.java b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
index 0f9a869..d22872a 100644
--- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java
+++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -88,7 +88,7 @@
                         break;
                     // 鍐欐暟鎹� ID+鐩爣绔�
                     case 2:
-                        write((StaProtocol)task.getData());
+                        write((StaProtocol)task.getData(), 0);
                         Thread.sleep(300);
                         read();
                         break;
@@ -232,18 +232,12 @@
     /**
      * 鍐欏叆 ID+鐩爣绔� =====> 鍗曠珯鐐瑰啓鍏�
      */
-    private void write(StaProtocol staProtocol) throws InterruptedException {
-        if (null == staProtocol) {
+    private void write(StaProtocol staProtocol, int times) throws InterruptedException {
+        if (null == staProtocol || times > 2) {
             return;
         }
         int index = staNos.indexOf(staProtocol.getSiteId());
         OperateResult write = siemensS7Net.Write("DB100." + index*2, staProtocol.getWorkNo());    // 宸ヤ綔鍙�
-        if(!write.IsSuccess){
-            News.error("鍐欏叆杈撻�佺嚎ID澶辫触,閲嶆柊娣诲姞浠诲姟鍒伴槦鍒椼�傝緭閫佺嚎plc缂栧彿={}锛岀珯鐐规暟鎹�={}", slave.getId(), JSON.toJSON(staProtocol));
-            OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戝啓鍏ヨ緭閫佺嚎绔欑偣鏁版嵁澶辫触銆傝緭閫佺嚎plc缂栧彿={1}锛岀珯鐐规暟鎹�={2}", slave.getId(), JSON.toJSON(staProtocol)));
-            MessageQueue.offer(SlaveType.Devp, slave.getId(), new Task(2, staProtocol));
-            return;
-        }
         Thread.sleep(200);
         OperateResult write1 = siemensS7Net.Write("DB101." + index*2, staProtocol.getStaNo());    // 鐩爣绔�
 
@@ -251,10 +245,12 @@
             MessageQueue.offer(SlaveType.Devp, slave.getId(), new Task(2, staProtocol));
             OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戝啓鍏ヨ緭閫佺嚎绔欑偣鏁版嵁澶辫触銆傝緭閫佺嚎plc缂栧彿={1}锛岀珯鐐规暟鎹�={2}", slave.getId(), JSON.toJSON(staProtocol)));
             News.error("鍐欏叆杈撻�佺嚎绔欑偣鏁版嵁澶辫触锛岄噸鏂版坊鍔犱换鍔″埌闃熷垪銆傝緭閫佺嚎plc缂栧彿={}锛岀珯鐐规暟鎹�={}", slave.getId(), JSON.toJSON(staProtocol));
-            staProtocol = station.get(staProtocol.getSiteId());
-            if (staProtocol.getWorkNo() == 0 && staProtocol.getStaNo() ==0) {
-                staProtocol.setPakMk(true);
-            }
+            times++;
+            write(staProtocol, times);
+//            staProtocol = station.get(staProtocol.getSiteId());
+//            if (staProtocol.getWorkNo() == 0 && staProtocol.getStaNo() ==0) {
+//                staProtocol.setPakMk(true);
+//            }
         } else {
             OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆� 杈撻�佺嚎鍛戒护涓嬪彂 [id:{1}] >>>>> {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(staProtocol)));
             News.info("杈撻�佺嚎鍛戒护涓嬪彂 [id:{}] >>>>> 鍛戒护涓嬪彂锛� {}",  slave.getId(), JSON.toJSON(staProtocol));

--
Gitblit v1.9.1