添加请求区域控制权(区域选择)相关属性、操作、逻辑;添加泰雷兹<道岔/命令>操作及相关属性、逻辑(未完)

This commit is contained in:
joylink_zhangsai 2021-02-20 13:34:25 +08:00
parent 0a84cbb690
commit 572f4f1b6d
12 changed files with 188 additions and 6 deletions

View File

@ -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,
//--------------------------- 列车 ---------------------------
/** 在指定区段加载一辆计划列车(本地开发使用) */

View File

@ -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<String> stationCodes, SimulationMember simulationMember) {
SimulationDataRepository repository = simulation.getRepository();
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(stationCodes, "未选择车站");
List<Station> stations = stationCodes.stream().map(stationCode -> repository.getByCode(stationCode, Station.class)).collect(Collectors.toList());
this.atsStationService.applyControl(simulation, stations, simulationMember);
}
}

View File

@ -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);
}
}

View File

@ -417,4 +417,14 @@ public class AtsStationService {
signalList.forEach(signal -> signal.setForcePhysical(false));
}
}
public void applyControl(Simulation simulation, List<Station> stations, SimulationMember member) {
stations.forEach(station -> {
if (station.getController() == null) {
station.setController(member);
} else {
station.setControlApplicant(member);
}
});
}
}

View File

@ -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);
}

View File

@ -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);
}
}
}

View File

@ -181,6 +181,11 @@ public class MapConfig {
*/
private boolean needApproachLockBeforeSetGuide;
/**
* 封锁命令状态仅在后备模式下有效
*/
private boolean blockadeCommandOnlyValidInStandbyMode;
private Set<SimulationMember.Type> 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());
}
}

View File

@ -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<Stand> 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 {
/**
* 交出未被接收

View File

@ -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;
}
/**

View File

@ -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;
}
}

View File

@ -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());
}

View File

@ -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);