From e407fcf19e50ed0972e7262d99da4b3a83d08706 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期五, 11 十月 2024 17:08:23 +0800
Subject: [PATCH] 1、修改协议驱动RTU上行数据解析出错时,RTU上下行数据日志中的RTU地址不正确的bug; 2、83功能码上行数据测试main方法实现。

---
 pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/DriverV202404.java |   23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/DriverV202404.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/DriverV202404.java
index 3602d3d..142836d 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/DriverV202404.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/DriverV202404.java
@@ -24,6 +24,20 @@
 		downCpParams = new ParseParamsForDownV202404() ;
 	}
 
+	/**
+	 * 娓呯┖鑷繁
+	 */
+	@Override
+	public void clear() {
+		if(this.upCpParams != null){
+			this.upCpParams.clear();
+		}
+		if(this.downCpParams != null){
+			this.downCpParams.clear();
+		}
+		this.reportOrResponse_trueOrFalse = null ;
+		this.rtuAddrInData = null ;
+	}
 
 	/**
 	 * 鎵弿璇嗗埆鍔熻兘鐮佹敞瑙g被
@@ -44,7 +58,7 @@
 	 */
 	@Override
 	public MidResult[] parseData(Boolean isLowPower, String rtuAddr, byte[] upBuffer, String upHex, DriverParserDataCallback callback, Object... params) {
-		reportOrResponse_trueOrFalse = null ;
+		this.clear();
 		boolean isFail = false ;
 		String upCode = null ;
 		try{
@@ -75,8 +89,7 @@
 			
 			upData.setSubData(dV1_0_1) ;
 			
-			this.upCpParams.clear();
-			this.upCpParams.setValue(ProtocolConstantV206V202404.protocolName, 
+			this.upCpParams.setValue(ProtocolConstantV206V202404.protocolName,
 					rtuAddr, 
 					upCode,
 					upHex, 
@@ -99,7 +112,7 @@
 			isFail = true ;
 			return new MidResult[]{(new MidResultError(ProtocolConstantV206V202404.protocolName, rtuAddr, "涓ラ噸閿欒锛屽垎鏋怰tu鏁版嵁鍑洪敊锛佹暟鎹负锛�" + upHex + (e.getMessage() == null?"":("锛屽嚭閿欎俊鎭細" + e.getMessage())), e))} ;
 		} finally{
-			callback.callback(rtuAddr, upCode, CodeV202404.getCodeName(upCode), upHex, reportOrResponse_trueOrFalse, isFail, rtuAddrInData);
+			callback.callback(rtuAddr, upCode, CodeV202404.getCodeName(upCode), upHex, reportOrResponse_trueOrFalse, isFail, rtuAddr);
 		}
 	}
 
@@ -111,6 +124,7 @@
 	 */
 	@Override
 	public MidResult[] createCommand(Boolean isLowPower, Command command, Object... params) {
+		this.clear();
 		String RtuResultSendWebUrl = command.getRtuResultSendWebUrl() ;
 		if(RtuResultSendWebUrl == null || RtuResultSendWebUrl.trim().equals("")){
 			return new MidResult[]{(new MidResultError(ProtocolConstantV206V202404.protocolName, null, "涓ラ噸閿欒锛屽懡浠や腑rtu杩斿洖鍛戒护缁撴灉鍙戝悜鐩殑鍦皐eb URL涓虹┖锛屼笉鑳芥瀯寤轰换浣曞懡浠わ紒", null))} ;
@@ -122,7 +136,6 @@
 		try {
 			String commandCode = command.getCode() ;
 			
-			this.downCpParams.clear();
 			this.downCpParams.setValue(
 					RtuResultSendWebUrl,
 					ProtocolConstantV206V202404.protocolName, 

--
Gitblit v1.8.0