收集模拟数据,事后删除

This commit is contained in:
tiger_zhou 2023-06-15 13:25:04 +08:00
parent 6c549b4b39
commit ddb8cd2b78
36 changed files with 1532 additions and 1317 deletions

View File

@ -133,6 +133,14 @@
</dependencies>
<build>
<!-- <resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>-->
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>

View File

@ -1,5 +1,6 @@
package club.joylink.xiannccda.ats.message;
import com.alibaba.fastjson2.annotation.JSONField;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.nio.ByteBuffer;
@ -29,8 +30,20 @@ public abstract class MessageData {
*/
@Setter
@Getter
@JSONField(serialize = false, deserialize = false)
MessageId msgId;
@JSONField(name = "msgId")
public Integer getState() {
return this.msgId.val;
}
@JSONField(name = "msgId")
public void setState(Integer code) {
MessageId messageId = MessageId.of(code);
this.msgId = messageId;
}
public MessageData(MessageId msgId, int contentLength) {
this.length = 8 + contentLength;
this.time = TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis());

View File

@ -9,6 +9,7 @@ import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
/**
* 2.8.10 操作命令消息
@ -19,6 +20,7 @@ import lombok.Getter;
*/
@Getter
@Setter
public class ActionReportResponse extends MessageResponse {
// public ActionReportResponse() {
@ -60,6 +62,7 @@ public class ActionReportResponse extends MessageResponse {
}
@Getter
@Setter
public static class ActionReportEntity implements ReadData<ActionReportEntity> {
/**

View File

@ -9,6 +9,7 @@ import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
/**
* 2.8.11 列车信息系统事件消息
@ -18,6 +19,7 @@ import lombok.Getter;
NCC FEP主动发起事件及告警信息查询OCC FEP收到此消息后发送列车信息系统事件给NCC
*/
@Getter
@Setter
public class AlarmReportResponse extends MessageResponse {
// public AlarmReportResponse() {
@ -58,6 +60,7 @@ public class AlarmReportResponse extends MessageResponse {
}
@Getter
@Setter
public static class AlarmReportEntity implements ReadData<AlarmReportEntity> {
/**

View File

@ -9,6 +9,7 @@ import io.netty.buffer.ByteBuf;
import java.time.LocalDateTime;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
/**
* 2.7.7 出入库派班计划消息
@ -29,6 +30,7 @@ import lombok.Getter;
当当天出入库派班计划发生变更时OCC FEP发送此信息给NCC
*/
@Getter
@Setter
public class DepotPlanResponse extends MessageResponse {
/*public DepotPlanResponse() {
@ -62,6 +64,7 @@ public class DepotPlanResponse extends MessageResponse {
}
@Getter
@Setter
public static class DepotPlanEntity implements ReadData<DepotPlanEntity> {
/**

View File

@ -8,6 +8,7 @@ import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
import io.netty.buffer.ByteBuf;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
/**
* 2.7.4 设备状态全体消息
@ -27,6 +28,7 @@ import lombok.Getter;
* 当某些线路集中站本身定时向OCC服务器发送全体数据时同时OCC FEP也会向NCC发全体数据这种情况下周期发送设备状态全体消息的间隔建议不小于600秒
*/
@Getter
@Setter
public class DeviceStatusBitmapResponse extends MessageResponse {
// public DeviceStatusBitmapResponse() {
@ -59,6 +61,7 @@ public class DeviceStatusBitmapResponse extends MessageResponse {
}
@Getter
@Setter
public static class DeviceTypeEntity implements ReadData<DeviceTypeEntity> {
/**
@ -94,6 +97,7 @@ public class DeviceStatusBitmapResponse extends MessageResponse {
}
@Getter
@Setter
public static class DeviceEntity implements ReadData<DeviceEntity> {
/**

View File

@ -6,6 +6,7 @@ import club.joylink.xiannccda.ats.message.line3.device.DeviceStatus;
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
import io.netty.buffer.ByteBuf;
import lombok.Getter;
import lombok.Setter;
/**
* 2.7.5 设备状态变化消息
@ -18,6 +19,7 @@ import lombok.Getter;
*/
@Getter
@Setter
public class DeviceStatusChangeResponse extends MessageResponse {
// public DeviceStatusChangeResponse() {

View File

@ -9,81 +9,83 @@ import lombok.Getter;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import lombok.Setter;
/**
* 2.8.6 调度日志报告消息
*/
@Getter
@Setter
public class DispatcherReportResponse 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<LogCell> logs;
/**
* 线路号(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<LogCell> logs;
@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.logs = new ArrayList<>(this.count);
for (int i = 0; i < this.count; i++) {
this.logs.add(new LogCell().decode(buf));
}
@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.logs = new ArrayList<>(this.count);
for (int i = 0; i < this.count; i++) {
this.logs.add(new LogCell().decode(buf));
}
}
@Getter
public static class LogCell {
@Getter
@Setter
public static class LogCell {
/**
* 日期(7)
*/
private LocalDateTime reportTime;
/**
* 调度员(32)
*/
private String userName;
/**
* 记录内容(256)
*/
private String logItem;
/**
* 日期(7)
*/
private LocalDateTime reportTime;
/**
* 调度员(32)
*/
private String userName;
/**
* 记录内容(256)
*/
private String logItem;
public LogCell decode(final ByteBuf buf) {
final byte[] reportTime = new byte[7];
final byte[] userName = new byte[32];
final byte[] logItem = new byte[256];
buf.readBytes(reportTime);
buf.readBytes(userName);
buf.readBytes(logItem);
//
this.reportTime = DateTimeUtil.convert(reportTime);
this.userName = new String(userName, MessageCons.STRING_CHARSET).trim();
this.logItem = new String(logItem, MessageCons.STRING_CHARSET).trim();
//
return this;
}
public LogCell decode(final ByteBuf buf) {
final byte[] reportTime = new byte[7];
final byte[] userName = new byte[32];
final byte[] logItem = new byte[256];
buf.readBytes(reportTime);
buf.readBytes(userName);
buf.readBytes(logItem);
//
this.reportTime = DateTimeUtil.convert(reportTime);
this.userName = new String(userName, MessageCons.STRING_CHARSET).trim();
this.logItem = new String(logItem, MessageCons.STRING_CHARSET).trim();
//
return this;
}
}
}

View File

@ -9,79 +9,82 @@ import lombok.Getter;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import lombok.Setter;
/**
* 2.8.5 司机驾驶里程报告消息
*/
@Getter
@Setter
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));
}
/**
* 线路号(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));
}
@Getter
public static class DriverCell {
/**
* 日期(7)
*/
private LocalDateTime date;
/**
* 司机号(13)
*/
private String driverId;
/**
* 行驶距离(4)
*/
private Integer distance;
}
public DriverCell decode(final ByteBuf buf) {
final byte[] date = new byte[7];
final byte[] driverId = new byte[13];
buf.readBytes(date);
buf.readBytes(driverId);
this.distance = buf.readInt();
//
this.date= DateTimeUtil.convert(date);
this.driverId=new String(driverId, MessageCons.STRING_CHARSET).trim();
//
return this;
}
@Getter
@Setter
public static class DriverCell {
/**
* 日期(7)
*/
private LocalDateTime date;
/**
* 司机号(13)
*/
private String driverId;
/**
* 行驶距离(4)
*/
private Integer distance;
public DriverCell decode(final ByteBuf buf) {
final byte[] date = new byte[7];
final byte[] driverId = new byte[13];
buf.readBytes(date);
buf.readBytes(driverId);
this.distance = buf.readInt();
//
this.date = DateTimeUtil.convert(date);
this.driverId = new String(driverId, MessageCons.STRING_CHARSET).trim();
//
return this;
}
}
}

View File

@ -7,169 +7,161 @@ import lombok.Getter;
import java.util.ArrayList;
import java.util.List;
import lombok.Setter;
/**
* 2.8.7 存备车报告消息
*/
@Getter
@Setter
public class GroupBakReportResponse 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<GroupBakCell> groups;
/**
* 线路号(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<GroupBakCell> groups;
@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.groups = new ArrayList<>(this.count);
for (int i = 0; i < this.count; i++) {
this.groups.add(new GroupBakCell().decode(buf));
}
@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.groups = new ArrayList<>(this.count);
for (int i = 0; i < this.count; i++) {
this.groups.add(new GroupBakCell().decode(buf));
}
}
@Getter
@Setter
public static class GroupBakCell {
/**
* 车组号(9)
*/
private String groupId;
/**
* 存备车状态(1)<br> 0x01:上线运营<br> 0x02:备车<br> 0x03:维修 <br>
*/
private GroupBakStatusEnum status;
/**
* 所处位置(1)<br> 0x01:车辆段1<br> 0x02:停车场1<br> 0x04:车辆段2<br> 0x08:停车场2<br>
*/
private GroupBakDepotEnum depot;
/**
* 所在轨道名称(20)
*/
private String trackName;
public GroupBakCell decode(final ByteBuf buf) {
final byte[] groupId = new byte[9];
byte status;
byte depot;
final byte[] trackName = new byte[20];
//
buf.readBytes(groupId);
status = buf.readByte();
depot = buf.readByte();
buf.readBytes(trackName);
//
this.groupId = new String(groupId, MessageCons.STRING_CHARSET).trim();
this.status = GroupBakStatusEnum.of(status);
this.depot = GroupBakDepotEnum.of(depot);
this.trackName = new String(trackName, MessageCons.STRING_CHARSET).trim();
return this;
}
}
/**
* 所处位置(1)<br> 0x01:车辆段1<br> 0x02:停车场1<br> 0x04:车辆段2<br> 0x08:停车场2<br>
*/
public static enum GroupBakDepotEnum {
/**
* 0x01:车辆段1
*/
Depot1(0x01),
/**
* 0x02:停车场1
*/
Parking1(0x02),
/**
* 0x04:车辆段2
*/
Depot2(0x04),
/**
* 0x08:停车场2
*/
Parking2(0x08),
;
private int depot;
private GroupBakDepotEnum(final int depot) {
this.depot = depot;
}
@Getter
public static class GroupBakCell {
/**
* 车组号(9)
*/
private String groupId;
/**
* 存备车状态(1)<br>
* 0x01:上线运营<br>
* 0x02:备车<br>
* 0x03:维修 <br>
*/
private GroupBakStatusEnum status;
/**
* 所处位置(1)<br>
* 0x01:车辆段1<br>
* 0x02:停车场1<br>
* 0x04:车辆段2<br>
* 0x08:停车场2<br>
*/
private GroupBakDepotEnum depot;
/**
* 所在轨道名称(20)
*/
private String trackName;
public GroupBakCell decode(final ByteBuf buf) {
final byte[] groupId = new byte[9];
byte status;
byte depot;
final byte[] trackName = new byte[20];
//
buf.readBytes(groupId);
status = buf.readByte();
depot = buf.readByte();
buf.readBytes(trackName);
//
this.groupId = new String(groupId, MessageCons.STRING_CHARSET).trim();
this.status = GroupBakStatusEnum.of(status);
this.depot = GroupBakDepotEnum.of(depot);
this.trackName = new String(trackName, MessageCons.STRING_CHARSET).trim();
return this;
}
public static GroupBakDepotEnum of(final int depot) {
for (final GroupBakDepotEnum stop : values()) {
if (depot == stop.depot) {
return stop;
}
}
return null;
}
}
/**
* 存备车状态(1)<br> 0x01:上线运营<br> 0x02:备车<br> 0x03:维修 <br>
*/
public static enum GroupBakStatusEnum {
/**
* 所处位置(1)<br>
* 0x01:车辆段1<br>
* 0x02:停车场1<br>
* 0x04:车辆段2<br>
* 0x08:停车场2<br>
* 0x01:上线运营
*/
public static enum GroupBakDepotEnum {
/**
* 0x01:车辆段1
*/
Depot1(0x01),
/**
* 0x02:停车场1
*/
Parking1(0x02),
/**
* 0x04:车辆段2
*/
Depot2(0x04),
/**
* 0x08:停车场2
*/
Parking2(0x08),
;
private int depot;
private GroupBakDepotEnum(final int depot) {
this.depot = depot;
}
public static GroupBakDepotEnum of(final int depot) {
for (final GroupBakDepotEnum stop : values()) {
if (depot == stop.depot) return stop;
}
return null;
}
}
Online(0x01),
/**
* 存备车状态(1)<br>
* 0x01:上线运营<br>
* 0x02:备车<br>
* 0x03:维修 <br>
* 0x02:备车
*/
public static enum GroupBakStatusEnum {
/**
* 0x01:上线运营
*/
Online(0x01),
/**
* 0x02:备车
*/
Bak(0x02),
/**
* 0x03:维修
*/
Repair(0x03),
;
private int state;
Bak(0x02),
/**
* 0x03:维修
*/
Repair(0x03),
;
private int state;
private GroupBakStatusEnum(final int state) {
this.state = state;
}
public static GroupBakStatusEnum of(final int state) {
for (final GroupBakStatusEnum gbse : values()) {
if (state == gbse.state) return gbse;
}
return null;
}
private GroupBakStatusEnum(final int state) {
this.state = state;
}
public static GroupBakStatusEnum of(final int state) {
for (final GroupBakStatusEnum gbse : values()) {
if (state == gbse.state) {
return gbse;
}
}
return null;
}
}
}

View File

@ -7,92 +7,94 @@ import lombok.Getter;
import java.util.ArrayList;
import java.util.List;
import lombok.Setter;
/**
* 2.8.4 车组运行里程报告消息
*/
@Getter
@Setter
public class GroupRunningReportResponse 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<GroupCell> groups;
/**
* 线路号(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<GroupCell> groups;
@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.groups = new ArrayList<>(this.count);
for (int i = 0; i < this.count; i++) {
this.groups.add(new GroupCell().decode(buf));
}
@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.groups = new ArrayList<>(this.count);
for (int i = 0; i < this.count; i++) {
this.groups.add(new GroupCell().decode(buf));
}
}
@Getter
public static class GroupCell {
@Getter
@Setter
public static class GroupCell {
/**
* 车组号(9)
*/
private String groupId;
/**
* 全运行距离(4)
*/
private Integer totalRunning;
/**
* 距上次月修距离(4)
*/
private Integer monthRepair;
/**
* 距上次定修距离(4)
*/
private Integer shelfRepair;
/**
* 距上次架修距离(4)
*/
private Integer periodRepair;
/**
* 距上次厂修距离(4)
*/
private Integer factoryRepair;
/**
* 车组号(9)
*/
private String groupId;
/**
* 全运行距离(4)
*/
private Integer totalRunning;
/**
* 距上次月修距离(4)
*/
private Integer monthRepair;
/**
* 距上次定修距离(4)
*/
private Integer shelfRepair;
/**
* 距上次架修距离(4)
*/
private Integer periodRepair;
/**
* 距上次厂修距离(4)
*/
private Integer factoryRepair;
public GroupCell decode(final ByteBuf buf) {
final byte[] groupId = new byte[9];
buf.readBytes(groupId);
this.groupId = new String(groupId, MessageCons.STRING_CHARSET).trim();
//
this.totalRunning = buf.readInt();
this.monthRepair = buf.readInt();
this.shelfRepair = buf.readInt();
this.periodRepair = buf.readInt();
this.factoryRepair = buf.readInt();
//
return this;
}
public GroupCell decode(final ByteBuf buf) {
final byte[] groupId = new byte[9];
buf.readBytes(groupId);
this.groupId = new String(groupId, MessageCons.STRING_CHARSET).trim();
//
this.totalRunning = buf.readInt();
this.monthRepair = buf.readInt();
this.shelfRepair = buf.readInt();
this.periodRepair = buf.readInt();
this.factoryRepair = buf.readInt();
//
return this;
}
}
}

View File

@ -7,111 +7,111 @@ import lombok.Getter;
import java.util.ArrayList;
import java.util.List;
import lombok.Setter;
/**
* 2.8.8 列车整备状态报告消息
*/
@Getter
@Setter
public class GroupStatusReportResponse 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<GroupStatusCell> groups;
/**
* 线路号(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<GroupStatusCell> groups;
@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.groups = new ArrayList<>(this.count);
for (int i = 0; i < this.count; i++) {
this.groups.add(new GroupStatusCell().decode(buf));
}
@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.groups = new ArrayList<>(this.count);
for (int i = 0; i < this.count; i++) {
this.groups.add(new GroupStatusCell().decode(buf));
}
}
@Getter
@Setter
public static class GroupStatusCell {
/**
* 车组号(9)
*/
private String groupId;
/**
* 列车位置(1)<br> 0x01:车辆段/停车场<br> 0x02: 正线<br>
*/
private GroupPositionEnum depot;
/**
* 整备状态(42)
*/
private byte[] status = new byte[42];
public GroupStatusCell decode(final ByteBuf buf) {
final byte[] groupId = new byte[9];
byte depot;
//
buf.readBytes(groupId);
depot = buf.readByte();
buf.readBytes(this.status);
//
this.groupId = new String(groupId, MessageCons.STRING_CHARSET).trim();
this.depot = GroupPositionEnum.of(depot);
//
return this;
}
}
/**
* 列车位置(1)<br> 0x01:车辆段/停车场<br> 0x02: 正线<br>
*/
public static enum GroupPositionEnum {
/**
* 0x01:车辆段/停车场
*/
DepotParting(0x01),
/**
* 0x02: 正线
*/
MainLine(0x02),
;
private int depot;
private GroupPositionEnum(final int depot) {
this.depot = depot;
}
@Getter
public static class GroupStatusCell {
/**
* 车组号(9)
*/
private String groupId;
/**
* 列车位置(1)<br>
* 0x01:车辆段/停车场<br>
* 0x02: 正线<br>
*/
private GroupPositionEnum depot;
/**
* 整备状态(42)
*/
private byte[] status = new byte[42];
public GroupStatusCell decode(final ByteBuf buf) {
final byte[] groupId = new byte[9];
byte depot;
//
buf.readBytes(groupId);
depot = buf.readByte();
buf.readBytes(this.status);
//
this.groupId = new String(groupId, MessageCons.STRING_CHARSET).trim();
this.depot = GroupPositionEnum.of(depot);
//
return this;
}
}
/**
* 列车位置(1)<br>
* 0x01:车辆段/停车场<br>
* 0x02: 正线<br>
*/
public static enum GroupPositionEnum {
/**
* 0x01:车辆段/停车场
*/
DepotParting(0x01),
/**
* 0x02: 正线
*/
MainLine(0x02),
;
private int depot;
private GroupPositionEnum(final int depot) {
this.depot = depot;
}
public static GroupPositionEnum of(final int depot) {
for (final GroupPositionEnum stop : values()) {
if (depot == stop.depot) return stop;
}
return null;
}
public static GroupPositionEnum of(final int depot) {
for (final GroupPositionEnum stop : values()) {
if (depot == stop.depot) {
return stop;
}
}
return null;
}
}
}

View File

@ -8,6 +8,7 @@ import io.netty.buffer.ByteBuf;
import java.time.LocalDateTime;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
/**
* 2.8.15 实际列车运行图消息
@ -20,6 +21,7 @@ import lombok.Getter;
*/
@Getter
@Setter
public class HistoryScheduleResponse extends MessageResponse {
// public HistoryScheduleResponse() {
@ -70,6 +72,7 @@ public class HistoryScheduleResponse extends MessageResponse {
}
@Getter
@Setter
public static class HistoryScheduleEntity implements ReadData<HistoryScheduleEntity> {
/**

View File

@ -7,53 +7,53 @@ import io.netty.buffer.ByteBuf;
import lombok.Getter;
import java.time.LocalDateTime;
import lombok.Setter;
/**
* 2.7.14 当天计划运行图参数消息
*/
@Getter
@Setter
public class InUsedScheduleParameterResponse extends MessageResponse {
/**
* 线路号(2)
*/
private Short lineId;
/**
* INUSED_SCHEDULE日期(7)
*/
private LocalDateTime date;
/**
* 参数是否有效(1)
* 0x01:参数有效
* 0x02:参数无效
*/
private Boolean valid;
/**
* 当天计划运行图图号(48)
*/
private String inUsedScheduleName;
/**
* 预留(8)
*/
private byte[] reserve = new byte[8];
/**
* 线路号(2)
*/
private Short lineId;
/**
* INUSED_SCHEDULE日期(7)
*/
private LocalDateTime date;
/**
* 参数是否有效(1) 0x01:参数有效 0x02:参数无效
*/
private Boolean valid;
/**
* 当天计划运行图图号(48)
*/
private String inUsedScheduleName;
/**
* 预留(8)
*/
private byte[] reserve = new byte[8];
@Override
public void decode2(ByteBuf buf) throws Exception {
final byte[] date = new byte[7];
byte valid;
final byte[] inUsedScheduleName = new byte[48];
//
this.lineId = buf.readShort();
buf.readBytes(date);
valid = buf.readByte();
buf.readBytes(inUsedScheduleName);
buf.readBytes(this.reserve);
//
this.date = DateTimeUtil.convert(date);
switch (valid) {
case 0x01 -> this.valid = true;
case 0x02 -> this.valid = false;
}
this.inUsedScheduleName = new String(inUsedScheduleName, MessageCons.STRING_CHARSET).trim();
@Override
public void decode2(ByteBuf buf) throws Exception {
final byte[] date = new byte[7];
byte valid;
final byte[] inUsedScheduleName = new byte[48];
//
this.lineId = buf.readShort();
buf.readBytes(date);
valid = buf.readByte();
buf.readBytes(inUsedScheduleName);
buf.readBytes(this.reserve);
//
this.date = DateTimeUtil.convert(date);
switch (valid) {
case 0x01 -> this.valid = true;
case 0x02 -> this.valid = false;
}
this.inUsedScheduleName = new String(inUsedScheduleName, MessageCons.STRING_CHARSET).trim();
}
}

View File

@ -8,6 +8,7 @@ import io.netty.buffer.ByteBuf;
import java.time.LocalDateTime;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
/**
* 2.8.14 计划列车运行图消息
@ -21,6 +22,7 @@ import lombok.Getter;
* 当OCC收到NCC ATS信息请求消息时发送当天计划列车运行信息给NCC
*/
@Getter
@Setter
public class InusedScheduleResponse extends MessageResponse {
// public InusedScheduleResponse() {
@ -67,6 +69,7 @@ public class InusedScheduleResponse extends MessageResponse {
}
@Getter
@Setter
public static class InusedScheduleEntity implements ReadData<InusedScheduleEntity> {
/**
@ -102,6 +105,7 @@ public class InusedScheduleResponse extends MessageResponse {
}
@Getter
@Setter
public static class EntityRecord implements ReadData<EntityRecord> {
/**

View File

@ -4,39 +4,41 @@ import club.joylink.xiannccda.ats.message.MessageResponse;
import club.joylink.xiannccda.ats.message.line3.MessageCons;
import io.netty.buffer.ByteBuf;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class MessageAlarmResponse extends MessageResponse {
/**
* 线路号(2)
*/
private Short lineId;
/**
* 报警事件产生的时间(4)
*/
private Long genTime;
/**
* 报警标识字符串(tagLen)
*/
private String tagId;
/**
* 报警内容(alarmLen)
*/
private String alarmContent;
/**
* 线路号(2)
*/
private Short lineId;
/**
* 报警事件产生的时间(4)
*/
private Long genTime;
/**
* 报警标识字符串(tagLen)
*/
private String tagId;
/**
* 报警内容(alarmLen)
*/
private String alarmContent;
@Override
public void decode2(ByteBuf buf) throws Exception {
this.lineId = buf.readShort();
this.genTime = buf.readUnsignedInt();
final short tagLen = buf.readShort();
final byte[] tagId = new byte[tagLen];
buf.readBytes(tagId);
final short alarmLen = buf.readShort();
final byte[] alarmContent = new byte[alarmLen];
buf.readBytes(alarmContent);
//
this.tagId = new String(tagId, MessageCons.STRING_CHARSET).trim();
this.alarmContent = new String(alarmContent, MessageCons.STRING_CHARSET).trim();
}
@Override
public void decode2(ByteBuf buf) throws Exception {
this.lineId = buf.readShort();
this.genTime = buf.readUnsignedInt();
final short tagLen = buf.readShort();
final byte[] tagId = new byte[tagLen];
buf.readBytes(tagId);
final short alarmLen = buf.readShort();
final byte[] alarmContent = new byte[alarmLen];
buf.readBytes(alarmContent);
//
this.tagId = new String(tagId, MessageCons.STRING_CHARSET).trim();
this.alarmContent = new String(alarmContent, MessageCons.STRING_CHARSET).trim();
}
}

View File

@ -5,6 +5,7 @@ import club.joylink.xiannccda.ats.message.MessageId;
import club.joylink.xiannccda.ats.message.MessageResponse;
import io.netty.buffer.ByteBuf;
import lombok.Getter;
import lombok.Setter;
/**
* 2.7.2 信息源网络状态消息
@ -14,6 +15,7 @@ import lombok.Getter;
* 当网络状态变化时发送此消息当NCC FEP与OCC FEP初始建立通信时OCC FEP也发送此消息
*/
@Getter
@Setter
public class NetworkAliveStatusResponse extends MessageResponse {
/**

View File

@ -3,82 +3,78 @@ package club.joylink.xiannccda.ats.message.line3.rep;
import club.joylink.xiannccda.ats.message.MessageResponse;
import io.netty.buffer.ByteBuf;
import lombok.Getter;
import lombok.Setter;
/**
* 2.8.2 查询结果开始消息
*/
@Getter
@Setter
public class ReportBeginResponse extends MessageResponse {
/**
* 线路号(2)
*/
private Short lineId;
/**
* 查询标识号(2)<br>
* 同一时间多个查询的report_id不允许重复答复消息中的report_id值跟查询消息中的相同
*/
private Short reportId;
/**
* 消息种类(2)<br>
* 1 车组运行里程报告<br>
* 2 司机驾驶里程报告<br>
* 3 调度日志报告<br>
* 4 存备车报告<br>
* 5 列车整备状态报告<br>
* 6 操作命令<br>
* 7 列车信息/系统事件<br>
*/
private ReportTypeEnum reportType;
/**
* 线路号(2)
*/
private Short lineId;
/**
* 查询标识号(2)<br> 同一时间多个查询的report_id不允许重复答复消息中的report_id值跟查询消息中的相同
*/
private Short reportId;
/**
* 消息种类(2)<br> 1 车组运行里程报告<br> 2 司机驾驶里程报告<br> 3 调度日志报告<br> 4 存备车报告<br> 5 列车整备状态报告<br> 6 操作命令<br> 7 列车信息/系统事件<br>
*/
private ReportTypeEnum reportType;
@Override
public void decode2(ByteBuf buf) throws Exception {
this.lineId = buf.readShort();
this.reportId=buf.readShort();
this.reportType=ReportTypeEnum.of(buf.readShort());
@Override
public void decode2(ByteBuf buf) throws Exception {
this.lineId = buf.readShort();
this.reportId = buf.readShort();
this.reportType = ReportTypeEnum.of(buf.readShort());
}
public static enum ReportTypeEnum {
/**
* 1 车组运行里程报告
*/
GROUP_RUNNING_REPORT(1),
/**
* 2 司机驾驶里程报告
*/
DRIVER_DISTANCE_REPORT(2),
/**
* 3 调度日志报告
*/
DISPATCHER_REPORT(3),
/**
* 4 存备车报告
*/
GROUP_BAK_REPORT(4),
/**
* 5 列车整备状态报告
*/
GROUP_STATUS_REPORT(5),
/**
* 6 操作命令
*/
ACTION_REPORT(6),
/**
* 7 列车信息/系统事件
*/
ALARM_REPORT(7),
;
private short type;
ReportTypeEnum(int type) {
this.type = (short) type;
}
public static enum ReportTypeEnum {
/**
* 1 车组运行里程报告
*/
GROUP_RUNNING_REPORT(1),
/**
* 2 司机驾驶里程报告
*/
DRIVER_DISTANCE_REPORT(2),
/**
* 3 调度日志报告
*/
DISPATCHER_REPORT(3),
/**
* 4 存备车报告
*/
GROUP_BAK_REPORT(4),
/**
* 5 列车整备状态报告
*/
GROUP_STATUS_REPORT(5),
/**
* 6 操作命令
*/
ACTION_REPORT(6),
/**
* 7 列车信息/系统事件
*/
ALARM_REPORT(7),
;
private short type;
ReportTypeEnum(int type) {
this.type = (short) type;
}
public static ReportTypeEnum of(int type) {
for (final ReportTypeEnum rt : values()) {
if (type == rt.type) return rt;
}
return null;
}
public static ReportTypeEnum of(int type) {
for (final ReportTypeEnum rt : values()) {
if (type == rt.type) {
return rt;
}
}
return null;
}
}
}

View File

@ -4,39 +4,33 @@ import club.joylink.xiannccda.ats.message.MessageResponse;
import club.joylink.xiannccda.ats.message.line3.rep.ReportBeginResponse;
import io.netty.buffer.ByteBuf;
import lombok.Getter;
import lombok.Setter;
/**
* 2.8.3 查询结果结束消息
*/
@Getter
@Setter
public class ReportEndResponse extends MessageResponse {
/**
* 线路号(2)
*/
private Short lineId;
/**
* 查询标识号(2)<br>
* 同一时间多个查询的report_id不允许重复答复消息中的report_id值跟查询消息中的相同
*/
private Short reportId;
/**
* 消息种类(2)<br>
* 1 车组运行里程报告<br>
* 2 司机驾驶里程报告<br>
* 3 调度日志报告<br>
* 4 存备车报告<br>
* 5 列车整备状态报告<br>
* 6 操作命令<br>
* 7 列车信息/系统事件<br>
*/
private ReportBeginResponse.ReportTypeEnum reportType;
/**
* 线路号(2)
*/
private Short lineId;
/**
* 查询标识号(2)<br> 同一时间多个查询的report_id不允许重复答复消息中的report_id值跟查询消息中的相同
*/
private Short reportId;
/**
* 消息种类(2)<br> 1 车组运行里程报告<br> 2 司机驾驶里程报告<br> 3 调度日志报告<br> 4 存备车报告<br> 5 列车整备状态报告<br> 6 操作命令<br> 7 列车信息/系统事件<br>
*/
private ReportBeginResponse.ReportTypeEnum reportType;
@Override
public void decode2(ByteBuf buf) throws Exception {
this.lineId = buf.readShort();
this.reportId=buf.readShort();
this.reportType= ReportBeginResponse.ReportTypeEnum.of(buf.readShort());
}
@Override
public void decode2(ByteBuf buf) throws Exception {
this.lineId = buf.readShort();
this.reportId = buf.readShort();
this.reportType = ReportBeginResponse.ReportTypeEnum.of(buf.readShort());
}
}

View File

@ -5,6 +5,7 @@ import club.joylink.xiannccda.ats.message.MessageResponse;
import io.netty.buffer.ByteBuf;
import java.util.Arrays;
import lombok.Getter;
import lombok.Setter;
/**
* 2.8.12 查询无结果消息
@ -17,11 +18,12 @@ import lombok.Getter;
*/
@Getter
@Setter
public class ReportNackResponse extends MessageResponse {
public ReportNackResponse() {
/*public ReportNackResponse() {
this.setMsgId(MessageId.REPORT_NACK);
}
}*/
/**
* 线路号(2)

View File

@ -6,36 +6,38 @@ import io.netty.buffer.ByteBuf;
import lombok.Getter;
import java.time.LocalDateTime;
import lombok.Setter;
/**
* 2.9.3.2 断点续传开始消息
*/
@Getter
@Setter
public class ResumeBeginAckResponse extends MessageResponse {
/**
* 线路号(2)
*/
private Short lineId;
/**
* 开始时间(7)
*/
private LocalDateTime beginTime;
/**
* 结束时间(7)
*/
private LocalDateTime endTime;
/**
* 线路号(2)
*/
private Short lineId;
/**
* 开始时间(7)
*/
private LocalDateTime beginTime;
/**
* 结束时间(7)
*/
private LocalDateTime endTime;
@Override
public void decode2(ByteBuf buf) throws Exception {
final byte[] beginTime = new byte[7];
final byte[] endTime = new byte[7];
//
this.lineId = buf.readShort();
buf.readBytes(beginTime);
buf.readBytes(endTime);
//
this.beginTime = DateTimeUtil.convert(beginTime);
this.endTime = DateTimeUtil.convert(endTime);
}
@Override
public void decode2(ByteBuf buf) throws Exception {
final byte[] beginTime = new byte[7];
final byte[] endTime = new byte[7];
//
this.lineId = buf.readShort();
buf.readBytes(beginTime);
buf.readBytes(endTime);
//
this.beginTime = DateTimeUtil.convert(beginTime);
this.endTime = DateTimeUtil.convert(endTime);
}
}

View File

@ -7,50 +7,52 @@ import lombok.Getter;
import java.util.ArrayList;
import java.util.List;
import lombok.Setter;
/**
* 2.9.3.3 断点续传数据消息
*/
@Getter
@Setter
public class ResumeDataResponse extends MessageResponse {
/**
* 线路号(2)
*/
private Short lineId;
/**
* 消息总数(2)
*/
private Short totalMessage;
/**
* 本消息的顺序号(2)
*/
private Short messageSequence;
/**
* 消息message_data的数量(2)
*/
private Short msgCnt;
/**
* 补传的消息(全部为响应类消息)消息格式内容和本接口协议定义的消息格式一致时间戳保持与实时发送时的一致
*/
private List<MessageResponse> messageData;
/**
* 线路号(2)
*/
private Short lineId;
/**
* 消息总数(2)
*/
private Short totalMessage;
/**
* 本消息的顺序号(2)
*/
private Short messageSequence;
/**
* 消息message_data的数量(2)
*/
private Short msgCnt;
/**
* 补传的消息(全部为响应类消息)消息格式内容和本接口协议定义的消息格式一致时间戳保持与实时发送时的一致
*/
private List<MessageResponse> messageData;
@Override
public void decode2(ByteBuf buf) throws Exception {
this.lineId = buf.readShort();
this.totalMessage = buf.readShort();
this.messageSequence = buf.readShort();
this.msgCnt = buf.readShort();
this.messageData = new ArrayList<>(this.msgCnt);
//
for (int i = 0; i < this.msgCnt; i++) {
final int _readIndex = buf.readerIndex();
buf.skipBytes(8);
final MessageId messageId = MessageId.of(buf.readShort());
buf.readerIndex(_readIndex);
final MessageResponse messageResponse = messageId.createResponse();
messageResponse.decode(buf);
this.messageData.add(messageResponse);
}
@Override
public void decode2(ByteBuf buf) throws Exception {
this.lineId = buf.readShort();
this.totalMessage = buf.readShort();
this.messageSequence = buf.readShort();
this.msgCnt = buf.readShort();
this.messageData = new ArrayList<>(this.msgCnt);
//
for (int i = 0; i < this.msgCnt; i++) {
final int _readIndex = buf.readerIndex();
buf.skipBytes(8);
final MessageId messageId = MessageId.of(buf.readShort());
buf.readerIndex(_readIndex);
final MessageResponse messageResponse = messageId.createResponse();
messageResponse.decode(buf);
this.messageData.add(messageResponse);
}
}
}

View File

@ -6,36 +6,38 @@ import io.netty.buffer.ByteBuf;
import lombok.Getter;
import java.time.LocalDateTime;
import lombok.Setter;
/**
* 2.9.3.4 断点续传结束消息
*/
@Getter
@Setter
public class ResumeEndAckResponse extends MessageResponse {
/**
* 线路号(2)
*/
private Short lineId;
/**
* 开始时间(7)
*/
private LocalDateTime beginTime;
/**
* 结束时间(7)
*/
private LocalDateTime endTime;
/**
* 线路号(2)
*/
private Short lineId;
/**
* 开始时间(7)
*/
private LocalDateTime beginTime;
/**
* 结束时间(7)
*/
private LocalDateTime endTime;
@Override
public void decode2(ByteBuf buf) throws Exception {
final byte[] beginTime = new byte[7];
final byte[] endTime = new byte[7];
//
this.lineId = buf.readShort();
buf.readBytes(beginTime);
buf.readBytes(endTime);
//
this.beginTime = DateTimeUtil.convert(beginTime);
this.endTime = DateTimeUtil.convert(endTime);
}
@Override
public void decode2(ByteBuf buf) throws Exception {
final byte[] beginTime = new byte[7];
final byte[] endTime = new byte[7];
//
this.lineId = buf.readShort();
buf.readBytes(beginTime);
buf.readBytes(endTime);
//
this.beginTime = DateTimeUtil.convert(beginTime);
this.endTime = DateTimeUtil.convert(endTime);
}
}

View File

@ -7,6 +7,7 @@ import io.netty.buffer.ByteBuf;
import java.util.Arrays;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
/**
@ -24,6 +25,7 @@ import lombok.Getter;
*/
@Getter
@Setter
public class SignalRouteStatusResponse extends MessageResponse {
public SignalRouteStatusResponse() {
@ -55,6 +57,7 @@ public class SignalRouteStatusResponse extends MessageResponse {
}
@Getter
@Setter
public static class SignalStatusEntity implements ReadData<SignalStatusEntity> {
/**
@ -81,6 +84,7 @@ public class SignalRouteStatusResponse extends MessageResponse {
}
@Getter
@Setter
public static class RouteStatusEntity implements ReadData<RouteStatusEntity> {
/**

View File

@ -8,135 +8,132 @@ import lombok.Getter;
import java.util.ArrayList;
import java.util.List;
import lombok.Setter;
/**
* 2.7.13 列车阻塞消息
*/
@Getter
@Setter
public class TrainBlockInfoResponse extends MessageResponse {
/**
* 线路号(2)
*/
private Short lineId;
/**
* 列车数量(2)
*/
private Short trainCnt;
/**
* 列车列表
*/
private List<TrainCell> trains;
/**
* 线路号(2)
*/
private Short lineId;
/**
* 列车数量(2)
*/
private Short trainCnt;
/**
* 列车列表
*/
private List<TrainCell> trains;
@Override
public void decode2(ByteBuf buf) throws Exception {
this.lineId = buf.readShort();
this.trainCnt = buf.readShort();
this.trains = new ArrayList<>(this.trainCnt);
for (int cnt = 0; cnt < this.trainCnt; cnt++) {
this.trains.add(new TrainCell().decode(buf));
}
@Override
public void decode2(ByteBuf buf) throws Exception {
this.lineId = buf.readShort();
this.trainCnt = buf.readShort();
this.trains = new ArrayList<>(this.trainCnt);
for (int cnt = 0; cnt < this.trainCnt; cnt++) {
this.trains.add(new TrainCell().decode(buf));
}
}
@Getter
@Setter
public static class TrainCell {
/**
* 列车编组号(9)
*/
private String groupId;
/**
* 表号(9)
*/
private String trainId;
/**
* 方向(1) 0上行 1下行 2未知
*/
private DirectionEnum direction;
/**
* 列车所在区间左边车站的站号(2)
*/
private Short stationIdInUpSide;
/**
* 列车所在区间右边车站的站号(2)
*/
private Short stationIdInDownSide;
/**
* 集中站站号(2)
*/
private Short rtuId;
/**
* 列车所在的设备的类型(2)
*/
private DeviceType devType;
/**
* 列车所在的设备的名称(24)
*/
private String devName;
/**
* 列车阻塞标记(1) 1列车阻塞 0列车没有阻塞
*/
private Boolean blockFlag;
private TrainCell decode(final ByteBuf buf) {
final byte[] groupId = new byte[9];
final byte[] trainId = new byte[9];
byte direction;
final byte[] devName = new byte[24];
byte blockFlag;
short devType;
//
buf.readBytes(groupId);
buf.readBytes(trainId);
direction = buf.readByte();
this.stationIdInUpSide = buf.readShort();
this.stationIdInDownSide = buf.readShort();
this.rtuId = buf.readShort();
devType = buf.readShort();
buf.readBytes(devName);
blockFlag = buf.readByte();
//
this.groupId = new String(groupId, MessageCons.STRING_CHARSET).trim();
this.trainId = new String(trainId, MessageCons.STRING_CHARSET).trim();
this.devType = DeviceType.of(devType);
this.devName = new String(devName, MessageCons.STRING_CHARSET).trim();
this.direction = DirectionEnum.of(direction);
switch (blockFlag) {
case 1 -> this.blockFlag = true;
case 0 -> this.blockFlag = false;
}
//
return this;
}
}
/**
* 方向(1) 0上行 1下行 2未知
*/
public static enum DirectionEnum {
Up(0),
Down(1),
Unknown(2),
;
private int value;
private DirectionEnum(final int value) {
this.value = value;
}
@Getter
public static class TrainCell {
/**
* 列车编组号(9)
*/
private String groupId;
/**
* 表号(9)
*/
private String trainId;
/**
* 方向(1)
* 0上行
* 1下行
* 2未知
*/
private DirectionEnum direction;
/**
* 列车所在区间左边车站的站号(2)
*/
private Short stationIdInUpSide;
/**
* 列车所在区间右边车站的站号(2)
*/
private Short stationIdInDownSide;
/**
* 集中站站号(2)
*/
private Short rtuId;
/**
* 列车所在的设备的类型(2)
*/
private DeviceType devType;
/**
* 列车所在的设备的名称(24)
*/
private String devName;
/**
* 列车阻塞标记(1)
* 1列车阻塞
* 0列车没有阻塞
*/
private Boolean blockFlag;
private TrainCell decode(final ByteBuf buf) {
final byte[] groupId = new byte[9];
final byte[] trainId = new byte[9];
byte direction;
final byte[] devName = new byte[24];
byte blockFlag;
short devType;
//
buf.readBytes(groupId);
buf.readBytes(trainId);
direction = buf.readByte();
this.stationIdInUpSide = buf.readShort();
this.stationIdInDownSide = buf.readShort();
this.rtuId = buf.readShort();
devType = buf.readShort();
buf.readBytes(devName);
blockFlag = buf.readByte();
//
this.groupId = new String(groupId, MessageCons.STRING_CHARSET).trim();
this.trainId = new String(trainId, MessageCons.STRING_CHARSET).trim();
this.devType = DeviceType.of(devType);
this.devName = new String(devName, MessageCons.STRING_CHARSET).trim();
this.direction = DirectionEnum.of(direction);
switch (blockFlag) {
case 1 -> this.blockFlag = true;
case 0 -> this.blockFlag = false;
}
//
return this;
}
}
/**
* 方向(1)
* 0上行
* 1下行
* 2未知
*/
public static enum DirectionEnum {
Up(0),
Down(1),
Unknown(2),
;
private int value;
private DirectionEnum(final int value) {
this.value = value;
}
public static DirectionEnum of(final int value) {
for (final DirectionEnum direction : values()) {
if (direction.value == value) return direction;
}
return DirectionEnum.Unknown;
}
public static DirectionEnum of(final int value) {
for (final DirectionEnum direction : values()) {
if (direction.value == value) {
return direction;
}
}
return DirectionEnum.Unknown;
}
}
}

View File

@ -10,158 +10,161 @@ import lombok.Getter;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import lombok.Setter;
/**
* 2.7.9列车信息全体消息
*/
@Getter
@Setter
public class TrainIndicationInitResponse extends MessageResponse {
/**
* 线路号(2)
*/
private Short lineId;
/**
* 列车数量(2)
*/
private Short trainCnt;
/**
* 列车列表
*/
private List<TrainCell> trains;
/**
* 线路号(2)
*/
private Short lineId;
/**
* 列车数量(2)
*/
private Short trainCnt;
/**
* 列车列表
*/
private List<TrainCell> trains;
@Override
public void decode2(ByteBuf buf) throws Exception {
this.lineId = buf.readShort();
this.trainCnt = buf.readShort();
this.trains = new ArrayList<>(this.trainCnt);
for (int cnt = 0; cnt < trainCnt; cnt++) {
this.trains.add(new TrainCell().decode(buf));
}
@Override
public void decode2(ByteBuf buf) throws Exception {
this.lineId = buf.readShort();
this.trainCnt = buf.readShort();
this.trains = new ArrayList<>(this.trainCnt);
for (int cnt = 0; cnt < trainCnt; cnt++) {
this.trains.add(new TrainCell().decode(buf));
}
}
@Getter
public static class TrainCell {
@Getter
@Setter
public static class TrainCell {
/**
* 集中站站号(2)
*/
private Short rtuId;
/**
* NCC车次窗编号(2)
*/
private Short nccWindow;
/**
* 列车在车次窗中的位置(1)
*/
private Byte nccWindowOffset;
/**
* 列车所在的设备的类型(2)
*/
private DeviceType devType;
/**
* 列车所在的设备的名称(24)
*/
private String devName;
/**
* 列车标示号全线唯一若无法提供缺省值为0(10)
*/
private String trainIndex;
/**
* 列车编组号(9)
*/
private String groupId;
/**
* 表号(9)
*/
private String trainId;
/**
* 车次号(12)
*/
private String globalId;
/**
* 目的地号(4)
*/
private Integer destinationId;
/**
* 编组数量(1)
*/
private byte rollingStock;
/**
* 司机号(13)
*/
private String driverId;
/**
* 根据实际报点和计划的偏离时间单位-215- +215 正数表示列车晚点秒数负数表示列车早点秒数(4)
*/
private Integer otpTime;
/**
* 列车状态见附录6.3.14列车状态定义(4)
*/
private Integer mode;
/**
* 列车到点(7)
*/
private LocalDateTime arriveTime;
/**
* 列车发点(7)
*/
private LocalDateTime departTime;
/**
* 满载率百分比例如50表示满载率为50%(4)
*/
private Integer rate;
/**
* 速度KM/H(1)
*/
private byte speed;
/**
* 预留(2)
*/
private byte[] reserve = new byte[2];
/**
* 集中站站号(2)
*/
private Short rtuId;
/**
* NCC车次窗编号(2)
*/
private Short nccWindow;
/**
* 列车在车次窗中的位置(1)
*/
private Byte nccWindowOffset;
/**
* 列车所在的设备的类型(2)
*/
private DeviceType devType;
/**
* 列车所在的设备的名称(24)
*/
private String devName;
/**
* 列车标示号全线唯一若无法提供缺省值为0(10)
*/
private String trainIndex;
/**
* 列车编组号(9)
*/
private String groupId;
/**
* 表号(9)
*/
private String trainId;
/**
* 车次号(12)
*/
private String globalId;
/**
* 目的地号(4)
*/
private Integer destinationId;
/**
* 编组数量(1)
*/
private byte rollingStock;
/**
* 司机号(13)
*/
private String driverId;
/**
* 根据实际报点和计划的偏离时间单位-215- +215 正数表示列车晚点秒数负数表示列车早点秒数(4)
*/
private Integer otpTime;
/**
* 列车状态见附录6.3.14列车状态定义(4)
*/
private Integer mode;
/**
* 列车到点(7)
*/
private LocalDateTime arriveTime;
/**
* 列车发点(7)
*/
private LocalDateTime departTime;
/**
* 满载率百分比例如50表示满载率为50%(4)
*/
private Integer rate;
/**
* 速度KM/H(1)
*/
private byte speed;
/**
* 预留(2)
*/
private byte[] reserve = new byte[2];
private TrainCell decode(final ByteBuf buf) {
short devType;
final byte[] devName = new byte[24];
final byte[] trainIndex = new byte[10];
final byte[] groupId = new byte[9];
final byte[] trainId = new byte[9];
final byte[] globalId = new byte[12];
final byte[] driverId = new byte[13];
final byte[] arriveTime = new byte[7];
final byte[] departTime = new byte[7];
//
this.rtuId = buf.readShort();
this.nccWindow = buf.readShort();
this.nccWindowOffset = buf.readByte();
devType = buf.readShort();
buf.readBytes(devName);
buf.readBytes(trainIndex);
buf.readBytes(groupId);
buf.readBytes(trainId);
buf.readBytes(globalId);
this.destinationId = buf.readInt();
this.rollingStock = buf.readByte();
buf.readBytes(driverId);
this.otpTime = buf.readInt();
this.mode = buf.readInt();
buf.readBytes(arriveTime);
buf.readBytes(departTime);
this.rate = buf.readInt();
this.speed = buf.readByte();
buf.readBytes(this.reserve);
//
this.devType = DeviceType.of(devType);
this.devName = new String(devName, MessageCons.STRING_CHARSET).trim();
this.trainIndex = new String(trainIndex, MessageCons.STRING_CHARSET).trim();
this.groupId = new String(groupId, MessageCons.STRING_CHARSET).trim();
this.trainId = new String(trainId, MessageCons.STRING_CHARSET).trim();
this.globalId = new String(globalId, MessageCons.STRING_CHARSET).trim();
this.driverId = new String(driverId, MessageCons.STRING_CHARSET).trim();
this.arriveTime = DateTimeUtil.convert(arriveTime);
this.departTime = DateTimeUtil.convert(departTime);
//
return this;
}
private TrainCell decode(final ByteBuf buf) {
short devType;
final byte[] devName = new byte[24];
final byte[] trainIndex = new byte[10];
final byte[] groupId = new byte[9];
final byte[] trainId = new byte[9];
final byte[] globalId = new byte[12];
final byte[] driverId = new byte[13];
final byte[] arriveTime = new byte[7];
final byte[] departTime = new byte[7];
//
this.rtuId = buf.readShort();
this.nccWindow = buf.readShort();
this.nccWindowOffset = buf.readByte();
devType = buf.readShort();
buf.readBytes(devName);
buf.readBytes(trainIndex);
buf.readBytes(groupId);
buf.readBytes(trainId);
buf.readBytes(globalId);
this.destinationId = buf.readInt();
this.rollingStock = buf.readByte();
buf.readBytes(driverId);
this.otpTime = buf.readInt();
this.mode = buf.readInt();
buf.readBytes(arriveTime);
buf.readBytes(departTime);
this.rate = buf.readInt();
this.speed = buf.readByte();
buf.readBytes(this.reserve);
//
this.devType = DeviceType.of(devType);
this.devName = new String(devName, MessageCons.STRING_CHARSET).trim();
this.trainIndex = new String(trainIndex, MessageCons.STRING_CHARSET).trim();
this.groupId = new String(groupId, MessageCons.STRING_CHARSET).trim();
this.trainId = new String(trainId, MessageCons.STRING_CHARSET).trim();
this.globalId = new String(globalId, MessageCons.STRING_CHARSET).trim();
this.driverId = new String(driverId, MessageCons.STRING_CHARSET).trim();
this.arriveTime = DateTimeUtil.convert(arriveTime);
this.departTime = DateTimeUtil.convert(departTime);
//
return this;
}
}
}

View File

@ -5,65 +5,67 @@ import club.joylink.xiannccda.ats.message.line3.MessageCons;
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
import io.netty.buffer.ByteBuf;
import lombok.Getter;
import lombok.Setter;
/**
* 2.7.11 列车信息删除消息
*/
@Getter
@Setter
public class TrainIndicationRemoveResponse extends MessageResponse {
/**
* 线路号(2)
*/
private Short lineId;
/**
* 集中站站号(2)
*/
private Short rtuId;
/**
* NCC车次窗编号(2)
*/
private Short nccWindow;
/**
* 列车在车次窗中的位置(1)
*/
private Byte nccWindowOffset;
/**
* 列车所在的设备的类型(2)
*/
private DeviceType devType;
/**
* 列车所在的设备的名称(24)
*/
private String devName;
/**
* 列车标示号全线唯一若无法提供缺省值为0(10)
*/
private String trainIndex;
/**
* 列车编组号(9)
*/
private String groupId;
/**
* 线路号(2)
*/
private Short lineId;
/**
* 集中站站号(2)
*/
private Short rtuId;
/**
* NCC车次窗编号(2)
*/
private Short nccWindow;
/**
* 列车在车次窗中的位置(1)
*/
private Byte nccWindowOffset;
/**
* 列车所在的设备的类型(2)
*/
private DeviceType devType;
/**
* 列车所在的设备的名称(24)
*/
private String devName;
/**
* 列车标示号全线唯一若无法提供缺省值为0(10)
*/
private String trainIndex;
/**
* 列车编组号(9)
*/
private String groupId;
@Override
public void decode2(ByteBuf buf) throws Exception {
short devType;
final byte[] devName = new byte[24];
final byte[] trainIndex = new byte[10];
final byte[] groupId = new byte[9];
//
this.lineId = buf.readShort();
this.rtuId = buf.readShort();
this.nccWindow = buf.readShort();
this.nccWindowOffset = buf.readByte();
devType = buf.readShort();
buf.readBytes(devName);
buf.readBytes(trainIndex);
buf.readBytes(groupId);
//
this.devType = DeviceType.of(devType);
this.devName = new String(devName, MessageCons.STRING_CHARSET).trim();
this.trainIndex = new String(trainIndex, MessageCons.STRING_CHARSET).trim();
this.groupId = new String(groupId, MessageCons.STRING_CHARSET).trim();
}
@Override
public void decode2(ByteBuf buf) throws Exception {
short devType;
final byte[] devName = new byte[24];
final byte[] trainIndex = new byte[10];
final byte[] groupId = new byte[9];
//
this.lineId = buf.readShort();
this.rtuId = buf.readShort();
this.nccWindow = buf.readShort();
this.nccWindowOffset = buf.readByte();
devType = buf.readShort();
buf.readBytes(devName);
buf.readBytes(trainIndex);
buf.readBytes(groupId);
//
this.devType = DeviceType.of(devType);
this.devName = new String(devName, MessageCons.STRING_CHARSET).trim();
this.trainIndex = new String(trainIndex, MessageCons.STRING_CHARSET).trim();
this.groupId = new String(groupId, MessageCons.STRING_CHARSET).trim();
}
}

View File

@ -9,164 +9,165 @@ import io.netty.buffer.ByteBuf;
import lombok.Getter;
import java.time.LocalDateTime;
import lombok.Setter;
/**
* 2.7.10 列车信息更新消息[增加/更新]
*/
@Getter
@Setter
public class TrainIndicationUpdateResponse extends MessageResponse {
/**
* 线路号(2)
*/
private Short lineId;
/**
* 线路号(2)
*/
private Short lineId;
/**
* 车次号变化状态(2) 0x01增加<br> 0x02更新<br> true-更新false-增加
*/
private Boolean type;
/**
* 集中站站号(2)
*/
private Short rtuId;
/**
* NCC车次窗编号(2)
*/
private Short nccWindow;
/**
* 列车在车次窗中的位置(1)
*/
private Byte nccWindowOffset;
/**
* 列车所在的设备的类型(2)
*/
private DeviceType devType;
/**
* 列车所在的设备的名称(24)
*/
private String devName;
/**
* 列车标示号全线唯一若无法提供缺省值为0(10)
*/
private String trainIndex;
/**
* 列车编组号(9)
*/
private String groupId;
/**
* 表号(9)
*/
private String trainId;
/**
* 车次号(12)
*/
private String globalId;
/**
* 目的地号(4)
*/
private Integer destinationId;
/**
* 编组数量(1)
*/
private byte rollingStock;
/**
* 司机号(13)
*/
private String driverId;
/**
* 运行路径号若无法提供缺省值为0(2)
*/
private Short routeId;
/**
* 计划偏离时间(4)
*/
private Integer optTime;
/**
* 列车状态见附录6.3.14列车状态定义(4)
*/
private Integer mode;
/**
* 列车到点(7)
*/
private LocalDateTime arriveTime;
/**
* 列车发点(7)
*/
private LocalDateTime departTime;
/**
* 满载率百分比例如50表示满载率为50%(4)
*/
private Integer rate;
/**
* 速度KM/H(1)
*/
private byte speed;
/**
* 预留(2)
*/
private byte[] reserve = new byte[2];
/**
* 列车是否有 trainMode对应的状态
*/
public boolean havingState(final DeviceStatus.TRAIN_MODE trainMode) {
return trainMode.is(mode);
}
@Override
public void decode2(ByteBuf buf) throws Exception {
short devType;
short type;
final byte[] devName = new byte[24];
final byte[] trainIndex = new byte[10];
final byte[] groupId = new byte[9];
final byte[] trainId = new byte[9];
final byte[] globalId = new byte[12];
final byte[] driverId = new byte[13];
final byte[] arriveTime = new byte[7];
final byte[] departTime = new byte[7];
//
this.lineId = buf.readShort();
type = buf.readShort();
this.rtuId = buf.readShort();
this.nccWindow = buf.readShort();
this.nccWindowOffset = buf.readByte();
devType = buf.readShort();
buf.readBytes(devName);
buf.readBytes(trainIndex);
buf.readBytes(groupId);
buf.readBytes(trainId);
buf.readBytes(globalId);
this.destinationId = buf.readInt();
this.rollingStock = buf.readByte();
buf.readBytes(driverId);
this.routeId = buf.readShort();
this.optTime = buf.readInt();
this.mode = buf.readInt();
buf.readBytes(arriveTime);
buf.readBytes(departTime);
this.rate = buf.readInt();
this.speed = buf.readByte();
buf.readBytes(this.reserve);
//
this.devType = DeviceType.of(devType);
this.devName = new String(devName, MessageCons.STRING_CHARSET).trim();
this.trainIndex = new String(trainIndex, MessageCons.STRING_CHARSET).trim();
this.groupId = new String(groupId, MessageCons.STRING_CHARSET).trim();
this.trainId = new String(trainId, MessageCons.STRING_CHARSET).trim();
this.globalId = new String(globalId, MessageCons.STRING_CHARSET).trim();
this.driverId = new String(driverId, MessageCons.STRING_CHARSET).trim();
this.arriveTime = DateTimeUtil.convert(arriveTime);
this.departTime = DateTimeUtil.convert(departTime);
/**
* 车次号变化状态(2)
* 0x01增加<br>
* 0x02更新<br>
* true-更新false-增加
*/
private Boolean type;
/**
* 集中站站号(2)
*/
private Short rtuId;
/**
* NCC车次窗编号(2)
*/
private Short nccWindow;
/**
* 列车在车次窗中的位置(1)
*/
private Byte nccWindowOffset;
/**
* 列车所在的设备的类型(2)
*/
private DeviceType devType;
/**
* 列车所在的设备的名称(24)
*/
private String devName;
/**
* 列车标示号全线唯一若无法提供缺省值为0(10)
*/
private String trainIndex;
/**
* 列车编组号(9)
*/
private String groupId;
/**
* 表号(9)
*/
private String trainId;
/**
* 车次号(12)
*/
private String globalId;
/**
* 目的地号(4)
*/
private Integer destinationId;
/**
* 编组数量(1)
*/
private byte rollingStock;
/**
* 司机号(13)
*/
private String driverId;
/**
* 运行路径号若无法提供缺省值为0(2)
*/
private Short routeId;
/**
* 计划偏离时间(4)
*/
private Integer optTime;
/**
* 列车状态见附录6.3.14列车状态定义(4)
*/
private Integer mode;
/**
* 列车到点(7)
*/
private LocalDateTime arriveTime;
/**
* 列车发点(7)
*/
private LocalDateTime departTime;
/**
* 满载率百分比例如50表示满载率为50%(4)
*/
private Integer rate;
/**
* 速度KM/H(1)
*/
private byte speed;
/**
* 预留(2)
*/
private byte[] reserve = new byte[2];
/**
* 列车是否有 trainMode对应的状态
*/
public boolean havingState(final DeviceStatus.TRAIN_MODE trainMode){
return trainMode.is(mode);
}
@Override
public void decode2(ByteBuf buf) throws Exception {
short devType;
short type;
final byte[] devName = new byte[24];
final byte[] trainIndex = new byte[10];
final byte[] groupId = new byte[9];
final byte[] trainId = new byte[9];
final byte[] globalId = new byte[12];
final byte[] driverId = new byte[13];
final byte[] arriveTime = new byte[7];
final byte[] departTime = new byte[7];
//
this.lineId = buf.readShort();
type = buf.readShort();
this.rtuId = buf.readShort();
this.nccWindow = buf.readShort();
this.nccWindowOffset = buf.readByte();
devType = buf.readShort();
buf.readBytes(devName);
buf.readBytes(trainIndex);
buf.readBytes(groupId);
buf.readBytes(trainId);
buf.readBytes(globalId);
this.destinationId = buf.readInt();
this.rollingStock = buf.readByte();
buf.readBytes(driverId);
this.routeId = buf.readShort();
this.optTime = buf.readInt();
this.mode = buf.readInt();
buf.readBytes(arriveTime);
buf.readBytes(departTime);
this.rate = buf.readInt();
this.speed = buf.readByte();
buf.readBytes(this.reserve);
//
this.devType = DeviceType.of(devType);
this.devName = new String(devName, MessageCons.STRING_CHARSET).trim();
this.trainIndex = new String(trainIndex, MessageCons.STRING_CHARSET).trim();
this.groupId = new String(groupId, MessageCons.STRING_CHARSET).trim();
this.trainId = new String(trainId, MessageCons.STRING_CHARSET).trim();
this.globalId = new String(globalId, MessageCons.STRING_CHARSET).trim();
this.driverId = new String(driverId, MessageCons.STRING_CHARSET).trim();
this.arriveTime = DateTimeUtil.convert(arriveTime);
this.departTime = DateTimeUtil.convert(departTime);
/**
* 车次号变化状态(2)
* 0x01增加<br>
* 0x02更新<br>
* true-更新false-增加
*/
switch (type) {
case 0x02 -> this.type = true;
case 0x01 -> this.type = false;
}
switch (type) {
case 0x02 -> this.type = true;
case 0x01 -> this.type = false;
}
}
}

View File

@ -7,174 +7,163 @@ import io.netty.buffer.ByteBuf;
import lombok.Getter;
import java.time.LocalDateTime;
import lombok.Setter;
/**
* 2.7.8列车报点消息
*/
@Getter
@Setter
public class TrainRecordResponse extends MessageResponse {
/**
* 线路号(2)
*/
private Short lineId;
/**
* 表号(9)
*/
private String trainId;
/**
* 车次号(12)
*/
private String globalId;
/**
* 局部序列号(4)
*/
private Integer localSubId;
/**
* 车组号(9)
*/
private String groupId;
/**
* 目的地(4)
*/
private Integer destinationId;
/**
* 列车类型(2)
* 0x01计划车<br>
* 0x02头码车<br>
* 0x03M0车<br>
* 0x04MM车<br>
*/
private TrainTypeEnum trainType;
/**
* 运行方向(1)
* 0x01下行 <br>
* 0x02上行<br>
* 0x00无方向<br>
*/
private DirectionEnum direction;
/**
* 站号(2)
*/
private Short stationId;
/**
* 站台编号(2)
*/
private Short sideId;
/**
* 轨道名称小区段名称(20)
*/
private String trackName;
/**
* 线路号(2)
*/
private Short lineId;
/**
* 表号(9)
*/
private String trainId;
/**
* 车次号(12)
*/
private String globalId;
/**
* 局部序列号(4)
*/
private Integer localSubId;
/**
* 车组号(9)
*/
private String groupId;
/**
* 目的地(4)
*/
private Integer destinationId;
/**
* 列车类型(2) 0x01计划车<br> 0x02头码车<br> 0x03M0车<br> 0x04MM车<br>
*/
private TrainTypeEnum trainType;
/**
* 运行方向(1) 0x01下行 <br> 0x02上行<br> 0x00无方向<br>
*/
private DirectionEnum direction;
/**
* 站号(2)
*/
private Short stationId;
/**
* 站台编号(2)
*/
private Short sideId;
/**
* 轨道名称小区段名称(20)
*/
private String trackName;
/**
* 到发点类型(2)<br> 0x01H到达<br> 0x02H出发<br> true-到达false-出发
*/
private Boolean recordType;
/**
* 到发时间(7)
*/
private LocalDateTime recordTime;
/**
* 预留(4)
*/
private byte[] reserve = new byte[4];
@Override
public void decode2(ByteBuf buf) throws Exception {
final byte[] trainId = new byte[9];
final byte[] globalId = new byte[12];
final byte[] groupId = new byte[9];
short trainType;
byte direction;
final byte[] trackName = new byte[20];
short recordType;
final byte[] recordTime = new byte[7];
//
this.lineId = buf.readShort();
buf.readBytes(trainId);
buf.readBytes(globalId);
this.localSubId = buf.readInt();
buf.readBytes(groupId);
this.destinationId = buf.readInt();
trainType = buf.readShort();
direction = buf.readByte();
this.stationId = buf.readShort();
this.sideId = buf.readShort();
buf.readBytes(trackName);
recordType = buf.readShort();
buf.readBytes(recordTime);
buf.readBytes(this.reserve);
//
this.trainId = new String(trainId, MessageCons.STRING_CHARSET).trim();
this.globalId = new String(globalId, MessageCons.STRING_CHARSET).trim();
this.groupId = new String(groupId, MessageCons.STRING_CHARSET).trim();
this.trainType = TrainTypeEnum.of(trainType);
this.direction = DirectionEnum.of(direction);
this.trackName = new String(trackName, MessageCons.STRING_CHARSET).trim();
/**
* 到发点类型(2)<br>
* 0x01H到达<br>
* 0x02H出发<br>
* true-到达false-出发
*/
private Boolean recordType;
/**
* 到发时间(7)
*/
private LocalDateTime recordTime;
/**
* 预留(4)
*/
private byte[] reserve = new byte[4];
switch (recordType) {
case 0x01 -> this.recordType = true;
case 0x02 -> this.recordType = false;
}
this.recordTime = DateTimeUtil.convert(recordTime);
}
@Override
public void decode2(ByteBuf buf) throws Exception {
final byte[] trainId = new byte[9];
final byte[] globalId = new byte[12];
final byte[] groupId = new byte[9];
short trainType;
byte direction;
final byte[] trackName = new byte[20];
short recordType;
final byte[] recordTime = new byte[7];
//
this.lineId = buf.readShort();
buf.readBytes(trainId);
buf.readBytes(globalId);
this.localSubId = buf.readInt();
buf.readBytes(groupId);
this.destinationId = buf.readInt();
trainType = buf.readShort();
direction = buf.readByte();
this.stationId = buf.readShort();
this.sideId = buf.readShort();
buf.readBytes(trackName);
recordType = buf.readShort();
buf.readBytes(recordTime);
buf.readBytes(this.reserve);
//
this.trainId = new String(trainId, MessageCons.STRING_CHARSET).trim();
this.globalId = new String(globalId, MessageCons.STRING_CHARSET).trim();
this.groupId = new String(groupId, MessageCons.STRING_CHARSET).trim();
this.trainType = TrainTypeEnum.of(trainType);
this.direction = DirectionEnum.of(direction);
this.trackName = new String(trackName, MessageCons.STRING_CHARSET).trim();
/**
* 到发点类型(2)<br>
* 0x01H到达<br>
* 0x02H出发<br>
* true-到达false-出发
*/
switch (recordType) {
case 0x01 -> this.recordType = true;
case 0x02 -> this.recordType = false;
}
this.recordTime = DateTimeUtil.convert(recordTime);
/**
* 运行方向(1) 0x01下行 <br> 0x02上行<br> 0x00无方向<br>
*/
public static enum DirectionEnum {
Down(0x01),
Up(0x02),
Unknown(0x00),
;
private int value;
private DirectionEnum(final int value) {
this.value = value;
}
/**
* 运行方向(1)
* 0x01下行 <br>
* 0x02上行<br>
* 0x00无方向<br>
*/
public static enum DirectionEnum {
Down(0x01),
Up(0x02),
Unknown(0x00),
;
private int value;
public static DirectionEnum of(final int value) {
for (final DirectionEnum direction : values()) {
if (direction.value == value) {
return direction;
}
}
return DirectionEnum.Unknown;
}
}
private DirectionEnum(final int value) {
this.value = value;
}
/**
* 列车类型(2) 0x01计划车<br> 0x02头码车<br> 0x03M0车<br> 0x04MM车<br>
*/
public static enum TrainTypeEnum {
PlannedTrain(0x01),
HeadTrain(0x02),
M0Train(0x03),
MMTrain(0x04),
;
private int type;
public static DirectionEnum of(final int value) {
for (final DirectionEnum direction : values()) {
if (direction.value == value) return direction;
}
return DirectionEnum.Unknown;
}
private TrainTypeEnum(final int type) {
this.type = type;
}
/**
* 列车类型(2)
* 0x01计划车<br>
* 0x02头码车<br>
* 0x03M0车<br>
* 0x04MM车<br>
*/
public static enum TrainTypeEnum {
PlannedTrain(0x01),
HeadTrain(0x02),
M0Train(0x03),
MMTrain(0x04),
;
private int type;
private TrainTypeEnum(final int type) {
this.type = type;
}
public static TrainTypeEnum of(final int type) {
for (final TrainTypeEnum tt : values()) {
if (type == tt.type) return tt;
}
return null;
}
public static TrainTypeEnum of(final int type) {
for (final TrainTypeEnum tt : values()) {
if (type == tt.type) {
return tt;
}
}
return null;
}
}
}

View File

@ -3,10 +3,15 @@ package club.joylink.xiannccda.mapper;
import club.joylink.xiannccda.entity.NccMockData;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.cursor.Cursor;
import org.apache.ibatis.mapping.ResultSetType;
/**
* <p>
* Mapper 接口
* Mapper 接口
* </p>
*
* @author walker-sheng
@ -15,4 +20,7 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface NccMockDataMapper extends BaseMapper<NccMockData> {
// @Options(resultSetType = ResultSetType.FORWARD_ONLY, fetchSize = 2)
// @Select("select * from ncc_mock_data ")
// Cursor<NccMockData> findAllForCursor222(@Param("limit") int limit);
}

View File

@ -2,16 +2,20 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="club.joylink.xiannccda.mapper.NccMockDataMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="club.joylink.xiannccda.entity.NccMockData">
<id column="id" property="id" />
<result column="mock_data" property="mockData" />
<result column="mock_receive_time" property="mockReceiveTime" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, mock_data, mock_receive_time
</sql>
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="club.joylink.xiannccda.entity.NccMockData">
<id column="id" property="id"/>
<result column="mock_data" property="mockData"/>
<result column="mock_receive_time" property="mockReceiveTime"/>
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id
, mock_data, mock_receive_time
</sql>
<!-- <select id="findAllForCursor" resultMap="BaseResultMap">
select *
from ncc_mock_data limit #{limit}
</select>-->
</mapper>

View File

@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 服务类
* 服务类
* </p>
*
* @author walker-sheng
@ -13,4 +13,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/
public interface INccMockDataRepository extends IService<NccMockData> {
// public void dd();
}

View File

@ -3,18 +3,41 @@ package club.joylink.xiannccda.repository.impl;
import club.joylink.xiannccda.entity.NccMockData;
import club.joylink.xiannccda.mapper.NccMockDataMapper;
import club.joylink.xiannccda.repository.INccMockDataRepository;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.io.IOException;
import java.util.List;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.cursor.Cursor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* <p>
* 服务实现类
* 服务实现类
* </p>
*
* @author walker-sheng
* @since 2023-06-13
*/
@Service
@Transactional
public class NccMockDataRepository extends ServiceImpl<NccMockDataMapper, NccMockData> implements INccMockDataRepository {
/* @Override
public void dd() {
*//*List<NccMockData> ddd = this.getBaseMapper().selectList(new QueryWrapper<>());
for (NccMockData mockData : ddd) {
System.out.println(mockData.getId() + " -------->");
}*//*
Cursor<NccMockData> cursor = this.getBaseMapper().findAllForCursor222(10100);
for (NccMockData mockData : cursor) {
System.out.println(mockData.getId() + " --- >");
}
System.out.println(cursor.isConsumed());
System.out.println(cursor.isOpen());
}*/
}

View File

@ -0,0 +1,90 @@
package club.joylink.xiannccda.service;
import club.joylink.xiannccda.ats.message.MessageData;
import club.joylink.xiannccda.ats.message.MessageId;
import club.joylink.xiannccda.entity.NccMockData;
import club.joylink.xiannccda.repository.impl.NccMockDataRepository;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
@Component
@RequiredArgsConstructor
@Slf4j
public class NccMockDataService {
private final NccMockDataRepository nccMockDataRepository;
private static Long LAST_ID;
private static boolean FINISH = false;
private final static int PAGE_SIZE = 200;
public void reset() {
LAST_ID = 0L;
FINISH = false;
}
public boolean finish() {
return FINISH;
}
private boolean isLast() {
if (Objects.isNull(LAST_ID) || LAST_ID <= 0L) {
LAST_ID = 0L;
FINISH = false;
return false;
} else {
return FINISH;
}
}
public List<MessageData> getMessageData() {
if (this.isLast()) {
return Collections.emptyList();
}
List<NccMockData> list = this.findData();
if (CollectionUtils.isEmpty(list)) {
FINISH = true;
} else {
NccMockData mockData = list.get(list.size() - 1);
LAST_ID = mockData.getId();
}
List<MessageData> dataList = Lists.newArrayListWithCapacity(list.size());
for (NccMockData data : list) {
JSONArray jsonArray = JSONArray.parse(data.getMockData());
this.parse(jsonArray, dataList);
}
return dataList;
}
private void parse(JSONArray jsonArray, List<MessageData> dataList) {
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jo = jsonArray.getJSONObject(i);
Integer msgId = jo.getInteger("msgId");
Class<? extends MessageData> clazz = MessageId.of(msgId).create().getClass();
MessageData md = jo.to(clazz);
dataList.add(md);
}
}
private List<NccMockData> findData() {
QueryWrapper<NccMockData> queryWrapper = Wrappers.query();
queryWrapper.gt(NccMockData.ID, LAST_ID);
queryWrapper.last(String.format(" limit %s", PAGE_SIZE));
List<NccMockData> list = this.nccMockDataRepository.list(queryWrapper);
return list;
}
}

View File

@ -33,6 +33,7 @@ mybatis-plus:
cache-enabled: false
call-setters-on-nulls: true
jdbc-type-for-null: 'null'
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
jwt:
key:
pub: classpath:app.pub

View File

@ -1,17 +1,26 @@
package club.joylink.xiannccda.service;
import club.joylink.xiannccda.ats.message.MessageData;
import club.joylink.xiannccda.ats.message.MessageId;
import club.joylink.xiannccda.ats.message.OccMessageDecoder.MockAppContext;
import club.joylink.xiannccda.ats.message.event.MockMessageDataEvent;
import club.joylink.xiannccda.ats.message.line3.DateTimeUtil;
import club.joylink.xiannccda.ats.message.line3.MessageCons;
import club.joylink.xiannccda.ats.message.line3.rep.ActionReportResponse;
import club.joylink.xiannccda.entity.NccMockData;
import club.joylink.xiannccda.protocal.x.TestUtil;
import club.joylink.xiannccda.repository.INccMockDataRepository;
import club.joylink.xiannccda.repository.impl.NccMockDataRepository;
import com.alibaba.fastjson2.JSON;
import com.google.common.collect.Lists;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
@ -59,15 +68,52 @@ public class MockMsgTest {
buf.writeShort("Test Content 2".getBytes().length);
buf.writeBytes("Test Content 2".getBytes());
ActionReportResponse response = new ActionReportResponse();
response.setMsgId(MessageId.ACTION_REPORT);
response.decode2(buf);
return response;
}
@Autowired
private INccMockDataRepository iNccMockDataRepository;
@Test
public void insert() throws Exception {
/* List<NccMockData> messageDataList2 = Lists.newArrayList();
for (int d = 0; d < 12000; d++) {
NccMockData data = new NccMockData();
data.setMockData(JSON.toJSONString(List.of(testData())));
data.setMockReceiveTime(LocalDateTime.now());
messageDataList2.add(data);
if (messageDataList2.size() % 80 == 0) {
this.iNccMockDataRepository.saveBatch(messageDataList2, 80);
messageDataList2.clear();
}
}*/
List<MessageData> messageDataList = Lists.newArrayList();
messageDataList.add(testData());
MockAppContext.publish(messageDataList);
Thread.sleep(10000);
}
@Autowired
private NccMockDataService dataService;
@Test
public void findMockData() {
List<MessageData> dataList = this.dataService.getMessageData();
System.out.println(dataList);
}
@Test
public void findAll() {
int i = 0;
while (!this.dataService.finish()) {
List<MessageData> dataList = this.dataService.getMessageData();
System.out.println((i++) + "----->" + dataList.size());
}
}
}