| | |
| | | |
| | | public static final int connectTimeout = 3000 ; |
| | | |
| | | public int sendTimes = 0 ;//发送数据次数 |
| | | public int heartbeatTimes = 0 ;//上报心跳次数 |
| | | public int sendTimes = 1 ;//发送数据次数 |
| | | public int heartbeatTimes = 1 ;//上报心跳次数 |
| | | |
| | | public long overStart = 0L; |
| | | public boolean isOver = false ; |
| | | |
| | | public MyThreadJob(){ |
| | |
| | | |
| | | @Override |
| | | public void execute() throws Exception { |
| | | log.info("RTU" + rtuAddr + "开始任务"); |
| | | if(session != null){ |
| | | log.info("RTU" + rtuAddr + "将要执行" + ServerProperties.sendTimes + "轮次任务,当前轮次是" + sendTimes); |
| | | if(sendTimes <= ServerProperties.sendTimes){ |
| | | log.info("RTU" + rtuAddr + "开始任务"); |
| | | log.info("RTU" + rtuAddr + "将要执行" + ServerProperties.sendTimes + "轮次任务,当前轮次是" + sendTimes); |
| | | sendDataOfP206V1_0_0() ; |
| | | }else{ |
| | | this.jobOver() ; |
| | | log.info("RTU" + rtuAddr + "等待一会,以接收通信中间件下行数据"); |
| | | if(overStart == 0){ |
| | | overStart = System.currentTimeMillis() ; |
| | | }else{ |
| | | long now = System.currentTimeMillis() ; |
| | | if(now - overStart >= 30 * 1000){ |
| | | this.jobOver() ; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void sendDataOfP206V1_0_0(){ |
| | | try{ |
| | | if(heartbeatTimes >= ServerProperties.heartbeatTimes){ |
| | | heartbeatTimes = 0 ; |
| | | if(heartbeatTimes > ServerProperties.heartbeatTimes){ |
| | | heartbeatTimes = 1 ; |
| | | this.sendReportData() ; |
| | | TcpClUnit.clientSendData(); |
| | | sendTimes++ ; |