From 959dcca95276888cd9c092d93d276ef9aa580aef Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期三, 30 四月 2025 16:26:19 +0800
Subject: [PATCH] 1、增加远程透传命令; 2、表阀一体机协议优化;
---
pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/tcpClient/upData/UpData.java | 76 ++++++++++++++++++++++++++++++++++++++
1 files changed, 76 insertions(+), 0 deletions(-)
diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/tcpClient/upData/UpData.java b/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/tcpClient/upData/UpData.java
new file mode 100644
index 0000000..3db4a2a
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mw-simulate-rtu/src/main/java/com/dy/simRtu/tcpClient/upData/UpData.java
@@ -0,0 +1,76 @@
+package com.dy.simRtu.tcpClient.upData;
+
+import com.dy.common.mw.protocol.p206V1.ProtocolConstantV206V1;
+import com.dy.common.mw.protocol.p206V1.parse.global.GlCreate;
+import com.dy.common.util.ByteUtil;
+import org.apache.mina.core.session.IoSession;
+
+/**
+ * @Author: liurunyu
+ * @Date: 2024/7/15 14:20
+ * @Description
+ */
+public class UpData {
+
+ protected static IoSession session ;
+
+ private static Object synObj = new Object() ;
+
+ public static void setSession(IoSession session){
+ UpData.session = session ;
+ }
+
+ protected static void upSend(byte[] bs) throws Exception{
+ synchronized (synObj){
+ session.write(bs) ;
+ }
+ }
+
+ protected static byte[] creatHead(String rtuAddr, String code, byte ctrl)throws Exception {
+ byte[] bsHead = new byte[ProtocolConstantV206V1.lenHead2Code] ;
+ byte index = 0 ;
+ bsHead[index] = ProtocolConstantV206V1.P_Head_Byte ;
+
+ index++ ;
+ bsHead[index] = 0 ;//甯ч暱搴�
+
+ index++ ;
+ bsHead[index] = ProtocolConstantV206V1.P_Head_Byte ;
+
+ index++ ;
+ bsHead[index] = ctrl; //鎺у埗鍩熷姛鑳界爜
+
+ index++ ;
+ GlCreate.createRtuAddr4P206(rtuAddr, bsHead, index);
+ index += 5 ;
+
+ ByteUtil.hex2Bytes(code, bsHead, index) ;
+
+ return bsHead ;
+ }
+
+ protected static byte[] creatHead4Upgrade(String rtuAddr, String preCode, String sufCode)throws Exception {
+ byte[] bsHead = new byte[12] ;
+ byte index = 0 ;
+ bsHead[index] = ProtocolConstantV206V1.UG_P_Head_Byte ;
+
+ index++ ;
+ bsHead[index] = 0 ;//甯ч暱搴�
+ index++ ;
+ bsHead[index] = 0 ;//甯ч暱搴�
+
+ index++ ;
+ bsHead[index] = ProtocolConstantV206V1.UG_P_Head_Byte ;
+
+ index++ ;
+ bsHead[index] = ByteUtil.hex2Bytes(preCode)[0]; //鍔熻兘鐮佸煙
+
+ index++ ;
+ bsHead[index] = ByteUtil.hex2Bytes(sufCode)[0]; //鍔熻兘鐮佸煙
+
+ index++ ;
+ GlCreate.createRtuAddr4P206(rtuAddr, bsHead, index);
+
+ return bsHead ;
+ }
+}
--
Gitblit v1.8.0