From 1a2b07f01ba4616fd9e894dddf474b56d020158c Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期一, 07 四月 2025 15:18:51 +0800
Subject: [PATCH] 整理版本

---
 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