diff --git a/src/main/java/club/joylink/xiannccda/ats/message/convertor/DeviceStatusConvertor.java b/src/main/java/club/joylink/xiannccda/ats/message/convertor/DeviceStatusConvertor.java index b088968..2e4b6ba 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/convertor/DeviceStatusConvertor.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/convertor/DeviceStatusConvertor.java @@ -11,7 +11,44 @@ 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)>>6; + final int speedLimitType = (statusBitMap&SPEED_LIMIT_TYPE_MASK)>>5; + 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)>>4; + final int nextSectionRunLevel = (spare&NEXT_SECTION_RUN_LEVEL_MASK)>>2; + // + final int STOP_TIME_MASK = 0xffff0000; + final int stopTime = (statusBitMap&STOP_TIME_MASK)>>4; + // + 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定义的设备状态 * @@ -45,35 +82,6 @@ public class DeviceStatusConvertor { setMethod.invoke(to, devStateMask == (statusBitMap & devStateMask)); } } - /** - * 轨道状态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)>>6; - final int speedLimitType = (statusBitMap&SPEED_LIMIT_TYPE_MASK)>>5; - 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)>>4; - final int nextSectionRunLevel = (spare&NEXT_SECTION_RUN_LEVEL_MASK)>>2; - // - final int STOP_TIME_MASK = 0xffff0000; - final int stopTime = (statusBitMap&STOP_TIME_MASK)>>4; - // - to.setNextSectionRunTime(nextSectionRuntime); - to.setNextSectionRunLevel(nextSectionRunLevel); - to.setStopTime(stopTime); - } /** * 以信号机为例测试 */ diff --git a/xian-ncc-da-message b/xian-ncc-da-message index 05401fc..d424b94 160000 --- a/xian-ncc-da-message +++ b/xian-ncc-da-message @@ -1 +1 @@ -Subproject commit 05401fc188150829e9a694ffb1ce354ac6dffaba +Subproject commit d424b9466a5eeda8b5553a275a495eb7aa1f172a