From 1157c9c0eca6484e197aaeb941ac7ce572a5cc03 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期三, 05 二月 2025 11:25:51 +0800
Subject: [PATCH] 取水口综合信息:监控数据信息,统计数据信息
---
pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/Server.java | 116 +++++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 83 insertions(+), 33 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 2dd5d45..17e9b85 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
@@ -9,8 +9,6 @@
import com.dy.rtuMw.server.tasks.FromRtuComResultConstantTask;
import com.dy.rtuMw.server.tasks.FromRtuDataConstantTask;
import com.dy.common.mw.UnitInterface;
-import com.dy.common.mw.channel.rmi.RmiConfigVo;
-import com.dy.common.mw.channel.rmi.RmiUnit;
import com.dy.common.mw.channel.tcp.TcpConfigVo;
import com.dy.common.mw.channel.tcp.TcpUnit;
import com.dy.common.mw.core.CoreUnit;
@@ -19,21 +17,26 @@
import com.dy.common.mw.protocol.ProtocolUnit;
import com.dy.common.mw.support.SupportUnit;
import com.dy.common.mw.support.SupportUnitConfigVo;
-import com.dy.rtuMw.server.tasks.ToRtuConstantTask;
+import com.dy.rtuMw.server.tasks.SendMsConstantTask;
+import com.dy.rtuMw.server.tasks.RtuDownConstantTask;
import com.dy.rtuMw.resource.ResourceUnit;
import com.dy.rtuMw.resource.ResourceUnitConfigVo;
import com.dy.common.springUtil.SpringContextUtil;
-import com.dy.common.util.ConfigXml;
+import com.dy.common.util.ConfigXml4Springboot;
import com.dy.common.util.IDLongGenerator;
+import com.dy.rtuMw.server.upgrade.UpgradeUnit;
+import com.dy.rtuMw.server.upgrade.UpgradeUnitConfigVo;
import org.jdom2.Document;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.core.io.ResourceLoader;
import org.springframework.stereotype.Component;
@Component
public class Server {
- private ConfigXml conf = null ;
+ private ConfigXml4Springboot conf = null ;
private Document doc = null ;
private boolean showStartInfo = false ;
@@ -44,6 +47,9 @@
@Value("${server.servlet.context-path}")
private String HttpSvPath ;
+ @Autowired
+ protected ResourceLoader resourceLoader ;
+
private List<UnitInterface> units = new ArrayList<UnitInterface>() ;
/*
@@ -52,27 +58,35 @@
new Server().startServer();
}
*/
+
+ public void startServer(){
+ /**
+ try {
+ URL url = Server.class.getResource("/config/this.licence");
+ if(!new Lnp(null).parese(url.getPath())){
+ System.out.println("licence error!") ;
+ return ;
+ }
+ } catch (Exception e) {
+ System.out.println("licence error!") ;
+ return ;
+ }
+ */
+ if(this.doStartServer()){
+ ServerShutDownHook.OnShutDown();
+ }
+ }
/**
* 鍚姩鏈嶅姟
*/
- public void startServer(){
-// try {
-// URL url = Server.class.getResource("/config/this.licence");
-// if(!new Lnp(null).parese(url.getPath())){
-// System.out.println("zhzc licence error!") ;
-// return ;
-// }
-// } catch (Exception e) {
-// System.out.println("zhzc licence error!") ;
-// return ;
-// }
- //Server sv = new Server();
+ private boolean doStartServer(){
+ boolean running = false ;
long start = System.currentTimeMillis() ;
try {
//ConfigProperties.init(this.getClass().getResourceAsStream("/config/config.properties"), false);
- this.conf = new ConfigXml() ;
- this.doc = this.conf.createDom(this.getClass(), "config.xml") ;
+ this.conf = new ConfigXml4Springboot() ;
+ this.doc = this.conf.createDom(this.resourceLoader, "config.xml") ;
////////////////
//鏈嶅姟 閰嶇疆
this.showStartInfo = this.conf.getSetAttrBoolean(this.doc, "config.server", "showStartInfo", null, null) ;
@@ -119,11 +133,13 @@
System.out.println("@@@@@@@@@@@@@@@@@@@@@@# &@@@@@@@@ Runing in standalone mode" ) ;
System.out.println("@@@@@@@@@@@@@@@@@@@@@& &@@@@@@@@ Startup in " + (System.currentTimeMillis() - start) + " MS" ) ;
System.out.println("@@@@@@@@@@@@@@@@@@@# &@@@@@@@@ " + company) ;
- System.out.println("@@@@@@@@@@@@@@@@#O &@@@@@@@@") ;
-
+ System.out.println("@@@@@@@@@@@@@@@@#O &@@@@@@@@") ;
+ running = true ;
}catch(Exception e){
e.printStackTrace();
+ running = false ;
}
+ return running ;
}
private void startUnits(){
@@ -165,10 +181,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
@@ -189,9 +207,12 @@
//宸ヤ綔鎶ュお棰戠箒锛孨娆′笂鎶ュ鐞�1娆★紝鍙栧�艰寖鍥存槸1-100
ServerProperties.workReportDealOneByTimes = conf.getSetAttrPlusInt(doc, "config.base", "workReportDealOneByTimes", null, 1, 100, null) ;
- if(ServerProperties.workReportDealOneByTimes < 1 || ServerProperties.workReportDealOneByTimes > 100){
- throw new Exception("workReportDealOneByTimes鍙栧�煎繀椤绘槸1~100") ;
- }
+
+ //瑙﹀彂鍙戦�侀拤閽夋姤璀︽秷鎭殑鍙栨按鍙f棩婕忔崯閲忕殑鏈�灏忓�硷紙鍖呮嫭浣嗛櫎0.0澶栵級
+ ServerProperties.intakeAlarmLossMinValue = conf.getSetAttrPlusDouble(doc, "config.base", "intakeAlarmLossMinValue", null, 0.0, 1000000.0, null) ;
+
+ //鏈夋姤璀﹀彂鐢熸椂锛屽悜閽夐拤鍙戦�佹秷鎭殑闂撮殧鏃堕暱锛堝垎閽燂級
+ ServerProperties.sendDingDingAlarmMsInterval = conf.getSetAttrPlusInt(doc, "config.base", "sendDingDingAlarmMsInterval", null, 1, 600, null) ;
//璁剧疆ID鐢熸垚鍣ㄧ殑鍚庣紑
IDLongGenerator.setSuffix(ServerProperties.dbDataIdSuffix.intValue());
@@ -270,7 +291,7 @@
//RTU鏃ュ織鏂囦欢瀛樺偍鐩綍(鐩稿鐩綍)
resVo.rtuLogDir = conf.getSetAttrTxt(doc, "config.resource", "rtuLogDir", null, false, null) ;
//RTU鏃ュ織鏂囦欢鏈�澶у瓧鑺傛暟(KB)
- resVo.rtuLogFileMaxSize = conf.getSetAttrPlusInt(doc, "config.resource", "rtuLogFileMaxSize", null, 100000, 2000000, null) ;
+ resVo.rtuLogFileMaxSize = conf.getSetAttrPlusInt(doc, "config.resource", "rtuLogFileMaxSize", null, 10, 2000000, null) ;
//RTU鏃ュ織鏂囦欢鏈�澶ф枃浠舵暟
resVo.rtuLogFileMaxCount = conf.getSetAttrPlusInt(doc, "config.resource", "rtuLogFileMaxCount", null, 1, 10, null) ;
@@ -294,7 +315,8 @@
/////////////////
- //RMI妯″潡
+ //RMI妯″潡 鏆傛椂涓嶅簲鐢�
+ /*
RmiConfigVo rmiVo = new RmiConfigVo();
rmiVo.enable = conf.getSetAttrBoolean(doc, "config.rmi", "enable", null, null) ;
if(rmiVo.enable){
@@ -310,11 +332,39 @@
RmiSvUrl = "[ip]:" + rmiVo.port + "/" + rmiVo.context ;
units.add(rmiUnit) ;
}
-
+ */
/////////////////
- //RTU涓婅鏁版嵁澶勭悊妯″潡
+ //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);
+ UpgradeUnit ugUnit = UpgradeUnit.getInstance();
+ ugUnit.setAdapter(ugAdap);
+ ugUnit.start(obj -> {
+ });
+ units.add(ugUnit) ;
+
+ /////////////////
+ //RTU涓婅鏁版嵁澶勭悊妯″潡锛堜换鍔℃爲锛�
RtuDataUnitConfigVo rducVo = new RtuDataUnitConfigVo();
+ rducVo.resourceLoader = this.resourceLoader ;
AdapterImp_RtuDataUnit rducAdap = new AdapterImp_RtuDataUnit();
rducAdap.setConfig(rducVo);
RtuDataUnit rducUnit = RtuDataUnit.getInstance();
@@ -328,8 +378,7 @@
// ///////////////
// 鏍稿績
CoreUnitConfigVo coreConfVo = new CoreUnitConfigVo();
- coreConfVo.sleepBigBusy = conf.getSetAttrPlusInt(doc, "config.core", "sleepBigBusy", null, 1, 200, null).longValue() ;
- coreConfVo.sleepSmallBusy = conf.getSetAttrPlusInt(doc, "config.core", "sleepSmallBusy", null, 2, 1000, null).longValue();
+ coreConfVo.coreInterval = conf.getSetAttrPlusInt(doc, "config.core", "coreInterval", null, 1, 200, null).longValue() ;
coreConfVo.queueWarnSize = ServerProperties.cacheUpDownDataWarnCount ;
coreConfVo.queueMaxSize = ServerProperties.cacheUpDownDataMaxCount ;
coreConfVo.showStartInfo = showStartInfo ;
@@ -337,9 +386,10 @@
coreAdap.setConfig(coreConfVo);
CoreUnit coreUnit = CoreUnit.getInstance();
coreUnit.setAdapter(coreAdap);
- CoreUnit.addConstantTask(new ToRtuConstantTask());
+ CoreUnit.addConstantTask(new RtuDownConstantTask());
CoreUnit.addConstantTask(new FromRtuDataConstantTask());
CoreUnit.addConstantTask(new FromRtuComResultConstantTask());
+ CoreUnit.addConstantTask(new SendMsConstantTask());
coreUnit.start(obj -> {
});
units.add(coreUnit) ;
--
Gitblit v1.8.0