| | |
| | | * 解析报文 |
| | | */ |
| | | public UPWarnMsgAdptInfo decode(WarnMsg warnMsg) { |
| | | byte[] data = warnMsg.getData(); |
| | | ByteBuf byteBuf = Unpooled.wrappedBuffer(data); |
| | | this.vehicleNo = warnMsg.getVehicleNo(); |
| | | this.vehicleColor = warnMsg.getVehicleColor(); |
| | | this.dataType = warnMsg.getDataType(); |
| | | this.dataLength = warnMsg.getDataLength(); |
| | | |
| | | //报警信息来源 |
| | | this.warnSrc = byteBuf.readByte(); |
| | | //报警类型 |
| | | this.warnType = byteBuf.readShort(); |
| | | byte[] readableBytes = new byte[8]; |
| | | byteBuf.readBytes(readableBytes); |
| | | String time = ByteArrayUtil.bytes2HexStr(readableBytes); |
| | | //报警时间 |
| | | this.warnTime = Long.parseLong(time, 16); |
| | | //信息ID |
| | | this.infoId = byteBuf.readInt(); |
| | | //报警数据长度 |
| | | this.infoLength = byteBuf.readInt(); |
| | | //上报报警信息内容 |
| | | this.infoContent = Jtt809Util.readGBKString(byteBuf, this.infoLength); |
| | | try { |
| | | byte[] data = warnMsg.getData(); |
| | | ByteBuf byteBuf = Unpooled.wrappedBuffer(data); |
| | | this.vehicleNo = warnMsg.getVehicleNo(); |
| | | this.vehicleColor = warnMsg.getVehicleColor(); |
| | | this.dataType = warnMsg.getDataType(); |
| | | this.dataLength = warnMsg.getDataLength(); |
| | | |
| | | //报警信息来源 |
| | | this.warnSrc = byteBuf.readByte(); |
| | | //报警类型 |
| | | this.warnType = byteBuf.readShort(); |
| | | byte[] readableBytes = new byte[8]; |
| | | byteBuf.readBytes(readableBytes); |
| | | String time = ByteArrayUtil.bytes2HexStr(readableBytes); |
| | | //报警时间 |
| | | this.warnTime = Long.parseLong(time, 16); |
| | | //信息ID |
| | | this.infoId = byteBuf.readInt(); |
| | | //报警数据长度 |
| | | this.infoLength = byteBuf.readInt(); |
| | | //上报报警信息内容 |
| | | this.infoContent = Jtt809Util.readGBKString(byteBuf, this.infoLength); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | return this; |
| | | } |
| | | } |