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-mw/pipIrr-mw-simulate-rtu202404/src/main/java/com/dy/simRtu202404/PipIrrMwSimulateRtu202404Application.java | 3 +
pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/tcpClient/downData/DownData.java | 5 ++
pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/PipIrrMwSimulateRtuApplication.java | 3 +
pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/tcpClient/upData/UpCd92.java | 53 ++++++++++++++++++++++++++
4 files changed, 61 insertions(+), 3 deletions(-)
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/PipIrrMwSimulateRtuApplication.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/PipIrrMwSimulateRtuApplication.java
index 2e20a49..02fcd72 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/PipIrrMwSimulateRtuApplication.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/PipIrrMwSimulateRtuApplication.java
@@ -22,10 +22,11 @@
"com.dy.common.aop..*",
"com.dy.common.apiDoc..*",
"com.dy.common.multiDataSource..*",
- "com.dy.common.mybatis..*",
"com.dy.common.singleDataSource..*",
+ "com.dy.common.mybatis..*",
"com.dy.common.webFilter..*",
"com.dy.common.webListener..*",
+ "com.dy.pipIrrGlobal.config..*",
"com.dy.pipIrrGlobal.webCtrls..*"
})
}
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/tcpClient/downData/DownData.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/tcpClient/downData/DownData.java
index 3876932..cebd5e2 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/tcpClient/downData/DownData.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/tcpClient/downData/DownData.java
@@ -30,7 +30,10 @@
}
}
private void dealP206V1(byte[] bs){
- //搴旇鏄摼璺娴嬫暟鎹�
+ String cdPre = ByteUtil.bytes2Hex(bs, false, ProtocolConstantV206V1.codeIndex, 1);
+ if(cdPre.equals("92")){
+ UpCd92.upData() ;
+ }
}
private void dealUpgrade(byte[] bs){
String cdPre = ByteUtil.bytes2Hex(bs, false, ProtocolConstantV206V1.UG_codeIndex, 1);
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/tcpClient/upData/UpCd92.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/tcpClient/upData/UpCd92.java
new file mode 100644
index 0000000..3e39cdf
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/tcpClient/upData/UpCd92.java
@@ -0,0 +1,53 @@
+package com.dy.simRtu.tcpClient.upData;
+
+import com.dy.common.mw.protocol.p206V1.parse.global.GlCreate;
+import com.dy.common.util.ByteUtil;
+import com.dy.simRtu.ServerProperties;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+/**
+ * @Author: liurunyu
+ * @Date: 2025/5/7 15:05
+ * @Description
+ */
+public class UpCd92 extends UpData {
+
+ private static final Logger log = LogManager.getLogger(UpCd92.class);
+
+ public static void upData() {
+ try {
+ if (UpData.session != null && UpData.session.isConnected()) {
+ byte[] bs = createData(ServerProperties.rtuAddr);
+ UpData.upSend(bs);
+ } else {
+ log.error("鏈繛鎺ラ�氫俊涓棿浠讹紝涓嶈兘鍙戦�佹暟鎹�");
+ }
+ } catch (Exception e) {
+ log.error("鍚戦�氫俊涓棿浠跺彂閫佹暟鎹骇鐢熷紓甯�", e);
+ }
+ }
+
+
+ /**
+ * 鏋勯�犳暟鎹�
+ *
+ * @return 瀛楄妭鏁扮粍
+ * @throws Exception 寮傚父
+ */
+ private static byte[] createData(String rtuAddr) throws Exception {
+ byte[] bytes = creatHead(rtuAddr, "92",(byte)0xB0);
+
+ byte[] bs = new byte[1];
+ bs[0] = (byte) 0xAA;//0xAA琛ㄧず鍛戒护鎺ユ敹鎴愬姛锛�0x00琛ㄧず鍛戒护涓嶈兘鎵ц
+ bytes = ByteUtil.bytesMerge(bytes, bs);
+
+ GlCreate.createLen(bytes);//闀垮害鏀惧瓧鑺傛暟缁勪腑
+
+ byte[] bsTail = GlCreate.createCrcTail4P206(bytes);//CRC鍜屽熬鍙犲姞瀛楄妭鏁扮粍涓�
+
+ bytes = ByteUtil.bytesMerge(bytes, bsTail);
+
+ return bytes;
+ }
+}
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu202404/src/main/java/com/dy/simRtu202404/PipIrrMwSimulateRtu202404Application.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu202404/src/main/java/com/dy/simRtu202404/PipIrrMwSimulateRtu202404Application.java
index 5c994c3..e65404c 100644
--- a/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu202404/src/main/java/com/dy/simRtu202404/PipIrrMwSimulateRtu202404Application.java
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu202404/src/main/java/com/dy/simRtu202404/PipIrrMwSimulateRtu202404Application.java
@@ -23,10 +23,11 @@
"com.dy.common.aop..*",
"com.dy.common.apiDoc..*",
"com.dy.common.multiDataSource..*",
- "com.dy.common.mybatis..*",
"com.dy.common.singleDataSource..*",
+ "com.dy.common.mybatis..*",
"com.dy.common.webFilter..*",
"com.dy.common.webListener..*",
+ "com.dy.pipIrrGlobal.config..*",
"com.dy.pipIrrGlobal.webCtrls..*"
})
}
--
Gitblit v1.8.0