From 5c3ba107b6fe756c5eab6cc83bb18ad0c8c5d9ec Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期二, 07 五月 2024 21:10:52 +0800
Subject: [PATCH] 实现王江海制定的协议实现到3.30节(功能码0x87)

---
 pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_16_Down.java |   44 +++++++++++++++++++++++++++++++++++---------
 1 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_16_Down.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_16_Down.java
index 4dc4781..9d08509 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_16_Down.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V202404/parse/Cd_16_Down.java
@@ -53,13 +53,12 @@
             if(cvo == null){
                 throw new Exception("json杞珻omCd16Vo涓簄ull") ;
             }
-            if(cvo.moneyAlarm < 0 || cvo.moneyAlarm > 65535){
-                throw new Exception("鍓╀綑閲戦鎶ヨ鍊煎繀椤绘槸0~65535鑼冨洿鍐呯殑鏁存暟") ;
+            if(cvo.moneyAlarm < 0 || cvo.moneyAlarm > 9999){
+                throw new Exception("鍓╀綑閲戦鎶ヨ鍊煎繀椤绘槸0~9999鑼冨洿鍐呯殑鏁存暟") ;
             }
-            if(cvo.waterAlarm < 0 || cvo.waterAlarm > 65535){
-                throw new Exception("鍓╀綑姘撮噺鎶ヨ鍊煎繀椤绘槸0~65535鑼冨洿鍐呯殑鏁存暟") ;
+            if(cvo.waterAlarm < 0 || cvo.waterAlarm > 9999){
+                throw new Exception("鍓╀綑姘撮噺鎶ヨ鍊煎繀椤绘槸0~9999鑼冨洿鍐呯殑鏁存暟") ;
             }
-
 
             byte[] bs = new byte[13] ;
             int index = 0 ;
@@ -68,16 +67,43 @@
             index ++ ;
             bs[index] = cvo.projectNo.byteValue() ;
 
-            index ++ ;
-            ByteUtilUnsigned.short2Bytes_BE(bs, cvo.waterAlarm, index);
 
             index ++ ;
-            ByteUtilUnsigned.short2Bytes_BE(bs, cvo.moneyAlarm, index);
+            String strTemp = "" + cvo.waterAlarm ;
+            byte[] bTemp = ByteUtil.string2BCD_LE(strTemp) ;
+            int bTempLen = bTemp.length ;
+            int count = 0 ;
+            for(int i = 0 ; i < bTempLen; i++){
+                bs[index++] = bTemp[i] ;
+                count ++ ;
+                if(count >= 2){
+                    break ;
+                }
+            }
+            for(; count < 2; count++){
+                bs[index++] = 0 ;
+            }
+
+            index += 4 ;
+            strTemp = "" + cvo.moneyAlarm ;
+            bTemp = ByteUtil.string2BCD_LE(strTemp) ;
+            bTempLen = bTemp.length ;
+            count = 0 ;
+            for(int i = 0 ; i < bTempLen; i++){
+                bs[index++] = bTemp[i] ;
+                count ++ ;
+                if(count >= 2){
+                    break ;
+                }
+            }
+            for(; count < 2; count++){
+                bs[index++] = 0 ;
+            }
 
             index ++ ;
             GlCreate.createPw(bs, index);
 
-            index ++ ;
+            index += 2 ;
             GlCreate.createS2D(bs, index) ;
 
             index += 4 ;

--
Gitblit v1.8.0