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/p206V1_0_0/parse/Cd_83_Up.java | 22 +++++++++++
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Driver.java | 5 ++
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/DriverV1_0_1.java | 23 +++++++++--
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/DriverV202404.java | 23 +++++++++--
4 files changed, 62 insertions(+), 11 deletions(-)
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Driver.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Driver.java
index 6071100..7593dab 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Driver.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/Driver.java
@@ -15,6 +15,10 @@
protected HashMap<String, CodeParse> downCode2ClassInstance = new HashMap<>() ;
/**
+ * 娓呯┖鑷繁
+ */
+ public abstract void clear() ;
+ /**
* 鍗曠嚎绋嬪崟渚婦river妯″紡涓嬭繍琛�
* 鎵弿璇嗗埆鍔熻兘鐮佹敞瑙g被
* @throws Exception 寮傚父
@@ -24,7 +28,6 @@
* 鎵弿璇嗗埆鍔熻兘鐮佹敞瑙g被
* @param driver 椹卞姩
* @param protocolName 鍗忚鍚嶇О
- * @param uri URI
* @param scanRootPackage 鎵弿鍖�
* @throws Exception 寮傚父
*/
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/DriverV1_0_1.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/DriverV1_0_1.java
index c641ff3..aa554a5 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/DriverV1_0_1.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/DriverV1_0_1.java
@@ -23,6 +23,20 @@
downCpParams = new ParseParamsForDownV1_0_1() ;
}
+ /**
+ * 娓呯┖鑷繁
+ */
+ @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被
@@ -43,7 +57,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{
@@ -74,8 +88,7 @@
upData.setSubData(dV1_0_1) ;
- this.upCpParams.clear();
- this.upCpParams.setValue(ProtocolConstantV206V1_0_0.protocolName,
+ this.upCpParams.setValue(ProtocolConstantV206V1_0_0.protocolName,
rtuAddr,
upCode,
upHex,
@@ -98,7 +111,7 @@
isFail = true ;
return new MidResult[]{(new MidResultError(ProtocolConstantV206V1_0_0.protocolName, rtuAddr, "涓ラ噸閿欒锛屽垎鏋怰tu鏁版嵁鍑洪敊锛佹暟鎹负锛�" + upHex + (e.getMessage() == null?"":("锛屽嚭閿欎俊鎭細" + e.getMessage())), e))} ;
} finally{
- callback.callback(rtuAddr, upCode, CodeV1_0_1.getCodeName(upCode), upHex, reportOrResponse_trueOrFalse, isFail, rtuAddrInData);
+ callback.callback(rtuAddr, upCode, CodeV1_0_1.getCodeName(upCode), upHex, reportOrResponse_trueOrFalse, isFail, rtuAddr);
}
}
@@ -110,6 +123,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(ProtocolConstantV206V1_0_0.protocolName, null, "涓ラ噸閿欒锛屽懡浠や腑rtu杩斿洖鍛戒护缁撴灉鍙戝悜鐩殑鍦皐eb URL涓虹┖锛屼笉鑳芥瀯寤轰换浣曞懡浠わ紒", null))} ;
@@ -121,7 +135,6 @@
try {
String commandCode = command.getCode() ;
- this.downCpParams.clear();
this.downCpParams.setValue(
RtuResultSendWebUrl,
ProtocolConstantV206V1_0_0.protocolName,
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_83_Up.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_83_Up.java
index 92e0803..7f76e88 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_83_Up.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_83_Up.java
@@ -193,4 +193,26 @@
cdData.rtuDt = GlParse.parseTp(bs, index) ;
//index += 6 ;
}
+
+ public static void main(String[] args) throws Exception {
+ Cd_83_Up obj = new Cd_83_Up() ;
+ String hex = "683C68B08485353448830200000000001000282353FE739444000001000313000101211615000101210000000000000000000200019000011518000101210A7B16";
+ byte[] bs = ByteUtil.hex2Bytes(hex) ;
+
+ Data data = new Data() ;
+ data.setSubData(new DataV1_0_1()) ;
+
+ int bsLen = new CommonV1_0_1().parseDataLen(bs) ;
+ if(bsLen > 0){
+ try {
+ obj.doParse(bs,
+ bsLen,
+ "83",
+ data) ;
+ }catch (Exception e){
+ e.printStackTrace();
+ }
+ }
+ System.out.println("data = " + data);
+ }
}
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