|  |  |  | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | 
|---|
|  |  |  | 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.SendMsConstantTask; | 
|---|
|  |  |  | import com.dy.rtuMw.server.tasks.ToRtuConstantTask; | 
|---|
|  |  |  | import com.dy.rtuMw.resource.ResourceUnit; | 
|---|
|  |  |  | import com.dy.rtuMw.resource.ResourceUnitConfigVo; | 
|---|
|  |  |  | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | 
|---|
|  |  |  | 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(){ | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //工作报太频繁,N次上报处理1次,取值范围是1-100 | 
|---|
|  |  |  | ServerProperties.workReportDealOneByTimes =  conf.getSetAttrPlusInt(doc, "config.base", "workReportDealOneByTimes", null, 1, 100, null) ; | 
|---|
|  |  |  | if(ServerProperties.workReportDealOneByTimes < 1 || ServerProperties.disconnectedByNoUpDataMinutes > 100){ | 
|---|
|  |  |  | throw new Exception("workReportDealOneByTimes取值必须是1~100") ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //有报警发生时,向钉钉发送消息的间隔时长(分钟) | 
|---|
|  |  |  | ServerProperties.sendDingDingAlarmMsInterval =  conf.getSetAttrPlusInt(doc, "config.base", "sendDingDingAlarmMsInterval", null, 1, 600, null) ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //设置ID生成器的后缀 | 
|---|
|  |  |  | IDLongGenerator.setSuffix(ServerProperties.dbDataIdSuffix.intValue()); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ///////////////// | 
|---|
|  |  |  | //RMI模块 | 
|---|
|  |  |  | //RMI模块 暂时不应用 | 
|---|
|  |  |  | /* | 
|---|
|  |  |  | RmiConfigVo rmiVo = new RmiConfigVo(); | 
|---|
|  |  |  | rmiVo.enable = conf.getSetAttrBoolean(doc, "config.rmi", "enable", null, null) ; | 
|---|
|  |  |  | if(rmiVo.enable){ | 
|---|
|  |  |  | 
|---|
|  |  |  | RmiSvUrl = "[ip]:" + rmiVo.port + "/" + rmiVo.context ; | 
|---|
|  |  |  | units.add(rmiUnit) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | */ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ///////////////// | 
|---|
|  |  |  | //RTU上行数据处理模块 | 
|---|
|  |  |  | 
|---|
|  |  |  | CoreUnit.addConstantTask(new ToRtuConstantTask()); | 
|---|
|  |  |  | CoreUnit.addConstantTask(new FromRtuDataConstantTask()); | 
|---|
|  |  |  | CoreUnit.addConstantTask(new FromRtuComResultConstantTask()); | 
|---|
|  |  |  | CoreUnit.addConstantTask(new SendMsConstantTask()); | 
|---|
|  |  |  | coreUnit.start(obj -> { | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | units.add(coreUnit) ; | 
|---|