ncc协议x

This commit is contained in:
xzb 2023-06-08 14:19:50 +08:00
parent 0ca0971f07
commit ef9f091308

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.7.13 列车阻塞消息
*/
@Getter
public class TrainBlockInfoResponse extends MessageResponse {
/**
@ -34,61 +36,103 @@ public class TrainBlockInfoResponse extends MessageResponse {
}
}
@Getter
public static class TrainCell {
/**
* 列车编组号(9)
*/
private byte[] groupId = new byte[9];
private String groupId;
/**
* 表号(9)
*/
private byte[] trainId = new byte[9];
private String trainId;
/**
* 方向(1)
* 0上行
* 1下行
* 2未知
*/
private byte direction;
private DirectionEnum direction;
/**
* 列车所在区间左边车站的站号(2)
*/
private Short stationIdInUpSide;
private Short stationIdInUpSide;
/**
* 列车所在区间右边车站的站号(2)
*/
private Short stationIdInDownSide;
private Short stationIdInDownSide;
/**
* 集中站站号(2)
*/
private Short rtuId;
private Short rtuId;
/**
* 列车所在的设备的类型(2)
*/
private Short devType;
private Short devType;
/**
* 列车所在的设备的名称(24)
*/
private byte[] devName = new byte[24];
private String devName;
/**
* 列车阻塞标记(1)
* 1列车阻塞
* 0列车没有阻塞
*/
private byte blockFlag;
private Boolean blockFlag;
private TrainCell decode(final ByteBuf buf) {
buf.readBytes(this.groupId);
buf.readBytes(this.trainId);
this.direction = buf.readByte();
final byte[] groupId = new byte[9];
final byte[] trainId = new byte[9];
byte direction;
final byte[] devName = new byte[24];
byte blockFlag;
//
buf.readBytes(groupId);
buf.readBytes(trainId);
direction = buf.readByte();
this.stationIdInUpSide = buf.readShort();
this.stationIdInDownSide = buf.readShort();
this.rtuId = buf.readShort();
this.devType = buf.readShort();
buf.readBytes(this.devName);
this.blockFlag = buf.readByte();
buf.readBytes(devName);
blockFlag = buf.readByte();
//
this.groupId = new String(groupId, MessageCons.STRING_CHARSET);
this.trainId = new String(trainId, MessageCons.STRING_CHARSET);
this.devName = new String(devName, MessageCons.STRING_CHARSET);
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;
}
}
}