From 5bfa227109b90b20b09345722b3232fac77a1ab1 Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期三, 11 九月 2024 11:41:53 +0800
Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV

---
 pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/rmiClient/RmiClUnit.java |  107 ++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 84 insertions(+), 23 deletions(-)

diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/rmiClient/RmiClUnit.java b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/rmiClient/RmiClUnit.java
index 008ed2a..b534caf 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/rmiClient/RmiClUnit.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/rmiClient/RmiClUnit.java
@@ -6,7 +6,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.mw.channel.rmi.RmiFrameWork;
 
 public class RmiClUnit  implements UnitInterface {
@@ -43,14 +43,14 @@
 	}
 
 	@Override
-	public void start(UnitStartedCallbackInterface callback) throws Exception {
+	public void start(UnitCallbackInterface callback) throws Exception {
 		System.out.println("Rmi Client妯″潡鎴愬姛鍚姩");
 		this.doStart();
 	    callback.call(null) ;
 	}
 
 	@Override
-	public void stop(UnitStartedCallbackInterface callback) throws Exception {
+	public void stop(UnitCallbackInterface callback) throws Exception {
 		callback.call(null);
 	}
 	
@@ -73,6 +73,8 @@
 	}
 	
 	public RmiFrameWork getRmiFrameWork(){
+		System.setProperty("java.rmi.server.hostname", confVo.svUrl) ;
+		System.out.println("Rmi寤虹珛杩炴帴璇锋眰鏈嶅姟绔細" + confVo.svUrl + ":" + confVo.svPort + "/" + confVo.svContext);
 		RmiClient rmiCl = new RmiClient(confVo.svUrl, confVo.svPort, confVo.svContext) ;
 		return rmiCl.getRmiInterface() ;
 	}
@@ -84,7 +86,7 @@
 			RmiRequestVo rqVo = new RmiRequestVo() ;
 			rqVo.id = id ;
 			rqVo.token = token ;
-			rqVo.code = Code.cd4 ;
+			rqVo.code = Code.cd5;
 			rqVo.count = count ;
 			String json = rqVo.toJson() ;
 			frmWork.syncRequest(json) ;
@@ -100,8 +102,8 @@
 			RmiRequestVo rqVo = new RmiRequestVo() ;
 			rqVo.id = id ;
 			rqVo.token = token ;
-			rqVo.code = Code.cd5 ;
-			rqVo.count = count ;
+			rqVo.code = Code.cd6;
+			rqVo.overCount = count ;
 			String json = rqVo.toJson() ;
 			frmWork.syncRequest(json) ;
 		} catch (Exception e) {
@@ -117,7 +119,7 @@
 			RmiRequestVo rqVo = new RmiRequestVo() ;
 			rqVo.id = id ;
 			rqVo.token = token ;
-			rqVo.code = Code.cd6 ;
+			rqVo.code = Code.cd7;
 			rqVo.over = true ;
 			rqVo.seconds = seconds ;
 			String json = rqVo.toJson() ;
@@ -200,6 +202,7 @@
 									ServerProperties.sendInterval = rVo.sendInterval ;
 									ServerProperties.heartbeatTimes = rVo.heartbeatTimes ;
 									ServerProperties.sendTimes = rVo.sendTimes ;
+									ServerProperties.sendOverThenCloseConnect = rVo.sendOverThenCloseConnect ;
 									log.info("寰楀埌閰嶇疆鎴愬姛");
 									log.info("    寮�濮婻tuAddr=" + ServerProperties.rtuAddrStart);
 									log.info("    鎴RtuAddr=" + ServerProperties.rtuAddrEnd);
@@ -208,6 +211,7 @@
 									log.info("    鍙戦�佹暟鎹棿闅�=" + ServerProperties.sendTimes);
 									log.info("    姣忚疆娆″彂閫佸績璺虫鏁�=" + ServerProperties.heartbeatTimes);
 									log.info("    姣廟TU涓婃姤鏁版嵁杞=" + ServerProperties.sendTimes);
+									log.info("    鍙戦�佸畬鏁版嵁鍚庯紝鏄惁鍏抽棴TCP杩炴帴(1鏄紝0鍚�)=" + ServerProperties.sendOverThenCloseConnect);
 									break ;
 								}else{
 									log.error("rmi寰楀埌閰嶇疆澶辫触锛歫son杞琑esConfigVo涓簄ull");
@@ -236,13 +240,14 @@
 			}
 		}
 		if(!error){
-			getStart(frmWork) ;
+			getStartTcpConnect(frmWork) ;
 		}
 	}
 	
-	//浠巑wTestServer寰楀埌寮�濮嬩笂鎶ユ暟鎹殑璇峰厑璁�
-	private void getStart(RmiFrameWork frmWork){
-		log.info("绛夊緟鏈嶅姟绔厑璁镐笂鎶ユ暟鎹�");
+	//浠巑wTestServer寰楀埌寮�濮婽CP杩炴帴鐨勮鍏佽
+	private void getStartTcpConnect(RmiFrameWork frmWork){
+		log.info("绛夊緟鏈嶅姟绔厑璁哥綉缁滆繛鎺�");
+		boolean error = false ;
 		while(true){
 			try {
 				Thread.sleep(100L);
@@ -253,37 +258,93 @@
 				String json = rqVo.toJson() ;
 				Object rObj = frmWork.syncRequest(json) ;
 				if(rObj != null){
-					RmiResponseVo rspVo = RmiResponseVo.jsonToObject(String.valueOf(rObj), ResStartVo.class) ;
+					RmiResponseVo rspVo = RmiResponseVo.jsonToObject(String.valueOf(rObj), ResStartTcpConnectVo.class) ;
 					if(rspVo != null){
 						if(rspVo.success){
-							if(rspVo.obj != null && rspVo.obj instanceof ResStartVo){
-								ResStartVo rVo = (ResStartVo)rspVo.obj ;
+							if(rspVo.obj != null && rspVo.obj instanceof ResStartTcpConnectVo){
+								ResStartTcpConnectVo rVo = (ResStartTcpConnectVo)rspVo.obj ;
 								if(rVo != null){
 									if(rVo.start){
-										ServerProperties.startWork = true ;
-										log.info("鍏佽涓婃姤鏁版嵁宸ヤ綔浜�( ^_^ )");
+										ServerProperties.startTcpConnectWork = true ;
+										log.info("鍏佽TCP缃戠粶杩炴帴浜�( ^_^ )");
+										error = false ;
 										break ;
 									}
 								}else{
-									log.error("rmi璇锋眰鍚姩澶辫触锛歫son杞琑esStartVo涓簄ull");
+									error = true ;
+									log.error("rmi璇锋眰TCP缃戠粶杩炴帴澶辫触锛歫son杞琑esStartTcpConnectVo涓簄ull");
 								}
 							}else{
-								log.error("rmi璇锋眰鍚姩澶辫触锛氭湇鍔$杩斿洖ResStartVo涓簄ull");
+								error = true ;
+								log.error("rmi璇锋眰TCP缃戠粶杩炴帴澶辫触锛氭湇鍔$杩斿洖ResStartTcpConnectVo涓簄ull");
 							}
 						}else{
-							log.error("rmi璇锋眰鍚姩澶辫触锛氭湇鍔$杩斿洖閿欒锛�" + rspVo.errorInfo);
+							error = true ;
+							log.error("rmi璇锋眰TCP缃戠粶杩炴帴澶辫触锛氭湇鍔$杩斿洖閿欒锛�" + rspVo.errorInfo);
 						}
 					}else{
-						log.error("rmi璇锋眰鍚姩澶辫触锛氭湇鍔$杩斿洖鐨凴miResponseVo涓簄ull");
+						error = true ;
+						log.error("rmi璇锋眰TCP缃戠粶杩炴帴澶辫触锛氭湇鍔$杩斿洖鐨凴miResponseVo涓簄ull");
 					}
 				}else{
-					log.error("rmi璇锋眰鍚姩澶辫触锛氭湇鍔$杩斿洖json涓簄ull");
+					error = true ;
+					log.error("rmi璇锋眰TCP缃戠粶杩炴帴澶辫触锛氭湇鍔$杩斿洖json涓簄ull");
 				}
 			} catch (Exception e) {
-				log.error("rmi璇锋眰鍚姩澶辫触" + e.getMessage());
+				error = true ;
+				log.error("rmi璇锋眰TCP缃戠粶杩炴帴澶辫触" + e.getMessage());
+				continue ;
+			}
+		}
+		if(!error){
+			getStartRtuReport(frmWork) ;
+		}
+	}
+
+	//浠巑wTestServer寰楀埌寮�濮婻TU涓婃姤鏁版嵁鐨勮鍏佽
+	private void getStartRtuReport(RmiFrameWork frmWork){
+		log.info("绛夊緟鏈嶅姟绔厑璁镐笂鎶ユ暟鎹�");
+		while(true){
+			try {
+				Thread.sleep(100L);
+				RmiRequestVo rqVo = new RmiRequestVo() ;
+				rqVo.id = id ;
+				rqVo.token = token ;
+				rqVo.code = Code.cd4 ;
+				String json = rqVo.toJson() ;
+				Object rObj = frmWork.syncRequest(json) ;
+				if(rObj != null){
+					RmiResponseVo rspVo = RmiResponseVo.jsonToObject(String.valueOf(rObj), ResStartRtuReportVo.class) ;
+					if(rspVo != null){
+						if(rspVo.success){
+							if(rspVo.obj != null && rspVo.obj instanceof ResStartRtuReportVo){
+								ResStartRtuReportVo rVo = (ResStartRtuReportVo)rspVo.obj ;
+								if(rVo != null){
+									if(rVo.report){
+										ServerProperties.startRtuReportWork = true ;
+										log.info("鍏佽RTU涓婃姤鏁版嵁宸ヤ綔浜�( ^_^ )");
+										break ;
+									}
+								}else{
+									log.error("rmi璇锋眰Rtu涓婃姤鏁版嵁澶辫触锛歫son杞琑esStartRtuReportVo涓簄ull");
+								}
+							}else{
+								log.error("rmi璇锋眰Rtu涓婃姤鏁版嵁澶辫触锛氭湇鍔$杩斿洖ResStartRtuReportVo涓簄ull");
+							}
+						}else{
+							log.error("rmi璇锋眰Rtu涓婃姤鏁版嵁澶辫触锛氭湇鍔$杩斿洖閿欒锛�" + rspVo.errorInfo);
+						}
+					}else{
+						log.error("rmi璇锋眰Rtu涓婃姤鏁版嵁澶辫触锛氭湇鍔$杩斿洖鐨凴miResponseVo涓簄ull");
+					}
+				}else{
+					log.error("rmi璇锋眰Rtu涓婃姤鏁版嵁澶辫触锛氭湇鍔$杩斿洖json涓簄ull");
+				}
+			} catch (Exception e) {
+				log.error("rmi璇锋眰Rtu涓婃姤鏁版嵁澶辫触" + e.getMessage());
 				continue ;
 			}
 		}
 	}
-	
+
 }
\ No newline at end of file

--
Gitblit v1.8.0