Merge remote-tracking branch 'origin/test' into test

# Conflicts:
#	src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java
#	src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStationService.java
This commit is contained in:
joylink_zhangsai 2021-02-22 10:02:02 +08:00
commit b895017e9c
13 changed files with 218 additions and 23 deletions

View File

@ -59,6 +59,9 @@ public interface GeneratorNew {
case STAND:
((Stand) mapDevice).getDeviceStation().setControlMode(Station.ControlMode.Local);
break;
case CYCLE:
((Cycle) mapDevice).getStation().setControlMode(Station.ControlMode.Local);
break;
}
}
// 实训基本信息

View File

@ -191,6 +191,10 @@ public class Operation {
Stand_Open_Psd,
/** 取消设置(扣车或跳停) */
Stand_Cancel_Setting,
/** 系统扣车 */
Stand_Sys_Hold_Train(),
/** 取消系统扣车 */
Stand_Cancel_Sys_Hold_Train(),
//--------------------------- 控制模式 ---------------------------
/** 请求站控 */
@ -211,7 +215,7 @@ public class Operation {
CM_Surrender_Control(),
/** 连锁控 */
CM_Interlock_Control(),
/** 回复控请求(同意/拒绝) */
/** 回复连锁控请求(同意/拒绝) */
CM_Reply_Interlock_Control(),
//--------------------------- 集中车站 ---------------------------
@ -247,10 +251,17 @@ public class Operation {
Station_Cancel_CI_Auto,
/** 设置/取消强制点灯 */
Station_Set_Or_Cancel_Force_Physical_Signal,
/** 区域选择(请求区域控制权【泰雷兹】) */
Station_Apply_Control,
/** 计轴预复位(宁波一) */
Station_Pre_Reset,
//车站控制授权
/** 区域选择(请求区域控制权【泰雷兹】) */
Station_Control_Apply,
/** 授权转移 */
Station_Control_Transfer,
/** 下放站控 */
Station_Control_Devolve,
/** 收回站控 */
Station_Control_Revoke,
//--------------------------- 列车 ---------------------------
/** 在指定区段加载一辆计划列车(本地开发使用) */

View File

@ -73,6 +73,22 @@ public class StandOperateHandler {
}
/**
* 设置系统扣车
*/
@OperateHandlerMapping(type = Operation.Type.Stand_Sys_Hold_Train)
public void setSysHoldTrain(Simulation simulation) {
this.atsStandService.sysHoldTrain(simulation);
}
/**
* 取消系统扣车
*/
@OperateHandlerMapping(type = Operation.Type.Stand_Cancel_Sys_Hold_Train)
public void cancelSysHoldTrain(Simulation simulation) {
this.atsStandService.cancelSysHoldTrain(simulation);
}
/**
* 提前发车
*/

View File

@ -163,6 +163,7 @@ public class StationOperateHandler {
atsStationService.emergencyStationControl(simulation, fromMember, stationCodes);
}
/**回复站控请求c*/
@OperateHandlerMapping(type = Operation.Type.CM_Reply_Station_Control)
public void replyForStationControl(Simulation simulation, List<ControlTransferReplyVO> replyVOList){
@ -189,14 +190,14 @@ public class StationOperateHandler {
repository.getSignalList().stream().filter(s -> Objects.equals(stationCode,s.getInterlockStation().getCode())).forEach(signal -> ciApiService.blockadeSignal(simulation, signal.getCode()));
}
/**交出控制权*/
/**交出控制权/下放站控*/
@OperateHandlerMapping(type = Operation.Type.CM_Surrender_Control)
public void surrenderControl(Simulation simulation, SimulationMember member, String stationCode){
SimulationDataRepository repository = simulation.getRepository();
this.atsStationService.surrenderControl(simulation, member, repository.getByCode(stationCode, Station.class));
}
/**交出控制权*/
/**接收控制权*/
@OperateHandlerMapping(type = Operation.Type.CM_Receive_Control)
public void receiveControl(Simulation simulation, SimulationMember member, String stationCode){
SimulationDataRepository repository = simulation.getRepository();
@ -227,12 +228,27 @@ public class StationOperateHandler {
this.atsStationService.setOrCancelForcePhysicalSignal(simulation, repository.getByCode(stationCode, Station.class));
}
@OperateHandlerMapping(type = Operation.Type.Station_Apply_Control)
@OperateHandlerMapping(type = Operation.Type.Station_Control_Apply)
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);
this.atsStationService.applyControl(simulation, stationCodes, simulationMember);
}
@OperateHandlerMapping(type = Operation.Type.Station_Control_Transfer)
public void transferControl(Simulation simulation, List<String> stationCodes, boolean agree, SimulationMember simulationMember) {
this.atsStationService.transferControl(simulation, stationCodes, agree, simulationMember);
}
@OperateHandlerMapping(type = Operation.Type.Station_Control_Devolve)
public void devolveControl(Simulation simulation, List<String> stationCodes, SimulationMember simulationMember) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(stationCodes, "未选择车站");
this.atsStationService.devolveControl(simulation, stationCodes, simulationMember);
}
@OperateHandlerMapping(type = Operation.Type.Station_Control_Revoke)
public void revokeControl(Simulation simulation, List<String> stationCodes, SimulationMember simulationMember) {
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(stationCodes, "未选择车站");
this.atsStationService.revokeControl(simulation, stationCodes, simulationMember);
}
@OperateHandlerMapping(type = Operation.Type.Station_Pre_Reset)

View File

@ -329,6 +329,10 @@ public class AtsStandService {
} else {
this.ciApiService.standHoldTrain(simulation, standCode, false);
}
checkAndSetTrainHold(simulation, stand);
}
private void checkAndSetTrainHold(Simulation simulation, Stand stand) {
if (stand.isHoldTrain()) {
// 先默认CBTC模式扣车状态发送给列车
List<TrainInfo> superviseTrainList = simulation.getRepository().getSuperviseTrainList();
@ -342,6 +346,34 @@ public class AtsStandService {
}
}
public void sysHoldTrain(Simulation simulation) {
List<Stand> stands = simulation.getRepository().getStandList();
stands.forEach(stand -> {
if (stand.isJumpStop()) {
stand.setAllSkip(false);
stand.getSkipSet().clear();
}
this.ciApiService.sysHoldTrain(simulation, stand.getCode());
checkAndSetTrainHold(simulation, stand);
});
List<VirtualRealityTrain> onlineTrainList = simulation.getRepository().getOnlineTrainList();
for (VirtualRealityTrain train : onlineTrainList) {
if (train.isJump()) {
this.onboardAtpApiService.cancelJump(simulation, train.getGroupNumber());
}
}
}
public void cancelSysHoldTrain(Simulation simulation) {
List<Stand> stands = simulation.getRepository().getStandList();
stands.forEach(stand -> {
if (stand.isSysHoldTrain()) {
this.ciApiService.sysHoldTrainCancel(simulation, stand.getCode());
this.checkAndCancelTrainHold(simulation, stand);
}
});
}
public void forceCancelHoldTrain(Simulation simulation, String standCode) {
Stand stand = simulation.getRepository().getByCode(standCode, Stand.class);
if (stand.isCenterHoldTrain()) {

View File

@ -425,19 +425,6 @@ public class AtsStationService {
}
}
/**
* 申请区域控制权
*/
public void applyControl(Simulation simulation, List<Station> stations, SimulationMember member) {
stations.forEach(station -> {
if (station.getController() == null) {
station.setController(member);
} else {
station.setControlApplicant(member);
}
});
}
/**
* 计轴预复位
*/
@ -464,4 +451,78 @@ public class AtsStationService {
station.setPreResetValidDuration(Math.max(0, remainderTime - SimulationConstants.ATS_LOOP_RATE));
}
}
public void applyControl(Simulation simulation, List<String> stationCodes, SimulationMember member) {
if (CollectionUtils.isEmpty(stationCodes)) {
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "申请控制的车站列表不能为空");
}
//TODO 角色和设备检查
synchronized (simulation) {
SimulationDataRepository repository = simulation.getRepository();
BusinessExceptionAssertEnum.INVALID_OPERATION.assertNotTrue(stationCodes.stream().filter(s -> Objects.nonNull(repository.getByCode(s, Station.class).getControlApplicant())).findAny().isPresent(), "申请列车存在已被申请的车站");
stationCodes.forEach(s -> {
Station station = repository.getByCode(s, Station.class);
if (station.getController() == null) {
station.setController(member);
} else {
station.setControlApplicant(member);
}
});
}
}
public void transferControl(Simulation simulation, List<String> stationCodes, boolean agree, SimulationMember member) {
if (CollectionUtils.isEmpty(stationCodes)) {
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "控制权转移的车站列表不能为空");
}
//TODO 角色和设备检查
synchronized (simulation) {
SimulationDataRepository repository = simulation.getRepository();
stationCodes.forEach(s -> {
Station station = repository.getByCode(s, Station.class);
if (agree) {
if (station.getController() == null || Objects.equals(station.getController(), member)) {
station.setController(station.getControlApplicant());
}
return;
}
station.setControlApplicant(null);
});
}
}
public void devolveControl(Simulation simulation, List<String> stationCodes, SimulationMember member) {
if (CollectionUtils.isEmpty(stationCodes)) {
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "控制权下放的车站列表不能为空");
}
//TODO 角色和设备检查
synchronized (simulation) {
SimulationDataRepository repository = simulation.getRepository();
stationCodes.forEach(s -> {
Station station = repository.getByCode(s, Station.class);
if (Objects.nonNull(station.getController()) && Objects.equals(station.getController(), member)) {
station.setController(null);
station.setEmergencyController(false);
station.setControlApplicant(null);
}
});
}
}
public void revokeControl(Simulation simulation, List<String> stationCodes, SimulationMember member) {
if (CollectionUtils.isEmpty(stationCodes)) {
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "回收控制权的车站列表不能为空");
}
//TODO 角色和设备检查
synchronized (simulation) {
SimulationDataRepository repository = simulation.getRepository();
stationCodes.forEach(s -> {
Station station = repository.getByCode(s, Station.class);
station.setController(member);
station.setEmergencyController(true);
station.setControlApplicant(null);
});
}
}
}

View File

@ -250,6 +250,8 @@ public interface CiApiService {
*/
void standHoldTrain(Simulation simulation, String standCode, boolean center);
void sysHoldTrain(Simulation simulation, String standCode);
/**
* 站台取消扣车联锁关系处理
* @param simulation
@ -258,6 +260,8 @@ public interface CiApiService {
*/
void standHoldTrainCancel(Simulation simulation, String standCode, boolean center);
void sysHoldTrainCancel(Simulation simulation, String standCode);
void standHoldTrainCancelAll(Simulation simulation, String standCode);
/**

View File

@ -345,12 +345,24 @@ public class CiApiServiceImpl implements CiApiService {
this.standService.holdTrain(simulation, stand, center);
}
@Override
public void sysHoldTrain(Simulation simulation, String standCode) {
Stand stand = simulation.getRepository().getByCode(standCode, Stand.class);
this.standService.sysHoldTrain(simulation, stand);
}
@Override
public void standHoldTrainCancel(Simulation simulation, String standCode, boolean center) {
Stand stand = simulation.getRepository().getByCode(standCode, Stand.class);
this.standService.cancelHoldTrain(simulation, stand, center);
}
@Override
public void sysHoldTrainCancel(Simulation simulation, String standCode) {
Stand stand = simulation.getRepository().getByCode(standCode, Stand.class);
this.standService.cancelSysHoldTrain(simulation, stand);
}
@Override
public void standHoldTrainCancelAll(Simulation simulation, String standCode) {
Stand stand = simulation.getRepository().getByCode(standCode, Stand.class);

View File

@ -89,6 +89,26 @@ public class StandService {
}
}
/**系统扣车*/
public void sysHoldTrain(Simulation simulation, Stand stand) {
stand.setSysHoldTrain(true);
// 关闭出站信号机
Signal signal = stand.getSection().getSignalOf(stand.isRight());
if (Objects.nonNull(signal)) {
MapConfig config = simulation.getRepository().getConfig();
if (config.isStandHoldCloseLogicLight() || !signal.isLogicLight()) {
this.signalService.close(simulation, signal);
}
}
}
public void cancelSysHoldTrain(Simulation simulation, Stand stand) {
stand.setSysHoldTrain(false);
// 如果所有扣车都取消开放出站信号机
if (!stand.isHoldTrain()) {
this.reopenSignal(simulation, stand);
}
}
/**
* 取消扣车
*

View File

@ -82,6 +82,9 @@ public class Stand extends MayOutOfOrderDevice {
*/
private volatile boolean centerHoldTrain;
/**系统扣车*/
private volatile boolean sysHoldTrain;
/**
* 区间自动扣车
*/
@ -153,6 +156,7 @@ public class Stand extends MayOutOfOrderDevice {
this.remainTime = 0;
this.stationHoldTrain = false;
this.centerHoldTrain = false;
this.sysHoldTrain = false;
this.autoHoldTrain = false;
this.allSkip = false;
this.skipSet = Collections.synchronizedSet(new HashSet<>());
@ -175,7 +179,7 @@ public class Stand extends MayOutOfOrderDevice {
*/
//TODO 反向扣车是否计算在内
public boolean isHoldTrain() {
return stationHoldTrain || centerHoldTrain;
return stationHoldTrain || centerHoldTrain || sysHoldTrain;
}
/**

View File

@ -422,6 +422,7 @@ public class Station extends MayOutOfOrderDevice {
* 紧急站控
*/
Emergency,
/**
* 联锁控
*/

View File

@ -41,6 +41,10 @@ public class StandStatus extends DeviceStatus {
@JsonSerialize(using = Boolean2NumSerializer.class)
private boolean centerHoldTrain;
/**中心是否扣车*/
@JsonSerialize(using = Boolean2NumSerializer.class)
private boolean sysHoldTrain;
/**区间自动扣车*/
@JsonSerialize(using = Boolean2NumSerializer.class)
private boolean autoHoldTrain;
@ -90,6 +94,7 @@ public class StandStatus extends DeviceStatus {
this.emergencyClosed = stand.isEmergencyClosed();
this.stationHoldTrain = stand.isStationHoldTrain();
this.centerHoldTrain = stand.isCenterHoldTrain();
this.sysHoldTrain = stand.isSysHoldTrain();
this.autoHoldTrain = stand.isAutoHoldTrain();
this.allSkip = stand.isAllSkip();
this.skipSet = new HashSet<>(stand.getSkipSet());
@ -143,6 +148,11 @@ public class StandStatus extends DeviceStatus {
status.setCenterHoldTrain(this.centerHoldTrain);
change = true;
}
if (!Objects.equals(this.sysHoldTrain, stand.isSysHoldTrain())) {
this.sysHoldTrain = stand.isSysHoldTrain();
status.setSysHoldTrain(this.sysHoldTrain);
change = true;
}
if (!Objects.equals(this.autoHoldTrain, stand.isAutoHoldTrain())) {
this.autoHoldTrain = stand.isAutoHoldTrain();
status.setAutoHoldTrain(this.autoHoldTrain);
@ -220,6 +230,7 @@ public class StandStatus extends DeviceStatus {
statusVO.setAllSkip(allSkip);
statusVO.setAutoHoldTrain(autoHoldTrain);
statusVO.setCenterHoldTrain(centerHoldTrain);
statusVO.setSysHoldTrain(sysHoldTrain);
statusVO.setStationHoldTrain(stationHoldTrain);
statusVO.setEmergencyClosed(emergencyClosed);
statusVO.setTrainParking(trainParking);

View File

@ -37,6 +37,10 @@ public class StandStatusVO extends DeviceStatusVO {
@JsonSerialize(using = Boolean2NumSerializer.class)
private Boolean centerHoldTrain;
/**是否系统扣车*/
@JsonSerialize(using = Boolean2NumSerializer.class)
private Boolean sysHoldTrain;
/**区间自动扣车*/
@JsonSerialize(using = Boolean2NumSerializer.class)
private Boolean autoHoldTrain;