From 572f4f1b6d40f30a11ea39ab60ff387c9c27156d Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Sat, 20 Feb 2021 13:34:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AF=B7=E6=B1=82=E5=8C=BA?= =?UTF-8?q?=E5=9F=9F=E6=8E=A7=E5=88=B6=E6=9D=83(=E5=8C=BA=E5=9F=9F?= =?UTF-8?q?=E9=80=89=E6=8B=A9)=E7=9B=B8=E5=85=B3=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E3=80=81=E6=93=8D=E4=BD=9C=E3=80=81=E9=80=BB=E8=BE=91=EF=BC=9B?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B3=B0=E9=9B=B7=E5=85=B9<=E9=81=93?= =?UTF-8?q?=E5=B2=94/=E5=91=BD=E4=BB=A4>=E6=93=8D=E4=BD=9C=E5=8F=8A?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E5=B1=9E=E6=80=A7=E3=80=81=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=88=E6=9C=AA=E5=AE=8C=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cbtc/ATS/operation/Operation.java | 4 ++ .../handler/StationOperateHandler.java | 10 +++++ .../handler/SwitchOperateHandler.java | 6 +++ .../cbtc/ATS/service/AtsStationService.java | 10 +++++ .../rtss/simulation/cbtc/CI/CiApiService.java | 5 +++ .../simulation/cbtc/CI/CiApiServiceImpl.java | 27 +++++++++++++ .../simulation/cbtc/data/map/MapConfig.java | 6 +++ .../simulation/cbtc/data/map/Station.java | 33 +++++++++++++++ .../rtss/simulation/cbtc/data/map/Switch.java | 24 +++++++++++ .../cbtc/data/status/StationStatus.java | 40 ++++++++++++++++++- .../cbtc/data/vo/StationStatusVO.java | 24 +++++++++-- .../rtss/vo/client/map/RealLineConfigVO.java | 5 +++ 12 files changed, 188 insertions(+), 6 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java index 17b35e042..50323b832 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java @@ -79,6 +79,8 @@ public class Operation { Switch_Force_Unlock, /** 挤岔恢复 */ Switch_Squeeze_Recovery, + /** 命令 */ + Switch_Command, //--------------------------- 区段 --------------------------- /** 封锁 */ @@ -245,6 +247,8 @@ public class Operation { Station_Cancel_CI_Auto, /** 设置/取消强制点灯 */ Station_Set_Or_Cancel_Force_Physical_Signal, + /** 区域选择(请求区域控制权【泰雷兹】) */ + Station_Apply_Control, //--------------------------- 列车 --------------------------- /** 在指定区段加载一辆计划列车(本地开发使用) */ diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/StationOperateHandler.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/StationOperateHandler.java index 23d0e809d..7f0bd0f12 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/StationOperateHandler.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/StationOperateHandler.java @@ -1,5 +1,6 @@ package club.joylink.rtss.simulation.cbtc.ATS.operation.handler; +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation; import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandler; import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandlerMapping; @@ -19,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; @Slf4j @OperateHandler @@ -224,4 +226,12 @@ public class StationOperateHandler { SimulationDataRepository repository = simulation.getRepository(); this.atsStationService.setOrCancelForcePhysicalSignal(simulation, repository.getByCode(stationCode, Station.class)); } + + @OperateHandlerMapping(type = Operation.Type.Station_Apply_Control) + public void applyControl(Simulation simulation, List stationCodes, SimulationMember simulationMember) { + SimulationDataRepository repository = simulation.getRepository(); + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(stationCodes, "未选择车站"); + List stations = stationCodes.stream().map(stationCode -> repository.getByCode(stationCode, Station.class)).collect(Collectors.toList()); + this.atsStationService.applyControl(simulation, stations, simulationMember); + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/SwitchOperateHandler.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/SwitchOperateHandler.java index f431421c5..784a0afc3 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/SwitchOperateHandler.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/SwitchOperateHandler.java @@ -266,4 +266,10 @@ public class SwitchOperateHandler { public void switchSqueezeRecovery(Simulation simulation, String switchCode) { ciApiService.switchSqueezeRecovery(simulation, switchCode); } + + /** 命令【泰雷兹】 */ + @OperateHandlerMapping(type = Operation.Type.Switch_Command) + public void switchCommand(Simulation simulation, String switchCode, Boolean auto, Boolean reserve, Boolean normal) { + ciApiService.switchCommand(simulation, switchCode, auto, reserve, normal); + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStationService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStationService.java index e01ca89a4..8a2b551d8 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStationService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStationService.java @@ -417,4 +417,14 @@ public class AtsStationService { signalList.forEach(signal -> signal.setForcePhysical(false)); } } + + public void applyControl(Simulation simulation, List stations, SimulationMember member) { + stations.forEach(station -> { + if (station.getController() == null) { + station.setController(member); + } else { + station.setControlApplicant(member); + } + }); + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiService.java index ff007355b..77a5e868e 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiService.java @@ -337,4 +337,9 @@ public interface CiApiService { * 挤岔恢复 */ void switchSqueezeRecovery(Simulation simulation, String switchCode); + + /** + * 命令 + */ + void switchCommand(Simulation simulation, String switchCode, Boolean auto, Boolean reserve, Boolean normal); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl.java index fa59b443c..179f94931 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl.java @@ -153,6 +153,13 @@ public class CiApiServiceImpl implements CiApiService { @Override public void blockadeSwitch(Simulation simulation, String switchCode) { Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); + if (simulation.getRepository().getConfig().isBlockadeCommandOnlyValidInStandbyMode()) { + boolean standbyMode = simulation.getRepository().getRouteList() + .stream().filter(route -> route.isRouteSwitch(aSwitch)).anyMatch(route -> !route.isCbtcMode()); //包含该道岔的进路是否有处于后备模式的 + if (!standbyMode) { + return; + } + } this.switchService.blockade(aSwitch); } @@ -547,4 +554,24 @@ public class CiApiServiceImpl implements CiApiService { Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); Switch.SwitchFault.SQUEEZE.fix(aSwitch); } + + @Override + public void switchCommand(Simulation simulation, String switchCode, Boolean auto, Boolean reserve, Boolean normal) { + Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); + if (auto != null) { + aSwitch.setAuto(auto); + } else { + if (normal != null) { + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(!aSwitch.isAuto(), "道岔未处于人工模式"); + if (normal) { + switchService.turn2NormalPosition(simulation, aSwitch); + } else { + switchService.turn2ReversePosition(simulation, aSwitch); + } + } + } + if (reserve != null) { + aSwitch.setDispatcherReserve(reserve); + } + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/MapConfig.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/MapConfig.java index a9b44d215..8477af003 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/MapConfig.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/MapConfig.java @@ -181,6 +181,11 @@ public class MapConfig { */ private boolean needApproachLockBeforeSetGuide; + /** + * 封锁命令(状态)仅在后备模式下有效 + */ + private boolean blockadeCommandOnlyValidInStandbyMode; + private Set needConfirmConnectMembers = Stream.of(DISPATCHER, STATION_SUPERVISOR, MAINTAINER, ELECTRIC_DISPATCHER).collect(Collectors.toSet()); @@ -218,6 +223,7 @@ public class MapConfig { setSetRouteBeforeSetFlt(configVO.isSetRouteBeforeSetFlt()); setCancelRouteWhenCancelFlt(configVO.isCancelRouteWhenCancelFlt()); setNeedApproachLockBeforeSetGuide(configVO.isNeedApproachLockBeforeSetGuide()); + setBlockadeCommandOnlyValidInStandbyMode(configVO.isBlockadeCommandOnlyValidInStandbyMode()); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Station.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Station.java index 4feee7ea2..717624066 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Station.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Station.java @@ -162,6 +162,21 @@ public class Station extends MayOutOfOrderDevice { */ private LocalTime restartTime; + /** + * 该车站的控制权拥有者 + */ + private SimulationMember controller; + + /** + * 是否紧急控制 + */ + private boolean emergencyController; + + /** + * 控制权申请者 + */ + private SimulationMember controlApplicant; + @Override public void reset() { super.reset(); @@ -180,6 +195,10 @@ public class Station extends MayOutOfOrderDevice { this.apply2TheControlMode = null; this.validDuration = null; this.interlockMachineStarting = false; + this.restartTime = null; + this.controller = null; + this.emergencyController = false; + this.controlApplicant = null; } public List getStandOf(boolean right) { @@ -362,6 +381,20 @@ public class Station extends MayOutOfOrderDevice { throw new SimulationException(SimulationExceptionType.Illegal_Argument, String.format("区段[%s]不是车站[%s]的站台轨", section.getCode(), this.getCode())); } + public String getControllerId() { + if (controller == null) { + return null; + } + return controller.getId(); + } + + public String getControlApplicantId() { + if (controlApplicant == null) { + return null; + } + return controlApplicant.getId(); + } + public enum ControlMode { /** * 交出未被接收 diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Switch.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Switch.java index 6d245a7de..ebac99e20 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Switch.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Switch.java @@ -104,6 +104,26 @@ public class Switch extends MayOutOfOrderDevice { */ private boolean preReset; + /** + * 自动 + */ + private boolean auto; + + /** + * 中央调度员预留 + */ + private boolean dispatcherReserve; + + /** + * 联锁预留 + */ + private boolean interlockReserve; + + /** + * 封锁失效 + */ + private boolean blockadeInvalid; + @Override public void reset() { super.reset(); @@ -118,6 +138,10 @@ public class Switch extends MayOutOfOrderDevice { this.delayTime = 0; this.noStatus = false; this.preReset = false; + this.auto = false; + this.dispatcherReserve = false; + this.interlockReserve = false; + this.blockadeInvalid = false; } /** diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/StationStatus.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/StationStatus.java index 9fccfba2c..cabed56e0 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/StationStatus.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/StationStatus.java @@ -1,13 +1,13 @@ package club.joylink.rtss.simulation.cbtc.data.status; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import club.joylink.rtss.simulation.cbtc.data.map.MapElement; import club.joylink.rtss.simulation.cbtc.data.map.Station; import club.joylink.rtss.simulation.cbtc.data.vo.DeviceStatusVO; import club.joylink.rtss.simulation.cbtc.data.vo.StationStatusVO; import club.joylink.rtss.util.jsonSerialize.Boolean2NumDeserializer; import club.joylink.rtss.util.jsonSerialize.Boolean2NumSerializer; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; import lombok.Getter; import java.time.LocalTime; @@ -54,6 +54,21 @@ public class StationStatus extends DeviceStatus { /**连锁机上电重启时间*/ private LocalTime restartTime; + /** + * 该车站的控制权拥有者 + */ + private String controller; + + /** + * 是否紧急控制 + */ + private boolean emergencyController; + + /** + * 控制权申请者 + */ + private String controlApplicant; + public StationStatus(Station station) { super(station.getCode(), station.getDeviceType()); this.controlMode = station.getControlMode(); @@ -63,6 +78,9 @@ public class StationStatus extends DeviceStatus { this.apply2TheControlMode = station.getApply2TheControlMode(); this.validDuration = station.getValidDurationInSeconds(); this.restartTime = station.getRestartTime(); + this.controller = station.getControllerId(); + this.emergencyController = station.isEmergencyController(); + this.controlApplicant = station.getControlApplicantId(); } @Override @@ -106,6 +124,21 @@ public class StationStatus extends DeviceStatus { this.restartTime = station.getRestartTime(); status.setRestartTime(restartTime); } + if (!Objects.equals(this.controller, station.getControllerId())) { + change = true; + this.controller = station.getControllerId(); + } + status.setController(this.controller); + if (!Objects.equals(this.emergencyController, station.isEmergencyController())) { + change = true; + this.emergencyController = station.isEmergencyController(); + status.setEmergencyController(this.emergencyController); + } + if (!Objects.equals(this.controlApplicant, station.getControlApplicantId())) { + change = true; + this.controlApplicant = station.getControlApplicantId(); + } + status.setControlApplicant(this.controlApplicant); return change; } @@ -119,6 +152,9 @@ public class StationStatus extends DeviceStatus { statusVO.setApply2TheControlMode(apply2TheControlMode); statusVO.setValidDuration(validDuration); statusVO.setRestartTime(restartTime); + statusVO.setController(controller); + statusVO.setEmergencyController(emergencyController); + statusVO.setControlApplicant(controlApplicant); return statusVO; } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/StationStatusVO.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/StationStatusVO.java index 526f9fa20..b61cd1b83 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/StationStatusVO.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/StationStatusVO.java @@ -1,15 +1,14 @@ package club.joylink.rtss.simulation.cbtc.data.vo; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import club.joylink.rtss.simulation.cbtc.data.map.Station; import club.joylink.rtss.util.jsonSerialize.Boolean2NumDeserializer; import club.joylink.rtss.util.jsonSerialize.Boolean2NumSerializer; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; import lombok.Getter; import lombok.Setter; -import java.time.LocalDateTime; import java.time.LocalTime; /** @@ -52,6 +51,23 @@ public class StationStatusVO extends DeviceStatusVO { private LocalTime restartTime; + /** + * 该车站的控制权拥有者 + */ + @JsonInclude() + private String controller; + + /** + * 是否紧急控制 + */ + private Boolean emergencyController; + + /** + * 控制权申请者 + */ + @JsonInclude() + private String controlApplicant; + public StationStatusVO(Station station) { super(station.getCode(), station.getDeviceType()); } diff --git a/src/main/java/club/joylink/rtss/vo/client/map/RealLineConfigVO.java b/src/main/java/club/joylink/rtss/vo/client/map/RealLineConfigVO.java index 53bda1a33..1b8e3b3e0 100644 --- a/src/main/java/club/joylink/rtss/vo/client/map/RealLineConfigVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/map/RealLineConfigVO.java @@ -120,6 +120,11 @@ public class RealLineConfigVO { */ private boolean needApproachLockBeforeSetGuide = true; + /** + * 封锁命令(状态)仅在后备模式下有效 + */ + private boolean blockadeCommandOnlyValidInStandbyMode; + public static RealLineConfigVO parseJsonStr(String configData) { if (StringUtils.hasText(configData)) { return JsonUtils.read(configData, RealLineConfigVO.class);