From 4b99aedffe4e64425c059611dbb89d7d28b9ed06 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期三, 07 五月 2025 15:28:04 +0800
Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV
---
pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/Manager.java | 211 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 211 insertions(+), 0 deletions(-)
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/Manager.java b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/Manager.java
new file mode 100644
index 0000000..8d9b36c
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-server/src/main/java/com/dy/testServer/forRmi/Manager.java
@@ -0,0 +1,211 @@
+package com.dy.testServer.forRmi;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.dy.testServer.ServerProperties;
+
+public class Manager {
+
+ public static boolean enablemwTestStartTcpConnect = false ;
+
+ public static boolean enablemwTestStartRtuReport = false ;
+
+ public static int clientId = 1 ;
+
+ public static long maxClient = 0 ;
+
+ public static Map<String, String> id2TokenMap = new HashMap<>() ;
+
+ public static Map<String, MwTestClientStatus> token2ClientMap = new HashMap<>() ;
+
+ public static List<Object[]> rtuAddrList = new ArrayList<>() ;
+
+ public static void init(){
+ maxClient = (ServerProperties.rtuAddrEnd - ServerProperties.rtuAddrStart)/ServerProperties.rtuAddrPerMwTest ;
+ if((ServerProperties.rtuAddrEnd - ServerProperties.rtuAddrStart)%ServerProperties.rtuAddrPerMwTest > 0 ){
+ maxClient = maxClient + 1 ;
+ }
+ int count = 0 ;
+ for(int i = 0; i < maxClient; i++){
+ long start = ServerProperties.rtuAddrStart + (i * ServerProperties.rtuAddrPerMwTest) ;
+ long end = ServerProperties.rtuAddrStart + ((i + 1) * ServerProperties.rtuAddrPerMwTest - 1) ;
+ if(end > ServerProperties.rtuAddrEnd){
+ end = ServerProperties.rtuAddrEnd ;
+ }
+ if(end < start){
+ break ;
+ }else{
+ rtuAddrList.add(count++, new Object[]{start, end});
+ }
+ }
+ }
+
+ public synchronized static String dealRequest(Object obj) throws Exception{
+ RmiResponseVo resVo ;
+ if(obj == null){
+ resVo = new RmiResponseVo() ;
+ resVo.success = false ;
+ resVo.errorInfo = "鏀跺埌鐨勬暟鎹负null" ;
+ }else if(!(obj instanceof String)){
+ resVo = new RmiResponseVo() ;
+ resVo.success = false ;
+ resVo.errorInfo = "鏀跺埌鐨勬暟鎹笉鏄瓧绗︿覆绫诲瀷" ;
+ }else{
+ RmiRequestVo rqVo = RmiRequestVo.jsonToObject((String)obj) ;
+ resVo = doDeal(rqVo) ;
+ }
+ return resVo.toJson() ;
+ }
+
+ private static RmiResponseVo doDeal(RmiRequestVo rqVo){
+ RmiResponseVo resVo = new RmiResponseVo() ;
+ resVo.code = rqVo.code ;
+ if(rqVo.code.equals(Code.cd1)){
+ if(rqVo.id == null || rqVo.id.trim().equals("")){
+ resVo.success = false ;
+ resVo.errorInfo = "娉ㄥ唽澶辫触锛屽繀椤绘彁渚涘鎴风ID " ;
+ }else{
+ ResRegisterVo vo = doDealRegister(rqVo) ;
+ if(vo != null){
+ resVo.obj = vo ;
+ }else{
+ resVo.success = false ;
+ resVo.errorInfo = "rtuAddr宸茬粡鍒嗛厤瀹屾垚锛屾敞鍐屽け璐�" ;
+ }
+ }
+ }else if(rqVo.code.equals(Code.cd2)){
+ resVo.obj = doDealGetConfig(rqVo) ;
+ }else if(rqVo.code.equals(Code.cd3)){
+ resVo.obj = doDealGetStart(rqVo) ;
+ }else if(rqVo.code.equals(Code.cd4)){
+ resVo.obj = doDealGetReport(rqVo) ;
+ }else if(rqVo.code.equals(Code.cd5)){
+ doDealReportCount(rqVo) ;
+ }else if(rqVo.code.equals(Code.cd6)){
+ doDealReportOver(rqVo) ;
+ }else if(rqVo.code.equals(Code.cd7)){
+ doDealAllOver(rqVo) ;
+ }
+ return resVo ;
+ }
+
+ private static ResRegisterVo doDealRegister(RmiRequestVo rqVo){
+ ResRegisterVo resVo = null ;
+ String token = id2TokenMap.get(rqVo.id) ;
+ if(token == null){
+ if(clientId <= rtuAddrList.size()){
+ resVo = new ResRegisterVo() ;
+ resVo.token = "" + clientId ;
+ id2TokenMap.put(rqVo.id, resVo.token) ;
+ clientId++ ;
+ }
+ }else{
+ resVo = new ResRegisterVo() ;
+ resVo.token = token ;
+ }
+ return resVo ;
+ }
+
+ private static MwConfigVo doDealGetConfig(RmiRequestVo rqVo){
+ MwConfigVo conVo ;
+ int token = Integer.parseInt(rqVo.token) ;
+ MwTestClientStatus sta = token2ClientMap.get("" + token);
+ if(sta == null){
+ Object[] rtuAddrs = rtuAddrList.get(token-1) ;
+ conVo = new MwConfigVo() ;
+ conVo.rtuAddrStart = (Long)rtuAddrs[0] ;
+ conVo.rtuAddrEnd = (Long)rtuAddrs[1] ;
+ conVo.tcpServerIp = ServerProperties.tcpServerIp ;
+ conVo.tcpServerPort = ServerProperties.tcpServerPort ;
+ conVo.sendInterval = ServerProperties.sendInterval ;
+ conVo.heartbeatTimes = ServerProperties.heartbeatTimes ;
+ conVo.sendTimes = ServerProperties.sendTimes ;
+ conVo.sendOverThenCloseConnect = ServerProperties.sendOverThenCloseConnect ;
+ sta = new MwTestClientStatus() ;
+ sta.confVo = conVo ;
+ token2ClientMap.put("" + token, sta);
+ }else{
+ conVo = sta.confVo;
+ }
+ return conVo ;
+ }
+ private static ResStartTcpConnectVo doDealGetStart(RmiRequestVo rqVo){
+ ResStartTcpConnectVo rvo = new ResStartTcpConnectVo() ;
+ rvo.start = enablemwTestStartTcpConnect ;
+ int token = Integer.parseInt(rqVo.token) ;
+ MwTestClientStatus sta = token2ClientMap.get("" + token);
+ if(sta == null){
+ sta = new MwTestClientStatus() ;
+ sta.startVo = rvo ;
+ token2ClientMap.put("" + token, sta);
+ }else{
+ sta.startVo = rvo ;
+ }
+ return rvo ;
+ }
+ private static ResStartRtuReportVo doDealGetReport(RmiRequestVo rqVo){
+ ResStartRtuReportVo rvo = new ResStartRtuReportVo() ;
+ rvo.report = enablemwTestStartRtuReport ;
+ int token = Integer.parseInt(rqVo.token) ;
+ MwTestClientStatus sta = token2ClientMap.get("" + token);
+ if(sta == null){
+ sta = new MwTestClientStatus() ;
+ sta.reportVo = rvo ;
+ token2ClientMap.put("" + token, sta);
+ }else{
+ sta.reportVo = rvo ;
+ }
+ return rvo ;
+ }
+
+
+ private static void doDealReportCount(RmiRequestVo rqVo){
+ int token = Integer.parseInt(rqVo.token) ;
+ MwTestClientStatus sta = token2ClientMap.get("" + token);
+ if(sta == null){
+ sta = new MwTestClientStatus() ;
+ sta.count = rqVo.count ;
+ token2ClientMap.put("" + token, sta);
+ }else{
+ sta.count = rqVo.count ;
+ }
+ }
+
+
+ private static void doDealReportOver(RmiRequestVo rqVo){
+ int token = Integer.parseInt(rqVo.token) ;
+ MwTestClientStatus sta = token2ClientMap.get("" + token);
+ if(sta == null){
+ sta = new MwTestClientStatus() ;
+ sta.overCount = rqVo.overCount ;
+ token2ClientMap.put("" + token, sta);
+ }else{
+ sta.overCount = rqVo.overCount ;
+ }
+ }
+
+
+ private static void doDealAllOver(RmiRequestVo rqVo){
+ int token = Integer.parseInt(rqVo.token) ;
+ MwTestClientStatus sta = token2ClientMap.get("" + token);
+ if(sta == null){
+ sta = new MwTestClientStatus() ;
+ if(rqVo.over != null && rqVo.over){
+ sta.over = true ;
+ sta.seconds = rqVo.seconds ;
+ }
+ token2ClientMap.put("" + token, sta);
+ }else{
+ if(rqVo.over != null && rqVo.over){
+ sta.over = true ;
+ sta.seconds = rqVo.seconds ;
+ }
+ }
+ }
+
+
+
+}
--
Gitblit v1.8.0