From 4b067b4db5c1f2a068d6e27cc138118810785e2d Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期三, 07 五月 2025 10:47:13 +0800
Subject: [PATCH] 1、创建命令生成器模块,实现部分命令数据生成,还需继续实现其他命令; 2、完善代码。
---
pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/upData/UpCd83Open.java | 78 +++++++++++++++++++++++++++++++++++++++
1 files changed, 78 insertions(+), 0 deletions(-)
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/upData/UpCd83Open.java b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/upData/UpCd83Open.java
new file mode 100644
index 0000000..eb1c429
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-mwTest-rtu/src/main/java/com/dy/pipIrrMwTestRtu/tcpClient/upData/UpCd83Open.java
@@ -0,0 +1,78 @@
+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/15 14:58
+ * @Description
+ */
+public class UpCd83Open extends UpData {
+
+ private static final Logger log = LogManager.getLogger(UpCd83Open.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, "83", (byte)0xB0);
+
+ byte[] bs = new byte[1] ;
+ bs[0] = (byte)0x01 ;//鍒峰崱寮�闃�
+
+ bytes = ByteUtil.bytesMerge(bytes, bs) ;
+
+ bs = new byte[5] ;//绱娴侀噺
+ ByteUtil.int2BCD_LE(UpConstant.totalAmount, 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] ;//IC鍗″湴鍧�
+ ByteUtil.hex2Bytes_LE(ServerProperties.icCardAddr, 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[6] ;//寮�闃�鏃堕棿
+ GlCreate.createTp(UpConstant.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 ;
+ }
+}
--
Gitblit v1.8.0