【半自动操作:事故按钮、闭塞、复原操作】(未测试)

This commit is contained in:
weizhihong 2022-05-05 18:14:01 +08:00
parent e63664b6d2
commit 0e950db851
7 changed files with 310 additions and 86 deletions

View File

@ -861,7 +861,11 @@ public class Operation {
/**
* 按下复原按钮
*/
ASSIST_PRESS_RESTORE
ASSIST_PRESS_RESTORE,
/**
* 事故按钮
*/
ASSIST_PRESS_ACCIDENT,
}
/**

View File

@ -63,7 +63,7 @@ public class StationDirectionOperateHandler {
@OperateHandlerMapping(type = Operation.Type.ASSIST_PRESS_RECEIVE_ASSIST)
public void pressReceiveAssist(Simulation simulation, String stationCode, DirectionLabelEnum labelEnum) {
stationDirectionService.changeButtonAspect(simulation, stationCode, labelEnum, StationDirection.ButtonTypeEnum.RECEIVE_ASSIST
, Boolean.TRUE, stationDirectionService.turnAssistValid, stationDirectionService.receiveAssistThen);
, Boolean.TRUE, stationDirectionService.receiveAssistValid, stationDirectionService.receiveAssistThen);
}
/**
@ -88,8 +88,8 @@ public class StationDirectionOperateHandler {
*/
@OperateHandlerMapping(type = Operation.Type.ASSIST_PRESS_BLOCK)
public void pressBlockBtn(Simulation simulation, String stationCode, DirectionLabelEnum labelEnum) {
stationDirectionService.changeButtonAspect(simulation, stationCode, labelEnum, StationDirection.ButtonTypeEnum.BLOCK
, Boolean.TRUE, null, null);
stationDirectionService.changeButtonAspect(simulation, stationCode, labelEnum, StationDirection.ButtonTypeEnum.OCCLUSION
, Boolean.TRUE, null, stationDirectionService.turnBlockThen);
}
/**
@ -101,7 +101,21 @@ public class StationDirectionOperateHandler {
*/
@OperateHandlerMapping(type = Operation.Type.ASSIST_PRESS_RESTORE)
public void pressRestoreBtn(Simulation simulation, String stationCode, DirectionLabelEnum labelEnum) {
stationDirectionService.changeButtonAspect(simulation, stationCode, labelEnum, StationDirection.ButtonTypeEnum.BLOCK
, Boolean.TRUE, null, stationDirectionService.turnRestoreThen);
stationDirectionService.changeButtonAspect(simulation, stationCode, labelEnum, StationDirection.ButtonTypeEnum.RESTORE
, Boolean.TRUE, stationDirectionService.turnRestoreValid, stationDirectionService.turnRestoreThen);
}
/**
* 按下事故按钮
*
* @param simulation 仿真数据
* @param stationCode 车站编码
* @param labelEnum 运行方向
* @param pressDown 按下1抬起0
*/
@OperateHandlerMapping(type = Operation.Type.ASSIST_PRESS_ACCIDENT)
public void pressAccidentBtn(Simulation simulation, String stationCode, DirectionLabelEnum labelEnum, Integer pressDown) {
stationDirectionService.changeButtonAspect(simulation, stationCode, labelEnum, StationDirection.ButtonTypeEnum.ACCIDENT
, (pressDown == 1), null, null);
}
}

View File

@ -3,10 +3,7 @@ package club.joylink.rtss.simulation.cbtc.ATS.service.assist;
import club.joylink.rtss.constants.DirectionLabelEnum;
import club.joylink.rtss.entity.DraftMapStationDirection;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.map.Route;
import club.joylink.rtss.simulation.cbtc.data.map.Stand;
import club.joylink.rtss.simulation.cbtc.data.map.Station;
import club.joylink.rtss.simulation.cbtc.data.map.StationDirection;
import club.joylink.rtss.simulation.cbtc.data.map.*;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
@ -98,8 +95,7 @@ public class StationDirectionService {
standList = stationDirection.getStation().getLdStandList();
}
// 获取靠停列车
List<String> sectionCodeList = simulation.getRepository().getOnlineTrainList()
.stream()
List<String> sectionCodeList = simulation.getRepository().getOnlineTrainList().stream()
.filter(VirtualRealityTrain::isStop)
.map(trainInfo -> trainInfo.getHeadPosition().getSection().getCode())
.collect(Collectors.toList());
@ -110,7 +106,7 @@ public class StationDirectionService {
};
/**
* 发辅助按钮操作校验
* 发辅助按钮操作校验
*/
public ButtonValidInterface turnAssistValid = (simulation, stationDirection) -> {
if (!stationDirection.isMainAssistStatus()) {
@ -118,6 +114,36 @@ public class StationDirectionService {
}
};
/**
* 接辅助按钮操作校验
*/
public ButtonValidInterface receiveAssistValid = (simulation, stationDirection) -> {
// 判断总辅助
this.turnAssistValid.valid(simulation, stationDirection);
// 获取邻站实体
Optional<Station> nextStationOptional = getAdjacentStationOptional(simulation, stationDirection);
// 存在邻站
if (nextStationOptional.isPresent()) {
// 方向标签
DirectionLabelEnum relativeDirectionLabelEnum = stationDirection.getRelativeDirectionLabelEnum();
if (DirectionLabelEnum.NO.equals(relativeDirectionLabelEnum)) {
throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:无对应方向");
} else {
// 发车方向
StationDirection deliverDirection = nextStationOptional.get().getStationDirectionMap().get(relativeDirectionLabelEnum);
if (deliverDirection == null) {
throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:无对应方向");
} else {
// 邻站发辅助是否按下
if (!deliverDirection.isDeliverAssistStatus()) {
throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:邻站未按下发辅助");
}
}
}
} else {
throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:邻站不存在");
}
};
/**
* 总辅助后续操作
@ -155,7 +181,16 @@ public class StationDirectionService {
* 复原按钮操作验证
*/
public ButtonValidInterface turnRestoreValid = (simulation, stationDirection) -> {
// 接车方向需要判断是否已过信号机内方第一道岔区段
if (StationDirection.DirectionRunModel.S.equals(stationDirection.getRunModel())
&& StationDirection.ReceiveAndDeliverModel.R.equals(stationDirection.getRunStatus())) {
Section section = stationDirection.getSignal().getSection();
Section nextSection = section.getNextSection(stationDirection.getSignal().isRight());
// 判断信号机所在下一个区段是否锁闭,判断
if (section.isRouteLock() || nextSection.isRouteLock()) {
throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:区段未解锁");
}
}
};
/**
@ -168,23 +203,18 @@ public class StationDirectionService {
&& StationDirection.ReceiveAndDeliverModel.R.equals(stationDirection.getRunStatus())) {
// 将本方向接发车状态恢复
stationDirection.reset();
// 接车进路方向朝向
boolean right = stationDirection.getReceiveRouteList().stream().findFirst().stream().anyMatch(Route::isRight);
// 寻找车站位置用于获取邻站
List<Station> stationList = simulation.getRepository().getStationList();
int index = stationList.indexOf(stationDirection.getStation());
// 范围内
if (index != 0 && index != stationList.size() - 1) {
index = right ? index + 1 : index - 1;
Station adjacentStation = stationList.get(index);
if (adjacentStation != null) {
adjacentStation.getStationDirectionMap().values()
.stream()
.filter(sd -> StationDirection.DirectionRunModel.S.equals(sd.getRunModel()))
.filter(sd -> sd.getDeliverRouteList().stream().anyMatch(route -> route.isRight() == right))
.forEach(sd -> sd.reset());
// 获取邻站实体
Optional<Station> adjacentStationOptional = getAdjacentStationOptional(simulation, stationDirection);
// 存在邻站
if (adjacentStationOptional.isPresent()) {
// 方向标签
DirectionLabelEnum relativeDirectionLabelEnum = stationDirection.getRelativeDirectionLabelEnum();
// 发车方向
StationDirection deliverDirection = adjacentStationOptional.get().getStationDirectionMap().get(relativeDirectionLabelEnum);
// 发车方向还原
if (deliverDirection != null) {
deliverDirection.reset();
}
}
}
} finally {
@ -193,6 +223,33 @@ public class StationDirectionService {
}
};
/**
* 闭塞按钮操作
*/
public ButtonThenInterface turnBlockThen = (simulation, stationDirection) -> {
// 获取邻站实体
Optional<Station> adjacentStationOptional = getAdjacentStationOptional(simulation, stationDirection);
// 存在邻站
if (adjacentStationOptional.isPresent()) {
// 方向标签
DirectionLabelEnum relativeDirectionLabelEnum = stationDirection.getRelativeDirectionLabelEnum();
// 发车方向
StationDirection adjacentDirection = adjacentStationOptional.get().getStationDirectionMap().get(relativeDirectionLabelEnum);
if (adjacentDirection != null) {
// 如果存在闭塞说明本站是接车站
if (adjacentDirection.isBlockStatus()) {
// 预备状态
stationDirection.setReadyStatus(true);
adjacentDirection.setReadyStatus(true);
} else { // 不存在闭塞则本站是发车进路
// 将本站邻站接发状态设置为预备状态
stationDirection.setRunStatus(StationDirection.ReceiveAndDeliverModel.D);
adjacentDirection.setRunStatus(StationDirection.ReceiveAndDeliverModel.R);
}
}
}
};
/**
* 获取当前车站实体
*
@ -214,4 +271,23 @@ public class StationDirectionService {
}
return station;
}
/**
* 获取接车进路的邻站
* 接车进路
*
* @param simulation 仿真实体数据
* @param stationDirection 方向实体
* @return 车站
*/
private Optional<Station> getAdjacentStationOptional(Simulation simulation, StationDirection stationDirection) {
// 获取接进路的方向
boolean right = stationDirection.getReceiveRouteList().stream().findAny().get().isRight();
// 找上一个车站序号
int index = stationDirection.getStation().getSn() + (right ? -1 : 1);
Optional<Station> adjacentStationOptional = simulation.getRepository().getStationList().stream()
.filter(station -> station.getSn() == index)
.findFirst();
return adjacentStationOptional;
}
}

View File

@ -18,7 +18,6 @@ import java.util.concurrent.atomic.AtomicInteger;
@Getter
@Slf4j
public class StationDirection extends MapNamedElement {
/**
* 发辅助默认倒计时 25s
*/
@ -109,6 +108,16 @@ public class StationDirection extends MapNamedElement {
*/
private boolean restoreStatus;
/**
* 预备状态
*/
private boolean readyStatus;
/**
* 事故
*/
private boolean accidentStatus;
/**
* 接车进路以指示灯为起点的进路
*/
@ -216,12 +225,48 @@ public class StationDirection extends MapNamedElement {
this.restoreStatus = pressDown;
break;
// 闭塞
case BLOCK:
case OCCLUSION:
this.blockStatus = pressDown;
break;
// 事故
case ACCIDENT:
this.accidentStatus = pressDown;
}
}
/**
* 获取对应的方向
*
* @return 对应方向
*/
public DirectionLabelEnum getRelativeDirectionLabelEnum() {
DirectionLabelEnum nextLabelEnum;
switch (labelEnum) {
case X:
nextLabelEnum = DirectionLabelEnum.XF;
break;
case XF:
nextLabelEnum = DirectionLabelEnum.X;
break;
case XD:
nextLabelEnum = DirectionLabelEnum.SD;
break;
case S:
nextLabelEnum = DirectionLabelEnum.SF;
break;
case SF:
nextLabelEnum = DirectionLabelEnum.S;
break;
case SD:
nextLabelEnum = DirectionLabelEnum.XD;
break;
default:
nextLabelEnum = DirectionLabelEnum.NO;
break;
}
return nextLabelEnum;
}
/**
* 设置默认属性
*/
@ -231,6 +276,7 @@ public class StationDirection extends MapNamedElement {
this.receiveAssistStatus = false;
this.deliverAssistStatus = false;
this.blockStatus = false;
this.readyStatus = false;
this.receiveAspect = IndicatorStatusEnum.F;
this.deliverAspect = IndicatorStatusEnum.F;
this.sectionAspect = IndicatorStatusEnum.F;
@ -247,7 +293,7 @@ public class StationDirection extends MapNamedElement {
} else if (DirectionLabelEnum.XF.equals(labelEnum) || DirectionLabelEnum.SF.equals(labelEnum)) { // SFXF方向默认发车灯亮起
return ReceiveAndDeliverModel.D;
} else { // SDXD方向默认发车灯亮起
return ReceiveAndDeliverModel.N;
return ReceiveAndDeliverModel.NO;
}
}
@ -270,11 +316,10 @@ public class StationDirection extends MapNamedElement {
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();
// 判断信号机所在下一个区段是否锁闭
if (!isLock) {
section = section.getNextSection(getSignal().isRight());
isLock = section.isRouteLock();
}
return isLock;
}
@ -336,20 +381,6 @@ public class StationDirection extends MapNamedElement {
* 半自动闭塞,不会自动恢复
*/
private void semiAutomaticModelAspectStatus() {
// 只有当状态为空时才做判断
if (ReceiveAndDeliverModel.N.equals(this.runStatus)) {
// 进路锁闭判断接发状态
// 接车进路锁闭
boolean receiveRouteBlock = this.receiveRouteList.stream().anyMatch(Route::isLock);
if (receiveRouteBlock) {
// 接发状态
this.runStatus = ReceiveAndDeliverModel.R;
} else {
// 发车进路锁闭
boolean deliverRouteBlock = this.deliverRouteList.stream().anyMatch(Route::isLock);
this.runStatus = deliverRouteBlock ? ReceiveAndDeliverModel.D : this.runStatus;
}
}
// 点灯
if (ReceiveAndDeliverModel.R.equals(this.runStatus)) { // 接车方向
if (IndicatorStatusEnum.F.equals(this.receiveAspect) && IndicatorStatusEnum.O.equals(this.sectionAspect)) {
@ -360,7 +391,7 @@ public class StationDirection extends MapNamedElement {
if (IndicatorStatusEnum.F.equals(this.deliverAspect) && IndicatorStatusEnum.O.equals(this.sectionAspect)) {
this.deliverAspect = IndicatorStatusEnum.O;
}
} else if (ReceiveAndDeliverModel.N.equals(this.runStatus)) {
} else if (ReceiveAndDeliverModel.NO.equals(this.runStatus)) {
this.deliverAspect = IndicatorStatusEnum.F;
this.receiveAspect = IndicatorStatusEnum.F;
}
@ -374,14 +405,16 @@ public class StationDirection extends MapNamedElement {
//
A,
//
N
NO
}
public enum IndicatorStatusEnum {
// 占用
O,
// 空闲
F
F,
// 预备
R
}
public enum ButtonTypeEnum {
@ -396,7 +429,9 @@ public class StationDirection extends MapNamedElement {
// 复原
RESTORE,
// 闭塞
BLOCK,
OCCLUSION,
// 事故
ACCIDENT,
NO;
}

View File

@ -69,6 +69,26 @@ public class StationDirectionStatus extends DeviceStatus {
*/
private AtomicInteger remain;
/**
* 闭塞按钮
*/
private boolean blockStatus;
/**
* 复原按钮
*/
private boolean restoreStatus;
/**
* 预备状态
*/
private boolean readyStatus;
/**
* 事故
*/
private boolean accidentStatus;
public StationDirectionStatus(StationDirection stationDirection) {
super(stationDirection.getCode(), stationDirection.getDeviceType());
this.stationCode = stationDirection.getStation().getCode();
@ -83,73 +103,101 @@ public class StationDirectionStatus extends DeviceStatus {
this.receiveAssistStatus = stationDirection.isReceiveAssistStatus();
this.deliverAssistStatus = stationDirection.isDeliverAssistStatus();
this.remain = new AtomicInteger(stationDirection.getRemain().intValue());
this.blockStatus = stationDirection.isBlockStatus();
this.restoreStatus = stationDirection.isRestoreStatus();
this.readyStatus = stationDirection.isReadyStatus();
this.accidentStatus = stationDirection.isAccidentStatus();
}
@Override
public boolean compareAndChange(MapElement device, DeviceStatusVO statusVO) {
StationDirection labelEnum = (StationDirection) device;
StationDirection stationDirection = (StationDirection) device;
StationDirectionStatusVO status = (StationDirectionStatusVO) statusVO;
boolean change = false;
// 接车发车口
if (!Objects.equals(labelEnum.getRunStatus(), runStatus)) {
this.runStatus = labelEnum.getRunStatus();
status.setRunStatus(labelEnum.getRunStatus());
if (!Objects.equals(stationDirection.getRunStatus(), runStatus)) {
this.runStatus = stationDirection.getRunStatus();
status.setRunStatus(stationDirection.getRunStatus());
change = true;
}
// 接车
if (!Objects.equals(labelEnum.getReceiveAspect(), receiveAspect)) {
this.receiveAspect = labelEnum.getReceiveAspect();
if (!Objects.equals(stationDirection.getReceiveAspect(), receiveAspect)) {
this.receiveAspect = stationDirection.getReceiveAspect();
status.setReceiveAspect(receiveAspect);
change = true;
}
// 发车
if (!Objects.equals(labelEnum.getDeliverAspect(), deliverAspect)) {
this.deliverAspect = labelEnum.getDeliverAspect();
if (!Objects.equals(stationDirection.getDeliverAspect(), deliverAspect)) {
this.deliverAspect = stationDirection.getDeliverAspect();
status.setDeliverAspect(deliverAspect);
change = true;
}
// 区间
if (!Objects.equals(labelEnum.getSectionAspect(), sectionAspect)) {
this.sectionAspect = labelEnum.getSectionAspect();
if (!Objects.equals(stationDirection.getSectionAspect(), sectionAspect)) {
this.sectionAspect = stationDirection.getSectionAspect();
status.setSectionAspect(sectionAspect);
change = true;
}
// 辅助灯
if (!Objects.equals(labelEnum.getAssistAspect(), assistAspect)) {
this.assistAspect = labelEnum.getAssistAspect();
if (!Objects.equals(stationDirection.getAssistAspect(), assistAspect)) {
this.assistAspect = stationDirection.getAssistAspect();
status.setAssistAspect(assistAspect);
change = true;
}
// 改方按钮
if (!Objects.equals(labelEnum.isChangeDirectionStatus(), changeDirectionStatus)) {
this.changeDirectionStatus = labelEnum.isChangeDirectionStatus();
if (!Objects.equals(stationDirection.isChangeDirectionStatus(), changeDirectionStatus)) {
this.changeDirectionStatus = stationDirection.isChangeDirectionStatus();
status.setChangeDirectionStatus(changeDirectionStatus);
change = true;
}
// 总辅助按钮
if (!Objects.equals(labelEnum.isMainAssistStatus(), mainAssistStatus)) {
this.mainAssistStatus = labelEnum.isMainAssistStatus();
if (!Objects.equals(stationDirection.isMainAssistStatus(), mainAssistStatus)) {
this.mainAssistStatus = stationDirection.isMainAssistStatus();
status.setMainAssistStatus(mainAssistStatus);
change = true;
}
// 接辅助按钮
if (!Objects.equals(labelEnum.isReceiveAssistStatus(), receiveAssistStatus)) {
this.receiveAssistStatus = labelEnum.isReceiveAssistStatus();
if (!Objects.equals(stationDirection.isReceiveAssistStatus(), receiveAssistStatus)) {
this.receiveAssistStatus = stationDirection.isReceiveAssistStatus();
status.setReceiveAssistStatus(receiveAssistStatus);
change = true;
}
// 发辅助按钮
if (!Objects.equals(labelEnum.isDeliverAssistStatus(), deliverAssistStatus)) {
this.deliverAssistStatus = labelEnum.isDeliverAssistStatus();
if (!Objects.equals(stationDirection.isDeliverAssistStatus(), deliverAssistStatus)) {
this.deliverAssistStatus = stationDirection.isDeliverAssistStatus();
status.setDeliverAssistStatus(deliverAssistStatus);
change = true;
}
// 倒计时判断
if (!Objects.equals(labelEnum.getRemain().intValue(), remain.intValue())) {
this.remain.set(labelEnum.getRemain().intValue());
if (!Objects.equals(stationDirection.getRemain().intValue(), remain.intValue())) {
this.remain.set(stationDirection.getRemain().intValue());
status.setRemain(remain.intValue());
change = true;
}
// 闭塞状态
if (!Objects.equals(stationDirection.isBlockStatus(), blockStatus)) {
this.blockStatus = stationDirection.isBlockStatus();
status.setBlockStatus(stationDirection.isBlockStatus());
change = true;
}
// 复原状态
if (!Objects.equals(stationDirection.isRestoreStatus(), restoreStatus)) {
this.restoreStatus = stationDirection.isRestoreStatus();
status.setRestoreStatus(stationDirection.isRestoreStatus());
change = true;
}
// 预备状态
if (!Objects.equals(stationDirection.isReadyStatus(), readyStatus)) {
this.readyStatus = stationDirection.isReadyStatus();
status.setReadyStatus(stationDirection.isReadyStatus());
change = true;
}
// 预备状态
if (!Objects.equals(stationDirection.isAccidentStatus(), accidentStatus)) {
this.accidentStatus = stationDirection.isAccidentStatus();
status.setAccidentStatus(stationDirection.isAccidentStatus());
change = true;
}
return change;
}
@ -167,6 +215,11 @@ public class StationDirectionStatus extends DeviceStatus {
statusVO.setMainAssistStatus(mainAssistStatus);
statusVO.setReceiveAssistStatus(receiveAssistStatus);
statusVO.setDeliverAssistStatus(deliverAssistStatus);
statusVO.setRemain(remain.intValue());
statusVO.setBlockStatus(blockStatus);
statusVO.setRestoreStatus(restoreStatus);
statusVO.setReadyStatus(readyStatus);
statusVO.setAccidentStatus(accidentStatus);
return statusVO;
}
}

View File

@ -63,6 +63,26 @@ public class StationDirectionStatusVO extends DeviceStatusVO {
*/
private Integer remain;
/**
* 闭塞按钮
*/
private Boolean blockStatus;
/**
* 复原按钮
*/
private Boolean restoreStatus;
/**
* 预备状态
*/
private Boolean readyStatus;
/**
* 事故
*/
private Boolean accidentStatus;
public StationDirectionStatusVO(StationDirection stationDirection) {
super(stationDirection.getCode(), stationDirection.getDeviceType());
}

View File

@ -38,19 +38,33 @@ public class MapSignalButtonVO {
private DirectionLabelEnum labelEnum;
public enum Type {
/** 接车按钮 */
/**
* 接车按钮
*/
PICK,
/** 通过按钮 */
/**
* 通过按钮
*/
PASS,
/** 引导按钮 */
/**
* 引导按钮
*/
GUIDE,
/** 变通按钮 */
/**
* 变通按钮
*/
FLEXIBLE,
/** 坡道终端按钮 */
/**
* 坡道终端按钮
*/
RAMP_TERMINAL,
/** 列车终端按钮 */
/**
* 列车终端按钮
*/
TRAIN_TERMINAL,
/** 调车终端按钮 */
/**
* 调车终端按钮
*/
SHUNT_TERMINAL,
/**
@ -72,6 +86,14 @@ public class MapSignalButtonVO {
/**
* 改方按钮
*/
CHANGE_DIRECTION
CHANGE_DIRECTION,
/**
* 复原
*/
RECOVERY,
/**
* 闭塞
*/
OCCLUSION
}
}