|  |  |  | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | 
|---|
|  |  |  | 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 ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | 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){ | 
|---|
|  |  |  | //报警数据 | 
|---|
|  |  |  | 
|---|
|  |  |  | 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) ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|