非实时消息
This commit is contained in:
parent
2687a98b76
commit
68c7cb0a4d
@ -80,37 +80,37 @@ public class DeviceStatusBitmapResponse extends MessageResponse {
|
||||
/**
|
||||
* 设备名称(24)(左对齐,其它空字符填\0)
|
||||
*/
|
||||
private String devName;
|
||||
|
||||
/**
|
||||
* 设备的状态,见附录3(4)
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 预留(4)
|
||||
*/
|
||||
private Integer spare;
|
||||
// private String devName;
|
||||
//
|
||||
// /**
|
||||
// * 设备的状态,见附录3(4)
|
||||
// */
|
||||
// private Integer status;
|
||||
// /**
|
||||
// * 预留(4)
|
||||
// */
|
||||
// private Integer spare;
|
||||
|
||||
private List<DeviceEntity> deviceList;
|
||||
|
||||
public void runTime() {
|
||||
if (type == DeviceType.DEVICE_TYPE_PLATFORM) {
|
||||
// this.spare;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void runLevel() {
|
||||
if (type == DeviceType.DEVICE_TYPE_PLATFORM) {
|
||||
// this.spare;
|
||||
}
|
||||
}
|
||||
|
||||
public void speedLimit() {
|
||||
if (type == DeviceType.DEVICE_TYPE_SWITCH) {
|
||||
// this.spare;
|
||||
}
|
||||
}
|
||||
// public void runTime() {
|
||||
// if (type == DeviceType.DEVICE_TYPE_PLATFORM) {
|
||||
//// this.spare;
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void runLevel() {
|
||||
// if (type == DeviceType.DEVICE_TYPE_PLATFORM) {
|
||||
//// this.spare;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void speedLimit() {
|
||||
// if (type == DeviceType.DEVICE_TYPE_SWITCH) {
|
||||
//// this.spare;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
@Override
|
||||
@ -119,9 +119,9 @@ public class DeviceStatusBitmapResponse extends MessageResponse {
|
||||
|
||||
entity.type = DeviceType.of(buf.readShort());
|
||||
entity.objCount = buf.readShort();
|
||||
entity.devName = EntityParseUtil.convertStr(buf, 24);
|
||||
entity.status = buf.readInt();
|
||||
entity.spare = buf.readInt();
|
||||
// entity.devName = EntityParseUtil.convertStr(buf, 24);
|
||||
// entity.status = buf.readInt();
|
||||
// entity.spare = buf.readInt();
|
||||
entity.deviceList = EntityParseUtil.collect(entity.objCount, buf, DeviceEntity.class);
|
||||
return entity;
|
||||
}
|
||||
@ -167,6 +167,24 @@ public class DeviceStatusBitmapResponse extends MessageResponse {
|
||||
*/
|
||||
private Integer spare;
|
||||
|
||||
// public void runTime() {
|
||||
// if (type == DeviceType.DEVICE_TYPE_PLATFORM) {
|
||||
//// this.spare;
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void runLevel() {
|
||||
// if (type == DeviceType.DEVICE_TYPE_PLATFORM) {
|
||||
//// this.spare;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void speedLimit() {
|
||||
// if (type == DeviceType.DEVICE_TYPE_SWITCH) {
|
||||
//// this.spare;
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public DeviceEntity read(ByteBuf buf) {
|
||||
|
@ -2,10 +2,14 @@ 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.DeviceStatus.RTU;
|
||||
import club.joylink.xiannccda.ats.message.rep.device.DeviceStatus.SIGNAL;
|
||||
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.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class EntityParseUtil {
|
||||
@ -34,9 +38,29 @@ public class EntityParseUtil {
|
||||
}
|
||||
|
||||
|
||||
/*public static List<Enum> convertDeviceStatus(Short lineId, DeviceType type) {
|
||||
private static final List<Integer> FILTER_TYPE_LINE3 = List.of(1, 3, 7, 12, 13, 14);
|
||||
|
||||
}*/
|
||||
// public static List<Enum> convertDeviceStatus(Short lineId, DeviceType type,Integer status) {
|
||||
// if (lineId == 3 && FILTER_TYPE_LINE3.contains(type.ordinal() + 1)) {
|
||||
// return Collections.emptyList();
|
||||
// }
|
||||
// switch (type) {
|
||||
// case DEVICE_TYPE_RTU -> {
|
||||
// return RTU.FILTER.parse(lineId,status);
|
||||
// }
|
||||
// case DEVICE_TYPE_STATION ->
|
||||
// case DEVICE_TYPE_SIGNAL ->
|
||||
// case DEVICE_TYPE_SWITCH ->
|
||||
// case DEVICE_TYPE_TRACK ->
|
||||
// case DEVICE_TYPE_ENTRY ->
|
||||
// case DEVICE_TYPE_PLATFORM ->
|
||||
// case DEVICE_TYPE_SCADA ->
|
||||
// case DEVICE_TYPE_WATERPROOF_DOOR ->
|
||||
// case DEVICE_TYPE_WORK_AREA ->
|
||||
// case DEVICE_TYPE_GAMA ->
|
||||
// case DEVICE_TYPE_UNKNOW ->
|
||||
// }
|
||||
// }
|
||||
|
||||
public interface ReadData<T> {
|
||||
|
||||
|
@ -12,7 +12,7 @@ public class DeviceStatus {
|
||||
|
||||
public interface Status {
|
||||
|
||||
List<Enum> parse(Short lineId, Integer status);
|
||||
boolean isSet(Short lineId, Integer status);
|
||||
|
||||
}
|
||||
|
||||
@ -23,8 +23,9 @@ public class DeviceStatus {
|
||||
IP_RTU_STUS_DOWN(0x00008000),// 通信中断
|
||||
IP_RTU_STUS_IN_LOCAL_CTRL(0x00000001),// 站控
|
||||
IP_RTU_STUS_IN_CENTRAL_CTRL(0x00000002),// 遥控
|
||||
IP_RTU_STUS_IN_EMERGENCY_CTRL(0x00000004);// 紧急站控
|
||||
|
||||
IP_RTU_STUS_IN_EMERGENCY_CTRL(0x00000004),// 紧急站控
|
||||
;
|
||||
@Getter
|
||||
int val;
|
||||
|
||||
RTU(int val) {
|
||||
@ -33,9 +34,8 @@ public class DeviceStatus {
|
||||
|
||||
|
||||
@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);
|
||||
public boolean isSet(Short lineId, Integer status) {
|
||||
return this.val == status;
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,12 +77,12 @@ public class DeviceStatus {
|
||||
}
|
||||
|
||||
@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);
|
||||
public boolean isSet(Short lineId, Integer status) {
|
||||
if (lineId == 3) {
|
||||
return false;
|
||||
|
||||
}
|
||||
return Collections.emptyList();
|
||||
return this.val == status;
|
||||
}
|
||||
}
|
||||
|
||||
@ -149,13 +149,15 @@ public class DeviceStatus {
|
||||
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());
|
||||
public boolean isSet(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());
|
||||
|
||||
return stream.filter(d -> (status & d.val) == d.val).collect(Collectors.toList());*/
|
||||
return (status & this.val) == this.val;
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,8 +178,9 @@ public class DeviceStatus {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Enum> parse(Short lineId, Integer status) {
|
||||
return Arrays.stream(ENTRY.values()).filter(d -> d.val == status).collect(Collectors.toList());
|
||||
public boolean isSet(Short lineId, Integer status) {
|
||||
return this.val == status;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -224,12 +227,13 @@ public class DeviceStatus {
|
||||
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());
|
||||
public boolean isSet(Short lineId, Integer status) {
|
||||
return (status & this.val) == this.val;
|
||||
// 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());
|
||||
}
|
||||
}
|
||||
|
||||
@ -264,12 +268,8 @@ public class DeviceStatus {
|
||||
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());
|
||||
public boolean isSet(Short lineId, Integer status) {
|
||||
return (status & this.val) == this.val;
|
||||
}
|
||||
}
|
||||
|
||||
@ -298,9 +298,9 @@ public class DeviceStatus {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Enum> parse(Short lineId, Integer status) {
|
||||
|
||||
return Arrays.stream(PLATFORM.values()).filter(d -> d.val == status).collect(Collectors.toList());
|
||||
public boolean isSet(Short lineId, Integer status) {
|
||||
return this.val == status;
|
||||
// return Arrays.stream(PLATFORM.values()).filter(d -> d.val == status).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@ -319,9 +319,9 @@ public class DeviceStatus {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Enum> parse(Short lineId, Integer status) {
|
||||
|
||||
return Arrays.stream(WATERPROOF_DOOR.values()).filter(d -> d.value == status).collect(Collectors.toList());
|
||||
public boolean isSet(Short lineId, Integer status) {
|
||||
return this.value == status;
|
||||
// return Arrays.stream(WATERPROOF_DOOR.values()).filter(d -> d.value == status).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@ -350,11 +350,12 @@ public class DeviceStatus {
|
||||
}
|
||||
|
||||
@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());
|
||||
public boolean isSet(Short lineId, Integer status) {
|
||||
return (status & this.value) == this.value;
|
||||
// if (lineId == 3) {
|
||||
// return Collections.emptyList();
|
||||
// }
|
||||
// return Arrays.stream(WATERPROOF_DOOR.values()).filter(d -> d.value == status).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@ -376,11 +377,12 @@ public class DeviceStatus {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Enum> parse(Short lineId, Integer status) {
|
||||
if (lineId == 3) {
|
||||
public boolean isSet(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();
|
||||
return IP_STUS_WORK_AREA_ENABLE.val == status ? List.of(IP_STUS_WORK_AREA_ENABLE) : Collections.emptyList();*/
|
||||
return this.val == status;
|
||||
}
|
||||
}
|
||||
|
||||
@ -401,11 +403,12 @@ public class DeviceStatus {
|
||||
}
|
||||
|
||||
@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();
|
||||
public boolean isSet(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();
|
||||
return this.val == status;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user