From 67be611a90e29e06ea0539b6bc953d5a3e6ba310 Mon Sep 17 00:00:00 2001
From: wuzeyu <1223318623@qq.com>
Date: 星期一, 30 十二月 2024 11:54:37 +0800
Subject: [PATCH]  修改分布式文件系统配置

---
 pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/tcpClient/TcpClUnit.java |   69 +---------------------------------
 1 files changed, 3 insertions(+), 66 deletions(-)

diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/tcpClient/TcpClUnit.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/tcpClient/TcpClUnit.java
index ae2a3a1..41b0fe6 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/tcpClient/TcpClUnit.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/tcpClient/TcpClUnit.java
@@ -14,14 +14,12 @@
 
 public class TcpClUnit implements UnitInterface {
 
-    private static final Logger log = LogManager.getLogger(TcpClUnit.class) ;
-
     private static TcpClUnit instance = new TcpClUnit() ;
 
     public static TcpClUnitAdapter adapter ;
     public static TcpClUnitConfigVo confVo ;
 
-    public static IoSession session ;
+    private static Worker worker ;
 
     private TcpClUnit(){} ;
 
@@ -39,12 +37,13 @@
         if(TcpClUnit.confVo == null){
             throw new Exception("Tcp Client妯″潡閰嶇疆瀵硅薄涓嶈兘涓虹┖锛�") ;
         }
+        TcpClUnit.worker = Worker.getInstance(TcpClUnit.confVo) ;
     }
 
     @Override
     public void start(UnitCallbackInterface callback) throws Exception {
         System.out.println("Tcp Client妯″潡鎴愬姛鍚姩");
-        this.doStart();
+        TcpClUnit.worker.doStart();
         callback.call(null) ;
     }
 
@@ -53,67 +52,5 @@
         callback.call(null);
     }
 
-    private void doStart(){
-        new Thread(() -> {
-            Exception ex ;
-            while(true){
-                ex = null ;
-                try {
-                    new TcpConnect().createSession(
-                            confVo.mwServerIp,
-                            confVo.mwServerPort,
-                            confVo.connectTimeout,
-                            new TcpHandler(),
-                            new Callback() {
-                                @Override
-                                public void call(Object obj) {
-                                    if (obj == null) {
-                                        log.error("鍒涘缓缃戠粶浼氳瘽杩斿洖涓簄ull");
-                                    } else {
-                                        TcpClUnit.session = (IoSession) obj;
-                                        log.info("鎴愬姛鍒涘缓涓庨�氫俊涓棿浠剁殑缃戠粶杩炴帴");
-                                        UpData.setSession(TcpClUnit.session);
-                                        heartBeat() ;
-                                    }
-                                }
-                                @Override
-                                public void call(Object... objs) {
-                                }
-                                @Override
-                                public void exception(Exception e) {
-                                }
-                            });
-                }catch (Exception e){
-                   ex = e ;
-                }
-                if(ex == null){
-                    break ;
-                }else{
-                    try{
-                        Thread.sleep(100);
-                    }catch (Exception e){
-                    }
-                }
-            }
-        }).start();
-    }
-
-
-    private void heartBeat(){
-        new Thread(new Runnable(){
-            @Override
-            public void run() {
-                while(true){
-                    try {
-                        UpHeartBeat.upCd02Data(ServerProperties.rtuAddr);
-                        Thread.sleep(30000L);
-                        //Thread.sleep(30000000L);
-                    }catch (Exception e){
-                        continue;
-                    }
-                }
-            }
-        }).start();
-    }
 
 }

--
Gitblit v1.8.0