非实时消息
This commit is contained in:
parent
f4c54a0424
commit
251e99b63c
@ -3,6 +3,8 @@ package club.joylink.xiannccda.ats.message.rep;
|
||||
import club.joylink.xiannccda.ats.message.MessageId;
|
||||
import club.joylink.xiannccda.ats.message.MessageResponse;
|
||||
import club.joylink.xiannccda.ats.message.rep.EntityParseUtil.ReadData;
|
||||
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.DeviceType;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.util.List;
|
||||
@ -119,34 +121,11 @@ 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.deviceList = EntityParseUtil.collect(entity.objCount, buf, DeviceEntity.class);
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
/* int d = 0x00040000;
|
||||
System.out.println((d & DeviceTypeStatusSIGNALEnum.APPROACH_LOCK.getVal()));
|
||||
boolean dd = (d & DeviceTypeStatusSIGNALEnum.APPROACH_LOCK.getVal()) == DeviceTypeStatusSIGNALEnum.APPROACH_LOCK.getVal();
|
||||
System.out.println(dd);*/
|
||||
|
||||
int i1 = -119;
|
||||
String s1 = Integer.toBinaryString(i1);
|
||||
System.out.println(s1);
|
||||
int i2 = 240;
|
||||
String s2 = Integer.toBinaryString(i2);
|
||||
System.out.println(s2);
|
||||
|
||||
int i3 = i1 & i2;
|
||||
System.out.println(i3);
|
||||
String s3 = Integer.toBinaryString(i3);
|
||||
System.out.println(s3);
|
||||
System.out.println(i1 & i2);
|
||||
System.out.println(4 & 7);
|
||||
}
|
||||
|
||||
public static class DeviceEntity implements ReadData<DeviceEntity> {
|
||||
|
||||
@ -167,7 +146,7 @@ public class DeviceStatusBitmapResponse extends MessageResponse {
|
||||
*/
|
||||
private Integer spare;
|
||||
|
||||
// public void runTime() {
|
||||
// public void runTime() {
|
||||
// if (type == DeviceType.DEVICE_TYPE_PLATFORM) {
|
||||
//// this.spare;
|
||||
//
|
||||
@ -185,6 +164,9 @@ public class DeviceStatusBitmapResponse extends MessageResponse {
|
||||
//// this.spare;
|
||||
// }
|
||||
// }
|
||||
public boolean havingState(final DeviceStatus.Status status) {
|
||||
return status.isSet(null, this.status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceEntity read(ByteBuf buf) {
|
||||
|
@ -3,6 +3,7 @@ package club.joylink.xiannccda.ats.message.rep;
|
||||
import club.joylink.xiannccda.ats.message.MessageData;
|
||||
import club.joylink.xiannccda.ats.message.MessageId;
|
||||
import club.joylink.xiannccda.ats.message.MessageResponse;
|
||||
import club.joylink.xiannccda.ats.message.rep.device.DeviceStatus;
|
||||
import club.joylink.xiannccda.ats.message.rep.device.DeviceType;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
@ -56,6 +57,10 @@ public class DeviceStatusChangeResponse extends MessageResponse {
|
||||
*/
|
||||
private Integer spare;
|
||||
|
||||
public boolean havingState(final DeviceStatus.Status status) {
|
||||
return status.isSet(null, this.deviceStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode2(ByteBuf buf) throws Exception {
|
||||
this.lineId = buf.readShort();
|
||||
|
@ -146,7 +146,6 @@ public class DeviceStatus {
|
||||
this.val = val;
|
||||
}
|
||||
|
||||
private final static List<Integer> FILTER_LINE3 = Lists.newArrayList(2, 4, 6, 8, 10, 12, 13, 14, 17, 23);
|
||||
|
||||
@Override
|
||||
public boolean isSet(Short lineId, Integer status) {
|
||||
@ -224,16 +223,11 @@ public class DeviceStatus {
|
||||
this.val = val;
|
||||
}
|
||||
|
||||
private final static List<Integer> FILTER_LINE3 = Lists.newArrayList(9, 10, 11, 12, 13, 14, 15, 16);
|
||||
|
||||
@Override
|
||||
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());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -265,7 +259,6 @@ public class DeviceStatus {
|
||||
this.val = val;
|
||||
}
|
||||
|
||||
private final static List<Integer> FILTER_LINE3 = Lists.newArrayList(5, 6, 7);
|
||||
|
||||
@Override
|
||||
public boolean isSet(Short lineId, Integer status) {
|
||||
@ -297,9 +290,10 @@ public class DeviceStatus {
|
||||
this.val = val;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isSet(Short lineId, Integer status) {
|
||||
return this.val == status;
|
||||
return (status & this.val) == this.val;
|
||||
// return Arrays.stream(PLATFORM.values()).filter(d -> d.val == status).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@ -469,11 +463,12 @@ public class DeviceStatus {
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* mode中是否有该枚举定义的状态
|
||||
*/
|
||||
public boolean is(final int mode){
|
||||
return (mode & value) == value;
|
||||
public boolean is(final int mode) {
|
||||
return (mode & value) == value;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 51743f0de38e3abf76bc2f6456000a25acbff33e
|
||||
Subproject commit 633fbff292030582a98f6a6040969b59d4815028
|
Loading…
Reference in New Issue
Block a user