From 85a2968c85ab196eec3c189395f89f8e067701ef Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期三, 07 五月 2025 15:27:50 +0800
Subject: [PATCH] RTU模拟器增加命令92的响应,以测试透传命令。
---
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/DriverV1.java | 46 ++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/DriverV1.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/DriverV1.java
index 54279c3..b6a4038 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/DriverV1.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1/DriverV1.java
@@ -1,6 +1,7 @@
package com.dy.common.mw.protocol.p206V1;
import com.dy.common.mw.protocol.*;
+import com.dy.common.mw.protocol.p206V1.parse.TransparentDown;
import com.dy.common.util.DateTime;
@AnnotationDriver(enable = true,
@@ -59,6 +60,7 @@
this.clear();
boolean isFail = false ;
String upCode = null ;
+ Object[] codeDataGrp = {null};
try{
CommonV1 cp = new CommonV1() ;
Boolean p206TrueUgFalse = cp.protocolType_p206TrueUgFalse(upBuffer) ;
@@ -100,9 +102,10 @@
}else{
return codeParse.parse(isLowPower, this.upCpParams, new CodeParseCallback(){
@Override
- public void callback(Boolean flag) {
+ public void callback(Boolean flag, Object codeData) {
reportOrResponse_trueOrFalse = flag ;
rtuAddrInData = dV1.getRtuAddr() ;
+ codeDataGrp[0] = codeData ;
}
@Override
public void notify(NotifyInfo ...infos) {
@@ -116,7 +119,7 @@
} finally{
if(upCode != null){
//CRC楠岃瘉澶辫触鏃讹紝upCode涓簄ull锛屾鏃朵笉杩涜鍥炶皟
- callback.callback(rtuAddr, upCode, CodeV1.getCodeName(upCode), upHex, reportOrResponse_trueOrFalse, isFail, rtuAddr);
+ callback.callback(rtuAddr, upCode, CodeV1.getCodeName(upCode), upHex, reportOrResponse_trueOrFalse, isFail, rtuAddr, codeDataGrp[0]);
}
}
}
@@ -166,5 +169,44 @@
}
}
+ /**
+ * 鏋勯�犱笅琛岄�忎紶鏁版嵁锛堝懡浠わ級
+ * @param isLowPower 鏄惁鍦ㄤ綆鍔熻�楃幆澧冧笅杩愯
+ * @param command 鍛戒护
+ * @return MidResult[]
+ */
+ @Override
+ public MidResult[] transparentCommand(Boolean isLowPower, Command command, Object... params){
+ this.clear();
+ String RtuResultSendWebUrl = command.getRtuResultSendWebUrl() ;
+ if(RtuResultSendWebUrl == null || RtuResultSendWebUrl.trim().equals("")){
+ return new MidResult[]{(new MidResultError(ProtocolConstantV206V1.protocolName, null, "涓ラ噸閿欒锛屽懡浠や腑rtu杩斿洖鍛戒护缁撴灉鍙戝悜鐩殑鍦皐eb URL涓虹┖锛屼笉鑳芥瀯寤轰换浣曞懡浠わ紒", null))} ;
+ }
+ String rtuAddr = command.getRtuAddr() ;
+ if(rtuAddr == null || rtuAddr.trim().equals("")){
+ return new MidResult[]{(new MidResultError(ProtocolConstantV206V1.protocolName, null, "涓ラ噸閿欒锛屽懡浠や腑Rtu鍦板潃涓虹┖锛屼笉鑳芥瀯寤轰换浣曞懡浠わ紒", null))} ;
+ }
+ try {
+ String commandCode = command.getCode() ;
+
+ this.downCpParams.setValue(
+ RtuResultSendWebUrl,
+ ProtocolConstantV206V1.protocolName,
+ command.protocolVersion==null?ProtocolConstantV206V1.protocolVer:command.protocolVersion,
+ rtuAddr,
+ command.getId(),
+ commandCode,
+ command.getParam(),
+ command.getAttachment());
+
+ if(commandCode == null){
+ return new MidResult[]{(new MidResultError(ProtocolConstantV206V1.protocolName, rtuAddr, "涓ラ噸閿欒锛屽懡浠や腑鍔熻兘鐮佷负绌猴紝涓嶈兘鏋勫缓浠讳綍鍛戒护锛�", null))} ;
+ }else{
+ return new TransparentDown().parse(isLowPower, this.downCpParams, null);
+ }
+ } catch (Exception e) {
+ return new MidResult[]{(new MidResultError(ProtocolConstantV206V1.protocolName, rtuAddr, "涓ラ噸閿欒锛屾瀯閫犱笅琛屾暟鎹嚭閿欙紒鍛戒护涓猴細" + command.toString(), e))} ;
+ }
+ }
}
\ No newline at end of file
--
Gitblit v1.8.0