1、meterNo改为rtuAddr;
2、去掉一些main方法;
3、pom.xml中依赖common和global的<scope>provided</scope>改为<scope>compile</scope>
4、pipIrr-mwTest-server一些修改;
5、.gitignore文件提交。
| | |
| | | * org.apache.mina.filter.codec.ProtocolDecoderOutput) |
| | | */ |
| | | protected boolean doDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) { |
| | | String meterNo = (String)session.getAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrIdKey) ; |
| | | if(meterNo == null){ |
| | | String rtuAddr = (String)session.getAttribute(TcpIoSessionAttrIdIsRtuAddr.sessionArrIdKey) ; |
| | | if(rtuAddr == null){ |
| | | //会话未被管理 |
| | | //会话管理器中不存在此会话,说明刚建立网络连接, |
| | | return this.doDecode_onLineData(session, in, out) ; |
| | | }else{ |
| | | //会话已被管理 |
| | | //会话管理器中存在此会话,说明已经上线了, |
| | | return this.doDecode_data(session, in, out, meterNo) ; |
| | | return this.doDecode_data(session, in, out, rtuAddr) ; |
| | | } |
| | | } |
| | | |
| | |
| | | * @param session IO会话 |
| | | * @param in 输入Buffer |
| | | * @param out 协议输出编码 |
| | | * @param meterNo 控制器编号 |
| | | * @param rtuAddr 控制器地址 |
| | | * @return 是否正好或粘包 |
| | | */ |
| | | @SuppressWarnings("unused") |
| | | private boolean doDecode_data(IoSession session, IoBuffer in, ProtocolDecoderOutput out, String meterNo) { |
| | | private boolean doDecode_data(IoSession session, IoBuffer in, ProtocolDecoderOutput out, String rtuAddr) { |
| | | //非上线数据,可能会出现断包或粘包现象 |
| | | PrefixedDataAvailableStatus dataStatus = this.pdaHandle.forUpData(in) ; |
| | | if(dataStatus == null){ |
| | | //不可能发生 |
| | | log.error("严重错误,Rtu (水表号为" + meterNo + ")上行数据完整性检查时,返回的对象为空。") ; |
| | | log.error("严重错误,Rtu (RTU" + rtuAddr + ")上行数据完整性检查时,返回的对象为空。") ; |
| | | this.nextDeal(in, null, out) ; |
| | | return true; |
| | | }else{ |
| | |
| | | this.nextDeal(in, dataStatus.getDataLen(), out) ; |
| | | if(dataStatus.isAdjoined()){ |
| | | //说明粘包了,还有数据,需要对这些数据再次执行doDecode_方法. |
| | | return this.doDecode_data(session, in, out, meterNo) ;//加上递归 |
| | | return this.doDecode_data(session, in, out, rtuAddr) ;//加上递归 |
| | | }else if(dataStatus.isCompleted()){ |
| | | //数据不断不粘 |
| | | return true; |
| | |
| | | |
| | | return this ; |
| | | } |
| | | /* |
| | | public static void main(String[] args){ |
| | | String json = "{\"attachment\":null,\"code\":\"03\",\"deviceId\":\"d8c9601f214747d98d47a4736e5\",\"id\":\"999999999\",\"meterNo\":\"23040600377\",\"productId\":16873252,\"param\":\"0002\",\"protocol\":\"HAC_NBhV2_5\",\"rtuAddr\":\"863318060168996\",\"type\":\"outerCommand\"}" ; |
| | | try { |
| | | Command com = jsonToObject(json) ; |
| | | System.out.println(com.param); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | */ |
| | | |
| | | public String getId() { |
| | | return id; |
| | |
| | | Data d = new Data() ; |
| | | d.code = "01" ; |
| | | d.rtuAddr = "123234" ; |
| | | d.meterNo = "1234567890123456" ; |
| | | |
| | | DataV1_0_1 subD = new DataV1_0_1() ; |
| | | subD.rtuAddr = "2342345" ; |
| | | subD.meterNo = "1234567890123456" ; |
| | | |
| | | d.subData = subD ; |
| | | |
| | |
| | | /** |
| | | * 日志 |
| | | */ |
| | | private Logger log = LogManager.getLogger(MonitorThread.class.getName()); |
| | | |
| | | private static final Logger log = LogManager.getLogger(MonitorThread.class) ; |
| | | |
| | | /** |
| | | * 线程池构造方法 |
| | |
| | | HELP.md |
| | | target/ |
| | | /pipIrr-mw.iml |
| | | !.mvn/wrapper/maven-wrapper.jar |
| | | !**/src/main/**/target/ |
| | | !**/src/test/**/target/ |
| | | |
| | | ### STS ### |
| | | .apt_generated |
| | | .classpath |
| | | .factorypath |
| | | .project |
| | | .settings |
| | | .springBeans |
| | | .sts4-cache |
| | | |
| | | ### IntelliJ IDEA ### |
| | | .idea |
| | | *.iws |
| | | *.iml |
| | | *.ipr |
| | | |
| | | ### NetBeans ### |
| | | /nbproject/private/ |
| | | /nbbuild/ |
| | | /dist/ |
| | | /nbdist/ |
| | | /.nb-gradle/ |
| | | build/ |
| | | !**/src/main/**/build/ |
| | | !**/src/test/**/build/ |
| | | |
| | | ### VS Code ### |
| | | .vscode/ |
| | |
| | | if(orgBusi == null){ |
| | | log.error("严重错误,未能得到标签为" + nbRtu.orgTag + "的供水机构数据库业务Busi"); |
| | | }else{ |
| | | BaMeter meter = DbOrgBuzi.getMeterByImeiAndNo(orgBusi, imei, meterNo) ; |
| | | BaMeter meter = DbOrgBuzi.getMeterByImeiAndNo(orgBusi, imei, rtuAddr) ; |
| | | //可能未查询到meter,即仍是流浪者RTU,但仍要后续处理:(1)、仍能识别出流浪者RTU,(2)、仍要记录其上报数据 |
| | | if(meter != null){ |
| | | String protocol = d.getProtocol() ; |
| | |
| | | }else{ |
| | | //NB产品(RTU实体)未分配给具体的供水机构 |
| | | //流浪者RTU |
| | | rtuTramp = DbSyBuzi.getSyRtuTramp(baseBusi, imei, meterNo) ; |
| | | rtuTramp = DbSyBuzi.getSyRtuTramp(baseBusi, imei, rtuAddr) ; |
| | | if(rtuTramp == null){ |
| | | rtuTramp = new SyRtuTramp(imei, meterNo) ; |
| | | rtuTramp = new SyRtuTramp(imei, rtuAddr) ; |
| | | } |
| | | this.taskResult = new Object[]{baseBusi, orgBusi, nbRtu, rtuTramp, null} ; |
| | | this.toNextOneTask(data, TkDealRtuTramp.taskId); |
| | |
| | | }else{ |
| | | //数据库中未查询到NB产品(RTU实体) |
| | | //流浪者RTU |
| | | rtuTramp = DbSyBuzi.getSyRtuTramp(baseBusi, imei, meterNo) ; |
| | | rtuTramp = DbSyBuzi.getSyRtuTramp(baseBusi, imei, rtuAddr) ; |
| | | if(rtuTramp == null){ |
| | | rtuTramp = new SyRtuTramp(imei, meterNo) ; |
| | | rtuTramp = new SyRtuTramp(imei, rtuAddr) ; |
| | | } |
| | | this.taskResult = new Object[]{baseBusi, orgBusi, nbRtu, rtuTramp, null} ; |
| | | this.toNextOneTask(data, TkDealRtuTramp.taskId); |
| | |
| | | </dependencies> |
| | | |
| | | <build> |
| | | <resources> |
| | | <resource> |
| | | <directory>src/main/java</directory> |
| | | <includes> |
| | | <include>**/*.xml</include> |
| | | </includes> |
| | | </resource> |
| | | <resource> |
| | | <directory>src/main/resources</directory> |
| | | <includes> |
| | | <include>**/*.xml</include> |
| | | <include>**/*.yml</include> |
| | | </includes> |
| | | </resource> |
| | | </resources> |
| | | <plugins> |
| | | <plugin> |
| | | <!-- 该插件不会将项目中引入的依赖打进最终的 Jar 文件 --> |
| | |
| | | long start = System.currentTimeMillis() ; |
| | | try { |
| | | sv.conf = new ConfigXml() ; |
| | | sv.doc = sv.conf.createDom(sv.getClass(), "/config.xml") ; |
| | | sv.doc = sv.conf.createDom(sv.getClass(), "config.xml") ; |
| | | //////////////// |
| | | //服务 配置 |
| | | sv.showStartInfo = sv.conf.getSetAttrBoolean(sv.doc, "config.server", "showStartInfo", null, null) ; |
| | |
| | | } |
| | | ServerProperties.tcpServerIp = conf.getSetAttrTxt(doc, "config.base", "tcpServerIp", null, false, null) ; |
| | | ServerProperties.tcpServerPort = conf.getSetAttrPlusInt(doc, "config.base", "tcpServerPort", null, 1, 65535, null) ; |
| | | ServerProperties.sendInterval = conf.getSetAttrPlusInt(doc, "config.base", "sendInterval", null, 1, null, null) ; |
| | | ServerProperties.heartbeatTimes = conf.getSetAttrPlusInt(doc, "config.base", "heartbeatTimes", null, 1, null, null) ; |
| | | ServerProperties.sendTimes = conf.getSetAttrPlusInt(doc, "config.base", "sendTimes", null, 1, null, null) ; |
| | | |
| | | |
| | |
| | | public static String tcpServerIp = "" ; |
| | | //服务端上下文 |
| | | public static Integer tcpServerPort = 60000 ; |
| | | //发送数据间隔 秒 |
| | | public static Integer sendInterval = 0 ; |
| | | //每一轮次发送数据,其中包括心跳发送次数 |
| | | public static Integer heartbeatTimes = 0 ; |
| | | //发送数据次数 |
| | | public static Integer sendTimes = 0 ; |
| | | |
| | |
| | | prtWrt.println(" 每个mwTest分配的RtuAddr数:" + ServerProperties.rtuAddrPerMwTest); |
| | | prtWrt.println(" 通信中间件IP:" + ServerProperties.tcpServerIp); |
| | | prtWrt.println(" 通信中间件端口:" + ServerProperties.tcpServerPort); |
| | | prtWrt.println(" mwTest发送数据间隔(秒):" + ServerProperties.sendInterval); |
| | | prtWrt.println(" mwTest每RtuAddr号发送数据次数:" + ServerProperties.sendTimes); |
| | | prtWrt.println(" mwTest每一轮次发送数据,其中包括心跳发送次数:" + ServerProperties.heartbeatTimes); |
| | | prtWrt.println("本服务RMI Server配置"); |
| | | String ip = null ; |
| | | try { |
| | |
| | | |
| | | public static String cd4 = "004" ;//向服务端上报信息 |
| | | |
| | | public static String cd5 = "005" ;//向服务端上报 数据上报工作已经完成 |
| | | public static String cd5 = "005" ;//向服务端上报 完成任务的数量 |
| | | |
| | | public static String cd6 = "006" ;//向服务端上报 全部任务完成 |
| | | } |
| | |
| | | doDealReportCount(rqVo) ; |
| | | }else if(rqVo.code.equals(Code.cd5)){ |
| | | doDealReportOver(rqVo) ; |
| | | }else if(rqVo.code.equals(Code.cd6)){ |
| | | doDealAllOver(rqVo) ; |
| | | } |
| | | return resVo ; |
| | | } |
| | |
| | | conVo.rtuAddrEnd = (Long)rtuAddrs[1] ; |
| | | conVo.tcpServerIp = ServerProperties.tcpServerIp ; |
| | | conVo.tcpServerPort = ServerProperties.tcpServerPort ; |
| | | conVo.sendInterval = ServerProperties.sendInterval ; |
| | | conVo.heartbeatTimes = ServerProperties.heartbeatTimes ; |
| | | conVo.sendTimes = ServerProperties.sendTimes ; |
| | | sta = new MwTestClientStatus() ; |
| | | sta.confVo = conVo ; |
| | |
| | | MwTestClientStatus sta = token2ClientMap.get("" + token); |
| | | if(sta == null){ |
| | | sta = new MwTestClientStatus() ; |
| | | sta.overCount = rqVo.count ; |
| | | token2ClientMap.put("" + token, sta); |
| | | }else{ |
| | | sta.count = rqVo.count ; |
| | | } |
| | | } |
| | | |
| | | |
| | | private static void doDealAllOver(RmiRequestVo rqVo){ |
| | | int token = Integer.parseInt(rqVo.token) ; |
| | | MwTestClientStatus sta = token2ClientMap.get("" + token); |
| | | if(sta == null){ |
| | | sta = new MwTestClientStatus() ; |
| | | if(rqVo.over != null && rqVo.over){ |
| | | sta.over = true ; |
| | | sta.seconds = rqVo.seconds ; |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | public String tcpServerIp = "" ; |
| | | //通信中间件端口 |
| | | public Integer tcpServerPort = 0 ; |
| | | //发送数据数据间隔 |
| | | public Integer sendInterval = 2 ;//秒 |
| | | //每一轮次发送数据,其中包括心跳发送次数 |
| | | public Integer heartbeatTimes = 3 ; |
| | | //发送数据次数 |
| | | public Integer sendTimes = 0 ; |
| | | |
| | | /** |
| | | * 对象转成json |
| | | * @return 返回 json |
| | |
| | | this.tcpServerPort = tcpServerPort; |
| | | } |
| | | |
| | | public Integer getSendInterval() { |
| | | return sendInterval; |
| | | } |
| | | |
| | | public void setSendInterval(Integer sendInterval) { |
| | | this.sendInterval = sendInterval; |
| | | } |
| | | |
| | | public Integer getHeartbeatTimes() { |
| | | return heartbeatTimes; |
| | | } |
| | | |
| | | public void setHeartbeatTimes(Integer heartbeatTimes) { |
| | | this.heartbeatTimes = heartbeatTimes; |
| | | } |
| | | |
| | | public Integer getSendTimes() { |
| | | return sendTimes; |
| | | } |
| | |
| | | |
| | | public Integer count ;//mwTest上报数据数量 |
| | | |
| | | public Integer overCount ;//mwTest完成全部上报数据RTU数量 |
| | | |
| | | public Boolean over ;//mwTest上报数据结束 |
| | | |
| | | public Long seconds ;//mwTest上报数据用时(秒) |
| | |
| | | rtuAddrsPerMwTest: 每个mwTest分配的RtuAddr数 |
| | | tcpServerIp: 通信中间件IP |
| | | tcpServerPort: 通信中间件端口 |
| | | sendInterval:发送数据间隔 秒 |
| | | heartbeatTimes:每一轮次发送数据,其中包括心跳发送次数 |
| | | sendTimes:发送数据次数 |
| | | --> |
| | | <base |
| | |
| | | rtuAddrPerMwTest="1" |
| | | tcpServerIp="127.0.0.1" |
| | | tcpServerPort="60000" |
| | | sendInterval="2" |
| | | heartbeatTimes="3" |
| | | sendTimes="1" |
| | | /> |
| | | |
| | |
| | | <groupId>com.dy</groupId> |
| | | <artifactId>pipIrr-common</artifactId> |
| | | <version>1.0.0</version> |
| | | <scope>provided</scope> |
| | | <!-- |
| | | scope不能用provided,否则Server.java的运行不起来 |
| | | scope不能用runtime,否则不能编辑 |
| | | --> |
| | | <scope>compile</scope> |
| | | <optional>true</optional> |
| | | <exclusions> |
| | | <exclusion> |
| | |
| | | <groupId>com.dy</groupId> |
| | | <artifactId>pipIrr-global</artifactId> |
| | | <version>1.0.0</version> |
| | | <scope>provided</scope> |
| | | <scope>compile</scope> |
| | | <optional>true</optional> |
| | | <exclusions> |
| | | <exclusion> |
| | |
| | | target/ |
| | | /pipIrr-web.iml |
| | | pipIrr-web.iml |
| | |
| | | HELP.md |
| | | target/ |
| | | /pipIrr-web-sso.iml |
| | | mvnw |
| | | !.mvn/wrapper/maven-wrapper.jar |
| | | !**/src/main/**/target/ |
| | | !**/src/test/**/target/ |