| | |
| | | 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; |
| | |
| | | private Document doc = null ; |
| | | private boolean showStartInfo = false ; |
| | | |
| | | private String orgTag ; |
| | | private String RmiSvUrl ; |
| | | private String TcpSvUrl ; |
| | | @Value("${server.port}") |
| | |
| | | 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") ; |
| | |
| | | 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{ |
| | |
| | | }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 &@@@@@@@@") ; |
| | |
| | | /////////////// |
| | | //基本配置 |
| | | 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 ; |
| | |
| | | ServerProperties.downComandMaxResendTimes = conf.getSetAttrPlusInt(doc, "config.base", "downComandMaxResendTimes", null, 1, 5, null).byteValue() ; |
| | | //针对一个RTU,下发命令的时间间隔 |
| | | ServerProperties.commandSendInterval = conf.getSetAttrPlusInt(doc, "config.base", "commandSendInterval", null, 1, 40, null) * 1000L ; |
| | | //针对一个RTU,下发快速命令的时间间隔 |
| | | 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 ; |
| | | //数据库数据id生成器的id后缀,0是默认的后缀,一般web系统应用,数据中间件id后缀大于等于1 |
| | |
| | | } |
| | | */ |
| | | |
| | | |
| | | ///////////////// |
| | | //消息中心模块 |
| | | 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); |