|  |  |  | 
|---|
|  |  |  | }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{ | 
|---|
|  |  |  | mqVo.svUserPassword = mqVo.svUserPassword.trim() ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | mqVo.poolMaxSize = conf.getSetAttrPlusInt(doc, "config.mqtt", "poolMaxSize", null, 5, 360000, null); | 
|---|
|  |  |  | if(mqVo.poolMaxSize <= 1 || mqVo.poolMaxSize > 1000){ | 
|---|
|  |  |  | throw new Exception("config.mqtt.poolMaxSize配置的连接池连接最大数量不合法") ; | 
|---|
|  |  |  | mqVo.poolMaxSize = conf.getSetAttrPlusInt(doc, "config.mqtt", "poolMaxSize", null, 1, 1000, null); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | mqVo.sendInterval = conf.getSetAttrPlusInt(doc, "config.mqtt", "sendInterval", null, 1, 3600, null) * 1000L ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | mqVo.reSendTimesByNoResult = conf.getSetAttrPlusInt(doc, "config.mqtt", "reSendTimesByNoResult", null, 0, 100, null); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | mqVo.comCacheTimeout = conf.getSetAttrPlusInt(doc, "config.mqtt", "comCacheTimeout", null, 1, 3600, null) * 1000L ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ServerProperties.acceptManureDataMinInterval = conf.getSetAttrPlusInt(doc, "config.mqtt", "acceptManureDataMinInterval", null, 1, 720, null) * 60 * 1000L ; | 
|---|
|  |  |  | ServerProperties.acceptSoilDataMinInterval = conf.getSetAttrPlusInt(doc, "config.mqtt", "acceptSoilDataMinInterval", null, 1, 720, null) * 60 * 1000L ; | 
|---|
|  |  |  | ServerProperties.acceptWeatherDataMinInterval = conf.getSetAttrPlusInt(doc, "config.mqtt", "acceptWeatherDataMinInterval", null, 1, 720, null) * 60 * 1000L ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | mqVo.useMemoryPersistence = conf.getSetAttrBoolean(doc, "config.mqtt", "useMemoryPersistence", null, null) ; | 
|---|
|  |  |  | String proAndDevIds = conf.getSetAttrTxt(doc, "config.mqtt", "protocolAndDeviceIds", null, true, null) ; | 
|---|
|  |  |  | if(proAndDevIds != null && !proAndDevIds.trim().equals("")){ | 
|---|
|  |  |  | 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 topicAndQos = conf.getSetAttrTxt(doc, "config.mqtt", "topicAndQos", null, true, null) ; | 
|---|
|  |  |  | if(topicAndQos == null || topicAndQos.trim().equals("")){ | 
|---|
|  |  |  | throw new Exception("config.mqtt.topicAndQos配置的主题及Qos不合法") ; | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | topicAndQos = topicAndQos.trim() ; | 
|---|
|  |  |  | topicAndQos = topicAndQos.replaceAll(",", ","); | 
|---|
|  |  |  | topicAndQos = topicAndQos.replaceAll(";", ";"); | 
|---|
|  |  |  | String[] topicAndQosArr = topicAndQos.split(";") ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | String subTopicAndQos = conf.getSetAttrTxt(doc, "config.mqtt", "subTopicAndQos", null, true, null) ; | 
|---|
|  |  |  | if(subTopicAndQos != null && !subTopicAndQos.trim().equals("")){ | 
|---|
|  |  |  | 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); | 
|---|