ncc协议x

This commit is contained in:
xzb 2023-06-08 13:40:44 +08:00
parent f6cc6bcba5
commit c023c4889a

View File

@ -2,6 +2,7 @@ package club.joylink.xiannccda.ats.message.line3;
import club.joylink.xiannccda.ats.message.MessageResponse;
import io.netty.buffer.ByteBuf;
import lombok.Getter;
import java.util.ArrayList;
import java.util.List;
@ -9,6 +10,7 @@ import java.util.List;
/**
* 2.8.8 列车整备状态报告消息
*/
@Getter
public class GroupStatusReportResponse extends MessageResponse {
/**
@ -50,28 +52,65 @@ public class GroupStatusReportResponse extends MessageResponse {
}
}
@Getter
public static class GroupStatusCell {
/**
* 车组号(9)
*/
private byte[] groupId = new byte[9];
private String groupId;
/**
* 列车位置(1)<br>
* 0x01:车辆段/停车场<br>
* 0x02: 正线<br>
*/
private byte depot;
private GroupPositionEnum depot;
/**
* 整备状态(42)
*/
private byte[] status = new byte[42];
private byte[] status = new byte[42];
public GroupStatusCell decode(final ByteBuf buf) {
buf.readBytes(this.groupId);
this.depot = buf.readByte();
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);
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;
}
}
}