| | |
| | | import com.dy.common.mw.protocol.*; |
| | | import com.dy.common.mw.protocol.p206V1.*; |
| | | import com.dy.common.mw.protocol.p206V1.parse.global.GlParse; |
| | | import com.dy.common.mw.protocol.p206V1.upVos.DataCd81Vo; |
| | | import com.dy.common.mw.protocol.p206V1.upVos.DataCd83CloseVo; |
| | | import com.dy.common.mw.protocol.p206V1.upVos.DataCd83OpenVo; |
| | | import com.dy.common.mw.protocol.rtuState.ValveStateInfo; |
| | |
| | | @Override |
| | | public MidResult[] parse(Boolean isLowPower, CodeParseParams params, CodeParseCallback callback)throws Exception { |
| | | ParseParamsForUpV1 para = (ParseParamsForUpV1)params ; |
| | | int bsLen = new CommonV1().parseDataLen(para.upBuffer) ; |
| | | int bsLen = new CommonV1().parseDataLen4P206(para.upBuffer) ; |
| | | if(bsLen > 0){ |
| | | this.doParse(para.upBuffer, |
| | | bsLen, |
| | |
| | | } |
| | | } |
| | | |
| | | callback.callback(midRs.reportOrResponse_trueOrFalse); |
| | | return new MidResult[]{midRs, confirmCommand} ; |
| | | callback.callback(midRs.reportOrResponse_trueOrFalse, para.data.subData==null?null:((DataV1)(para.data.subData)).subData); |
| | | return new MidResult[]{confirmCommand, midRs} ; |
| | | } |
| | | /** |
| | | * 执行分析 |
| | |
| | | |
| | | short index = ProtocolConstantV206V1.dataIndex + 1 ; |
| | | //累计流量:5字节BCD码,取值范围0~99999999.99,单位为m3。 |
| | | int tpInt = ByteUtil.BCD2Int_LE(bs, index, index + 4) ; |
| | | cdData.totalAmount = tpInt/100.0 ; |
| | | long tpLong = ByteUtil.BCD2Long_LE(bs, index, index + 4) ; |
| | | cdData.totalAmount = tpLong/100.0 ; |
| | | |
| | | index += 5 ; |
| | | //用水户号数据格式:8字节低位在前高位在后。 |
| | | if(ByteUtil.bytesIsAll0xFF(bs, index, 8)){ |
| | | throw new Exception("IC卡号数据格式错误,8字节全部为0xFF,舍弃数据") ; |
| | | } |
| | | cdData.icCardNo = GlParse.parseIcCardNo(bs, index) ; |
| | | |
| | | index += 8 ; |
| | | //IC卡号格式:4字节HEX码低位在前高位在后。 |
| | | if(ByteUtil.bytesIsAll0xFF(bs, index, 4)){ |
| | | throw new Exception("IC地址数据格式错误,4字节全部为0xFF,舍弃数据") ; |
| | | } |
| | | cdData.icCardAddr = ByteUtil.bytes2Hex_LE(bs, false, index, 4) ; |
| | | |
| | | index += 4 ; |
| | | //用水户余额:用户余额4字节BCD码,取值范围0.00~999999.99,单位为元。 |
| | | tpInt = ByteUtil.BCD2Int_LE(bs, index, index + 3) ; |
| | | int tpInt = ByteUtil.BCD2Int_LE(bs, index, index + 3) ; |
| | | cdData.remainMoney = tpInt/100.0 ; |
| | | |
| | | index += 4 ; |
| | |
| | | |
| | | short index = ProtocolConstantV206V1.dataIndex + 1 ; |
| | | //累计流量:5字节BCD码,取值范围0~9999999999,单位为m3。 |
| | | int tpInt = ByteUtil.BCD2Int_LE(bs, index, index + 4) ; |
| | | cdData.totalAmount = tpInt/100.0 ; |
| | | long tpLong = ByteUtil.BCD2Long_LE(bs, index, index + 4) ; |
| | | cdData.totalAmount = tpLong/100.0 ; |
| | | |
| | | index += 5 ; |
| | | //用水户号数据格式:8字节低位在前高位在后。 |
| | | if(ByteUtil.bytesIsAll0xFF(bs, index, 8)){ |
| | | throw new Exception("IC卡号数据格式错误,8字节全部为0xFF,舍弃数据") ; |
| | | } |
| | | cdData.icCardNo = GlParse.parseIcCardNo(bs, index) ; |
| | | |
| | | index += 8 ; |
| | | //IC卡号格式:4字节HEX码低位在前高位在后。 |
| | | if(ByteUtil.bytesIsAll0xFF(bs, index, 4)){ |
| | | throw new Exception("IC地址数据格式错误,4字节全部为0xFF,舍弃数据") ; |
| | | } |
| | | cdData.icCardAddr = ByteUtil.bytes2Hex_LE(bs, false, index, 4) ; |
| | | |
| | | index += 4 ; |
| | | //用水户余额:用户余额4字节BCD码,取值范围0.00~999999.99,单位为元。 |
| | | tpInt = ByteUtil.BCD2Int_LE(bs, index, index + 3) ; |
| | | cdData.remainMoney = tpInt/100.0 ; |
| | | tpLong = ByteUtil.BCD2Long_LE(bs, index, index + 3) ; |
| | | cdData.remainMoney = tpLong/100.0 ; |
| | | |
| | | index += 4 ; |
| | | //用水户用水开始时间:6字节BCD码,顺序是年月日时分秒,其中公元年=2000+年。 |
| | |
| | | |
| | | index += 6 ; |
| | | //用水户本次用水量:累计流量5字节BCD码,取值范围0~9999999999,单位为m3。 |
| | | tpInt = ByteUtil.BCD2Int_LE(bs, index, index + 4) ; |
| | | cdData.thisAmount = tpInt/100.0 ; |
| | | tpLong = ByteUtil.BCD2Long_LE(bs, index, index + 4) ; |
| | | cdData.thisAmount = tpLong/100.0 ; |
| | | |
| | | index += 5 ; |
| | | //用水户本次消费金额:用户余额4字节BCD码,取值范围0.00~999999.99,单位为元。 |
| | | tpInt = ByteUtil.BCD2Int_LE(bs, index, index + 3) ; |
| | | cdData.thisMoney = tpInt/100.0 ; |
| | | tpLong = ByteUtil.BCD2Long_LE(bs, index, index + 3) ; |
| | | cdData.thisMoney = tpLong/100.0 ; |
| | | |
| | | index += 4 ; |
| | | //用水户本次用水时长:用水时长2字节BCD码,取值范围0~9999,单位为分钟。 |
| | | tpInt = ByteUtil.BCD2Int_LE(bs, index, index + 1) ; |
| | | int tpInt = ByteUtil.BCD2Int_LE(bs, index, index + 1) ; |
| | | cdData.thisTime = tpInt; |
| | | |
| | | index += 2 ; |
| | |
| | | Cd_83_Up obj = new Cd_83_Up() ; |
| | | //下面两条上报数据,IC卡编码都是非BCD编码而异常 |
| | | //String hex = "683C68B08485353448830200000000001000282353FE739444000001000313000101211615000101210000000000000000000200019000011518000101210A7B16"; |
| | | String hex = "683C68B05301154CEA8306001000000004343638483BBBB9E0001000001603000101215907000101210000000000000000000500019000015308000101210AF716"; |
| | | //String hex = "683C68B05301154CEA8306001000000004343638483BBBB9E0001000001603000101215907000101210000000000000000000500019000015308000101210AF716"; |
| | | String hex = "683868B0532328B90083074065840000FE00061010282353535B7F7691590100404022231024737F3F3F1FFF957296944239050000390001900000F916"; |
| | | byte[] bs = ByteUtil.hex2Bytes(hex) ; |
| | | |
| | | Data data = new Data() ; |
| | | data.setSubData(new DataV1()) ; |
| | | |
| | | int bsLen = new CommonV1().parseDataLen(bs) ; |
| | | int bsLen = new CommonV1().parseDataLen4P206(bs) ; |
| | | if(bsLen > 0){ |
| | | try { |
| | | obj.doParse(bs, |