From ecef3df4890be54c1da2a8a4fc1c8c1f50f1c263 Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期一, 07 四月 2025 15:41:47 +0800
Subject: [PATCH] 式样代码管理

---
 pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/RtuUpData.java |  286 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 286 insertions(+), 0 deletions(-)

diff --git a/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/RtuUpData.java b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/RtuUpData.java
new file mode 100644
index 0000000..37a0fc7
--- /dev/null
+++ b/pipIrr-platform/pipIrr-mw/pipIrr-mwTest-client/src/main/java/com/dy/testClient/tcpClient/RtuUpData.java
@@ -0,0 +1,286 @@
+package com.dy.testClient.tcpClient;
+
+import com.dy.common.mw.protocol.p206V1.CommonV1;
+import com.dy.common.mw.protocol.p206V1.ProtocolConstantV206V1;
+import com.dy.common.mw.protocol.p206V1.parse.global.GlCreate;
+import com.dy.common.util.ByteUtil;
+
+/**
+ * @Author: liurunyu
+ * @Date: 2024/7/11 13:55
+ * @Description
+ */
+public class RtuUpData {
+
+    private 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 ;
+    }
+
+
+    /**
+     * 鏋勯�犲績璺虫暟鎹�
+     * @return 瀛楄妭鏁扮粍
+     * @throws Exception 寮傚父
+     */
+    public static byte[] createHeartbeat(String rtuAddr) throws Exception {
+        byte[] bytes = creatHead(rtuAddr, "02", (byte)0xB0);
+
+        byte[] bs = new byte[1] ;
+        bs[0] = (byte)0xF2 ;//鏁版嵁鍩燂細 1 涓瓧鑺傦紝F0 鐧诲綍锛� F1 閫�鍑虹櫥褰曪紝F2 鍦ㄧ嚎淇濇寔銆�
+
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        GlCreate.createLen(bytes);//闀垮害鏀惧瓧鑺傛暟缁勪腑
+
+        byte[] bsTail = GlCreate.createCrcTail4P206(bytes) ;//CRC鍜屽熬鍙犲姞瀛楄妭鏁扮粍涓�
+
+        bytes = ByteUtil.bytesMerge(bytes, bsTail) ;
+
+        return bytes ;
+    }
+
+    /**
+     * 鏋勯�犱笂鎶ユ暟鎹�
+     * @return 瀛楄妭鏁扮粍
+     * @throws Exception 寮傚父
+     */
+    public static byte[] createCd83Open(String rtuAddr, String icCardAddr, String icCardNo, String openValveDt) throws Exception {
+        byte[] bytes = creatHead(rtuAddr, "83", (byte)0xB0);
+
+        byte[] bs = new byte[1] ;
+        bs[0] = (byte)0x01 ;//鍒峰崱寮�闃�
+
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        bs = new byte[5] ;//绱娴侀噺
+        bs[0] = ByteUtil.int2BCD_LE (21)[0] ;
+        bs[1] = ByteUtil.int2BCD_LE (43)[0] ;
+        bs[2] = ByteUtil.int2BCD_LE (0)[0] ;
+        bs[3] = ByteUtil.int2BCD_LE (0)[0] ;
+        bs[4] = ByteUtil.int2BCD_LE (0)[0] ;
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        bs = new byte[8] ;//IC鍗$紪鍙�
+        GlCreate.createIcCardNo(icCardNo, bs, 0);
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        bs = new byte[4] ;//IC鍗″湴鍧�
+        ByteUtil.hex2Bytes_LE(icCardAddr, bs, 0);
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        bs = new byte[4] ;//鐢ㄦ按鎴蜂綑棰�
+        bs[0] = ByteUtil.int2BCD_LE (21)[0] ;
+        bs[1] = ByteUtil.int2BCD_LE (43)[0] ;
+        bs[2] = ByteUtil.int2BCD_LE (0)[0] ;
+        bs[3] = ByteUtil.int2BCD_LE (0)[0] ;
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        bs = new byte[6] ;//寮�闃�鏃堕棿
+        GlCreate.createTp(openValveDt, bs, 0);
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        bs = new byte[6] ;//鎺у埗鍣ㄦ椂閽�
+        GlCreate.createTp(bs, 0);
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        GlCreate.createLen(bytes);//闀垮害鏀惧瓧鑺傛暟缁勪腑
+
+        byte[] bsTail = GlCreate.createCrcTail4P206(bytes) ;//CRC鍜屽熬鍙犲姞瀛楄妭鏁扮粍涓�
+
+        bytes = ByteUtil.bytesMerge(bytes, bsTail) ;
+
+        return bytes ;
+    }
+
+
+    /**
+     * 鏋勯�犱笂鎶ユ暟鎹�
+     * @return 瀛楄妭鏁扮粍
+     * @throws Exception 寮傚父
+     */
+    public static byte[] createCd83Close(String rtuAddr, String icCardAddr, String icCardNo, String openValveDt) throws Exception {
+        byte[] bytes = creatHead(rtuAddr, "83", (byte)0xB0);
+
+        byte[] bs = new byte[1] ;
+        bs[0] = (byte)0x02 ;//鍒峰崱鍏抽榾
+
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        bs = new byte[5] ;//绱娴侀噺
+        bs[0] = ByteUtil.int2BCD_LE (21)[0] ;
+        bs[1] = ByteUtil.int2BCD_LE (53)[0] ;
+        bs[2] = ByteUtil.int2BCD_LE (0)[0] ;
+        bs[3] = ByteUtil.int2BCD_LE (0)[0] ;
+        bs[4] = ByteUtil.int2BCD_LE (0)[0] ;
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        bs = new byte[8] ;//IC鍗$紪鍙�
+        GlCreate.createIcCardNo(icCardNo, bs, 0);
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        bs = new byte[4] ;//IC鍗″湴鍧�
+        ByteUtil.hex2Bytes_LE(icCardAddr, bs, 0);
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        bs = new byte[4] ;//鐢ㄦ按鎴蜂綑棰�
+        bs[0] = ByteUtil.int2BCD_LE (21)[0] ;
+        bs[1] = ByteUtil.int2BCD_LE (33)[0] ;
+        bs[2] = ByteUtil.int2BCD_LE (0)[0] ;
+        bs[3] = ByteUtil.int2BCD_LE (0)[0] ;
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        bs = new byte[6] ;//寮�闃�鏃堕棿
+        GlCreate.createTp(openValveDt, bs, 0);
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        bs = new byte[6] ;//鍏抽榾鏃堕棿
+        GlCreate.createTp(bs, 0);
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        bs = new byte[5] ;//鐢ㄦ按鎴锋湰娆$敤姘撮噺
+        bs[0] = ByteUtil.int2BCD_LE (0)[0] ;
+        bs[1] = ByteUtil.int2BCD_LE (10)[0] ;
+        bs[2] = ByteUtil.int2BCD_LE (0)[0] ;
+        bs[3] = ByteUtil.int2BCD_LE (0)[0] ;
+        bs[4] = ByteUtil.int2BCD_LE (0)[0] ;
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        bs = new byte[4] ;//鐢ㄦ按鎴锋湰娆℃秷璐归噾棰�
+        bs[0] = ByteUtil.int2BCD_LE (0)[0] ;
+        bs[1] = ByteUtil.int2BCD_LE (10)[0] ;
+        bs[2] = ByteUtil.int2BCD_LE (0)[0] ;
+        bs[3] = ByteUtil.int2BCD_LE (0)[0] ;
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        bs = new byte[2] ;//鐢ㄦ按鎴锋湰娆$敤姘存椂闀�
+        bs[0] = ByteUtil.int2BCD_LE (10)[0] ;
+        bs[1] = ByteUtil.int2BCD_LE (0)[0] ;
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        bs = new byte[1] ;//姘翠环绫诲瀷
+        bs[0] = ByteUtil.int2BCD_LE (1)[0] ;
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        bs = new byte[2] ;//姘翠环
+        bs[0] = ByteUtil.int2BCD_LE (0)[0] ;
+        bs[1] = ByteUtil.int2BCD_LE (1)[0] ;
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        bs = new byte[6] ;//鎺у埗鍣ㄦ椂閽�
+        GlCreate.createTp(bs, 0);
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        bs = new byte[1] ;//鍗$被鍨�
+        bs[0] = ByteUtil.int2BCD_LE (1)[0] ;
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        GlCreate.createLen(bytes);//闀垮害鏀惧瓧鑺傛暟缁勪腑
+
+        byte[] bsTail = GlCreate.createCrcTail4P206(bytes) ;//CRC鍜屽熬鍙犲姞瀛楄妭鏁扮粍涓�
+
+        bytes = ByteUtil.bytesMerge(bytes, bsTail) ;
+
+        return bytes ;
+    }
+
+    /**
+     * 鏋勯�犱笂鎶ユ暟鎹�
+     * @return 瀛楄妭鏁扮粍
+     * @throws Exception 寮傚父
+     */
+    public static byte[] createCdC0(String rtuAddr) throws Exception {
+        CommonV1 commonV_1 = new CommonV1() ;
+        byte[] bytes ;
+        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] = commonV_1.createCtrl((byte)0x80, (byte)3) ;//鎺у埗鍩熷姛鑳界爜3锛氳嚜鎶ュ抚锛屾祦閲忥紙姘撮噺锛夊弬鏁�
+
+        index++ ;
+        GlCreate.createRtuAddr4P206(rtuAddr, bsHead, index);
+        index += 5 ;
+
+        ByteUtil.hex2Bytes("C0", bsHead, index) ;
+
+        byte[] bs = new byte[2] ;
+        bs[0] = (byte)0x04 ;//鏈夋祦閲忔暟鎹�
+        bs[1] = (byte)0xE0 ;//鏈夋按鍘嬨�佺數姹犵數鍘嬨�佷俊鍙峰己搴�
+
+        bytes = ByteUtil.bytesMerge(bsHead, bs) ;
+
+        bs = new byte[5] ;//鐬椂娴侀噺
+        bs[0] = ByteUtil.int2BCD_LE (21)[0] ;
+        bs[1] = ByteUtil.int2BCD_LE (43)[0] ;
+        bs[2] = ByteUtil.int2BCD_LE (65)[0] ;
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        bs = new byte[5] ;//绱娴侀噺
+        bs[0] = ByteUtil.int2BCD_LE (21)[0] ;
+        bs[1] = ByteUtil.int2BCD_LE (43)[0] ;
+        bs[2] = ByteUtil.int2BCD_LE (65)[0] ;
+        bs[3] = ByteUtil.int2BCD_LE (87)[0] ;
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        bs = new byte[5] ;//鎹熷け娴侀噺
+        bs[0] = ByteUtil.int2BCD_LE (10)[0] ;
+        bs[1] = ByteUtil.int2BCD_LE (32)[0] ;
+        bs[2] = ByteUtil.int2BCD_LE (54)[0] ;
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        bs = new byte[4] ;//姘村帇
+        bs[0] = ByteUtil.int2BCD_LE (10)[0] ;
+        bs[1] = ByteUtil.int2BCD_LE (32)[0] ;
+        bs[2] = ByteUtil.int2BCD_LE (4)[0] ;
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        bs = new byte[4] ;//鐢垫睜鐢靛帇
+        bs[0] = ByteUtil.int2BCD_LE (10)[0] ;
+        bs[1] = ByteUtil.int2BCD_LE (32)[0] ;
+        bs[2] = ByteUtil.int2BCD_LE (10)[0] ;
+        bs[3] = ByteUtil.int2BCD_LE (32)[0] ;
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        bs = new byte[1] ;//淇″彿寮哄害
+        bs[0] = ByteUtil.int2BCD_LE (21)[0] ;
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        bs = new byte[6] ;//鏃堕挓
+        GlCreate.createTp(bs, 0);
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        GlCreate.createLen(bytes);//闀垮害鏀惧瓧鑺傛暟缁勪腑
+
+        byte[] bsTail = GlCreate.createCrcTail4P206(bytes) ;//CRC鍜屽熬鍙犲姞瀛楄妭鏁扮粍涓�
+
+        bytes = ByteUtil.bytesMerge(bytes, bsTail) ;
+
+        return bytes ;
+    }
+}

--
Gitblit v1.8.0