ncc协议x
This commit is contained in:
parent
0ca0971f07
commit
ef9f091308
@ -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,23 +36,24 @@ 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)
|
||||
*/
|
||||
@ -70,25 +73,66 @@ public class TrainBlockInfoResponse extends MessageResponse {
|
||||
/**
|
||||
* 列车所在的设备的名称(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user