From 1a2b07f01ba4616fd9e894dddf474b56d020158c Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期一, 07 四月 2025 15:18:51 +0800
Subject: [PATCH] 整理版本

---
 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