From 7bdf147a26675542054563a5727977c54cfda9ef Mon Sep 17 00:00:00 2001 From: liurunyu <lry9898@163.com> Date: 星期四, 13 二月 2025 14:19:53 +0800 Subject: [PATCH] 实现功能:远程模块remote接收通信中间件消息,补全取水口名称(编号)后,通过websocket向前端推送。 --- pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/forTcp/TcpDownCommandObj.java | 35 +++++++++++++++++++++++++++-------- 1 files changed, 27 insertions(+), 8 deletions(-) diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/forTcp/TcpDownCommandObj.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/forTcp/TcpDownCommandObj.java index c70efd8..3a76be7 100644 --- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/forTcp/TcpDownCommandObj.java +++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-rtu/src/main/java/com/dy/rtuMw/server/forTcp/TcpDownCommandObj.java @@ -36,16 +36,16 @@ //宸茬粡鏀跺埌鍛戒护缁撴灉 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 ; } @@ -59,7 +59,7 @@ removeNodeFromCach = true ; }else{ //涓嶅湪绾垮懡浠ょ紦瀛� - if(now - this.cachTime >= ServerProperties.offLineCachTimeout){ + if(now - this.cachTime >= ServerProperties.offLineCacheTimeout){ //缂撳瓨瓒呮椂 removeNodeFromCach = true ; } @@ -72,9 +72,28 @@ return false ; } - Long lastSendStamp = tcpSe.lastDownComTime ; - if(this.result.isQuickSend || lastSendStamp == null || (now - lastSendStamp >= ServerProperties.commandSendInterval)){ - //鏈敹鍒板懡浠ょ粨鏋滐紝鏈揪鍒版渶澶у彂閫佹鏁帮紝RTU鍦ㄧ嚎锛岄�熷彂鍛戒护鎴栬秴杩囧懡浠や笅鍙戦棿闅旓紝浠ヤ笂婊¤冻鍙戦�佸懡浠ゆ潯浠讹紝鎵ц鍙戦�佸懡浠� + boolean nowSend = false ; + if(this.result.countdown4Send > 0){ + this.result.countdown4Send -= 1 ; + }else{ + Long lastDownComTime = tcpSe.lastDownComTime ; + if(this.result.isQuickSend){ + //鍦ㄥ懡浠ゆ瀯寤烘椂锛屽彧鏈夊湪浣庡姛鑰楁儏鍐典笅锛屾墠浼氭妸isQuickSend浠樺�间负true + //鏈敹鍒板懡浠ょ粨鏋滐紝鏈揪鍒版渶澶у彂閫佹鏁帮紝RTU鍦ㄧ嚎锛岀涓婅鏁版嵁鏃跺埢涓嶈繎锛屽綋鍓嶆槸閫熷彂鍛戒护锛屾弧瓒冲彂閫佸懡浠ゆ潯浠讹紝鎵ц鍙戦�佸懡浠� + nowSend = true ; + }else if(lastDownComTime == null){ + //鏈敹鍒板懡浠ょ粨鏋滐紝鏈揪鍒版渶澶у彂閫佹鏁帮紝RTU鍦ㄧ嚎锛岀涓婅鏁版嵁鏃跺埢涓嶈繎锛屽綋鍓峈TU涓婄嚎浠ユ潵鏈浘涓嬪彂杩囧懡浠わ紝婊¤冻鍙戦�佸懡浠ゆ潯浠讹紝鎵ц鍙戦�佸懡浠� + nowSend = true ; + }else if(this.result.isFastCom && (now - lastDownComTime) >= ServerProperties.fastCommandSendInterval){ + //鏈敹鍒板懡浠ょ粨鏋滐紝鏈揪鍒版渶澶у彂閫佹鏁帮紝RTU鍦ㄧ嚎锛岀涓婅鏁版嵁鏃跺埢涓嶈繎锛孯TU涓婄嚎浠ユ潵鏇句笅鍙戣繃鍛戒护锛屽綋鍓嶅懡浠ゆ槸蹇�熷懡浠や笖瓒呰繃鍛戒护涓嬪彂闂撮殧锛屾弧瓒冲彂閫佸懡浠ゆ潯浠讹紝鎵ц鍙戦�佸懡浠� + nowSend = true ; + }else if(!this.result.isFastCom && (now - lastDownComTime) >= ServerProperties.commandSendInterval){ + //鏈敹鍒板懡浠ょ粨鏋滐紝鏈揪鍒版渶澶у彂閫佹鏁帮紝RTU鍦ㄧ嚎锛岀涓婅鏁版嵁鏃跺埢涓嶈繎锛孯TU涓婄嚎浠ユ潵鏇句笅鍙戣繃鍛戒护锛屽綋鍓嶅懡浠ら潪蹇�熷懡浠わ紝RTU涓嬪彂鍛戒护闂撮殧瓒呰繃鍛戒护涓嬪彂闂撮殧锛屾弧瓒冲彂閫佸懡浠ゆ潯浠讹紝鎵ц鍙戦�佸懡浠� + nowSend = true ; + } + } + + if(nowSend){ tcpSe.ioSession.write(this.result.downBuffer) ; tcpSe.lastDownComTime = now ; if(!this.result.hasResponse){ @@ -88,7 +107,7 @@ //璁板綍鏃ュ織 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.downCodeName==null?"":("锛�" + this.result.downCodeName + "锛�")) + "] " + this.result.downBufHex ) ; } -- Gitblit v1.8.0