| | |
| | | }catch(Exception e){ |
| | | company = "" ; |
| | | } |
| | | System.out.println("OOOOOOOOOO OOOOOOOO OOOOOOOO") ; |
| | | System.out.println("@@@@@@@@@@@@@@@@#O $@@@@@@@@& @@@@@@@@#") ; |
| | | System.out.println("@@@@@@@@@@@@@@@@@@@# @@@@@@@@# $@@@@@@@@&") ; |
| | | System.out.println("@@@@@@@@@@@@@@@@@@@@@# #@@@@@@@@@@@@@@@@O") ; |
| | | System.out.println("@@@@@@@@@@@@@@@@@@@@@@@ &@@@@@@@@@@@@@@") ; |
| | | System.out.println("@@@@@@$ $@@@@@@@@@& O@@@@@@@@@@@#") ; |
| | | System.out.println("$$$$$$$$$$$$ $$$$$$$$ $$$$$$$$") ; |
| | | System.out.println("@@@@@@@@@@@@@@@@#$ $@@@@@@@@& @@@@@@@@#") ; |
| | | System.out.println("@@@@@@@@@@@@@@@@@@@# @@@@@@@@# $@@@@@@@@&") ; |
| | | System.out.println("@@@@@@@@@@@@@@@@@@@@@# #@@@@@@@@@@@@@@@@$") ; |
| | | System.out.println("@@@@@@@@@@@@@@@@@@@@@@@ &@@@@@@@@@@@@@@") ; |
| | | System.out.println("@@@@@@$ $@@@@@@@@@& $@@@@@@@@@@@#") ; |
| | | 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) ; |
| | |
| | | mqVo.enable = conf.getSetAttrBoolean(doc, "config.mqtt", "enable", null, null) ; |
| | | ServerProperties.mqttUnitEnable = mqVo.enable ; |
| | | if(mqVo.enable){ |
| | | mqVo.svIp = conf.getSetAttrTxt(doc, "config.mqtt", "svIp", null, true, null) ; |
| | | mqVo.svIp = conf.getSetAttrTxt(doc, "config.mqtt", "svIp", null, false, null) ; |
| | | if(!IPUtils.ipValid(mqVo.svIp)){ |
| | | throw new Exception("config.mqtt.svIp配置的IP不合法") ; |
| | | } |
| | |
| | | if(mqVo.svPort < 0 || mqVo.svPort > 65535){ |
| | | throw new Exception("config.mqtt.svPort配置的端口不合法") ; |
| | | } |
| | | mqVo.svUserName = conf.getSetAttrTxt(doc, "config.mqtt", "svUserName", null, true, null) ; |
| | | mqVo.svUserName = conf.getSetAttrTxt(doc, "config.mqtt", "svUserName", null, false, null) ; |
| | | if(mqVo.svUserName == null || mqVo.svUserName.trim().equals("")){ |
| | | throw new Exception("config.mqtt.svUserName配置的用户名不合法") ; |
| | | }else{ |
| | | mqVo.svUserName = mqVo.svUserName.trim() ; |
| | | } |
| | | mqVo.svUserPassword = conf.getSetAttrTxt(doc, "config.mqtt", "svUserPassword", null, true, null) ; |
| | | mqVo.svUserPassword = conf.getSetAttrTxt(doc, "config.mqtt", "svUserPassword", null, false, null) ; |
| | | if(mqVo.svUserPassword == null || mqVo.svUserPassword.trim().equals("")){ |
| | | throw new Exception("config.mqtt.svUserName配置的用户密码不合法") ; |
| | | }else{ |
| | |
| | | if(mqVo.poolMaxSize <= 1 || mqVo.poolMaxSize > 1000){ |
| | | throw new Exception("config.mqtt.poolMaxSize配置的连接池连接最大数量不合法") ; |
| | | } |
| | | String topicAndQos = conf.getSetAttrTxt(doc, "config.mqtt", "topicAndQos", null, true, null) ; |
| | | if(topicAndQos == null || topicAndQos.trim().equals("")){ |
| | | throw new Exception("config.mqtt.topicAndQos配置的主题及Qos不合法") ; |
| | | String proAndDevIds = conf.getSetAttrTxt(doc, "config.mqtt", "protocolAndDeviceIds", null, false, null) ; |
| | | if(proAndDevIds == null || proAndDevIds.trim().equals("")){ |
| | | throw new Exception("config.mqtt.protocolAndDeviceIds配置不合法") ; |
| | | }else{ |
| | | topicAndQos = topicAndQos.trim() ; |
| | | topicAndQos = topicAndQos.replaceAll(",", ","); |
| | | topicAndQos = topicAndQos.replaceAll(";", ";"); |
| | | String[] topicAndQosArr = topicAndQos.split(";") ; |
| | | proAndDevIds = proAndDevIds.trim() ; |
| | | proAndDevIds = proAndDevIds.replaceAll(",", ","); |
| | | proAndDevIds = proAndDevIds.replaceAll(";", ";"); |
| | | proAndDevIds = proAndDevIds.replaceAll("\\\\", "/"); |
| | | mqVo.protocolAndDeviceIds = proAndDevIds.split(",") ; |
| | | mqVo.deviceIds = new String[mqVo.protocolAndDeviceIds.length] ; |
| | | int index = 0 ; |
| | | for(String topicAndQosStr : mqVo.protocolAndDeviceIds){ |
| | | String[] pd = topicAndQosStr.split("/") ; |
| | | mqVo.deviceIds[index] = pd[1].trim() ; |
| | | index++ ; |
| | | } |
| | | } |
| | | |
| | | |
| | | String subTopicAndQos = conf.getSetAttrTxt(doc, "config.mqtt", "subTopicAndQos", null, false, null) ; |
| | | if(subTopicAndQos == null || subTopicAndQos.trim().equals("")){ |
| | | throw new Exception("config.mqtt.subTopicAndQos配置的主题及Qos不合法") ; |
| | | }else{ |
| | | subTopicAndQos = subTopicAndQos.trim() ; |
| | | subTopicAndQos = subTopicAndQos.replaceAll(",", ","); |
| | | subTopicAndQos = subTopicAndQos.replaceAll(";", ";"); |
| | | String[] topicAndQosArr = subTopicAndQos.split(";") ; |
| | | mqVo.subTopics = new String[topicAndQosArr.length] ; |
| | | mqVo.topicsQos = new int[topicAndQosArr.length] ; |
| | | mqVo.subTopicsQos = new int[topicAndQosArr.length] ; |
| | | int index = 0 ; |
| | | for(String topicAndQosStr : topicAndQosArr){ |
| | | String[] tq = topicAndQosStr.split(",") ; |
| | | mqVo.subTopics[index] = tq[0].trim() ; |
| | | mqVo.topicsQos[index] = Integer.parseInt(tq[1].trim()) ; |
| | | mqVo.subTopicsQos[index] = Integer.parseInt(tq[1].trim()) ; |
| | | index++ ; |
| | | } |
| | | } |
| | | mqVo.publishQos = conf.getSetAttrPlusInt(doc, "config.mqtt", "publishQos", null, 0, 3, null); |
| | | if(mqVo.publishQos < 0 || mqVo.publishQos > 3){ |
| | | throw new Exception("config.mqtt.publishQos配置不合法") ; |
| | | mqVo.pubTopicQos = conf.getSetAttrPlusInt(doc, "config.mqtt", "pubTopicQos", null, 0, 3, null); |
| | | if(mqVo.pubTopicQos < 0 || mqVo.pubTopicQos > 3){ |
| | | throw new Exception("config.mqtt.pubTopicQos配置不合法") ; |
| | | } |
| | | |
| | | Integer intNoSubThenOff = conf.getSetAttrPlusInt(doc, "config.mqtt", "noSubThenOff", null, 1, 1440, null); |
| | | mqVo.noSubThenOff = intNoSubThenOff * 60 * 1000L ; |
| | | |
| | | mqVo.showStartInfo = showStartInfo ; |
| | | AdapterImp_MqttUnit mqAdapt = new AdapterImp_MqttUnit(); |
| | | mqAdapt.setConfig(mqVo); |