【接发辅助灯状态逻辑重写】

【辅助按钮操作(逻辑未完成)】
This commit is contained in:
weizhihong 2022-04-28 17:01:01 +08:00
parent 765d830bed
commit c56e657ecf
4 changed files with 111 additions and 9 deletions

View File

@ -839,6 +839,21 @@ public class Operation {
* 改方按钮操作 * 改方按钮操作
*/ */
ASSIST_PRESS_DOWN_TURN_DIRECTION, ASSIST_PRESS_DOWN_TURN_DIRECTION,
/**
* 总辅助按钮操作
*/
ASSIST_PRESS_MAIN_ASSIST,
/**
* 接辅助按钮操作
*/
ASSIST_PRESS_RECEIVE_ASSIST,
/**
* 发辅助按钮操作
*/
ASSIST_PRESS_DELIVER_ASSIST
} }
/** /**

View File

@ -23,7 +23,7 @@ public class StationDirectionOperateHandler {
* *
* @param simulation 仿真数据 * @param simulation 仿真数据
* @param stationCode 车站编码 * @param stationCode 车站编码
* @param labelEnum 按钮类型 * @param labelEnum 运行方向
* @param pressDown 弹起0按下1 * @param pressDown 弹起0按下1
*/ */
@OperateHandlerMapping(type = Operation.Type.ASSIST_PRESS_DOWN_TURN_DIRECTION) @OperateHandlerMapping(type = Operation.Type.ASSIST_PRESS_DOWN_TURN_DIRECTION)
@ -38,4 +38,44 @@ public class StationDirectionOperateHandler {
, Button.ButtonTypeEnum.CHANGE_DIRECTION, isPressDown, validInterface, null); , Button.ButtonTypeEnum.CHANGE_DIRECTION, isPressDown, validInterface, null);
} }
/**
* 总辅助按钮操作
*
* @param simulation 仿真数据
* @param stationCode 车站编码
* @param labelEnum 运行方向
* @param pressDown 弹起0按下1
*/
@OperateHandlerMapping(type = Operation.Type.ASSIST_PRESS_MAIN_ASSIST)
public void pressMainAssist(Simulation simulation, String stationCode, DirectionLabelEnum labelEnum
, Integer pressDown) {
stationDirectionService.changeButtonAspect(simulation, stationCode, labelEnum, Button.ButtonTypeEnum.MAIN_ASSIST
, (pressDown == 1), null, null);
}
/**
* 按下接辅助
*
* @param simulation 仿真数据
* @param stationCode 车站编码
* @param labelEnum 运行方向
*/
@OperateHandlerMapping(type = Operation.Type.ASSIST_PRESS_RECEIVE_ASSIST)
public void pressReceiveAssist(Simulation simulation, String stationCode, DirectionLabelEnum labelEnum) {
stationDirectionService.changeButtonAspect(simulation, stationCode, labelEnum, Button.ButtonTypeEnum.RECEIVE_ASSIST
, Boolean.TRUE, stationDirectionService.turnAssistValid, stationDirectionService.receiveAssistThen);
}
/**
* 按下发辅助
*
* @param simulation 仿真数据
* @param stationCode 车站编码
* @param labelEnum 运行方向
*/
@OperateHandlerMapping(type = Operation.Type.ASSIST_PRESS_DELIVER_ASSIST)
public void pressDeliverAssist(Simulation simulation, String stationCode, DirectionLabelEnum labelEnum) {
stationDirectionService.changeButtonAspect(simulation, stationCode, labelEnum, Button.ButtonTypeEnum.DELIVER_ASSIST
, Boolean.TRUE, stationDirectionService.turnAssistValid, stationDirectionService.deliverAssistThen);
}
} }

View File

@ -107,6 +107,30 @@ public class StationDirectionService {
} }
}; };
/**
* 发辅助按钮操作校验
*/
public ButtonValidInterface turnAssistValid = (simulation, stationLabelEnum) -> {
if (!stationLabelEnum.isMainAssistStatus()) {
throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:总辅助按钮未按下");
}
};
/**
* 接辅助按钮后续操作
*/
public ButtonThenInterface receiveAssistThen = (simulation, stationLabelEnum) -> {
};
/**
* 接辅助按钮后续操作
*/
public ButtonThenInterface deliverAssistThen = (simulation, stationLabelEnum) -> {
};
/** /**
* 获取当前车站实体 * 获取当前车站实体
* *

View File

@ -18,6 +18,17 @@ import java.util.List;
@Getter @Getter
@Slf4j @Slf4j
public class StationDirection extends MapNamedElement { public class StationDirection extends MapNamedElement {
/**
* 发辅助默认倒计时 25s
*/
public static final int DEFAULT_DELIVER_DELAY_TIME = 25 * 1000;
/**
* 接辅助默认倒计时 15s
*/
public static final int DEFAULT_RECEIVE_DELAY_TIME = 15 * 1000;
/** /**
* 车站 * 车站
*/ */
@ -170,17 +181,12 @@ public class StationDirection extends MapNamedElement {
// 进路区段占用判断点灯颜色 // 进路区段占用判断点灯颜色
if (ReceiveAndDeliverModel.RECEIVE.equals(this.receiveAndDeliver)) { if (ReceiveAndDeliverModel.RECEIVE.equals(this.receiveAndDeliver)) {
deliverAspect = IndicatorStatusEnum.No; deliverAspect = IndicatorStatusEnum.No;
boolean receiveSectionBlock = this.receiveRouteList // 接车进路锁闭
.stream() receiveAspect = judgeSignalLock() ? IndicatorStatusEnum.R : IndicatorStatusEnum.Y;
.anyMatch(route -> route.getSectionList().stream().anyMatch(Section::isRouteLock));
receiveAspect = receiveSectionBlock ? IndicatorStatusEnum.R : IndicatorStatusEnum.Y;
} else if (ReceiveAndDeliverModel.DELIVER.equals(this.receiveAndDeliver)) { } else if (ReceiveAndDeliverModel.DELIVER.equals(this.receiveAndDeliver)) {
receiveAspect = IndicatorStatusEnum.No; receiveAspect = IndicatorStatusEnum.No;
// 发车进路锁闭 // 发车进路锁闭
boolean deliverSectionBlock = this.deliverRouteList deliverAspect = judgeSignalLock() ? IndicatorStatusEnum.R : IndicatorStatusEnum.G;
.stream()
.anyMatch(route -> route.getSectionList().stream().anyMatch(Section::isRouteLock));
deliverAspect = deliverSectionBlock ? IndicatorStatusEnum.R : IndicatorStatusEnum.G;
} else { } else {
receiveAspect = this.receiveAspect; receiveAspect = this.receiveAspect;
deliverAspect = this.receiveAspect; deliverAspect = this.receiveAspect;
@ -226,6 +232,23 @@ public class StationDirection extends MapNamedElement {
} }
} }
/**
* 如果信号灯所在区段任意一边被锁闭
*
* @return 锁闭状态
*/
private boolean judgeSignalLock() {
Section section = this.getSignal().getSection();
boolean isLock = section.isRouteLock();
if (!isLock && section.getLeftSection() != null) {
isLock = section.getLeftSection().isRouteLock();
}
if (!isLock && section.getRightSection() != null) {
isLock = section.getRightSection().isRouteLock();
}
return isLock;
}
public enum ReceiveAndDeliverModel { public enum ReceiveAndDeliverModel {
// //
RECEIVE, RECEIVE,