From 5a94989472dfd69584ec307b09349dbf8113af47 Mon Sep 17 00:00:00 2001 From: xzb <223@qq.com> Date: Mon, 12 Jun 2023 10:37:26 +0800 Subject: [PATCH] =?UTF-8?q?ncc=E5=8D=8F=E8=AE=AEx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../convertor/DeviceStatusConvertor.java | 68 +++++++++++-------- xian-ncc-da-message | 2 +- 2 files changed, 39 insertions(+), 31 deletions(-) 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