Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
commit
e1f1d8bc5e
@ -52,9 +52,10 @@ public class StationDirectionOperateHandler {
|
||||
@OperateHandlerMapping(type = Operation.Type.ASSIST_PRESS_MAIN_ASSIST)
|
||||
public void pressMainAssist(Simulation simulation, String stationCode, DirectionLabelEnum labelEnum
|
||||
, Integer pressDown) {
|
||||
ButtonValidInterface validInterface = stationDirectionService.getValidMethodByType(Operation.Type.ASSIST_PRESS_MAIN_ASSIST);
|
||||
ButtonThenInterface thenInterface = stationDirectionService.getThenMethodByType(Operation.Type.ASSIST_PRESS_MAIN_ASSIST);
|
||||
stationDirectionService.changeButtonAspect(simulation, stationCode, labelEnum
|
||||
, StationDirection.ButtonTypeEnum.MAIN_ASSIST, (pressDown == 1), null, thenInterface);
|
||||
, StationDirection.ButtonTypeEnum.MAIN_ASSIST, (pressDown == 1), validInterface, thenInterface);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -52,11 +52,20 @@ public class StationDirectionService {
|
||||
if (StationDirection.IndicatorStatusEnum.O.equals(stationDirection.getSectionAspect())) {
|
||||
throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:区段非空闲");
|
||||
}
|
||||
// 接车进路有锁闭,有车进入
|
||||
// 原接车站无接车进路锁闭
|
||||
boolean isReceiveConflict = stationDirection.getReceiveRouteList().stream().anyMatch(Route::isLock);
|
||||
if (isReceiveConflict) {
|
||||
throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:存在接车进路冲突");
|
||||
}
|
||||
// 原发车站无发车进路锁闭
|
||||
StationDirection relativeDirection = getRelativeStationDirection(simulation, stationDirection);
|
||||
boolean isDeliverConflict = relativeDirection != null;
|
||||
if (isDeliverConflict) {
|
||||
isDeliverConflict = relativeDirection.getDeliverRouteList().stream().anyMatch(Route::isLock);
|
||||
}
|
||||
if (isDeliverConflict) {
|
||||
throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:相对方向存在发车进路");
|
||||
}
|
||||
// 查找发车进路方向的站台上是否有停靠列车
|
||||
Optional<Route> routeOptional = stationDirection.getReceiveRouteList().stream().findAny();
|
||||
if (routeOptional.isEmpty()) {
|
||||
@ -65,9 +74,28 @@ public class StationDirectionService {
|
||||
};
|
||||
|
||||
/**
|
||||
* 发辅助按钮操作校验
|
||||
* 总辅助校验
|
||||
*/
|
||||
private final ButtonValidInterface turnAssistValid = (simulation, stationDirection) -> {
|
||||
// 原接车站无接车进路锁闭
|
||||
boolean isReceiveConflict = stationDirection.getReceiveRouteList().stream().anyMatch(Route::isLock);
|
||||
// 原发车站无发车进路锁闭
|
||||
boolean isDeliverConflict = stationDirection.getDeliverRouteList().stream().anyMatch(Route::isLock);
|
||||
// 相对车站
|
||||
StationDirection relativeDirection = getRelativeStationDirection(simulation, stationDirection);
|
||||
if (relativeDirection != null) {
|
||||
isReceiveConflict = isReceiveConflict || relativeDirection.getReceiveRouteList().stream().anyMatch(Route::isLock);
|
||||
isDeliverConflict = isDeliverConflict || relativeDirection.getDeliverRouteList().stream().anyMatch(Route::isLock);
|
||||
}
|
||||
if (isReceiveConflict || isDeliverConflict) {
|
||||
throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:存在锁闭进路");
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 发辅助按钮操作校验
|
||||
*/
|
||||
private final ButtonValidInterface deliverAssistValid = (simulation, stationDirection) -> {
|
||||
if (!stationDirection.isMainAssistStatus()) {
|
||||
throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:总辅助按钮未按下");
|
||||
}
|
||||
@ -78,7 +106,9 @@ public class StationDirectionService {
|
||||
*/
|
||||
private final ButtonValidInterface receiveAssistValid = (simulation, stationDirection) -> {
|
||||
// 判断总辅助
|
||||
this.turnAssistValid.valid(simulation, stationDirection);
|
||||
if (!stationDirection.isMainAssistStatus()) {
|
||||
throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:总辅助按钮未按下");
|
||||
}
|
||||
// 发车方向
|
||||
StationDirection deliverDirection = getRelativeStationDirection(simulation, stationDirection);
|
||||
if (deliverDirection == null) {
|
||||
@ -118,11 +148,10 @@ public class StationDirectionService {
|
||||
* 总辅助后续操作
|
||||
*/
|
||||
private final ButtonThenInterface turnAssistThen = (simulation, stationDirection) -> {
|
||||
// 总辅助弹起后,接发辅助、倒计时重置
|
||||
// 总辅助弹起后
|
||||
if (!stationDirection.isMainAssistStatus()) {
|
||||
stationDirection.setReceiveAssistStatus(false);
|
||||
stationDirection.setDeliverAssistStatus(false);
|
||||
stationDirection.getRemain().set(0);
|
||||
// 接发辅助、倒计时重置
|
||||
stationDirection.resetAssistStatus();
|
||||
// 总辅助抬起后将辅助准备状态
|
||||
stationDirection.setAssistReadyStatus(false);
|
||||
// 相对方向辅助准备状态也恢复
|
||||
@ -140,13 +169,15 @@ public class StationDirectionService {
|
||||
// 接辅助完成后,改变接方向
|
||||
stationDirection.setRunStatus(StationDirection.ReceiveAndDeliverModel.R);
|
||||
stationDirection.setAssistReadyStatus(true);
|
||||
// 邻站修改发方向
|
||||
StationDirection adjacentDirection = getRelativeStationDirection(simulation, stationDirection);
|
||||
adjacentDirection.setRunStatus(StationDirection.ReceiveAndDeliverModel.D);
|
||||
adjacentDirection.setAssistReadyStatus(true);
|
||||
// 办理完成后
|
||||
stationDirection.resetAssistStatus();
|
||||
// 邻站修改发方向
|
||||
StationDirection adjacentDirection = getRelativeStationDirection(simulation, stationDirection);
|
||||
if (adjacentDirection != null) {
|
||||
adjacentDirection.setRunStatus(StationDirection.ReceiveAndDeliverModel.D);
|
||||
adjacentDirection.setAssistReadyStatus(true);
|
||||
adjacentDirection.resetAssistStatus();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -157,6 +188,13 @@ public class StationDirectionService {
|
||||
stationDirection.setReceiveAssistStatus(false);
|
||||
// 重新设置倒计时时间
|
||||
stationDirection.getRemain().set(StationDirection.DEFAULT_DELIVER_DELAY_TIME);
|
||||
// 就绪状态恢复
|
||||
stationDirection.setAssistReadyStatus(false);
|
||||
// 邻站修改发方向
|
||||
StationDirection adjacentDirection = getRelativeStationDirection(simulation, stationDirection);
|
||||
if (adjacentDirection != null) {
|
||||
adjacentDirection.setAssistReadyStatus(false);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -264,10 +302,12 @@ public class StationDirectionService {
|
||||
this.operationButtonValidMap = new HashMap<>();
|
||||
// 改方按下验证函数
|
||||
this.operationButtonValidMap.put(Operation.Type.ASSIST_PRESS_DOWN_TURN_DIRECTION, this.turnDirectionPressDownValid);
|
||||
// 总辅助按下验证函数
|
||||
this.operationButtonValidMap.put(Operation.Type.ASSIST_PRESS_MAIN_ASSIST, this.turnAssistValid);
|
||||
// 接辅助按下验证函数
|
||||
this.operationButtonValidMap.put(Operation.Type.ASSIST_PRESS_RECEIVE_ASSIST, this.receiveAssistValid);
|
||||
// 发辅助按下验证函数
|
||||
this.operationButtonValidMap.put(Operation.Type.ASSIST_PRESS_DELIVER_ASSIST, this.turnAssistValid);
|
||||
this.operationButtonValidMap.put(Operation.Type.ASSIST_PRESS_DELIVER_ASSIST, this.deliverAssistValid);
|
||||
// 操作按钮后续操作集合
|
||||
this.operationButtonThenMap = new HashMap<>();
|
||||
// 总辅助后续操作
|
||||
|
@ -259,7 +259,7 @@ public class StationDirection extends MapNamedElement {
|
||||
this.receiveAssistStatus = false;
|
||||
}
|
||||
// 如果总辅助、(接发任意一方按下为白灯)
|
||||
if (this.mainAssistStatus && (this.deliverAssistStatus || this.receiveAssistStatus)) {
|
||||
if (this.mainAssistStatus && (this.deliverAssistStatus || this.receiveAssistStatus || this.assistReadyStatus)) {
|
||||
this.assistAspect = IndicatorStatusEnum.O;
|
||||
} else {
|
||||
this.assistAspect = IndicatorStatusEnum.F;
|
||||
|
Loading…
Reference in New Issue
Block a user