From 18f9dc6d0f15cad4a74e68fcf87b1a9aa83b5e66 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期四, 18 七月 2024 14:28:28 +0800
Subject: [PATCH] 实现协议中各种命令结果日志数据库永久更新保存功能

---
 pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_C0_Up.java |  128 +++++++++++++-----------------------------
 1 files changed, 39 insertions(+), 89 deletions(-)

diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_C0_Up.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_C0_Up.java
index dd61198..0116141 100644
--- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_C0_Up.java
+++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mw/protocol/p206V1_0_0/parse/Cd_C0_Up.java
@@ -3,6 +3,7 @@
 import com.dy.common.mw.protocol.*;
 import com.dy.common.mw.protocol.p206V1_0_0.*;
 import com.dy.common.mw.protocol.p206V1_0_0.parse.global.GlParse;
+import com.dy.common.mw.protocol.p206V1_0_0.upVos.DataCdC0Vo;
 import com.dy.common.util.ByteUtil;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
@@ -43,6 +44,7 @@
         String confirmComCode = para.upCode ;
         ParseParamsForDownV1_0_1 downCpParams  = new ParseParamsForDownV1_0_1() ;
         downCpParams.setValue(
+                null,
                 ProtocolConstantV206V1_0_0.protocolName,
                 para.rtuAddr,
                 Command.defaultId,
@@ -50,7 +52,7 @@
                 null,
                 null);
         //鏋勯�犲簲绛�
-        byte[] data = new Cd_02_Down().doParse(downCpParams) ;
+        byte[] data = new Cd_C0_Down().doParse(downCpParams) ;
 
         MidResultToRtu confirmCommand = new MidResultToRtu() ;
         confirmCommand.protocolName = para.protocolName ;//鍗忚鍚嶇О
@@ -83,24 +85,26 @@
     protected void doParse(byte[] bs, int bsLen, String dataCode, Data data) throws Exception {
         DataV1_0_1 dV1 = (DataV1_0_1)data.getSubData() ;
         DataCdC0Vo cdData = new DataCdC0Vo() ;
-        dV1.dataCdC0Vo = cdData ;
+        dV1.subData = cdData ;
 
-        boolean hasWaterAmount = false ;//鏄惁鏈夋祦閲忔暟鎹�
-        boolean hasWaterPress = false ;//鏄惁鏈夋按鍘嬫暟鎹�
-        boolean hasEleVolt = false ;//鏄惁鏈夌數鍘嬫暟鎹�
-        boolean hasSignal = false ;//鏄惁鏈変俊鍙峰己搴︽暟鎹�
-        boolean hasAlarmStatus = false ;//鏄惁鏈夋暟鎹�
+        boolean hasWaterAmount = true ;//鏄惁鏈夋祦閲忔暟鎹�
+        boolean hasWaterPress = true ;//鏄惁鏈夋按鍘嬫暟鎹�
+        boolean hasEleVolt = true ;//鏄惁鏈夌數鍘嬫暟鎹�
+        boolean hasSignal = true ;//鏄惁鏈変俊鍙峰己搴︽暟鎹�
+        boolean hasAlarmStatus = true ;//鏄惁鏈夋暟鎹�
 
         short index = ProtocolConstantV206V1_0_0.dataIndex ;
 
         byte tmpBt1 = bs[index] ;
         index++ ;
+        /* RTU瀹炵幇涓�瀹氭湁娴侀噺鏁版嵁
         if(((tmpBt1 & 4) >> 2) == 1){
             hasWaterAmount = true ;
         }
-
+        */
         byte tmpBt2 = bs[index] ;
         index++ ;
+        /*RTU瀹炵幇涓�瀹氭湁涓嬮潰鍚勯」鏁版嵁
         if(((tmpBt2 & 0x10) >> 4) == 1){
             hasAlarmStatus = true ;
         }
@@ -113,102 +117,42 @@
         if(((tmpBt2 & 0x80) >> 7) == 1){
             hasSignal = true ;
         }
-
+        */
         if(hasWaterAmount){
             //鐬椂娴侀噺锛�5瀛楄妭BCD鐮侊紝鍙栧�艰寖鍥�0~9999999.999锛屽崟浣嶄负m3/h銆�
-            cdData.instantAmount = 0.0D ;
-            int tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
-            index++ ;
-            cdData.instantAmount += tpInt/1000.0 ;
-            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
-            index++ ;
-            cdData.instantAmount += tpInt/10.0 ;
-            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
-            index++ ;
-            cdData.instantAmount += tpInt * 10.0 ;
-            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
-            index++ ;
-            cdData.instantAmount += tpInt * 1000.0 ;
-            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
-            index++ ;
-            cdData.instantAmount += tpInt * 100000.0 ;
+            int tpInt = ByteUtil.BCD2Int_LE(bs, index, index + 4) ;
+            cdData.instantAmount = tpInt/1000.0 ;
 
-            //绱娴侀噺锛�5瀛楄妭BCD鐮侊紝鍙栧�艰寖鍥�0~9999999999锛屽崟浣嶄负m3銆�
-            cdData.totalAmount = 0.0D ;
-            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
-            index++ ;
-            cdData.totalAmount += tpInt;
-            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
-            index++ ;
-            cdData.totalAmount += tpInt * 100.0 ;
-            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
-            index++ ;
-            cdData.totalAmount += tpInt * 10000.0 ;
-            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
-            index++ ;
-            cdData.totalAmount += tpInt * 1000000.0 ;
-            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
-            index++ ;
-            cdData.totalAmount += tpInt * 100000000.0 ;
+            index += 5 ;
+            //绱娴侀噺锛�5瀛楄妭BCD鐮侊紝鍙栧�艰寖鍥�0~99999999.99锛屽崟浣嶄负m3銆�
+            tpInt = ByteUtil.BCD2Int_LE(bs, index, index + 4) ;
+            cdData.totalAmount = tpInt/100.0;
 
+            index += 5 ;
             //鎹熷け娴侀噺锛�5瀛楄妭BCD鐮侊紝鍙栧�艰寖鍥�0~9999999999锛屽崟浣嶄负m3銆�
-            cdData.lossAmount = 0.0D ;
-            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
-            index++ ;
-            cdData.lossAmount += tpInt;
-            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
-            index++ ;
-            cdData.lossAmount += tpInt * 100.0 ;
-            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
-            index++ ;
-            cdData.lossAmount += tpInt * 10000.0 ;
-            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
-            index++ ;
-            cdData.lossAmount += tpInt * 1000000.0 ;
-            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
-            index++ ;
-            cdData.lossAmount += tpInt * 100000000.0 ;
+            tpInt = ByteUtil.BCD2Int_LE(bs, index, index + 4) ;
+            cdData.lossAmount = tpInt/100.0;
+
+            index += 5 ;
         }
         if(hasWaterPress){
             //姘村帇锛�4瀛楄妭BCD鐮侊紝鍙栧�艰寖鍥�0~999999.99锛屽崟浣嶄负KPa銆�
-            cdData.waterPress = 0.0D ;
-            int tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
-            index++ ;
-            cdData.waterPress += tpInt/100.0 ;
-            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
-            index++ ;
-            cdData.waterPress += tpInt;
-            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
-            index++ ;
-            cdData.waterPress += tpInt * 100.0 ;
-            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
-            index++ ;
-            cdData.waterPress += tpInt * 10000.0 ;
+            int tpInt = ByteUtil.BCD2Int_LE(bs, index, index + 3) ;
+            cdData.waterPress = tpInt/100.0 ;
+            index += 4 ;
         }
         if(hasEleVolt){
-            //鐢垫睜鐢靛帇锛�4瀛楄妭BCD鐮侊紝鍙栧�艰寖鍥�0~99.99锛屽崟浣嶄负V銆�
-            cdData.batteryVolt = 0.0D ;//钃勭數姹犵數鍘�
-            cdData.sunVolt = 0.0D ;//澶槼鑳界數鍘�
-            int tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
-            index++ ;
-            cdData.batteryVolt += tpInt/100.0 ;
-            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
-            index++ ;
-            cdData.batteryVolt += tpInt;
-            //澶槼鑳界數鍘嬶細4瀛楄妭BCD鐮侊紝鍙栧�艰寖鍥�0~99.99锛屽崟浣嶄负V銆�
-            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
-            index++ ;
-            cdData.sunVolt += tpInt/100.0 ;
-            tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
-            index++ ;
-            cdData.sunVolt += tpInt;
+            //鐢垫睜鐢靛帇锛�2瀛楄妭BCD鐮侊紝鍙栧�艰寖鍥�0~99.99锛屽崟浣嶄负V銆�
+            //钃勭數姹犵數鍘�
+            int tpInt = ByteUtil.BCD2Int_LE(bs, index, index + 1) ;
+            cdData.batteryVolt = tpInt/100.0 ;
+            index += 2 ;
         }
         if(hasSignal){
             //淇″彿寮哄害锛�1瀛楄妭BCD鐮侊紝鍙栧�艰寖鍥�0~99銆�
-            cdData.signal = 0 ;
             int tpInt = ByteUtil.BCD2Int_LE(bs, index, index) ;
+            cdData.signalValue = tpInt  ;
             index++ ;
-            cdData.signal += tpInt  ;
         }
         if(hasAlarmStatus){
             //鎶ヨ鏁版嵁
@@ -218,6 +162,12 @@
             cdData.stateVo = GlParse.parseState(bs, index) ;
             index += 2 ;
         }
+
+        //姘翠环锛�2瀛楄妭BCD鐮侊紝鍙栧�艰寖鍥�0~99.99锛屽崟浣嶄负鍏冦��
+        int tpInt = ByteUtil.BCD2Int_LE(bs, index, index + 1) ;
+        cdData.waterPrice = tpInt/100.0 ;
+
+        index += 2 ;
         cdData.rtuDt = GlParse.parseTp(bs, index) ;
 
     }

--
Gitblit v1.8.0