非实时消息

This commit is contained in:
tiger_zhou 2023-06-07 15:12:20 +08:00
parent f87c8f860e
commit 3f44f18645
10 changed files with 594 additions and 15 deletions

View File

@ -2,6 +2,7 @@ package club.joylink.xiannccda.ats.message;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.nio.ByteBuffer;
import java.time.LocalDateTime;
import lombok.NoArgsConstructor;
import lombok.Setter;
@ -109,14 +110,15 @@ public abstract class MessageData {
this.second = (byte) localDateTime.getSecond();
}
public void aa() {
ByteBuf buf = Unpooled.buffer(7);
buf.writeShort(this.year);
buf.writeByte(this.month);
buf.writeByte(this.day);
buf.writeByte(this.hour);
buf.writeByte(this.minute);
buf.writeByte(this.second);
public byte[] requestData() {
ByteBuffer buf = ByteBuffer.allocate(7);
buf.putShort(this.year);
buf.put(this.month);
buf.put(this.day);
buf.put(this.hour);
buf.put(this.minute);
buf.put(this.second);
return buf.array();
}
public static DateTime parseNow() {

View File

@ -8,12 +8,18 @@ import club.joylink.xiannccda.ats.message.line3.TrainIndicationInitResponse;
import club.joylink.xiannccda.ats.message.line3.TrainIndicationRemoveResponse;
import club.joylink.xiannccda.ats.message.line3.TrainIndicationUpdateResponse;
import club.joylink.xiannccda.ats.message.line3.TrainRecordResponse;
import club.joylink.xiannccda.ats.message.rep.ActionReportResponse;
import club.joylink.xiannccda.ats.message.rep.AlarmReportResponse;
import club.joylink.xiannccda.ats.message.rep.DepotPlanResponse;
import club.joylink.xiannccda.ats.message.rep.DeviceStatusBitmapResponse;
import club.joylink.xiannccda.ats.message.rep.DeviceStatusChangeResponse;
import club.joylink.xiannccda.ats.message.rep.HistoryScheduleResponse;
import club.joylink.xiannccda.ats.message.rep.InusedScheduleResponse;
import club.joylink.xiannccda.ats.message.rep.NetworkAliveStatusResponse;
import club.joylink.xiannccda.ats.message.rep.SignalRouteStatusResponse;
import club.joylink.xiannccda.ats.message.req.AlarmAckRequest;
import club.joylink.xiannccda.ats.message.req.LoadDeviceStatusRequest;
import club.joylink.xiannccda.ats.message.req.LoadHistoryTGDataRequest;
public enum MessageId {
UNKNOWN(0x0000, null),
@ -89,27 +95,27 @@ public enum MessageId {
/**
* 事件及告警信息请求
*/
ALARM_ASK(0x0018, null),
ALARM_ASK(0x0018, () -> new AlarmAckRequest()),
/**
* 操作命令
*/
ACTION_REPORT(0x0019, null),
ACTION_REPORT(0x0019, () -> new ActionReportResponse()),
/**
* 列车信息系统事件
*/
ALARM_REPORT(0x0020, null),
ALARM_REPORT(0x0020, () -> new AlarmReportResponse()),
/**
* 历史运行图申请
*/
LOAD_HISTORY_TG_DATA(0x0021, null),
LOAD_HISTORY_TG_DATA(0x0021, () -> new LoadHistoryTGDataRequest()),
/**
* 计划列车运行图消息
*/
INUSED_SCHEDULE(0x0022, null),
INUSED_SCHEDULE(0x0022, () -> new InusedScheduleResponse()),
/**
* 实际列车运行图消息
*/
HISTORY_SCHEDULE(0x0023, null),
HISTORY_SCHEDULE(0x0023, () -> new HistoryScheduleResponse()),
/**
* 断电续传申请
*/

View File

@ -0,0 +1,95 @@
package club.joylink.xiannccda.ats.message.rep;
import club.joylink.xiannccda.ats.message.MessageResponse;
import io.netty.buffer.ByteBuf;
/**
* 2.8.10 操作命令消息
*/
/*
发送条件
NCC FEP主动发起事件及告警信息查询OCC FEP收到此消息后发送操作命令信息给NCC
*/
public class ActionReportResponse extends MessageResponse {
/**
* 线路号
*/
private Short lineId;
/**
* 查询标识号(2)
*/
private Short reportId;
/**
* 消息总数(2)
*/
private Short totalMessage;
/**
* 本消息的顺序号(2)
*/
private Short messageSequence;
/**
* 操作记录数量
*/
private Short count;
/**
* 单位类型(1) 0x01车站 0x02中心 0x00未知
*/
private Byte actionSite;
/**
* 单位编码(2) 单位类型为中心时单位编码为调度台ID中心服务器为0 单位类型为车站时单位编码为站码 当单位类型为未知时此项无效
*/
private Short actionSiteid;
/**
* 被查询单位名称(20)
*/
private byte[] actionName = new byte[20];
/**
* 命令发送时的系统时间(7)以数字表示年
*/
private DateTime actionTime;
/**
* 事件/告警对应的操作员名称(20)
*/
private byte[] actionUser = new byte[20];
/**
* 操作类型详见附录操作类型定义(2)
* <p>
* 西安3号线的操作命令无操作类型Action_type区分将按照统一的操作类型Action_type发送
*/
private Short actionType;
/**
* 操作子类型预留(2)
*/
private Short actionSubType;
/**
* 命令描述长度(2)
*/
private Short atctionLen;
/**
* 命令描述(N)
*/
private byte[] actionContent;
@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.actionSite = buf.readByte();
this.actionSiteid = buf.readShort();
buf.readBytes(this.actionName);
this.actionTime = new DateTime(buf);
buf.readBytes(this.actionUser);
this.actionType = buf.readShort();
this.actionSubType = buf.readShort();
this.atctionLen = buf.readShort();
this.actionContent = new byte[this.atctionLen];
buf.readBytes(this.actionContent);
}
}

View File

@ -0,0 +1,114 @@
package club.joylink.xiannccda.ats.message.rep;
import club.joylink.xiannccda.ats.message.MessageId;
import club.joylink.xiannccda.ats.message.MessageResponse;
import io.netty.buffer.ByteBuf;
/**
* 2.8.11 列车信息系统事件消息
*/
/*
发送条件
NCC FEP主动发起事件及告警信息查询OCC FEP收到此消息后发送列车信息系统事件给NCC
*/
public class AlarmReportResponse extends MessageResponse {
public AlarmReportResponse() {
this.setMsgId(MessageId.ALARM_REPORT);
}
/**
* 线路号(2)
*/
private Short lineId;
/**
* 查询标识号(2)
*/
private Short reportId;
/**
* 消息总数(2)
*/
private Short totalMessage;
/**
* 本消息的顺序号(2)
*/
private Short messageSequence;
/**
* 报警记录数量(2)
*/
private Short count;
/**
* 单位类型(1) 0x01车站 0x02中心 0x00未知
*/
private Byte alamrSite;
/**
* 单位编码(2) 单位类型为中心时单位编码为调度台ID中心服务器为0 单位类型为车站时单位编码为站码 当单位类型为未知时此项无效
*/
private Short alarmSiteid;
/**
* 报警单位名称(20)
*/
private byte[] alarmNname = new byte[20];
/**
* 报警发送时的系统时间以数字表示年(7)
*/
private DateTime alarmTime;
/**
* 报警类型详见附录报警类型定义(2)
* <p>
* 西安3号线告警无报警类型alarm _type区分将按照统一的报警类型发送本消息
*/
private Short alarmType;
/**
* 报警子类型预留(2)
*/
private Short alarmSubType;
/**
* 报警描述长度(2)
*/
private Short alarmLen;
/**
* 报警描述(N)
*/
private byte[] alarmContent;
/**
* 确认单位编码(2)
*/
private Short alarmAckSiteid;
/**
* 确认单位名称(32)
*/
private byte[] alarmAckSite = new byte[32];
/**
* 32 确认人员用户名称(32)
*/
private byte[] alarmAckName = new byte[32];
/**
* 确认时间
*/
private DateTime alarmAckTime;
@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.alamrSite = buf.readByte();
this.alarmSiteid = buf.readShort();
buf.readBytes(this.alarmNname);
this.alarmTime = new DateTime(buf);
this.alarmType = buf.readShort();
this.alarmSubType = buf.readShort();
this.alarmLen = buf.readShort();
this.alarmContent = new byte[this.alarmLen];
buf.readBytes(this.alarmContent);
this.alarmAckSiteid = buf.readShort();
buf.readBytes(this.alarmAckSite);
buf.readBytes(alarmAckName);
this.alarmAckTime = new DateTime(buf);
}
}

View File

@ -0,0 +1,120 @@
package club.joylink.xiannccda.ats.message.rep;
import club.joylink.xiannccda.ats.message.MessageId;
import club.joylink.xiannccda.ats.message.MessageResponse;
import io.netty.buffer.ByteBuf;
/**
* 2.8.15 实际列车运行图消息
*/
/*
发送条件
当OCC收到NCC的历史运行图申请消息时OCC根据消息类型发送历史实际运行信息给NCC
当OCC收到NCC ATS信息请求消息时发送当天实际列车运行信息给NCC
*/
public class HistoryScheduleResponse extends MessageResponse {
public HistoryScheduleResponse() {
this.setMsgId(MessageId.HISTORY_SCHEDULE);
}
/**
* 线路号(2)
*/
private Short lineId;
/**
* HISTORY_SCHEDULE日期(7)
*/
private DateTime date;
/**
* 0x0001: 计划列车运行信息消息开始标记
* <p>
* 0x0002: 计划列车运行信息消息数据标记
* <p>
* 0x0003:计划列车运行信息消息结束标记
*/
private Short subId;
/**
* 车组号(9)
*/
private byte[] groupId = new byte[9];
/**
* 记录数(2)
*/
private Short recCnt;
/**
* 站号(2)
*/
private Short stationId;
/**
* 站台号(2)
*/
private Short platformId;
/**
* 到站时间(7)
*/
private DateTime aTime;
/**
* 离站时间(7)
*/
private DateTime dTime;
/**
* 1表示下行2表示上行0表示未知
*/
private Short flag;
/**
* 表号(9)
*/
private byte[] serviceId;
/**
* 车次号12
*/
private byte[] globalId = new byte[12];
/**
* 目的地号(4)
*/
private byte[] destinationId;
/**
* 类型 1表示计划车0表示非计划车
*/
private Short type;
/**
* 局部序列号(4)
*/
private Integer localSubId;
// 下一条记录重复10~19
@Override
public void decode2(ByteBuf buf) throws Exception {
this.lineId = buf.readShort();
this.date = new DateTime(buf);
this.subId = buf.readShort();
if (this.subId == ScheduleSubIdType.RUNING.val) {
buf.readBytes(this.groupId);
this.recCnt = buf.readShort();
this.stationId = buf.readShort();
this.platformId = buf.readShort();
this.aTime = new DateTime(buf);
this.dTime = new DateTime(buf);
this.flag = buf.readShort();
buf.readBytes(this.serviceId);
buf.readBytes(this.globalId);
buf.readBytes(this.destinationId);
this.type = buf.readShort();
this.localSubId = buf.readInt();
}
}
}

View File

@ -0,0 +1,120 @@
package club.joylink.xiannccda.ats.message.rep;
import club.joylink.xiannccda.ats.message.MessageId;
import club.joylink.xiannccda.ats.message.MessageResponse;
import io.netty.buffer.ByteBuf;
/**
* 2.8.14 计划列车运行图消息
*/
/*
发送条件
当OCC端创建当天计划或当天计划进行了更新OCC主动发送当天计划列车运行信息给NCC
当OCC收到NCC的历史运行图申请消息时OCC根据消息类型发送历史计划运行信息给NCC
当OCC收到NCC ATS信息请求消息时发送当天计划列车运行信息给NCC
*/
public class InusedScheduleResponse extends MessageResponse {
public InusedScheduleResponse() {
this.setMsgId(MessageId.INUSED_SCHEDULE);
}
/**
* 线路号(2)
*/
private Short lineId;
/**
* INUSED_SCHEDULE日期(7)
*/
private DateTime date;
/**
* 0x0001: 计划列车运行信息消息开始标记
* <p>
* 0x0002: 计划列车运行信息消息数据标记
* <p>
* 0x0003:计划列车运行信息消息结束标记
*/
private Short subId;
/**
* 表号(9)
*/
private byte[] trainId = new byte[9];
/**
* 单程数(2)
*/
private Short tripCnt;
/**
* 车次号(12)
*/
private byte[] globalId = new byte[12];
/**
* 车组号本字段预留(9)
*/
private byte[] groupId;
/**
* 目的地号(4);
*/
private byte[] destinationId;
/**
* 记录数本车次经过的站台数(2)
*/
private Short recCnt;
/**
* 站号(2)
*/
private Short stationId;
/**
* 站台号(2)
*/
private Short platformId;
/**
* 到站时间(7)
*/
private DateTime aTime;
/**
* 离站时间
*/
private DateTime dTime;
/**
* 第4位为1表示出库第5位为1表示入库第6位为1表示下行为0表示上行首位为第0位(2)
*/
private Short flag;
private byte[] flagBit;
/**
* 局部序列号(4)
*/
private Integer LocalSubId;
// 下一条记录重复14~19
// 下一个单程重复10~20重复
@Override
public void decode2(ByteBuf buf) throws Exception {
this.lineId = buf.readShort();
this.date = new DateTime(buf);
this.subId = buf.readShort();
if (this.subId == ScheduleSubIdType.RUNING.val) {
buf.readBytes(this.trainId);
this.tripCnt = buf.readShort();
buf.readBytes(this.globalId);
buf.readBytes(this.groupId);
buf.readBytes(this.destinationId);
this.recCnt = buf.readShort();
this.stationId = buf.readShort();
this.platformId = buf.readShort();
this.aTime = new DateTime(buf);
this.dTime = new DateTime(buf);
this.flag = buf.readShort();
this.LocalSubId = buf.readInt();
String binaryResultStr = String.format("%8s", Integer.toBinaryString(this.flag))
.replace(" ", "0");
this.flagBit = binaryResultStr.getBytes();
}
}
}

View File

@ -0,0 +1,54 @@
package club.joylink.xiannccda.ats.message.rep;
import club.joylink.xiannccda.ats.message.MessageId;
import club.joylink.xiannccda.ats.message.MessageResponse;
import io.netty.buffer.ByteBuf;
/**
* 2.8.12 查询无结果消息
*/
/*
2.8.12.1 应用场景
NCC FEP主动发起查询请求因某种原因查询无结果数据量太大与信息源中断等导致OCC FEP无法正常返回查询结果时可使用此消息进行答复
对统计信息查询消息REPORT_ASK事件及告警信息请求消息ALARM_ACK在特殊情况下OCC FEP均可使用此消息进行答复
*/
public class ReportNackResponse extends MessageResponse {
public ReportNackResponse() {
this.setMsgId(MessageId.REPORT_NACK);
}
/**
* 线路号(2)
*/
private Short lineId;
/**
* 查询标识号(2)
*/
private Short reportId;
/**
* 异常码(4)
* <p>
* 0: 查询无结果
* <p>
* 1查询结果超过10000条
* <p>
* 2与信息源中断详细原因可参考content字段内容描述
* <p>
* 3查询异常原因为content字段内容描述
*/
private Integer result;
/**
* 异常描述(50)
*/
private byte[] content = new byte[50];
@Override
public void decode2(ByteBuf buf) throws Exception {
this.lineId = buf.readShort();
this.reportId = buf.readShort();
this.result = buf.readInt();
buf.readBytes(this.content);
}
}

View File

@ -0,0 +1,13 @@
package club.joylink.xiannccda.ats.message.rep;
public enum ScheduleSubIdType {
BEGIN(0X0001),
RUNING(0X0002),
STOP(0X0003);
int val;
ScheduleSubIdType(int d) {
this.val = d;
}
}

View File

@ -32,6 +32,10 @@ public class AlarmAckRequest extends MessageRequest {
private Short reportId;
/**
* 消息格式(2)
* <p>
* 01H:操作命令
* <p>
* 02H:列车信息系统事件
*/
private Short msgType;
/**
@ -45,6 +49,10 @@ public class AlarmAckRequest extends MessageRequest {
@Override
public void encode2(ByteBuf buf) {
buf.writeShort(this.lineId);
buf.writeShort(this.reportId);
buf.writeShort(this.msgType);
buf.writeBytes(startTime.requestData());
buf.writeBytes(endTime.requestData());
}
}

View File

@ -0,0 +1,47 @@
package club.joylink.xiannccda.ats.message.req;
import club.joylink.xiannccda.ats.message.MessageId;
import club.joylink.xiannccda.ats.message.MessageRequest;
import io.netty.buffer.ByteBuf;
/**
* 2.8.13 历史运行图申请消息
*/
/*
2.8.13.1 应用场景
定义
用于申请指定日期的历史计划和历史实际运行数据
发送条件
当NCC与OCC通信长时间中断引起某些日期的历史数据非当天缺损时NCC FEP人工发起此消息给OCC FEP由OCC FEP根据消息类型和申请时间发送历史计划和历史运行数据给NCC
*/
public class LoadHistoryTGDataRequest extends MessageRequest {
public LoadHistoryTGDataRequest() {
super(MessageId.LOAD_HISTORY_TG_DATA, 10);
}
/**
* 线路号(2)
*/
private Short lineId;
/**
* 日期(7)
*/
private DateTime date;
/**
* 申请类型(1) 0x01:计划图
* <p>
* 0x02:实际图
*/
private Byte tgType;
@Override
public void encode2(ByteBuf buf) {
buf.writeShort(this.lineId);
buf.writeBytes(this.date.requestData());
buf.writeByte(this.tgType);
}
}