From 7df8ed14d605bcc731341ff12349bc117714b69e Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期四, 17 四月 2025 16:18:24 +0800
Subject: [PATCH] 优化代码
---
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/Server.java | 41 +++++++++++++++++++++++++++++++++++------
1 files changed, 35 insertions(+), 6 deletions(-)
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/Server.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/Server.java
index 129aa1f..2a405c4 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/Server.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/Server.java
@@ -3,7 +3,10 @@
import java.util.ArrayList;
import java.util.List;
+import com.dy.common.util.ConfigProperties;
import com.dy.rtuMw.server.*;
+import com.dy.rtuMw.server.msCenter.MsCenterConfigVo;
+import com.dy.rtuMw.server.msCenter.MsCenterUnit;
import com.dy.rtuMw.server.rtuData.RtuDataUnit;
import com.dy.rtuMw.server.rtuData.RtuDataUnitConfigVo;
import com.dy.rtuMw.server.tasks.FromRtuComResultConstantTask;
@@ -40,6 +43,7 @@
private Document doc = null ;
private boolean showStartInfo = false ;
+ private String orgTag ;
private String RmiSvUrl ;
private String TcpSvUrl ;
@Value("${server.port}")
@@ -83,7 +87,7 @@
boolean running = false ;
long start = System.currentTimeMillis() ;
try {
- //ConfigProperties.init(this.getClass().getResourceAsStream("/config/config.properties"), false);
+ ConfigProperties.init(this.getClass().getResourceAsStream("/config.properties"), false);
this.conf = new ConfigXml4Springboot() ;
this.doc = this.conf.createDom(this.resourceLoader, "config.xml") ;
@@ -113,7 +117,7 @@
System.out.println("@@@@@@@@@@@@@@@@@@@@@# #@@@@@@@@@@@@@@@@O") ;
System.out.println("@@@@@@@@@@@@@@@@@@@@@@@ &@@@@@@@@@@@@@@") ;
System.out.println("@@@@@@$ $@@@@@@@@@& O@@@@@@@@@@@#") ;
- System.out.println("@@@@@@$ @@@@@@@@@ @@@@@@@@@& " + svName + "RtuMw 1.0.00" ) ;
+ System.out.println("@@@@@@$ @@@@@@@@@ @@@@@@@@@& " + this.orgTag + svName + "RtuMw 1.0.00" ) ;
if(this.HttpSvPath != null && this.HttpSvPort != null){
System.out.println("@@@@@@$ O@@@@@@@@@ &@@@@@@@@ HttpSv [ip]:" + this.HttpSvPort + this.HttpSvPath) ;
}else{
@@ -130,7 +134,7 @@
}else{
System.out.println("@@@@@@$ #@@@@@@@@@$ &@@@@@@@@" ) ;
}
- System.out.println("@@@@@@@@@@@@@@@@@@@@@@# &@@@@@@@@ Runing in standalone mode" ) ;
+ System.out.println("@@@@@@@@@@@@@@@@@@@@@@# &@@@@@@@@ Running in standalone mode" ) ;
System.out.println("@@@@@@@@@@@@@@@@@@@@@& &@@@@@@@@ Startup in " + (System.currentTimeMillis() - start) + " MS" ) ;
System.out.println("@@@@@@@@@@@@@@@@@@@# &@@@@@@@@ " + company) ;
System.out.println("@@@@@@@@@@@@@@@@#O &@@@@@@@@") ;
@@ -147,9 +151,10 @@
///////////////
//鍩烘湰閰嶇疆
ServerProperties.orgTag = this.conf.getSetAttrTxt(this.doc, "config.base", "orgTag", null, false, null) ;
- if(ServerProperties.orgTag==null || ServerProperties.orgTag.trim().equals("")){
+ if(ServerProperties.orgTag == null || ServerProperties.orgTag.trim().equals("")){
throw new Exception("鏈烘瀯tag涓嶈兘涓虹┖") ;
}
+ this.orgTag = ServerProperties.orgTag ;
ServerProperties.isLowPower = conf.getSetAttrBoolean(doc, "config.base", "isLowPower", null, null) ;
if(ServerProperties.isLowPower == null){
ServerProperties.isLowPower = false ;
@@ -181,10 +186,12 @@
ServerProperties.downComandMaxResendTimes = conf.getSetAttrPlusInt(doc, "config.base", "downComandMaxResendTimes", null, 1, 5, null).byteValue() ;
//閽堝涓�涓猂TU锛屼笅鍙戝懡浠ょ殑鏃堕棿闂撮殧
ServerProperties.commandSendInterval = conf.getSetAttrPlusInt(doc, "config.base", "commandSendInterval", null, 1, 40, null) * 1000L ;
+ //閽堝涓�涓猂TU锛屼笅鍙戝揩閫熷懡浠ょ殑鏃堕棿闂撮殧
+ ServerProperties.fastCommandSendInterval = conf.getSetAttrPlusInt(doc, "config.base", "fastCommandSendInterval", null, 1, 40000, null) * 1L ;
//鍛戒护宸茬粡鍙戦�佽揪鏈�澶ф鏁帮紝浠嶆湭鏀跺埌鍛戒护缁撴灉锛岄渶瑕佸湪缂撳瓨缁х画绛夊緟锛屽叾绛夊緟鏈�澶ф椂闀�
- ServerProperties.cachWaitResultTimeout = conf.getSetAttrPlusInt(doc, "config.base", "cachWaitResultTimeout", null, 10, 360, null) * 1000L ;
+ ServerProperties.cacheWaitResultTimeout = conf.getSetAttrPlusInt(doc, "config.base", "cacheWaitResultTimeout", null, 10, 360, null) * 1000L ;
//涓嶅湪绾跨紦瀛樼殑鍛戒护鏈�澶х紦瀛樻椂闀�
- ServerProperties.offLineCachTimeout = conf.getSetAttrPlusInt(doc, "config.base", "offLineCachTimeout", null, 15, 172800, null) * 1000L ;
+ ServerProperties.offLineCacheTimeout = conf.getSetAttrPlusInt(doc, "config.base", "offLineCacheTimeout", null, 15, 172800, null) * 1000L ;
//TCP涓婅鏁版嵁鏃跺埢缂撳瓨鏃堕暱锛屽綋杈惧埌鏃堕暱鏃讹紝TCP涓婅鏁版嵁鏃跺埢琚竻绌猴紝閲囩敤TCP涓婅鏁版嵁鏃跺埢鐩殑鏄紝闃绘涓婃暟鎹悓鏃朵笅鍙戞暟鎹紝鍥犱负RTU澶勭悊涓嶈繃鏉�
ServerProperties.lastUpDataTimeLive = conf.getSetAttrPlusInt(doc, "config.base", "lastUpDataTimeLive", null, 0, 5000, null) * 1L ;
//鏁版嵁搴撴暟鎹甶d鐢熸垚鍣ㄧ殑id鍚庣紑锛�0鏄粯璁ょ殑鍚庣紑锛屼竴鑸瑆eb绯荤粺搴旂敤锛屾暟鎹腑闂翠欢id鍚庣紑澶т簬绛変簬1
@@ -332,18 +339,40 @@
}
*/
+
+ /////////////////
+ //娑堟伅涓績妯″潡
+ MsCenterConfigVo mscVo = new MsCenterConfigVo();
+ mscVo.enable = conf.getSetAttrBoolean(doc, "config.msCenter", "enable", null, null) ;
+ mscVo.notifyMsInterval = conf.getSetAttrPlusInt(doc, "config.msCenter", "notifyInterval", null, 1, 600, null) * 1000L ;
+ mscVo.showStartInfo = showStartInfo ;
+ AdapterImp_MsCenterUnit mscAdapt = new AdapterImp_MsCenterUnit();
+ mscAdapt.setConfig(mscVo);
+ MsCenterUnit mscUnit = MsCenterUnit.getInstance();
+ mscUnit.setAdapter(mscAdapt);
+ mscUnit.start(obj -> {
+ });
+ units.add(mscUnit) ;
+
+
/////////////////
//RTU杩滅▼鍗囩骇妯″潡
UpgradeUnitConfigVo ugVo = new UpgradeUnitConfigVo();
ugVo.enable = conf.getSetAttrBoolean(doc, "config.upgrade", "enable", null, null) ;
+ ugVo.openNoUpgrade = conf.getSetAttrBoolean(doc, "config.upgrade", "openNoUpgrade", null, null) ;
+ ugVo.lastOpenMaxGoOn = conf.getSetAttrPlusInt(doc, "config.upgrade", "lastOpenMaxGoOn", null, 5, 360000, null);
+ ugVo.lastOpenMaxGoOn = ugVo.lastOpenMaxGoOn * 1000 ;//鍙樻垚姣
ugVo.noOneRtuUpgradeMaxDuration = conf.getSetAttrPlusInt(doc, "config.upgrade", "noOneRtuUpgradeMaxDuration", null, 5, 360000, null);
ugVo.noOneRtuUpgradeMaxDuration = ugVo.noOneRtuUpgradeMaxDuration * 1000 ;//鍙樻垚姣
+ ugVo.runningAndIdleDuration = conf.getSetAttrPlusInt(doc, "config.upgrade", "runningAndIdleDuration", null, 5, 360000, null);
+ ugVo.runningAndIdleDuration = ugVo.runningAndIdleDuration * 1000 ;//鍙樻垚姣
ugVo.failTryTimes = conf.getSetAttrPlusInt(doc, "config.upgrade", "failTryTimes", null, 0, 100, null);
ugVo.ugMaxRtuAtOnce = conf.getSetAttrPlusInt(doc, "config.upgrade", "ugMaxRtuAtOnce", null, 0, 1000000, null);
ugVo.rtuOffLineWaitDuration = conf.getSetAttrPlusInt(doc, "config.upgrade", "rtuOffLineWaitDuration", null, 1, 3600000, null);
ugVo.rtuOffLineWaitDuration = ugVo.rtuOffLineWaitDuration * 1000;//鍙樻垚姣
ugVo.notifyStateInterval = conf.getSetAttrPlusInt(doc, "config.upgrade", "notifyStateInterval", null, 1, 300, null);
ugVo.notifyStateInterval = ugVo.notifyStateInterval * 1000;//鍙樻垚姣
+ ugVo.notifyTimesAfterOver = conf.getSetAttrPlusInt(doc, "config.upgrade", "notifyTimesAfterOver", null, 0, null, null);
ugVo.showStartInfo = showStartInfo ;
AdapterImp_UpgradeUnit ugAdap = new AdapterImp_UpgradeUnit();
ugAdap.setConfig(ugVo);
--
Gitblit v1.8.0