From 99bf09fbc855590e209dda4cd2b6c725101cbe9c Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期五, 26 七月 2024 14:39:43 +0800
Subject: [PATCH] 1、完善代码,把开关阀类型编码改为BCD码; 2、制定并实现协议“定时关阀计划开阀(A1H)”和“定量关阀计划开阀(A2H)”.

---
 pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/global/GlParse.java |   27 +++++++++++++++++++++++----
 1 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/global/GlParse.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/global/GlParse.java
index 2f087bc..2484a8f 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/global/GlParse.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/global/GlParse.java
@@ -3,6 +3,7 @@
 import com.dy.common.mw.protocol.p206V1_0_0.upVos.DataAlarmVo;
 import com.dy.common.mw.protocol.p206V1_0_0.upVos.DataStateVo;
 import com.dy.common.util.ByteUtil;
+import com.dy.common.util.ByteUtilUnsigned;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
@@ -20,11 +21,11 @@
         闃�闂細鎶ヨ
         */
         DataAlarmVo avo = new DataAlarmVo() ;
-        byte b = bs[index + 1] ;
+        byte b = bs[index] ;
         avo.batteryVolt = (byte)((b & 0x2) >> 1) ;
         avo.meter = (byte)((b & 0x20) >> 5) ;
 
-        b = bs[index] ;
+        b = bs[index + 1] ;
         avo.loss = (byte)((b & 0x2) >> 1) ;
         avo.valve = (byte)((b & 0x4) >> 2) ;
         return avo ;
@@ -32,13 +33,31 @@
 
     public static DataStateVo parseState(byte[] bs, short index){
         DataStateVo avo = new DataStateVo() ;
-        byte b = bs[index + 1] ;
+        byte b = bs[index] ;
         avo.icCard = (byte)((b & 0x4) >> 2) ;
-        avo.working = (byte)((b & 0x10) >> 4) ;
+        avo.valveState = (byte)((b & 0x10) >> 4) ;
         avo.powerType = (byte)((b & 0x40) >> 6) ;
         return avo ;
     }
 
+    /**
+     * 鍒嗘瀽IC鍗$紪鍙�
+     * @param bs 涓婅瀛楄妭鏁扮粍
+     * @param index 鍚浣�
+     * @return 鎺у埗鍣ㄥ湴鍧�
+     * @throws Exception 寮傚父
+     */
+    public static String parseIcCardNo(byte[] bs, int index)throws Exception{
+        String icNoStr = "" + ByteUtilUnsigned.bytes2Short_LE(bs, index) ;
+        String icNoBCD = "" + ByteUtil.BCD2Long_LE(bs, index + 2, index + 7) ;
+        while(icNoStr.length() < 5){
+            icNoStr = "0" + icNoStr ;
+        }
+        return icNoBCD + icNoStr ;
+    }
+
+
+
     public static String parseTp(byte[] bs, short index){
         String dt = "" ;
         try{

--
Gitblit v1.8.0