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

---
 pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/upData/UpCd84.java |   89 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 89 insertions(+), 0 deletions(-)

diff --git a/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/upData/UpCd84.java b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/upData/UpCd84.java
new file mode 100644
index 0000000..2e4c595
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/upData/UpCd84.java
@@ -0,0 +1,89 @@
+package com.dy.pipIrrMwTestRtu.tcpClient.upData;
+
+import com.dy.common.mw.protocol.p206V1.parse.global.GlCreate;
+import com.dy.common.util.ByteUtil;
+import com.dy.pipIrrMwTestRtu.ServerProperties;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+/**
+ * @Author: liurunyu
+ * @Date: 2024/7/16 19:32
+ * @Description
+ */
+public class UpCd84 extends UpData {
+
+    private static final Logger log = LogManager.getLogger(UpCd84.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 {
+        UpConstant.addValve();//璋冩暣娴侀噺
+
+        byte[] bytes = creatHead(rtuAddr, "84", (byte)0xB0);
+
+        byte[] bs = new byte[1] ;
+        bs[0] = (byte)0x01 ;//鍒峰崱寮�闃�
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        bs = new byte[1] ;
+        bs[0] = (byte)0x01 ;//鍗$被鍨� 鐢ㄦ埛鍗�
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        bs = new byte[4] ;//IC鍗″湴鍧�
+        ByteUtil.hex2Bytes_LE(ServerProperties.icCardAddr, bs, 0);
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        bs = new byte[8] ;//IC鍗$紪鍙�
+        GlCreate.createIcCardNo(ServerProperties.icCardNo, bs, 0);
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        bs = new byte[4] ;//鐢ㄦ按鎴蜂綑棰�
+        ByteUtil.int2BCD_LE(UpConstant.remainMoney, bs, 0);
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        bs = new byte[5] ;//绱娴侀噺
+        ByteUtil.int2BCD_LE(UpConstant.totalAmount, bs, 0);
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        bs = new byte[5] ;//鐬椂娴侀噺
+        ByteUtil.int2BCD_LE(UpConstant.instantAmount, bs, 0);
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        bs = new byte[]{0x00, 0x00} ;//鎶ヨ
+        bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+        bs = new byte[]{0x00, 0x00} ;//鐘舵��
+        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