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/DriverV1_0_1.java | 23 ++++++++++++++++++----- 1 files changed, 18 insertions(+), 5 deletions(-) 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, -- Gitblit v1.8.0