| | |
| | | * 解析报文 |
| | | */ |
| | | public GnssData decode(ByteBuf byteBuf) { |
| | | this.encrypt = byteBuf.readByte(); |
| | | int d = byteBuf.readByte(); |
| | | int m = byteBuf.readByte(); |
| | | int y = byteBuf.readShort(); |
| | | this.date = y + "-" + String.format("%02d", m) + "-" + String.format("%02d", d); |
| | | int h = byteBuf.readByte(); |
| | | int mi = byteBuf.readByte(); |
| | | int s = byteBuf.readByte(); |
| | | this.time = String.format("%02d", h) + ":" + String.format("%02d", mi) + ":" + String.format("%02d", s); |
| | | this.lon = byteBuf.readInt(); |
| | | this.lat = byteBuf.readInt(); |
| | | this.vec1 = byteBuf.readShort(); |
| | | this.vec2 = byteBuf.readShort(); |
| | | this.vec3 = byteBuf.readInt(); |
| | | this.direction = byteBuf.readShort(); |
| | | this.altitude = byteBuf.readShort(); |
| | | this.state = byteBuf.readInt(); |
| | | this.alarm = byteBuf.readInt(); |
| | | try { |
| | | this.encrypt = byteBuf.readByte(); |
| | | int d = byteBuf.readByte(); |
| | | int m = byteBuf.readByte(); |
| | | int y = byteBuf.readShort(); |
| | | this.date = y + "-" + String.format("%02d", m) + "-" + String.format("%02d", d); |
| | | int h = byteBuf.readByte(); |
| | | int mi = byteBuf.readByte(); |
| | | int s = byteBuf.readByte(); |
| | | this.time = String.format("%02d", h) + ":" + String.format("%02d", mi) + ":" + String.format("%02d", s); |
| | | this.lon = byteBuf.readInt(); |
| | | this.lat = byteBuf.readInt(); |
| | | this.vec1 = byteBuf.readShort(); |
| | | this.vec2 = byteBuf.readShort(); |
| | | this.vec3 = byteBuf.readInt(); |
| | | this.direction = byteBuf.readShort(); |
| | | this.altitude = byteBuf.readShort(); |
| | | this.state = byteBuf.readInt(); |
| | | this.alarm = byteBuf.readInt(); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | return this; |
| | | } |
| | | } |