ncc协议x

This commit is contained in:
xzb 2023-06-07 14:57:17 +08:00
parent 9117df92bf
commit 86b4e39390
2 changed files with 77 additions and 1 deletions

View File

@ -66,7 +66,7 @@ public enum MessageId {
/**
* 司机驾驶里程报告
*/
DRIVER_DISTANCE_REPORT(0x0014, null),
DRIVER_DISTANCE_REPORT(0x0014, ()->new DriverDistanceReportResponse()),
/**
* 调度日志报告
*/

View File

@ -0,0 +1,76 @@
package club.joylink.xiannccda.ats.message.line3;
import club.joylink.xiannccda.ats.message.MessageResponse;
import io.netty.buffer.ByteBuf;
import java.util.ArrayList;
import java.util.List;
/**
* 2.8.5 司机驾驶里程报告消息
*/
public class DriverDistanceReportResponse extends MessageResponse {
/**
* 线路号(2)
*/
private Short lineId;
/**
* 查询标识号(2)<br>
* 同一时间多个查询的report_id不允许重复答复消息中的report_id值跟查询消息中的相同
*/
private Short reportId;
/**
* 消息总数(2)
*/
private Short totalMessage;
/**
* 本消息的顺序号(2)
*/
private Short messageSequence;
/**
* 记录条数(2)
*/
private Short count;
/**
* 司机驾驶列表
*/
private List<DriverCell> drivers;
@Override
public void decode2(ByteBuf buf) throws Exception {
this.lineId = buf.readShort();
this.reportId = buf.readShort();
this.totalMessage = buf.readShort();
this.messageSequence = buf.readShort();
this.count = buf.readShort();
this.drivers = new ArrayList<>(this.count);
for (int i = 0; i < this.count; i++) {
this.drivers.add(new DriverCell().decode(buf));
}
}
public static class DriverCell {
/**
* 日期(7)
*/
private byte[] date = new byte[7];
/**
* 司机号(13)
*/
private byte[] driverId = new byte[13];
/**
* 行驶距离(4)
*/
private Integer distance;
public DriverCell decode(final ByteBuf buf) {
buf.readBytes(this.date);
buf.readBytes(this.driverId);
this.distance = buf.readInt();
return this;
}
}
}