| | |
| | | //已经收到命令结果 |
| | | removeNodeFromCach = true ; |
| | | //记录状态 |
| | | RtuStatusDealer.commandSuccess(this.result.rtuAddr); |
| | | RtuStatusDealer.commandSuccess(this.result.rtuAddr, this.result.downCode, this.result.downCodeName); |
| | | return removeNodeFromCach ; |
| | | } |
| | | if(this.sendedTimes >= this.result.maxSendTimes){ |
| | | //发送次数达到最大值 |
| | | if(now - this.lastSendStamp >= ServerProperties.cachWaitResultTimeout){ |
| | | if(now - this.lastSendStamp >= ServerProperties.cacheWaitResultTimeout){ |
| | | //超时 |
| | | removeNodeFromCach = true ; |
| | | //记录状态 |
| | | RtuStatusDealer.commandFailure(this.result.rtuAddr); |
| | | RtuStatusDealer.commandFailure(this.result.rtuAddr, this.result.downCode, this.result.downCodeName); |
| | | } |
| | | return removeNodeFromCach ; |
| | | } |
| | |
| | | removeNodeFromCach = true ; |
| | | }else{ |
| | | //不在线命令缓存 |
| | | if(now - this.cachTime >= ServerProperties.offLineCachTimeout){ |
| | | if(now - this.cachTime >= ServerProperties.offLineCacheTimeout){ |
| | | //缓存超时 |
| | | removeNodeFromCach = true ; |
| | | } |
| | |
| | | } |
| | | |
| | | Long lastSendStamp = tcpSe.lastDownComTime ; |
| | | if(this.result.isQuickSend || lastSendStamp == null || (now - lastSendStamp >= ServerProperties.commandSendInterval)){ |
| | | //未收到命令结果,未达到最大发送次数,RTU在线,速发命令或超过命令下发间隔,以上满足发送命令条件,执行发送命令 |
| | | boolean nowSend = false ; |
| | | if(this.result.isQuickSend || lastSendStamp == null || (this.result.isFastCom && now - lastSendStamp >= ServerProperties.fastCommandSendInterval)){ |
| | | //未收到命令结果,未达到最大发送次数,RTU在线,当前是速发命令,或者是快速命令超过命令下发间隔,以上满足发送命令条件,执行发送命令 |
| | | nowSend = true ; |
| | | }else if(this.result.isQuickSend || lastSendStamp == null || (now - lastSendStamp >= ServerProperties.commandSendInterval)) { |
| | | //未收到命令结果,未达到最大发送次数,RTU在线,当前是速发命令,或者是命令超过命令下发间隔,以上满足发送命令条件,执行发送命令 |
| | | nowSend = true ; |
| | | } |
| | | if(nowSend){ |
| | | tcpSe.ioSession.write(this.result.downBuffer) ; |
| | | tcpSe.lastDownComTime = now ; |
| | | if(!this.result.hasResponse){ |
| | |
| | | this.lastSendStamp = now ; |
| | | |
| | | //记录日志 |
| | | RtuLogDealer.log(this.result.rtuAddr, "下行数据 " + this.result.downCode + ":" + this.result.downBufHex); |
| | | RtuLogDealer.log(this.result.rtuAddr, "下行数据 " + this.result.downCode + (this.result.downCodeName==null?"":("(" + this.result.downCodeName + ")")) + ":" + this.result.downBufHex); |
| | | //记录状态 |
| | | RtuStatusDealer.downData(this.result.rtuAddr, this.result.downBuffer.length); |
| | | RtuStatusDealer.downData(this.result.rtuAddr, this.result.downCode, this.result.downCodeName, this.result.downBuffer.length); |
| | | |
| | | log.info("下行RTU(地址=" + this.result.rtuAddr + ")命令(功能码=" + this.result.downCode + ") " + this.result.downBufHex ) ; |
| | | log.info("下行RTU(地址=" + this.result.rtuAddr + ")命令[功能码=" + this.result.downCode + (this.result.downCodeName==null?"":("(" + this.result.downCodeName + ")")) + "] " + this.result.downBufHex ) ; |
| | | } |
| | | |
| | | return removeNodeFromCach ; |