| | |
| | | */ |
| | | public static String parseIcCardNo(byte[] bs, int index, int len1, int len2)throws Exception{ |
| | | String rtuAddrBCD = "" + ByteUtil.BCD2Long_BE(bs, index, index + len1 - 1) ; |
| | | String rtuAddrStr = "" + ByteUtilUnsigned.bytes2Short_LE(bs, index + len1 + len2 -1 ) ; |
| | | String rtuAddrStr = "" + ByteUtilUnsigned.bytes2Short_LE(bs, index + len1) ; |
| | | while(rtuAddrStr.length() < 5){ |
| | | rtuAddrStr = "0" + rtuAddrStr ; |
| | | } |
| | | return rtuAddrBCD + rtuAddrStr ; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 分析状态与报警 |
| | | * @param bs |
| | | * @param index |
| | | * @return |
| | | */ |
| | | public static void parseAlarmAndState(byte[] bs, int index, DataCd80_5BVo vo){ |
| | | byte b = bs[index] ; |
| | | vo.statePump = (byte)(b & 0x1) ; |
| | | vo.alarmWaterRemain = (byte)(b >> 1 & 1) ; |
| | | vo.alarm0WaterRemain = (byte)(b >> 2 & 1) ; |
| | | vo.alarmExceedYear = (byte)(b >> 3 & 1) ; |
| | | vo.alarmWaterMeterFault = (byte)(b >> 4 & 1) ; |
| | | vo.alarmSteal = (byte)(b >> 5 & 1) ; |
| | | vo.alarmWaterMeterBreak = (byte)(b >> 6 & 1) ; |
| | | vo.alarmEleMeterFault = (byte)(b >> 7 & 1) ; |
| | | |
| | | index++ ; |
| | | b = bs[index] ; |
| | | vo.alarm0MoneyRemain = (byte)(b & 0x1) ; |
| | | vo.alarmInnerDoor = (byte)(b >> 1 & 1) ; |
| | | vo.alarmOuterDoor = (byte)(b >> 2 & 1) ; |
| | | vo.alarmEleMiss = (byte)(b >> 3 & 1) ; |
| | | vo.alarmEleExceed = (byte)(b >> 4 & 1) ; |
| | | vo.alarmEleLowVolt = (byte)(b >> 5 & 1) ; |
| | | vo.stateIcEnable = (byte)(b >> 6 & 1) ; |
| | | } |
| | | /** |
| | | * 分析状态与报警 |
| | | * @param bs |
| | | * @param index |
| | | * @return |
| | | */ |
| | | public static void parseAlarmAndState(byte[] bs, int index, DataCd81Vo vo){ |
| | | byte b = bs[index] ; |
| | | vo.statePump = (byte)(b & 0x1) ; |
| | | vo.alarmWaterRemain = (byte)(b >> 1 & 1) ; |
| | | vo.alarm0WaterRemain = (byte)(b >> 2 & 1) ; |
| | | vo.alarmExceedYear = (byte)(b >> 3 & 1) ; |
| | | vo.alarmWaterMeterFault = (byte)(b >> 4 & 1) ; |
| | | vo.alarmSteal = (byte)(b >> 5 & 1) ; |
| | | vo.alarmWaterMeterBreak = (byte)(b >> 6 & 1) ; |
| | | vo.alarmEleMeterFault = (byte)(b >> 7 & 1) ; |
| | | |
| | | index++ ; |
| | | b = bs[index] ; |
| | | vo.alarm0MoneyRemain = (byte)(b & 0x1) ; |
| | | vo.alarmInnerDoor = (byte)(b >> 1 & 1) ; |
| | | vo.alarmOuterDoor = (byte)(b >> 2 & 1) ; |
| | | vo.alarmEleMiss = (byte)(b >> 3 & 1) ; |
| | | vo.alarmEleExceed = (byte)(b >> 4 & 1) ; |
| | | vo.alarmEleLowVolt = (byte)(b >> 5 & 1) ; |
| | | vo.stateIcEnable = (byte)(b >> 6 & 1) ; |
| | | } |
| | | /** |
| | | * 分析状态与报警 |
| | | * @param bs |
| | | * @param index |
| | | * @return |
| | | */ |
| | | public static void parseAlarmAndState(byte[] bs, int index, DataCd84Vo vo){ |
| | | byte b = bs[index] ; |
| | | vo.statePump = (byte)(b & 0x1) ; |
| | | vo.alarmWaterRemain = (byte)(b >> 1 & 1) ; |
| | | vo.alarm0WaterRemain = (byte)(b >> 2 & 1) ; |
| | | vo.alarmExceedYear = (byte)(b >> 3 & 1) ; |
| | | vo.alarmWaterMeterFault = (byte)(b >> 4 & 1) ; |
| | | vo.alarmSteal = (byte)(b >> 5 & 1) ; |
| | | vo.alarmWaterMeterBreak = (byte)(b >> 6 & 1) ; |
| | | vo.alarmEleMeterFault = (byte)(b >> 7 & 1) ; |
| | | |
| | | index++ ; |
| | | b = bs[index] ; |
| | | vo.alarm0MoneyRemain = (byte)(b & 0x1) ; |
| | | vo.alarmInnerDoor = (byte)(b >> 1 & 1) ; |
| | | vo.alarmOuterDoor = (byte)(b >> 2 & 1) ; |
| | | vo.alarmEleMiss = (byte)(b >> 3 & 1) ; |
| | | vo.alarmEleExceed = (byte)(b >> 4 & 1) ; |
| | | vo.alarmEleLowVolt = (byte)(b >> 5 & 1) ; |
| | | vo.stateIcEnable = (byte)(b >> 6 & 1) ; |
| | | } |
| | | /** |
| | | * 分析状态与报警 |
| | | * @param bs |
| | | * @param index |
| | | * @return |
| | | */ |
| | | public static void parseAlarmAndState(byte[] bs, int index, DataCd93_A3_85Vo vo){ |
| | | byte b = bs[index] ; |
| | | vo.statePump = (byte)(b & 0x1) ; |
| | | vo.alarmWaterRemain = (byte)(b >> 1 & 1) ; |
| | | vo.alarm0WaterRemain = (byte)(b >> 2 & 1) ; |
| | | vo.alarmExceedYear = (byte)(b >> 3 & 1) ; |
| | | vo.alarmWaterMeterFault = (byte)(b >> 4 & 1) ; |
| | | vo.alarmSteal = (byte)(b >> 5 & 1) ; |
| | | vo.alarmWaterMeterBreak = (byte)(b >> 6 & 1) ; |
| | | vo.alarmEleMeterFault = (byte)(b >> 7 & 1) ; |
| | | |
| | | index++ ; |
| | | b = bs[index] ; |
| | | vo.alarm0MoneyRemain = (byte)(b & 0x1) ; |
| | | vo.alarmInnerDoor = (byte)(b >> 1 & 1) ; |
| | | vo.alarmOuterDoor = (byte)(b >> 2 & 1) ; |
| | | vo.alarmEleMiss = (byte)(b >> 3 & 1) ; |
| | | vo.alarmEleExceed = (byte)(b >> 4 & 1) ; |
| | | vo.alarmEleLowVolt = (byte)(b >> 5 & 1) ; |
| | | vo.stateIcEnable = (byte)(b >> 6 & 1) ; |
| | | } |
| | | /** |
| | | * 分析状态与报警 |
| | | * @param bs |
| | | * @param index |
| | | * @return |
| | | */ |
| | | public static void parseAlarmAndState(byte[] bs, int index, DataCdC2Vo vo){ |
| | | public static void parseAlarmAndState(byte[] bs, int index, AlarmVo vo){ |
| | | byte b = bs[index] ; |
| | | vo.statePump = (byte)(b & 0x1) ; |
| | | vo.alarmWaterRemain = (byte)(b >> 1 & 1) ; |
| | |
| | | index++ ; |
| | | dt = ByteUtil.BCD2String_BE(bs, index, index) + " " + dt ;//日 |
| | | index++ ; |
| | | //bs[index] = (byte)(bs[index] & 0x10); |
| | | bs[index] = (byte)(bs[index] & 0x1F); |
| | | dt = ByteUtil.BCD2String_BE(bs, index, index) + "-" + dt ;//月 |
| | | index++ ; |
| | | dt = "20" + ByteUtil.BCD2String_BE(bs, index, index) + "-" + dt ;//年 |
| | |
| | | cdData.useWaterType = bs[index]; |
| | | |
| | | index++ ; |
| | | cdData.orderNo = ByteUtil.BCD2String_BE(bs, index, index + 4) ; |
| | | cdData.orderNo = ByteUtil.BCD2String_BE(bs, index, index + 7) ; |
| | | |
| | | index += 8 ; |
| | | cdData.icCardAddr = ByteUtil.bytes2Hex(bs, false, index, 4) ; |
| | |
| | | cdData.rtuDt = GlParse.parseRtuDt(bs, index) ; |
| | | |
| | | index += 6 ; |
| | | int waterLevel = ByteUtil.BCD2Int_BE(bs, index, index + 3) ; |
| | | Long waterLevel = ByteUtil.BCD2Long_LE(bs, index, index + 3) ; |
| | | cdData.waterLevel = waterLevel/1000.0D; |
| | | |
| | | index += 4 ; |
| | | int waterPress = ByteUtil.BCD2Int_BE(bs, index, index + 2) ; |
| | | int waterPress = ByteUtil.BCD2Int_LE(bs, index, index + 2) ; |
| | | cdData.waterPress = waterPress/100.0D; |
| | | |
| | | index += 3 ; |
| | | int waterInstant = ByteUtil.BCD2Int_BE(bs, index, index + 3) ; |
| | | Long waterInstant = ByteUtil.BCD2Long_LE(bs, index, index + 3) ; |
| | | cdData.waterInstant = waterInstant/100.0D; |
| | | |
| | | index += 4 ; |
| | | int waterTotal = ByteUtil.BCD2Int_BE(bs, index, index + 4) ; |
| | | Long waterTotal = ByteUtil.BCD2Long_LE(bs, index, index + 4) ; |
| | | cdData.waterTotal = waterTotal/100.0D; |
| | | |
| | | index += 5 ; |
| | | int eleTotal = ByteUtil.BCD2Int_BE(bs, index, index + 4) ; |
| | | Long eleTotal = ByteUtil.BCD2Long_LE(bs, index, index + 4) ; |
| | | cdData.eleTotal = eleTotal/100.0D; |
| | | |
| | | index += 5 ; |
| | | int moneyRemain = ByteUtil.BCD2Int_BE(bs, index, index + 4) ; |
| | | Long moneyRemain = ByteUtil.BCD2Long_LE(bs, index, index + 4) ; |
| | | cdData.moneyRemain = moneyRemain/100.0D; |
| | | |
| | | index += 5 ; |
| | | int waterRemain = ByteUtil.BCD2Int_BE(bs, index, index + 4) ; |
| | | Long waterRemain = ByteUtil.BCD2Long_LE(bs, index, index + 4) ; |
| | | cdData.waterRemain = waterRemain/100.0D; |
| | | |
| | | index += 5 ; |
| | | int thisEle = ByteUtil.BCD2Int_BE(bs, index, index + 3) ; |
| | | int thisEle = ByteUtil.BCD2Int_LE(bs, index, index + 3) ; |
| | | cdData.thisEle = thisEle/100.0D; |
| | | |
| | | index += 4 ; |
| | | int thisWater = ByteUtil.BCD2Int_BE(bs, index, index + 3) ; |
| | | int thisWater = ByteUtil.BCD2Int_LE(bs, index, index + 3) ; |
| | | cdData.thisWater = thisWater/100.0D; |
| | | |
| | | index += 4 ; |
| | | int thisMoney = ByteUtil.BCD2Int_BE(bs, index, index + 3) ; |
| | | int thisMoney = ByteUtil.BCD2Int_LE(bs, index, index + 3) ; |
| | | cdData.thisMoney = thisMoney/100.0D; |
| | | |
| | | index += 4 ; |
| | | cdData.thisDuration = ByteUtil.BCD2Int_BE(bs, index, index + 1) ; |
| | | cdData.thisDuration = ByteUtil.BCD2Int_LE(bs, index, index + 1) ; |
| | | |
| | | index += 2 ; |
| | | int waterPrice = ByteUtil.BCD2Int_BE(bs, index, index + 1) ; |
| | | int waterPrice = ByteUtil.BCD2Int_LE(bs, index, index + 1) ; |
| | | cdData.waterPrice = waterPrice/100.0D; |
| | | |
| | | index += 2 ; |
| | | int elePrice = ByteUtil.BCD2Int_BE(bs, index, index + 1) ; |
| | | int elePrice = ByteUtil.BCD2Int_LE(bs, index, index + 1) ; |
| | | cdData.elePrice = elePrice/100.0D; |
| | | |
| | | index += 2 ; |
| | | GlParse.parseAlarmAndState(bs, index, cdData) ; |
| | | |
| | | index += 2 ; |
| | | int aVolt = ByteUtil.BCD2Int_BE(bs, index, index + 1) ; |
| | | int aVolt = ByteUtil.BCD2Int_LE(bs, index, index + 1) ; |
| | | cdData.aVolt = aVolt/10.0D; |
| | | |
| | | index += 2 ; |
| | | int bVolt = ByteUtil.BCD2Int_BE(bs, index, index + 1) ; |
| | | int bVolt = ByteUtil.BCD2Int_LE(bs, index, index + 1) ; |
| | | cdData.bVolt = bVolt/10.0D; |
| | | |
| | | index += 2 ; |
| | | int cVolt = ByteUtil.BCD2Int_BE(bs, index, index + 1) ; |
| | | int cVolt = ByteUtil.BCD2Int_LE(bs, index, index + 1) ; |
| | | cdData.cVolt = cVolt/10.0D; |
| | | |
| | | index += 2 ; |
| | | int aCurrent = ByteUtil.BCD2Int_BE(bs, index, index + 1) ; |
| | | int aCurrent = ByteUtil.BCD2Int_LE(bs, index, index + 1) ; |
| | | cdData.aCurrent = aCurrent/10.0D; |
| | | |
| | | index += 2 ; |
| | | int bCurrent = ByteUtil.BCD2Int_BE(bs, index, index + 1) ; |
| | | int bCurrent = ByteUtil.BCD2Int_LE(bs, index, index + 1) ; |
| | | cdData.bCurrent = bCurrent/10.0D; |
| | | |
| | | index += 2 ; |
| | | int cCurrent = ByteUtil.BCD2Int_BE(bs, index, index + 1) ; |
| | | int cCurrent = ByteUtil.BCD2Int_LE(bs, index, index + 1) ; |
| | | cdData.cCurrent = cCurrent/10.0D; |
| | | |
| | | index += 2 ; |
| | | int batteryVolt = ByteUtil.BCD2Int_BE(bs, index, index + 1) ; |
| | | int batteryVolt = ByteUtil.BCD2Int_LE(bs, index, index + 1) ; |
| | | cdData.batteryVolt = batteryVolt/100.0D; |
| | | |
| | | index += 2 ; |
| | | int waterMeterTransVolt = ByteUtil.BCD2Int_BE(bs, index, index + 1) ; |
| | | int waterMeterTransVolt = ByteUtil.BCD2Int_LE(bs, index, index + 1) ; |
| | | cdData.waterMeterTransVolt = waterMeterTransVolt/100.0D; |
| | | |
| | | index += 2 ; |
| | | int waterMeterWorkVolt = ByteUtil.BCD2Int_BE(bs, index, index + 1) ; |
| | | int waterMeterWorkVolt = ByteUtil.BCD2Int_LE(bs, index, index + 1) ; |
| | | cdData.waterMeterWorkVolt = waterMeterWorkVolt/100.0D; |
| | | |
| | | index += 2 ; |
| | | cdData.csq = ByteUtil.BCD2Int_BE(bs, index, index) ; |
| | | cdData.csq = ByteUtil.BCD2Int_LE(bs, index, index) ; |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 分析功能93、A3和85数据 |
| | | * 分析功能85数据 |
| | | * @param bs |
| | | * @param cdData |
| | | * @throws Exception |
| | | */ |
| | | public static void parseCd93A3And85(byte[] bs, DataCd93_A3_85Vo cdData) throws Exception { |
| | | public static void parseCd85(byte[] bs, DataCd85Vo cdData) throws Exception { |
| | | int index = ProtocolConstantV206V202404.dataIndex ; |
| | | cdData.controllerType = ByteUtil.bytes2Hex(bs, false, index, 1) ; |
| | | |
| | | index++ ; |
| | | cdData.projectNo = (int)bs[index]; |
| | | |
| | | index ++ ; |
| | | cdData.opType = bs[index]; |
| | | |
| | | index++ ; |
| | | cdData.icCardAddr = ByteUtil.bytes2Hex(bs, false, index, 4) ; |
| | | |
| | | index += 4 ; |
| | | cdData.icCardNo = GlParse.parseIcCardNo(bs, index, 6, 2) ; |
| | | |
| | | index += 8 ; |
| | | cdData.orderNo = ByteUtil.BCD2String_BE(bs, index, index + 7) ; |
| | | |
| | | index += 8 ; |
| | | cdData.startDt = GlParse.parseRtuDt(bs, index) ; |
| | | |
| | | index += 6 ; |
| | | cdData.endDt = GlParse.parseRtuDt(bs, index) ; |
| | | |
| | | index += 6 ; |
| | | cdData.waterTotalAmount = ByteUtil.BCD2Long_LE(bs, index, index + 4)/100.0D ; |
| | | |
| | | index += 5 ; |
| | | cdData.eleTotalAmount = ByteUtil.BCD2Long_LE(bs, index, index + 4)/100.0D ; |
| | | |
| | | index += 5 ; |
| | | cdData.moneyRemain = ByteUtil.BCD2Long_LE(bs, index, index + 4)/100.0D ; |
| | | |
| | | index += 5 ; |
| | | cdData.waterRemain = ByteUtil.BCD2Long_LE(bs, index, index + 4)/100.0D ; |
| | | |
| | | index += 5 ; |
| | | cdData.thisEle = ByteUtil.BCD2Long_LE(bs, index, index + 3)/100.0D ; |
| | | |
| | | index += 4 ; |
| | | cdData.thisWater = ByteUtil.BCD2Long_LE(bs, index, index + 3)/100.0D ; |
| | | |
| | | index += 4 ; |
| | | cdData.thisMoney = ByteUtil.BCD2Long_LE(bs, index, index + 3)/100.0D ; |
| | | |
| | | index += 4 ; |
| | | cdData.thisDuration = ByteUtil.BCD2Int_LE(bs, index, index + 1) ; |
| | | |
| | | index += 2 ; |
| | | GlParse.parseAlarmAndState(bs, index, cdData) ; |
| | | } |
| | | /** |
| | | * 分析功能93、A3数据 |
| | | * @param bs |
| | | * @param cdData |
| | | * @throws Exception |
| | | */ |
| | | public static void parseCd93A3(byte[] bs, DataCd93_A3Vo cdData) throws Exception { |
| | | int index = ProtocolConstantV206V202404.dataIndex ; |
| | | cdData.controllerType = ByteUtil.bytes2Hex(bs, false, index, 1) ; |
| | | |
| | |
| | | index++ ; |
| | | cdData.icCardAddr = ByteUtil.bytes2Hex(bs, false, index, 4) ; |
| | | |
| | | index += 8 ; |
| | | index += 4 ; |
| | | cdData.icCardNo = GlParse.parseIcCardNo(bs, index, 6, 2) ; |
| | | |
| | | index += 8 ; |
| | | cdData.orderNo = ByteUtil.BCD2String_BE(bs, index, index + 7) ; |
| | | |
| | | index ++ ; |
| | | String mm = ByteUtil.BCD2String_LE(bs, index, index) ; |
| | | index ++ ; |
| | | String HH = ByteUtil.BCD2String_LE(bs, index, index) ; |
| | | index ++ ; |
| | | String dd = ByteUtil.BCD2String_LE(bs, index, index) ; |
| | | index ++ ; |
| | | String MM = ByteUtil.BCD2String_LE(bs, index, index) ; |
| | | cdData.startDt = MM + "月" + dd + "日" + HH + "时" + mm + "分" ; |
| | | index += 8 ; |
| | | cdData.startDt = GlParse.parseRtuDt(bs, index) ; |
| | | |
| | | index ++ ; |
| | | mm = ByteUtil.BCD2String_LE(bs, index, index) ; |
| | | index ++ ; |
| | | HH = ByteUtil.BCD2String_LE(bs, index, index) ; |
| | | index ++ ; |
| | | dd = ByteUtil.BCD2String_LE(bs, index, index) ; |
| | | index ++ ; |
| | | MM = ByteUtil.BCD2String_LE(bs, index, index) ; |
| | | cdData.endDt = MM + "月" + dd + "日" + HH + "时" + mm + "分" ; |
| | | index += 6 ; |
| | | cdData.endDt = GlParse.parseRtuDt(bs, index) ; |
| | | |
| | | index ++ ; |
| | | cdData.waterTotalAmount = ByteUtil.BCD2Int_BE(bs, index, index + 4)/100.0D ; |
| | | index += 6 ; |
| | | cdData.waterTotalAmount = ByteUtil.BCD2Long_LE(bs, index, index + 4)/100.0D ; |
| | | |
| | | index += 5 ; |
| | | cdData.eleTotalAmount = ByteUtil.BCD2Int_BE(bs, index, index + 4)/100.0D ; |
| | | cdData.eleTotalAmount = ByteUtil.BCD2Long_LE(bs, index, index + 4)/100.0D ; |
| | | |
| | | index += 5 ; |
| | | cdData.moneyRemain = ByteUtil.BCD2Int_BE(bs, index, index + 4)/100.0D ; |
| | | cdData.moneyRemain = ByteUtil.BCD2Long_LE(bs, index, index + 4)/100.0D ; |
| | | |
| | | index += 5 ; |
| | | cdData.waterRemain = ByteUtil.BCD2Int_BE(bs, index, index + 4)/100.0D ; |
| | | cdData.waterRemain = ByteUtil.BCD2Long_LE(bs, index, index + 4)/100.0D ; |
| | | |
| | | index += 5 ; |
| | | cdData.thisEle = ByteUtil.BCD2Int_BE(bs, index, index + 3)/100.0D ; |
| | | cdData.thisEle = ByteUtil.BCD2Long_LE(bs, index, index + 3)/100.0D ; |
| | | |
| | | index += 4 ; |
| | | cdData.thisWater = ByteUtil.BCD2Int_BE(bs, index, index + 3)/100.0D ; |
| | | cdData.thisWater = ByteUtil.BCD2Long_LE(bs, index, index + 3)/100.0D ; |
| | | |
| | | index += 4 ; |
| | | cdData.thisMoney = ByteUtil.BCD2Int_BE(bs, index, index + 3)/100.0D ; |
| | | cdData.thisMoney = ByteUtil.BCD2Long_LE(bs, index, index + 3)/100.0D ; |
| | | |
| | | index += 4 ; |
| | | cdData.thisDuration = ByteUtil.BCD2Int_BE(bs, index, index + 1) ; |
| | | cdData.thisDuration = ByteUtil.BCD2Int_LE(bs, index, index + 1) ; |
| | | |
| | | index += 2 ; |
| | | GlParse.parseAlarmAndState(bs, index, cdData) ; |