ncc协议x

This commit is contained in:
xzb 2023-06-06 16:38:19 +08:00
parent a94d64947e
commit d33f6366ac
2 changed files with 112 additions and 34 deletions

View File

@ -3,17 +3,92 @@ package club.joylink.xiannccda.ats.message.line3;
import club.joylink.xiannccda.ats.message.MessageData; import club.joylink.xiannccda.ats.message.MessageData;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import java.util.ArrayList;
import java.util.List;
/**
* 2.7.13 列车阻塞消息
*/
public class TrainBlockInfoRsp extends MessageData { public class TrainBlockInfoRsp extends MessageData {
/** /**
* 线路号(2) * 线路号(2)
*/ */
private Short lineId; private Short lineId;
/** /**
* 列车数量(2) * 列车数量(2)
*/ */
private Short trainCnt; private Short trainCnt;
/**
* 列车列表
*/
private List<TrainCell> trains;
@Override @Override
public void decode2(ByteBuf buf) throws Exception { 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));
}
}
public static class TrainCell {
/**
* 列车编组号(9)
*/
private byte[] groupId = new byte[9];
/**
* 表号(9)
*/
private byte[] trainId = new byte[9];
/**
* 方向(1)
* 0上行
* 1下行
* 2未知
*/
private byte direction;
/**
* 列车所在区间左边车站的站号(2)
*/
private Short stationIdInUpSide;
/**
* 列车所在区间右边车站的站号(2)
*/
private Short stationIdInDownSide;
/**
* 集中站站号(2)
*/
private Short rtuId;
/**
* 列车所在的设备的类型(2)
*/
private Short devType;
/**
* 列车所在的设备的名称(24)
*/
private byte[] devName = new byte[24];
/**
* 列车阻塞标记(1)
* 1列车阻塞
* 0列车没有阻塞
*/
private byte blockFlag;
private TrainCell decode(final ByteBuf buf) {
buf.readBytes(this.groupId);
buf.readBytes(this.trainId);
this.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();
return this;
}
} }
} }

View File

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