非实时消息

This commit is contained in:
tiger_zhou 2023-06-08 18:07:58 +08:00
parent 5c87f6a2bb
commit 670a103e7b
2 changed files with 137 additions and 16 deletions

View File

@ -1,6 +1,9 @@
package club.joylink.xiannccda.ats.message.rep;
import club.joylink.xiannccda.ats.message.line3.MessageCons;
import club.joylink.xiannccda.ats.message.rep.device.DeviceStatus;
import club.joylink.xiannccda.ats.message.rep.device.DeviceType;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import io.netty.buffer.ByteBuf;
import java.util.List;
@ -27,9 +30,14 @@ public class EntityParseUtil {
public static String convertStr(ByteBuf buf, int len) {
byte[] data = new byte[len];
buf.readBytes(data);
return new String(data, MessageCons.STRING_CHARSET);
return new String(data, MessageCons.STRING_CHARSET).trim();
}
/*public static List<Enum> convertDeviceStatus(Short lineId, DeviceType type) {
}*/
public interface ReadData<T> {
T read(ByteBuf buf);

View File

@ -1,20 +1,25 @@
package club.joylink.xiannccda.ats.message.rep.device;
import com.google.common.collect.Lists;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import lombok.Getter;
public class DeviceStatus {
public interface Status {
List<Enum> parse();
List<Enum> parse(Short lineId, Integer status);
}
/**
* 表6.3-1设备状态定义表 - RTU
*/
public enum RTU {
public enum RTU implements Status {
IP_RTU_STUS_DOWN(0x00008000),// 通信中断
IP_RTU_STUS_IN_LOCAL_CTRL(0x00000001),// 站控
IP_RTU_STUS_IN_CENTRAL_CTRL(0x00000002),// 遥控
@ -25,6 +30,13 @@ public class DeviceStatus {
RTU(int val) {
this.val = val;
}
@Override
public List<Enum> parse(Short lineId, Integer status) {
Enum nume = Arrays.stream(RTU.values()).filter(d -> d.val == status).findFirst().orElse(null);
return List.of(nume);
}
}
/**
@ -32,7 +44,7 @@ public class DeviceStatus {
* <p>
* 西安3号线信号系统不提供此类型设备的状态
*/
public enum STATION {
public enum STATION implements Status {
IP_STA_STUS_TERM_MODE1(0x00000001),//终端模式1(terminaL3)
IP_STA_STUS_TERM_MODE2(0x00000002),//终端模式2(terminal2)
IP_STA_STUS_TERM_MODE3(0x00000004),//终端模式3(terminal3)
@ -63,6 +75,15 @@ public class DeviceStatus {
STATION(int val) {
this.val = val;
}
@Override
public List<Enum> parse(Short lineId, Integer status) {
if (lineId != 3) {
Enum nume = Arrays.stream(STATION.values()).filter(d -> d.val == status).findFirst().orElse(null);
return List.of(nume);
}
return Collections.emptyList();
}
}
/**
@ -70,7 +91,7 @@ public class DeviceStatus {
* <p>
* 3西安3号线信号系统不提供序号为2468101213141723的信号机状态
*/
public enum SIGNAL {
public enum SIGNAL implements Status {
// 定义枚举对象RED_OPEN值为0x00000001表示红灯亮
RED_OPEN(0x00000001),
// 定义枚举对象RED_FLASH值为0x00000002表示红灯闪
@ -124,12 +145,24 @@ public class DeviceStatus {
SIGNAL(int val) {
this.val = val;
}
private final static List<Integer> FILTER_LINE3 = Lists.newArrayList(2, 4, 6, 8, 10, 12, 13, 14, 17, 23);
@Override
public List<Enum> parse(Short lineId, Integer status) {
Stream<SIGNAL> stream = Arrays.stream(SIGNAL.values());
if (lineId == 3) {
stream.filter(d -> !FILTER_LINE3.contains(d.ordinal() + 1));
}
return stream.filter(d -> (status & d.val) == d.val).collect(Collectors.toList());
}
}
/**
* 表6.3-4设备状态定义表 ENTRY 西安3号线信号系统不提供此类型设备的状态
*/
public enum ENTRY {
public enum ENTRY implements Status {
// 定义枚举对象DIR_LEFT值为0x00000001
DIR_LEFT(0x00000001),
// 定义枚举对象DIR_RIGHT值为0x00000002
@ -141,6 +174,11 @@ public class DeviceStatus {
ENTRY(int val) {
this.val = val;
}
@Override
public List<Enum> parse(Short lineId, Integer status) {
return Arrays.stream(ENTRY.values()).filter(d -> d.val == status).collect(Collectors.toList());
}
}
@ -149,7 +187,7 @@ public class DeviceStatus {
* <p>
* 西安3号线信号系统不提供序号为910111213141516的道岔状态
*/
public enum SWITCH {
public enum SWITCH implements Status {
IP_SINGLE_SWITCH_STUS_CI_OCCUPIED(0x00000002),//联锁报告道岔占用
IP_SINGLE_SWITCH_STUS_CBTC_OCCUPIED(0x00000004),//CBTC报告列车占用该道岔
IP_SINGLE_SWITCH_STUS_LOCKED(0x00000008),//道岔锁闭
@ -182,12 +220,25 @@ public class DeviceStatus {
SWITCH(int val) {
this.val = val;
}
private final static List<Integer> FILTER_LINE3 = Lists.newArrayList(9, 10, 11, 12, 13, 14, 15, 16);
@Override
public List<Enum> parse(Short lineId, Integer status) {
Stream<SWITCH> stream = Arrays.stream(SWITCH.values());
if (lineId == 3) {
stream.filter(d -> !FILTER_LINE3.contains(d.ordinal() + 1));
}
return stream.filter(d -> (status & d.val) == d.val).collect(Collectors.toList());
}
}
/**
* 表6.3-6 设备状态定义表 TRACK
* <p>
* 西安3号线信号系统不提供该设备序号为567的轨道设备状态
*/
public enum TRACK {
public enum TRACK implements Status {
CI_OCCUPIED(0x00000002), // 联锁报告区段占用
CBTC_OCCUPIED(0x00000004), // CBTC信息报告轨道占用
LOCKED(0x00000008), // 锁闭
@ -209,12 +260,23 @@ public class DeviceStatus {
TRACK(int val) {
this.val = val;
}
private final static List<Integer> FILTER_LINE3 = Lists.newArrayList(5, 6, 7);
@Override
public List<Enum> parse(Short lineId, Integer status) {
Stream<TRACK> stream = Arrays.stream(TRACK.values());
if (lineId == 3) {
stream.filter(d -> !FILTER_LINE3.contains(d.ordinal() + 1));
}
return stream.filter(d -> (status & d.val) == d.val).collect(Collectors.toList());
}
}
/**
* 表6.3-7 设备状态定义表 PLATFORM
*/
public enum PLATFORM {
public enum PLATFORM implements Status {
EMERGSTOP(0x00000001), // 紧急关闭
TRAINBERTH(0x00000002), // 列车停站
CLOSE(0x00000004), // 站台关闭清客
@ -234,9 +296,19 @@ public class DeviceStatus {
PLATFORM(int val) {
this.val = val;
}
@Override
public List<Enum> parse(Short lineId, Integer status) {
return Arrays.stream(PLATFORM.values()).filter(d -> d.val == status).collect(Collectors.toList());
}
}
public enum SCADA {
/**
* 3.3.8 DEVICE_TYPE_SCADA
*/
public enum SCADA implements Status {
SCADA_ON(0x00000001), // 有电
SCADA_SINGLE_POWER(0x00000002), // 单边供电
SCADA_UNKOWN(0x00000004); // 未知状态
@ -245,12 +317,20 @@ public class DeviceStatus {
SCADA(int value) {
this.value = value;
}
@Override
public List<Enum> parse(Short lineId, Integer status) {
return Arrays.stream(WATERPROOF_DOOR.values()).filter(d -> d.value == status).collect(Collectors.toList());
}
}
/**
* 设备状态定义表 WATERPROOF_DOOR
* <p>
* 西安3号线信号系统不提供此类型设备的状态
*/
public enum WATERPROOF_DOOR {
public enum WATERPROOF_DOOR implements Status {
DOOR_CLOSED(0x00000001), // 防淹门关闭
DOOR_EXPECT_CLOSE(0x00000002), // 请求防淹门关闭
@ -268,13 +348,23 @@ public class DeviceStatus {
WATERPROOF_DOOR(int value) {
this.value = value;
}
@Override
public List<Enum> parse(Short lineId, Integer status) {
if (lineId == 3) {
return Collections.emptyList();
}
return Arrays.stream(WATERPROOF_DOOR.values()).filter(d -> d.value == status).collect(Collectors.toList());
}
}
/**
* 设备状态定义表 WORK_AREA
* <p>
* 西安3号线信号系统不提供此类型设备的状态
*/
public enum WORK_AREA {
public enum WORK_AREA implements Status {
/**
* 该位为1 工作区使能
*/
@ -284,27 +374,49 @@ public class DeviceStatus {
WORK_AREA(int val) {
this.val = val;
}
@Override
public List<Enum> parse(Short lineId, Integer status) {
if (lineId == 3) {
return Collections.emptyList();
}
return IP_STUS_WORK_AREA_ENABLE.val == status ? List.of(IP_STUS_WORK_AREA_ENABLE) : Collections.emptyList();
}
}
/**
* 设备状态定义表 GAMA
* <p>
* 西安3号线信号系统不提供此类型设备的状态
*/
public enum DeviceTypeStatusGAMAEnum {
public enum GAMA implements Status {
/**
* 该位为1 GAMA不使能
*/
IP_STUS_GAMA_DISABLE(0x00000001);
int val;
DeviceTypeStatusGAMAEnum(int val) {
GAMA(int val) {
this.val = val;
}
@Override
public List<Enum> parse(Short lineId, Integer status) {
if (lineId == 3) {
return Collections.emptyList();
}
return IP_STUS_GAMA_DISABLE.val == status ? List.of(IP_STUS_GAMA_DISABLE) : Collections.emptyList();
}
}
/**
* TRAIN_MODE
* <p>
* 1.西安3号线信号系统不提供序号为56714162223的列车状态
* <p>
* 2.西安3号线信号系统不提供序号为49的列车驾驶模式
*/
public enum DeviceTypeStatusTRAIN_MODEEnum {
public enum TRAIN_MODE {
IP_MODE_TRAIN_TYPE_MANUAL(0x00000000), // 人工车
IP_MODE_TRAIN_TYPE_HEAD(0x00000001), // 头码车
IP_MODE_TRAIN_TYPE_SPECIAL(0x00000002), // 特殊人工车
@ -346,7 +458,7 @@ public class DeviceStatus {
private final int value;
// 枚举类型的构造函数
DeviceTypeStatusTRAIN_MODEEnum(int value) {
TRAIN_MODE(int value) {
this.value = value;
}
@ -354,6 +466,7 @@ public class DeviceStatus {
public int getValue() {
return value;
}
}
}