From 6f9b4c38d47b697941115cc4f7b42a66a028f8fc Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期六, 14 九月 2024 08:35:24 +0800
Subject: [PATCH] 增加因多次未上行数据,认为设备离的RTU日志。

---
 pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/TcpClUnit.java |   68 +++++++++++++++++++---------------
 1 files changed, 38 insertions(+), 30 deletions(-)

diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/TcpClUnit.java b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/TcpClUnit.java
index 78a8b90..4537b10 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/TcpClUnit.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/TcpClUnit.java
@@ -2,7 +2,7 @@
 
 import com.dy.common.mw.UnitAdapterInterface;
 import com.dy.common.mw.UnitInterface;
-import com.dy.common.mw.UnitStartedCallbackInterface;
+import com.dy.common.mw.UnitCallbackInterface;
 import com.dy.common.threadPool.ThreadPool;
 import com.dy.common.threadPool.TreadPoolFactory;
 import com.dy.common.util.Callback;
@@ -53,7 +53,7 @@
     }
 
     @Override
-    public void start(UnitStartedCallbackInterface callback) throws Exception {
+    public void start(UnitCallbackInterface callback) throws Exception {
         pool = TreadPoolFactory.getThreadPoolLong() ;
         System.out.println("Tcp Client妯″潡鎴愬姛鍚姩");
         this.doStart();
@@ -61,7 +61,7 @@
     }
 
     @Override
-    public void stop(UnitStartedCallbackInterface callback) throws Exception {
+    public void stop(UnitCallbackInterface callback) throws Exception {
         callback.call(null);
     }
 
@@ -71,7 +71,7 @@
             public void run() {
                 try {
                     while(true){
-                        if(!ServerProperties.startWork){
+                        if(!ServerProperties.startTcpConnectWork){
                             Thread.sleep(100L);
                         }else{
                             try{
@@ -83,10 +83,13 @@
                                 log.info("鍏辨ā鎷熶簡" + totalRtuClientCount + "鍙癛TU");
 
                                 Collection<MyThreadJob> collection = jobMap.values() ;
+                                int connectedCount = 0 ;
                                 for(MyThreadJob job : collection){
                                     connectServer(job) ;
+                                    connectedCount++ ;
+                                    log.info("褰撳墠寤虹珛涓庨�氫俊涓棿浠惰繛鎺ョ殑RTU鏁伴噺涓猴細" + connectedCount);
                                 }
-                                log.info("鍚姩鎵�鏈塕TU杩炴帴閫氫俊涓棿浠�");
+                                log.info("鎵�鏈塕TU宸蹭笌閫氫俊涓棿浠跺缓绔嬭繛鎺�");
 
                                 while (true){
                                     int noConnectedCount = checkConnected() ;
@@ -98,7 +101,15 @@
                                     }
                                 }
 
-                                startJob() ;
+                                while (true){
+                                    if(!ServerProperties.startRtuReportWork){
+                                        Thread.sleep(100L);
+                                    }else{
+                                        startJob() ;
+                                        break ;
+                                    }
+                                }
+
                                 while(true){
                                     if(totalOverClientCount.longValue() >= totalRtuClientCount.longValue()){
                                         Long seconds = (System.currentTimeMillis() - startTime)/1000 ;
@@ -176,30 +187,27 @@
     }
 
     private void startJob(){
-        new Thread(new Runnable(){
-            @Override
-            public void run() {
-                try {
-                    int notOverCount;
-                    while(true){
-                        notOverCount = 0 ;
-                        Collection<MyThreadJob> collection = jobMap.values() ;
-                        for(MyThreadJob job : collection){
-                            if(!job.isOver){
-                                notOverCount++ ;
-                                pool.putJob(job);
-                            }
-                        }
-                        if(notOverCount > 0){
-                            log.info("褰撳墠杩樻湁" + notOverCount + "鍙癛TU鏈畬鎴愪换鍔�");
-                            Thread.sleep(ServerProperties.sendInterval * 1000);
-                        }else{
-                            break ;
+        new Thread(() -> {
+            try {
+                int notOverCount;
+                while(true){
+                    notOverCount = 0 ;
+                    Collection<MyThreadJob> collection = jobMap.values() ;
+                    for(MyThreadJob job : collection){
+                        if(!job.isOver){
+                            notOverCount++ ;
+                            pool.putJob(job);
                         }
                     }
-                } catch (Exception e) {
-                    e.printStackTrace();
+                    if(notOverCount > 0){
+                        log.info("褰撳墠杩樻湁" + notOverCount + "鍙癛TU鏈畬鎴愪换鍔�");
+                        Thread.sleep(ServerProperties.sendInterval * 1000);
+                    }else{
+                        break ;
+                    }
                 }
+            } catch (Exception e) {
+                e.printStackTrace();
             }
         }).start();
     }
@@ -209,16 +217,16 @@
         totalSendDataCount++;
         if(totalOverClientCount.longValue() >= totalRtuClientCount.longValue()){
             RmiClUnit.getInstance().reportHadReportCount(totalSendDataCount);
-            System.out.println("宸茬粡鍙戦��" + totalSendDataCount + "鏉℃暟鎹�");
+            System.out.println("宸茬粡鍙戦��" + totalSendDataCount + "鏉℃暟鎹紙蹇冭烦鍜屼笂鎶ワ級");
         }else{
             if(totalRtuClientCount > 100){
                 if(totalSendDataCount % 100 == 0){
                     RmiClUnit.getInstance().reportHadReportCount(totalSendDataCount);
-                    System.out.println("宸茬粡鍙戦��" + totalSendDataCount + "鏉℃暟鎹�");
+                    System.out.println("宸茬粡鍙戦��" + totalSendDataCount + "鏉℃暟鎹紙蹇冭烦鍜屼笂鎶ワ級");
                 }
             }else{
                 RmiClUnit.getInstance().reportHadReportCount(totalSendDataCount);
-                System.out.println("宸茬粡鍙戦��" + totalSendDataCount + "鏉℃暟鎹�");
+                System.out.println("宸茬粡鍙戦��" + totalSendDataCount + "鏉℃暟鎹紙蹇冭烦鍜屼笂鎶ワ級");
             }
         }
     }

--
Gitblit v1.8.0