代码调整
This commit is contained in:
parent
f1cdafac78
commit
483b4fb01c
@ -84,57 +84,4 @@ public abstract class MessageData {
|
||||
return this.length + 2;
|
||||
}
|
||||
|
||||
|
||||
public enum ReportSiteEnum {
|
||||
STATION(0x01), CENTER(0x02), UNKNOW(0x00);
|
||||
int val;
|
||||
|
||||
ReportSiteEnum(int b) {
|
||||
this.val = b;
|
||||
}
|
||||
|
||||
public static ReportSiteEnum of(byte d) {
|
||||
return Arrays.stream(ReportSiteEnum.values()).filter(dd -> dd.val == d).findFirst().orElse(null);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public enum ActionTypeControlEnum {
|
||||
/**
|
||||
* 进路控制
|
||||
* <p>
|
||||
* 包括进路排列、引导进路办理、进路取消、进路人解等操作
|
||||
*/
|
||||
ROUTE(0X01),
|
||||
/**
|
||||
* 信号控制
|
||||
* <p>
|
||||
* 包括道岔操作、区段操作、信号机操作、站台操作等
|
||||
*/
|
||||
SIGNAL(0X02),
|
||||
/**
|
||||
* 列车管理
|
||||
* <p>
|
||||
* 包括列车识别号操作、列车控制操作等
|
||||
*/
|
||||
TRAIN(0X03),
|
||||
/**
|
||||
* 计划管理
|
||||
* <p>
|
||||
* 包括在线计划管理操作等
|
||||
*/
|
||||
PLAN(0X04), OTHER(0X05);
|
||||
int val;
|
||||
|
||||
ActionTypeControlEnum(int v) {
|
||||
this.val = v;
|
||||
}
|
||||
|
||||
public static ActionTypeControlEnum of(int d) {
|
||||
return Arrays.stream(ActionTypeControlEnum.values()).filter(dd -> dd.val == d).findFirst().orElse(null);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import club.joylink.xiannccda.ats.message.line3.rep.MessageAlarmResponse;
|
||||
import club.joylink.xiannccda.ats.message.line3.rep.NetworkAliveStatusResponse;
|
||||
import club.joylink.xiannccda.ats.message.line3.rep.ReportBeginResponse;
|
||||
import club.joylink.xiannccda.ats.message.line3.rep.ReportEndResponse;
|
||||
import club.joylink.xiannccda.ats.message.line3.rep.ReportNackResponse;
|
||||
import club.joylink.xiannccda.ats.message.line3.rep.ResumeBeginAckResponse;
|
||||
import club.joylink.xiannccda.ats.message.line3.rep.ResumeDataResponse;
|
||||
import club.joylink.xiannccda.ats.message.line3.rep.ResumeEndAckResponse;
|
||||
@ -87,21 +88,21 @@ public enum MessageId {
|
||||
*/
|
||||
GROUP_RUNNING_REPORT(0x0013, () -> new GroupRunningReportResponse()),
|
||||
/**
|
||||
*2.8.5 司机驾驶里程报告消息
|
||||
* 2.8.5 司机驾驶里程报告消息
|
||||
*/
|
||||
DRIVER_DISTANCE_REPORT(0x0014, () -> new DriverDistanceReportResponse()),
|
||||
/**
|
||||
* 2.8.6 调度日志报告消息
|
||||
*/
|
||||
DISPATCHER_REPORT(0x0015, ()->new DispatcherReportResponse()),
|
||||
DISPATCHER_REPORT(0x0015, () -> new DispatcherReportResponse()),
|
||||
/**
|
||||
* 2.8.7 存备车报告消息
|
||||
*/
|
||||
GROUP_BAK_REPORT(0x0016, ()->new GroupBakReportResponse()),
|
||||
GROUP_BAK_REPORT(0x0016, () -> new GroupBakReportResponse()),
|
||||
/**
|
||||
* 2.8.8 列车整备状态报告消息
|
||||
*/
|
||||
GROUP_STATUS_REPORT(0x0017, ()->new GroupStatusReportResponse()),
|
||||
GROUP_STATUS_REPORT(0x0017, () -> new GroupStatusReportResponse()),
|
||||
/**
|
||||
* 2.8.9 事件及告警信息请求消息
|
||||
*/
|
||||
@ -133,15 +134,15 @@ public enum MessageId {
|
||||
/**
|
||||
* 2.9.3.2 断点续传开始消息
|
||||
*/
|
||||
Resume_Begin_ACK(0x0025, ()->new ResumeBeginAckResponse()),
|
||||
Resume_Begin_ACK(0x0025, () -> new ResumeBeginAckResponse()),
|
||||
/**
|
||||
* 2.9.3.4 断点续传结束消息
|
||||
*/
|
||||
Resume_END_ACK(0x0026, ()->new ResumeEndAckResponse()),
|
||||
Resume_END_ACK(0x0026, () -> new ResumeEndAckResponse()),
|
||||
/**
|
||||
* 2.8.12 查询无结果消息
|
||||
*/
|
||||
REPORT_NACK(0x0027, null),
|
||||
REPORT_NACK(0x0027, () -> new ReportNackResponse()),
|
||||
/**
|
||||
* 2.8.2 查询结果开始消息
|
||||
*/
|
||||
@ -153,7 +154,7 @@ public enum MessageId {
|
||||
/**
|
||||
* 2.9.3.3 断点续传数据消息
|
||||
*/
|
||||
Resume_DATA(0x0030, ()->new ResumeDataResponse()),
|
||||
Resume_DATA(0x0030, () -> new ResumeDataResponse()),
|
||||
/**
|
||||
* 2.7.12 实时报警事件消息
|
||||
*/
|
||||
@ -169,9 +170,11 @@ public enum MessageId {
|
||||
;
|
||||
|
||||
int val;
|
||||
public int idValue(){
|
||||
return this.val;
|
||||
|
||||
public int idValue() {
|
||||
return this.val;
|
||||
}
|
||||
|
||||
/**
|
||||
* 消息对象创建接口
|
||||
*/
|
||||
@ -193,9 +196,12 @@ public enum MessageId {
|
||||
|
||||
public MessageResponse createResponse() {
|
||||
final MessageData messageData = create();
|
||||
if(null==messageData) return null;
|
||||
if (null == messageData) {
|
||||
return null;
|
||||
}
|
||||
return messageData instanceof MessageResponse ? (MessageResponse) messageData : null;
|
||||
}
|
||||
|
||||
public static MessageId of(int val) {
|
||||
for (MessageId messageId : MessageId.values()) {
|
||||
if (messageId.val == val) {
|
||||
|
@ -1,6 +1,5 @@
|
||||
package club.joylink.xiannccda.ats.message.convertor;
|
||||
|
||||
|
||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceStatus;
|
||||
import club.joylink.xiannccda.dto.protos.DeviceStatusProto;
|
||||
import com.google.protobuf.GeneratedMessageV3;
|
||||
@ -12,139 +11,144 @@ import java.lang.reflect.Method;
|
||||
* 设备状态转换相关
|
||||
*/
|
||||
public class DeviceStatusConvertor {
|
||||
/**
|
||||
* Track状态proto
|
||||
*/
|
||||
public static void convertForTrack(final int statusBitMap,final DeviceStatusProto.Track.Builder to) throws Exception {
|
||||
convert(DeviceStatus.TRACK.class, statusBitMap, to);
|
||||
final int SPEED_LIMIT_MASK = 0xff000000;
|
||||
final int SPEED_LIMIT_TYPE_MASK = 0x00f00000;
|
||||
final int speedLimit = (statusBitMap&SPEED_LIMIT_MASK)>>24;
|
||||
final int speedLimitType = (statusBitMap&SPEED_LIMIT_TYPE_MASK)>>20;
|
||||
to.setSpeedLimit(speedLimit);
|
||||
to.setLimitType(DeviceStatusProto.Track.LimitType.forNumber(speedLimitType));
|
||||
}
|
||||
/**
|
||||
* Platform状态proto
|
||||
*/
|
||||
public static void convertForPlatform(final int statusBitMap,final int spare,final DeviceStatusProto.Platform.Builder to) throws Exception{
|
||||
convert(DeviceStatus.PLATFORM.class,statusBitMap,to);
|
||||
final int NEXT_SECTION_RUNTIME_MASK = 0xffff0000;
|
||||
final int NEXT_SECTION_RUN_LEVEL_MASK = 0x0000ff00;
|
||||
final int nextSectionRuntime = (spare&NEXT_SECTION_RUNTIME_MASK)>>16;
|
||||
final int nextSectionRunLevel = (spare&NEXT_SECTION_RUN_LEVEL_MASK)>>8;
|
||||
//
|
||||
final int STOP_TIME_MASK = 0xffff0000;
|
||||
final int stopTime = (statusBitMap&STOP_TIME_MASK)>>16;
|
||||
//
|
||||
to.setNextSectionRunTime(nextSectionRuntime);
|
||||
to.setNextSectionRunLevel(nextSectionRunLevel);
|
||||
to.setStopTime(stopTime);
|
||||
}
|
||||
/**
|
||||
* Switch状态proto
|
||||
*/
|
||||
public static void convertForSwitch(final int statusBitMap,final int spare,final DeviceStatusProto.Switch.Builder to) throws Exception {
|
||||
convert(DeviceStatus.SWITCH.class,statusBitMap,to);
|
||||
final int SPEED_LIMIT_MASK = 0x000000ff;
|
||||
final int speedLimit = spare&SPEED_LIMIT_MASK;
|
||||
to.setSpeedLimit(speedLimit);
|
||||
}
|
||||
/**
|
||||
* 把设备位图状态转换为proto定义的设备状态
|
||||
*
|
||||
* @param deviceStatusEnum 如DeviceStatus.SIGNAL.class
|
||||
* @param statusBitMap 该设备的符合状态位图
|
||||
*/
|
||||
public static <T extends GeneratedMessageV3.Builder> T convert(final Class<?> deviceStatusEnum, final int statusBitMap) throws Exception {
|
||||
final GeneratedMessageV3.Builder to = findBy(deviceStatusEnum);
|
||||
convert(deviceStatusEnum, statusBitMap, to);
|
||||
return (T) to;
|
||||
}
|
||||
|
||||
/**
|
||||
* 把设备位图状态转换为proto定义的设备状态
|
||||
*
|
||||
* @param deviceStatusEnum 如DeviceStatus.SIGNAL.class
|
||||
* @param statusBitMap 该设备的符合状态位图
|
||||
* @param to proto设备状态
|
||||
*/
|
||||
public static void convert(final Class<?> deviceStatusEnum, final int statusBitMap, final GeneratedMessageV3.Builder to) throws Exception {
|
||||
final Class<?> toClass = to.getClass();
|
||||
final Method enumValues = deviceStatusEnum.getMethod("values");
|
||||
final Object values = enumValues.invoke(deviceStatusEnum);
|
||||
final int len = Array.getLength(values);
|
||||
for (int i = 0; i < len; i++) {
|
||||
final DeviceStatus.Status devStateEnum = (DeviceStatus.Status) Array.get(values, i);
|
||||
final String enumUnitName = devStateEnum.toString();
|
||||
final int devStateMask = devStateEnum.mask();
|
||||
final String setName = toSetName(enumUnitName);
|
||||
final Method setMethod = toClass.getMethod(setName, boolean.class);
|
||||
setMethod.invoke(to, devStateMask == (statusBitMap & devStateMask));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 以信号机为例测试
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
final int bitMap = DeviceStatus.SIGNAL.GREEN_OPEN.mask() | DeviceStatus.SIGNAL.GREEN_FLASH.mask();
|
||||
final DeviceStatusProto.Signal.Builder signal = convert(DeviceStatus.SIGNAL.class, bitMap);
|
||||
System.out.println(String.format("==>>greenOpen = %s greenFlash = %s blueFlash = %s", signal.getGreenOpen(), signal.getGreenFlash(), signal.getBlueFlash()));
|
||||
}
|
||||
/**
|
||||
* Track状态proto
|
||||
*/
|
||||
public static void convertForTrack(final int statusBitMap, final DeviceStatusProto.Track.Builder to) throws Exception {
|
||||
convert(DeviceStatus.TRACK.class, statusBitMap, to);
|
||||
final int SPEED_LIMIT_MASK = 0xff000000;
|
||||
final int SPEED_LIMIT_TYPE_MASK = 0x00f00000;
|
||||
final int speedLimit = (statusBitMap & SPEED_LIMIT_MASK) >> 24;
|
||||
final int speedLimitType = (statusBitMap & SPEED_LIMIT_TYPE_MASK) >> 20;
|
||||
to.setSpeedLimit(speedLimit);
|
||||
to.setLimitType(DeviceStatusProto.Track.LimitType.forNumber(speedLimitType));
|
||||
}
|
||||
|
||||
private static GeneratedMessageV3.Builder findBy(final Class<?> deviceStatusEnum) {
|
||||
/**
|
||||
* Platform状态proto
|
||||
*/
|
||||
public static void convertForPlatform(final int statusBitMap, final int spare, final DeviceStatusProto.Platform.Builder to) throws Exception {
|
||||
convert(DeviceStatus.PLATFORM.class, statusBitMap, to);
|
||||
final int NEXT_SECTION_RUNTIME_MASK = 0xffff0000;
|
||||
final int NEXT_SECTION_RUN_LEVEL_MASK = 0x0000ff00;
|
||||
final int nextSectionRuntime = (spare & NEXT_SECTION_RUNTIME_MASK) >> 16;
|
||||
final int nextSectionRunLevel = (spare & NEXT_SECTION_RUN_LEVEL_MASK) >> 8;
|
||||
//
|
||||
final int STOP_TIME_MASK = 0xffff0000;
|
||||
final int stopTime = (statusBitMap & STOP_TIME_MASK) >> 16;
|
||||
//
|
||||
to.setNextSectionRunTime(nextSectionRuntime);
|
||||
to.setNextSectionRunLevel(nextSectionRunLevel);
|
||||
to.setStopTime(stopTime);
|
||||
}
|
||||
|
||||
if (deviceStatusEnum.isAssignableFrom(DeviceStatus.RTU.class)) {
|
||||
return DeviceStatusProto.Rtu.newBuilder();
|
||||
} else if (deviceStatusEnum.isAssignableFrom(DeviceStatus.STATION.class)) {
|
||||
return DeviceStatusProto.Station.newBuilder();
|
||||
} else if (deviceStatusEnum.isAssignableFrom(DeviceStatus.SIGNAL.class)) {
|
||||
return DeviceStatusProto.Signal.newBuilder();
|
||||
} else if (deviceStatusEnum.isAssignableFrom(DeviceStatus.ENTRY.class)) {
|
||||
return DeviceStatusProto.Entry.newBuilder();
|
||||
} else if (deviceStatusEnum.isAssignableFrom(DeviceStatus.SWITCH.class)) {
|
||||
return DeviceStatusProto.Switch.newBuilder();
|
||||
} else if (deviceStatusEnum.isAssignableFrom(DeviceStatus.TRACK.class)) {
|
||||
return DeviceStatusProto.Track.newBuilder();
|
||||
} else if (deviceStatusEnum.isAssignableFrom(DeviceStatus.PLATFORM.class)) {
|
||||
return DeviceStatusProto.Platform.newBuilder();
|
||||
} else if (deviceStatusEnum.isAssignableFrom(DeviceStatus.SCADA.class)) {
|
||||
return DeviceStatusProto.Scada.newBuilder();
|
||||
} else if (deviceStatusEnum.isAssignableFrom(DeviceStatus.WATERPROOF_DOOR.class)) {
|
||||
return DeviceStatusProto.WaterProofDoor.newBuilder();
|
||||
} else if (deviceStatusEnum.isAssignableFrom(DeviceStatus.WORK_AREA.class)) {
|
||||
return DeviceStatusProto.WorkArea.newBuilder();
|
||||
} else if (deviceStatusEnum.isAssignableFrom(DeviceStatus.GAMA.class)) {
|
||||
return DeviceStatusProto.Gama.newBuilder();
|
||||
} else if (deviceStatusEnum.isAssignableFrom(DeviceStatus.TRAIN_MODE.class)) {
|
||||
return DeviceStatusProto.TrainMode.newBuilder();
|
||||
}
|
||||
throw new RuntimeException(String.format("枚举类型%s对应的proto不存在", deviceStatusEnum.getName()));
|
||||
}
|
||||
/**
|
||||
* Switch状态proto
|
||||
*/
|
||||
public static void convertForSwitch(final int statusBitMap, final int spare, final DeviceStatusProto.Switch.Builder to) throws Exception {
|
||||
convert(DeviceStatus.SWITCH.class, statusBitMap, to);
|
||||
final int SPEED_LIMIT_MASK = 0x000000ff;
|
||||
final int speedLimit = spare & SPEED_LIMIT_MASK;
|
||||
to.setSpeedLimit(speedLimit);
|
||||
}
|
||||
|
||||
private static String toSetName(final String src) {
|
||||
final String fieldName = toFieldName(src);
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append("set");
|
||||
sb.append(fieldName.substring(0, 1)
|
||||
.toUpperCase());
|
||||
sb.append(fieldName.substring(1));
|
||||
return sb.toString();
|
||||
}
|
||||
/**
|
||||
* 把设备位图状态转换为proto定义的设备状态
|
||||
*
|
||||
* @param deviceStatusEnum 如DeviceStatus.SIGNAL.class
|
||||
* @param statusBitMap 该设备的符合状态位图
|
||||
*/
|
||||
public static <T extends GeneratedMessageV3.Builder> T convert(final Class<?> deviceStatusEnum, final int statusBitMap) throws Exception {
|
||||
final GeneratedMessageV3.Builder to = findBy(deviceStatusEnum);
|
||||
convert(deviceStatusEnum, statusBitMap, to);
|
||||
return (T) to;
|
||||
}
|
||||
|
||||
private static String toFieldName(final String src) {
|
||||
final String[] aa = src.toLowerCase()
|
||||
.split("_");
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < aa.length; i++) {
|
||||
if (i == 0) {
|
||||
sb.append(aa[i]);
|
||||
} else {
|
||||
sb.append(aa[i].substring(0, 1)
|
||||
.toUpperCase())
|
||||
.append(aa[i].substring(1));
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
/**
|
||||
* 把设备位图状态转换为proto定义的设备状态
|
||||
*
|
||||
* @param deviceStatusEnum 如DeviceStatus.SIGNAL.class
|
||||
* @param statusBitMap 该设备的符合状态位图
|
||||
* @param to proto设备状态
|
||||
*/
|
||||
public static void convert(final Class<?> deviceStatusEnum, final int statusBitMap, final GeneratedMessageV3.Builder to) throws Exception {
|
||||
final Class<?> toClass = to.getClass();
|
||||
final Method enumValues = deviceStatusEnum.getMethod("values");
|
||||
final Object values = enumValues.invoke(deviceStatusEnum);
|
||||
final int len = Array.getLength(values);
|
||||
for (int i = 0; i < len; i++) {
|
||||
final DeviceStatus.Status devStateEnum = (DeviceStatus.Status) Array.get(values, i);
|
||||
final String enumUnitName = devStateEnum.toString();
|
||||
final int devStateMask = devStateEnum.mask();
|
||||
final String setName = toSetName(enumUnitName);
|
||||
final Method setMethod = toClass.getMethod(setName, boolean.class);
|
||||
setMethod.invoke(to, devStateMask == (statusBitMap & devStateMask));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 以信号机为例测试
|
||||
*/
|
||||
public static void main(String[] args) throws Exception {
|
||||
final int bitMap = DeviceStatus.SIGNAL.GREEN_OPEN.mask() | DeviceStatus.SIGNAL.GREEN_FLASH.mask();
|
||||
final DeviceStatusProto.Signal.Builder signal = convert(DeviceStatus.SIGNAL.class, bitMap);
|
||||
System.out.println(String.format("==>>greenOpen = %s greenFlash = %s blueFlash = %s", signal.getGreenOpen(), signal.getGreenFlash(), signal.getBlueFlash()));
|
||||
}
|
||||
|
||||
private static GeneratedMessageV3.Builder findBy(final Class<?> deviceStatusEnum) {
|
||||
|
||||
if (deviceStatusEnum.isAssignableFrom(DeviceStatus.RTU.class)) {
|
||||
return DeviceStatusProto.Rtu.newBuilder();
|
||||
} else if (deviceStatusEnum.isAssignableFrom(DeviceStatus.STATION.class)) {
|
||||
return DeviceStatusProto.Station.newBuilder();
|
||||
} else if (deviceStatusEnum.isAssignableFrom(DeviceStatus.SIGNAL.class)) {
|
||||
return DeviceStatusProto.Signal.newBuilder();
|
||||
} else if (deviceStatusEnum.isAssignableFrom(DeviceStatus.ENTRY.class)) {
|
||||
return DeviceStatusProto.Entry.newBuilder();
|
||||
} else if (deviceStatusEnum.isAssignableFrom(DeviceStatus.SWITCH.class)) {
|
||||
return DeviceStatusProto.Switch.newBuilder();
|
||||
} else if (deviceStatusEnum.isAssignableFrom(DeviceStatus.TRACK.class)) {
|
||||
return DeviceStatusProto.Track.newBuilder();
|
||||
} else if (deviceStatusEnum.isAssignableFrom(DeviceStatus.PLATFORM.class)) {
|
||||
return DeviceStatusProto.Platform.newBuilder();
|
||||
} else if (deviceStatusEnum.isAssignableFrom(DeviceStatus.SCADA.class)) {
|
||||
return DeviceStatusProto.Scada.newBuilder();
|
||||
} else if (deviceStatusEnum.isAssignableFrom(DeviceStatus.WATERPROOF_DOOR.class)) {
|
||||
return DeviceStatusProto.WaterProofDoor.newBuilder();
|
||||
} else if (deviceStatusEnum.isAssignableFrom(DeviceStatus.WORK_AREA.class)) {
|
||||
return DeviceStatusProto.WorkArea.newBuilder();
|
||||
} else if (deviceStatusEnum.isAssignableFrom(DeviceStatus.GAMA.class)) {
|
||||
return DeviceStatusProto.Gama.newBuilder();
|
||||
} else if (deviceStatusEnum.isAssignableFrom(DeviceStatus.TRAIN_MODE.class)) {
|
||||
return DeviceStatusProto.TrainMode.newBuilder();
|
||||
}
|
||||
throw new RuntimeException(String.format("枚举类型%s对应的proto不存在", deviceStatusEnum.getName()));
|
||||
}
|
||||
|
||||
private static String toSetName(final String src) {
|
||||
final String fieldName = toFieldName(src);
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append("set");
|
||||
sb.append(fieldName.substring(0, 1)
|
||||
.toUpperCase());
|
||||
sb.append(fieldName.substring(1));
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static String toFieldName(final String src) {
|
||||
final String[] aa = src.toLowerCase()
|
||||
.split("_");
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < aa.length; i++) {
|
||||
if (i == 0) {
|
||||
sb.append(aa[i]);
|
||||
} else {
|
||||
sb.append(aa[i].substring(0, 1)
|
||||
.toUpperCase())
|
||||
.append(aa[i].substring(1));
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,13 @@
|
||||
package club.joylink.xiannccda.ats.message.line3.rep;
|
||||
|
||||
import club.joylink.xiannccda.ats.message.MessageData;
|
||||
import club.joylink.xiannccda.ats.message.MessageResponse;
|
||||
import club.joylink.xiannccda.ats.message.line3.DateTimeUtil;
|
||||
import club.joylink.xiannccda.ats.message.line3.rep.EntityParseUtil.ReadData;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 2.8.10 操作命令消息
|
||||
@ -16,6 +17,7 @@ import java.util.List;
|
||||
NCC FEP主动发起事件及告警信息查询,OCC FEP收到此消息后发送操作命令信息给NCC 。
|
||||
*/
|
||||
|
||||
@Getter
|
||||
public class ActionReportResponse extends MessageResponse {
|
||||
|
||||
/**
|
||||
@ -52,7 +54,7 @@ public class ActionReportResponse extends MessageResponse {
|
||||
this.entityList = EntityParseUtil.collect(this.count, buf, ActionReportEntity.class);
|
||||
}
|
||||
|
||||
|
||||
@Getter
|
||||
public static class ActionReportEntity implements ReadData<ActionReportEntity> {
|
||||
|
||||
/**
|
||||
@ -64,7 +66,7 @@ public class ActionReportResponse extends MessageResponse {
|
||||
* <p>
|
||||
* 0x00:未知
|
||||
*/
|
||||
private ReportSiteEnum actionSite;
|
||||
private ActionReportSiteEnum actionSite;
|
||||
/**
|
||||
* 单位编码(2)
|
||||
* <p>
|
||||
@ -110,7 +112,7 @@ public class ActionReportResponse extends MessageResponse {
|
||||
public ActionReportEntity read(ByteBuf buf) {
|
||||
ActionReportEntity entity = new ActionReportEntity();
|
||||
|
||||
entity.actionSite = MessageData.ReportSiteEnum.of(buf.readByte());
|
||||
entity.actionSite = ActionReportSiteEnum.of(buf.readByte());
|
||||
|
||||
entity.actionSiteid = buf.readShort();
|
||||
entity.actionName = EntityParseUtil.convertStr(buf, 20);
|
||||
@ -126,4 +128,63 @@ public class ActionReportResponse extends MessageResponse {
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 单位类型
|
||||
* <p>
|
||||
* 2.8.10 操作命令消息(Action_site)
|
||||
*/
|
||||
public enum ActionReportSiteEnum {
|
||||
STATION(0x01), CENTER(0x02), UNKNOW(0x00);
|
||||
@Getter
|
||||
int val;
|
||||
|
||||
ActionReportSiteEnum(int b) {
|
||||
this.val = b;
|
||||
}
|
||||
|
||||
public static ActionReportSiteEnum of(byte d) {
|
||||
return Arrays.stream(ActionReportSiteEnum.values()).filter(dd -> dd.val == d).findFirst().orElse(null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 操作类型
|
||||
*/
|
||||
public enum ActionTypeControlEnum {
|
||||
/**
|
||||
* 进路控制
|
||||
* <p>
|
||||
* 包括进路排列、引导进路办理、进路取消、进路人解等操作
|
||||
*/
|
||||
ROUTE(0X01),
|
||||
/**
|
||||
* 信号控制
|
||||
* <p>
|
||||
* 包括道岔操作、区段操作、信号机操作、站台操作等
|
||||
*/
|
||||
SIGNAL(0X02),
|
||||
/**
|
||||
* 列车管理
|
||||
* <p>
|
||||
* 包括列车识别号操作、列车控制操作等
|
||||
*/
|
||||
TRAIN(0X03),
|
||||
/**
|
||||
* 计划管理
|
||||
* <p>
|
||||
* 包括在线计划管理操作等
|
||||
*/
|
||||
PLAN(0X04), OTHER(0X05);
|
||||
@Getter
|
||||
int val;
|
||||
|
||||
ActionTypeControlEnum(int v) {
|
||||
this.val = v;
|
||||
}
|
||||
|
||||
public static ActionTypeControlEnum of(int d) {
|
||||
return Arrays.stream(ActionTypeControlEnum.values()).filter(dd -> dd.val == d).findFirst().orElse(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,9 @@ import club.joylink.xiannccda.ats.message.line3.DateTimeUtil;
|
||||
import club.joylink.xiannccda.ats.message.line3.rep.EntityParseUtil.ReadData;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 2.8.11 列车信息、系统事件消息
|
||||
@ -15,7 +17,7 @@ import java.util.List;
|
||||
发送条件:
|
||||
NCC FEP主动发起事件及告警信息查询,OCC FEP收到此消息后发送列车信息、系统事件给NCC。
|
||||
*/
|
||||
|
||||
@Getter
|
||||
public class AlarmReportResponse extends MessageResponse {
|
||||
|
||||
public AlarmReportResponse() {
|
||||
@ -55,6 +57,7 @@ public class AlarmReportResponse extends MessageResponse {
|
||||
this.entityList = EntityParseUtil.collect(this.count, buf, AlarmReportEntity.class);
|
||||
}
|
||||
|
||||
@Getter
|
||||
public static class AlarmReportEntity implements ReadData<AlarmReportEntity> {
|
||||
|
||||
/**
|
||||
@ -66,7 +69,7 @@ public class AlarmReportResponse extends MessageResponse {
|
||||
* <p>
|
||||
* 0x00:未知
|
||||
*/
|
||||
private ReportSiteEnum alamrSite;
|
||||
private AlarmReportSiteEnum alamrSite;
|
||||
/**
|
||||
* 单位编码(2)
|
||||
* <p>
|
||||
@ -90,7 +93,7 @@ public class AlarmReportResponse extends MessageResponse {
|
||||
* <p>
|
||||
* 注:西安3号线告警无报警类型(alarm _type)区分,将按照统一的报警类型发送本消息。
|
||||
*/
|
||||
private ActionTypeControlEnum alarmType;
|
||||
private AlarmTypeControlEnum alarmType;
|
||||
/**
|
||||
* 报警子类型,预留(2)
|
||||
*/
|
||||
@ -124,12 +127,12 @@ public class AlarmReportResponse extends MessageResponse {
|
||||
@Override
|
||||
public AlarmReportEntity read(ByteBuf buf) {
|
||||
AlarmReportEntity entity = new AlarmReportEntity();
|
||||
entity.alamrSite = ReportSiteEnum.of(buf.readByte());
|
||||
entity.alamrSite = AlarmReportSiteEnum.of(buf.readByte());
|
||||
entity.alarmSiteid = buf.readShort();
|
||||
entity.alarmNname = EntityParseUtil.convertStr(buf, 20);
|
||||
|
||||
entity.alarmTime = DateTimeUtil.convert(buf);
|
||||
entity.alarmType = ActionTypeControlEnum.of(buf.readShort());
|
||||
entity.alarmType = AlarmTypeControlEnum.of(buf.readShort());
|
||||
entity.alarmSubType = buf.readShort();
|
||||
entity.alarmLen = buf.readShort();
|
||||
|
||||
@ -142,4 +145,69 @@ public class AlarmReportResponse extends MessageResponse {
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 单位类型
|
||||
* <p>
|
||||
* 2.8.11 列车信息、系统事件消息(alamr_site)
|
||||
*/
|
||||
public enum AlarmReportSiteEnum {
|
||||
STATION(0x01), CENTER(0x02), UNKNOW(0x00);
|
||||
@Getter
|
||||
int val;
|
||||
|
||||
AlarmReportSiteEnum(int b) {
|
||||
this.val = b;
|
||||
}
|
||||
|
||||
public static AlarmReportSiteEnum of(byte d) {
|
||||
return Arrays.stream(AlarmReportSiteEnum.values()).filter(dd -> dd.val == d).findFirst().orElse(null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 报警类型
|
||||
*/
|
||||
public enum AlarmTypeControlEnum {
|
||||
/**
|
||||
* 操作命令相关报警
|
||||
* <p>
|
||||
* 包括进路控制、信号控制、列车管理、计划管理及其它操作命令执行失败产生的报警
|
||||
*/
|
||||
ALARM_ACTION(0X01),
|
||||
/**
|
||||
* 信号相关报警
|
||||
* <p>
|
||||
* 包括轨道、道岔、信号机及其它信号设备相关的报警
|
||||
*/
|
||||
ALARM_SIGNAL(0X02),
|
||||
/**
|
||||
* 进路相关报警
|
||||
* <p>
|
||||
* 包括进路相关的报警
|
||||
*/
|
||||
ALARM_ROUTE(0X03),
|
||||
/**
|
||||
* 列车相关报警
|
||||
* <p>
|
||||
* 包括列车状态、列车管理、列车计划等相关报警
|
||||
*/
|
||||
ALARM_TRAIN(0X04),
|
||||
/**
|
||||
* 系统事件
|
||||
* <p>
|
||||
* 包括系统设备状态、网络状态、控制模式、外部接口状态等系统事件
|
||||
*/
|
||||
ALARM_SYS(0X05);
|
||||
@Getter
|
||||
int val;
|
||||
|
||||
AlarmTypeControlEnum(int v) {
|
||||
this.val = v;
|
||||
}
|
||||
|
||||
public static AlarmTypeControlEnum of(int d) {
|
||||
return Arrays.stream(AlarmTypeControlEnum.values()).filter(dd -> dd.val == d).findFirst().orElse(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import club.joylink.xiannccda.ats.message.line3.rep.EntityParseUtil.ReadData;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 2.7.7 出入库派班计划消息
|
||||
@ -27,7 +28,7 @@ import java.util.List;
|
||||
当OCC FEP判断和OCC服务器断开重连上后,发送此信息给NCC;
|
||||
当当天出入库派班计划发生变更时,OCC FEP发送此信息给NCC 。
|
||||
*/
|
||||
|
||||
@Getter
|
||||
public class DepotPlanResponse extends MessageResponse {
|
||||
|
||||
public DepotPlanResponse() {
|
||||
@ -61,6 +62,7 @@ public class DepotPlanResponse extends MessageResponse {
|
||||
|
||||
}
|
||||
|
||||
@Getter
|
||||
public static class DepotPlanEntity implements ReadData<DepotPlanEntity> {
|
||||
|
||||
/**
|
||||
|
@ -7,6 +7,7 @@ import club.joylink.xiannccda.ats.message.line3.device.DeviceStatus;
|
||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 2.7.4 设备状态全体消息
|
||||
@ -25,7 +26,7 @@ import java.util.List;
|
||||
* <p>
|
||||
* 当某些线路集中站本身定时向OCC服务器发送全体数据时,同时OCC FEP也会向NCC发全体数据。(这种情况下,周期发送设备状态全体消息的间隔建议不小于600秒)
|
||||
*/
|
||||
|
||||
@Getter
|
||||
public class DeviceStatusBitmapResponse extends MessageResponse {
|
||||
|
||||
public DeviceStatusBitmapResponse() {
|
||||
@ -57,6 +58,7 @@ public class DeviceStatusBitmapResponse extends MessageResponse {
|
||||
this.entityList = EntityParseUtil.collect(this.typeCnt, buf, DeviceTypeEntity.class);
|
||||
}
|
||||
|
||||
@Getter
|
||||
public static class DeviceTypeEntity implements ReadData<DeviceTypeEntity> {
|
||||
|
||||
/**
|
||||
@ -91,7 +93,7 @@ public class DeviceStatusBitmapResponse extends MessageResponse {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Getter
|
||||
public static class DeviceEntity implements ReadData<DeviceEntity> {
|
||||
|
||||
/**
|
||||
|
@ -5,6 +5,7 @@ import club.joylink.xiannccda.ats.message.MessageResponse;
|
||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceStatus;
|
||||
import club.joylink.xiannccda.ats.message.line3.device.DeviceType;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 2.7.5 设备状态变化消息
|
||||
@ -16,7 +17,7 @@ import io.netty.buffer.ByteBuf;
|
||||
* 当某个设备状态变化时,OCC发送该消息给NCC。集中站状态变化也作为设备状态变化发。
|
||||
*/
|
||||
|
||||
|
||||
@Getter
|
||||
public class DeviceStatusChangeResponse extends MessageResponse {
|
||||
|
||||
public DeviceStatusChangeResponse() {
|
||||
|
@ -7,6 +7,7 @@ import club.joylink.xiannccda.ats.message.line3.rep.EntityParseUtil.ReadData;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 2.8.15 实际列车运行图消息
|
||||
@ -18,7 +19,7 @@ import java.util.List;
|
||||
* 当OCC收到NCC ATS信息请求消息时,发送当天实际列车运行信息给NCC。
|
||||
*/
|
||||
|
||||
|
||||
@Getter
|
||||
public class HistoryScheduleResponse extends MessageResponse {
|
||||
|
||||
public HistoryScheduleResponse() {
|
||||
@ -68,6 +69,7 @@ public class HistoryScheduleResponse extends MessageResponse {
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
public static class HistoryScheduleEntity implements ReadData<HistoryScheduleEntity> {
|
||||
|
||||
/**
|
||||
|
@ -7,6 +7,7 @@ import club.joylink.xiannccda.ats.message.line3.rep.EntityParseUtil.ReadData;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 2.8.14 计划列车运行图消息
|
||||
@ -19,7 +20,7 @@ import java.util.List;
|
||||
* <p>
|
||||
* 当OCC收到NCC ATS信息请求消息时,发送当天计划列车运行信息给NCC。
|
||||
*/
|
||||
|
||||
@Getter
|
||||
public class InusedScheduleResponse extends MessageResponse {
|
||||
|
||||
public InusedScheduleResponse() {
|
||||
@ -65,6 +66,7 @@ public class InusedScheduleResponse extends MessageResponse {
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
public static class InusedScheduleEntity implements ReadData<InusedScheduleEntity> {
|
||||
|
||||
/**
|
||||
@ -99,6 +101,7 @@ public class InusedScheduleResponse extends MessageResponse {
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
public static class EntityRecord implements ReadData<EntityRecord> {
|
||||
|
||||
/**
|
||||
|
@ -4,6 +4,7 @@ import club.joylink.xiannccda.ats.message.MessageData;
|
||||
import club.joylink.xiannccda.ats.message.MessageId;
|
||||
import club.joylink.xiannccda.ats.message.MessageResponse;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 2.7.2 信息源网络状态消息
|
||||
@ -12,7 +13,7 @@ import io.netty.buffer.ByteBuf;
|
||||
* <p>
|
||||
* 当网络状态变化时发送此消息。当NCC FEP与OCC FEP初始建立通信时,OCC FEP也发送此消息
|
||||
*/
|
||||
|
||||
@Getter
|
||||
public class NetworkAliveStatusResponse extends MessageResponse {
|
||||
|
||||
/**
|
||||
|
@ -4,6 +4,7 @@ import club.joylink.xiannccda.ats.message.MessageId;
|
||||
import club.joylink.xiannccda.ats.message.MessageResponse;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.Arrays;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 2.8.12 查询无结果消息
|
||||
@ -15,7 +16,7 @@ import java.util.Arrays;
|
||||
* 对统计信息查询消息(REPORT_ASK)、事件及告警信息请求消息(ALARM_ACK),在特殊情况下OCC FEP均可使用此消息进行答复。
|
||||
*/
|
||||
|
||||
|
||||
@Getter
|
||||
public class ReportNackResponse extends MessageResponse {
|
||||
|
||||
public ReportNackResponse() {
|
||||
|
@ -6,6 +6,7 @@ import club.joylink.xiannccda.ats.message.line3.rep.EntityParseUtil.ReadData;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
|
||||
|
||||
/**
|
||||
@ -22,7 +23,7 @@ import java.util.List;
|
||||
* 当集中站的信号机人工/自动模式发生变化时,发送集中站的所有信号模式给NCC。
|
||||
*/
|
||||
|
||||
|
||||
@Getter
|
||||
public class SignalRouteStatusResponse extends MessageResponse {
|
||||
|
||||
public SignalRouteStatusResponse() {
|
||||
@ -53,6 +54,7 @@ public class SignalRouteStatusResponse extends MessageResponse {
|
||||
|
||||
}
|
||||
|
||||
@Getter
|
||||
public static class SignalStatusEntity implements ReadData<SignalStatusEntity> {
|
||||
|
||||
/**
|
||||
@ -78,6 +80,7 @@ public class SignalRouteStatusResponse extends MessageResponse {
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
public static class RouteStatusEntity implements ReadData<RouteStatusEntity> {
|
||||
|
||||
/**
|
||||
|
@ -6,6 +6,7 @@ import club.joylink.xiannccda.ats.message.line3.DateTimeUtil;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Arrays;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 2.8.9 事件及告警信息请求消息
|
||||
@ -16,7 +17,7 @@ import java.util.Arrays;
|
||||
NCC FEP主动发起事件及告警信息查询,OCC FEP收到此消息后发送事件及告警信息给NCC 。
|
||||
注:开始时间和结束时间范围不超过4小时
|
||||
*/
|
||||
|
||||
@Setter
|
||||
public class AlarmAckRequest extends MessageRequest {
|
||||
|
||||
|
||||
|
@ -4,6 +4,7 @@ import club.joylink.xiannccda.ats.message.MessageData;
|
||||
import club.joylink.xiannccda.ats.message.MessageId;
|
||||
import club.joylink.xiannccda.ats.message.MessageRequest;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 2.7.3 ATS信息请求消息
|
||||
@ -34,6 +35,7 @@ import io.netty.buffer.ByteBuf;
|
||||
* <p>
|
||||
* HISTORY_SCHEDULE(当天实际运行图消息)。
|
||||
*/
|
||||
@Setter
|
||||
public class LoadDeviceStatusRequest extends MessageRequest {
|
||||
|
||||
|
||||
|
@ -5,6 +5,7 @@ import club.joylink.xiannccda.ats.message.MessageRequest;
|
||||
import club.joylink.xiannccda.ats.message.line3.DateTimeUtil;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 2.8.13 历史运行图申请消息 定义:
|
||||
@ -15,6 +16,7 @@ import java.time.LocalDateTime;
|
||||
* <p>
|
||||
* 当NCC与OCC通信长时间中断引起某些日期的历史数据(非当天)缺损时,NCC FEP人工发起此消息给OCC FEP,由OCC FEP根据消息类型和申请时间发送历史计划和历史运行数据给NCC。
|
||||
*/
|
||||
@Setter
|
||||
public class LoadHistoryTGDataRequest extends MessageRequest {
|
||||
|
||||
public LoadHistoryTGDataRequest() {
|
||||
|
@ -0,0 +1,57 @@
|
||||
package club.joylink.xiannccda.protocal.x;
|
||||
|
||||
import club.joylink.xiannccda.ats.message.line3.DateTimeUtil;
|
||||
import club.joylink.xiannccda.ats.message.line3.MessageCons;
|
||||
import club.joylink.xiannccda.ats.message.line3.rep.ActionReportResponse;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class ActionReportResponseTest {
|
||||
|
||||
public static void main(String[] a) throws Exception {
|
||||
ByteBuf buf = Unpooled.buffer(1024);
|
||||
/*this.lineId = buf.readShort();
|
||||
this.reportId = buf.readShort();
|
||||
this.totalMessage = buf.readShort();
|
||||
this.messageSequence = buf.readShort();
|
||||
this.count = buf.readShort();*/
|
||||
buf.writeShort(1);
|
||||
buf.writeShort(2);
|
||||
buf.writeShort(3);
|
||||
buf.writeShort(3);
|
||||
buf.writeShort(2); //count
|
||||
|
||||
buf.writeByte(ActionReportResponse.ActionReportSiteEnum.CENTER.getVal());
|
||||
buf.writeShort(2);
|
||||
byte[] actions = new byte[20];
|
||||
TestUtil.fill("action name1", MessageCons.STRING_CHARSET, actions);
|
||||
buf.writeBytes(actions);
|
||||
buf.writeBytes(DateTimeUtil.convert(LocalDateTime.now()));
|
||||
byte[] users = new byte[20];
|
||||
TestUtil.fill("user name1", MessageCons.STRING_CHARSET, users);
|
||||
buf.writeBytes(users);
|
||||
buf.writeShort(ActionReportResponse.ActionTypeControlEnum.PLAN.getVal());
|
||||
buf.writeShort(1);
|
||||
buf.writeShort("Test Content".getBytes().length);
|
||||
buf.writeBytes("Test Content".getBytes());
|
||||
|
||||
buf.writeByte(ActionReportResponse.ActionReportSiteEnum.STATION.getVal());
|
||||
buf.writeShort(2);
|
||||
byte[] actions2 = new byte[20];
|
||||
TestUtil.fill("action name2", MessageCons.STRING_CHARSET, actions2);
|
||||
buf.writeBytes(actions2);
|
||||
buf.writeBytes(DateTimeUtil.convert(LocalDateTime.now()));
|
||||
byte[] users2 = new byte[20];
|
||||
TestUtil.fill("user name2", MessageCons.STRING_CHARSET, users2);
|
||||
buf.writeBytes(users2);
|
||||
buf.writeShort(ActionReportResponse.ActionTypeControlEnum.TRAIN.getVal());
|
||||
buf.writeShort(2);
|
||||
buf.writeShort("Test Content 2".getBytes().length);
|
||||
buf.writeBytes("Test Content 2".getBytes());
|
||||
ActionReportResponse response = new ActionReportResponse();
|
||||
response.decode2(buf);
|
||||
System.out.println(JSON.toJSONString(response));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user