|  |  |  | 
|---|
|  |  |  | package com.dy.common.mw.protocol.p206V1_0_0.parse.global; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.dy.common.mw.protocol.p206V1_0_0.DataAlarmVo; | 
|---|
|  |  |  | import com.dy.common.mw.protocol.p206V1_0_0.DataStateVo; | 
|---|
|  |  |  | 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 org.apache.logging.log4j.LogManager; | 
|---|
|  |  |  | import org.apache.logging.log4j.Logger; | 
|---|
|  |  |  | 
|---|
|  |  |  | private static final Logger log = LogManager.getLogger(GlParse.class); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static DataAlarmVo parseAlarm(byte[] bs, short index){ | 
|---|
|  |  |  | /* | 
|---|
|  |  |  | 11011111 (DF)  +  11111001 (F9) | 
|---|
|  |  |  | 报警: | 
|---|
|  |  |  | 蓄电池电压:报警 | 
|---|
|  |  |  | 漏损:报警 | 
|---|
|  |  |  | 仪表:报警 | 
|---|
|  |  |  | 阀门:报警 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | DataAlarmVo avo = new DataAlarmVo() ; | 
|---|
|  |  |  | byte b = bs[index] ; | 
|---|
|  |  |  | index++ ; | 
|---|
|  |  |  | avo.batteryVolt = (byte)(b & 0x2) ; | 
|---|
|  |  |  | avo.loss = (byte)(b & 0x8) ; | 
|---|
|  |  |  | avo.meter = (byte)(b & 0x20) ; | 
|---|
|  |  |  | avo.batteryVolt = (byte)((b & 0x2) >> 1) ; | 
|---|
|  |  |  | avo.meter = (byte)((b & 0x20) >> 5) ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | b = bs[index] ; | 
|---|
|  |  |  | avo.valve = (byte)(b & 0x20) ; | 
|---|
|  |  |  | b = bs[index + 1] ; | 
|---|
|  |  |  | avo.loss = (byte)((b & 0x2) >> 1) ; | 
|---|
|  |  |  | avo.valve = (byte)((b & 0x4) >> 2) ; | 
|---|
|  |  |  | return avo ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static DataStateVo parseState(byte[] bs, short index){ | 
|---|
|  |  |  | DataStateVo avo = new DataStateVo() ; | 
|---|
|  |  |  | byte b = bs[index] ; | 
|---|
|  |  |  | index++ ; | 
|---|
|  |  |  | avo.icCard = (byte)(b & 0x4) ; | 
|---|
|  |  |  | avo.working = (byte)(b & 0x8) ; | 
|---|
|  |  |  | avo.valve = (byte)(b & 0x20) ; | 
|---|
|  |  |  | avo.icCard = (byte)((b & 0x4) >> 2) ; | 
|---|
|  |  |  | avo.valveState = (byte)((b & 0x10) >> 4) ; | 
|---|
|  |  |  | avo.powerType = (byte)((b & 0x40) >> 6) ; | 
|---|
|  |  |  | return avo ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | index++ ; | 
|---|
|  |  |  | dt = ByteUtil.BCD2String_BE(bs, index, index) + " " + dt ;//日 | 
|---|
|  |  |  | index++ ; | 
|---|
|  |  |  | bs[index] = (byte)(bs[index] & 0x10); | 
|---|
|  |  |  | //bs[index] = (byte)(bs[index] & 0x10); | 
|---|
|  |  |  | dt = ByteUtil.BCD2String_BE(bs, index, index) + "-" + dt ;//月 | 
|---|
|  |  |  | index++ ; | 
|---|
|  |  |  | dt = "20" + ByteUtil.BCD2String_BE(bs, index, index) + "-" + dt ;//年 | 
|---|