【消息体增加运行方向状态】

This commit is contained in:
weizhihong 2022-04-28 18:17:49 +08:00
parent c56e657ecf
commit bd59012519
6 changed files with 59 additions and 51 deletions

View File

@ -67,33 +67,27 @@ public class StationDirectionService {
/** /**
* 改方按钮按下校验 * 改方按钮按下校验
*/ */
public ButtonValidInterface turnDirectionPressDownValid = (simulation, stationLabelEnum) -> { public ButtonValidInterface turnDirectionPressDownValid = (simulation, stationDirection) -> {
boolean isExist = stationLabelEnum.getButtonList()
.stream()
.anyMatch(button -> Button.ButtonTypeEnum.CHANGE_DIRECTION.equals(button.getType()));
if (!isExist) {
throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:按钮不存在");
}
// 区间是否空闲 // 区间是否空闲
if (IndicatorStatusEnum.R.equals(stationLabelEnum.getSectionAspect())) { if (IndicatorStatusEnum.R.equals(stationDirection.getSectionAspect())) {
throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:区段非空闲"); throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:区段非空闲");
} }
// 接车进路有锁闭有车进入 // 接车进路有锁闭有车进入
boolean isReceiveConflict = stationLabelEnum.getReceiveRouteList().stream().anyMatch(Route::isLock); boolean isReceiveConflict = stationDirection.getReceiveRouteList().stream().anyMatch(Route::isLock);
if (isReceiveConflict) { if (isReceiveConflict) {
throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:存在接车进路冲突"); throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:存在接车进路冲突");
} }
// 查找发车进路方向的站台上是否有停靠列车 // 查找发车进路方向的站台上是否有停靠列车
Optional<Route> routeOptional = stationLabelEnum.getReceiveRouteList().stream().findAny(); Optional<Route> routeOptional = stationDirection.getReceiveRouteList().stream().findAny();
if (routeOptional.isEmpty()) { if (routeOptional.isEmpty()) {
throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:没有接车进路"); throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:没有接车进路");
} }
Route route = routeOptional.get(); Route route = routeOptional.get();
List<Stand> standList; List<Stand> standList;
if (route.isRight()) { if (route.isRight()) {
standList = stationLabelEnum.getStation().getRdStandList(); standList = stationDirection.getStation().getRdStandList();
} else { } else {
standList = stationLabelEnum.getStation().getLdStandList(); standList = stationDirection.getStation().getLdStandList();
} }
// 获取靠停列车 // 获取靠停列车
List<String> sectionCodeList = simulation.getRepository().getOnlineTrainList() List<String> sectionCodeList = simulation.getRepository().getOnlineTrainList()
@ -111,8 +105,8 @@ public class StationDirectionService {
/** /**
* 发辅助按钮操作校验 * 发辅助按钮操作校验
*/ */
public ButtonValidInterface turnAssistValid = (simulation, stationLabelEnum) -> { public ButtonValidInterface turnAssistValid = (simulation, stationDirection) -> {
if (!stationLabelEnum.isMainAssistStatus()) { if (!stationDirection.isMainAssistStatus()) {
throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:总辅助按钮未按下"); throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:总辅助按钮未按下");
} }
}; };
@ -120,15 +114,17 @@ public class StationDirectionService {
/** /**
* 接辅助按钮后续操作 * 接辅助按钮后续操作
*/ */
public ButtonThenInterface receiveAssistThen = (simulation, stationLabelEnum) -> { public ButtonThenInterface receiveAssistThen = (simulation, stationDirection) -> {
// 重新设置倒计时时间
stationDirection.getRemain().set(StationDirection.DEFAULT_RECEIVE_DELAY_TIME);
}; };
/** /**
* 接辅助按钮后续操作 * 接辅助按钮后续操作
*/ */
public ButtonThenInterface deliverAssistThen = (simulation, stationLabelEnum) -> { public ButtonThenInterface deliverAssistThen = (simulation, stationDirection) -> {
// 重新设置倒计时时间
stationDirection.getRemain().set(StationDirection.DEFAULT_DELIVER_DELAY_TIME);
}; };
/** /**

View File

@ -46,6 +46,8 @@ public class CTCLogicLoop {
buildNewCtcStationPlan(simulation); buildNewCtcStationPlan(simulation);
updateCtcStationPlan(simulation); updateCtcStationPlan(simulation);
sendMessage(simulation); sendMessage(simulation);
// 车站运行方向倒计时
refreshStationDirection(simulation);
} }
private void sendMessage(Simulation simulation) { private void sendMessage(Simulation simulation) {
@ -233,4 +235,15 @@ public class CTCLogicLoop {
public void addJobs(Simulation simulation) { public void addJobs(Simulation simulation) {
simulation.addJob(NAME, () -> this.run(simulation), RATE); simulation.addJob(NAME, () -> this.run(simulation), RATE);
} }
/**
* 运行方向接发辅助按钮倒计时
*
* @param simulation 仿真信息
*/
private void refreshStationDirection(Simulation simulation) {
simulation.getRepository().getStationList().forEach(station -> station.getStationDirectionMap().values().stream()
.filter(stationDirection -> stationDirection.getRemain().intValue() != 0)
.forEach(stationDirection -> stationDirection.getRemain().decrementAndGet()));
}
} }

View File

@ -1601,16 +1601,6 @@ public class InterlockBuilder2 {
model.getDeliverRouteList().add((Route) elementMap.get(code)); model.getDeliverRouteList().add((Route) elementMap.get(code));
}); });
} }
// 放入按钮数据
station.getButtonList().stream()
.filter(button -> model.getLabelEnum().equals(button.getLabel()))
.forEach(button -> model.getButtonList().add(button));
// 放入指示灯数据
station.getIndicatorList().stream()
.filter(indicator -> model.getLabelEnum().equals(indicator.getLabel()))
.forEach(indicator -> model.getIndicatorList().add(indicator));
station.getStationDirectionMap().put(model.getLabelEnum(), model); station.getStationDirectionMap().put(model.getLabelEnum(), model);
elementMap.put(model.getCode(), model); elementMap.put(model.getCode(), model);
} }

View File

@ -10,6 +10,7 @@ import org.springframework.util.CollectionUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
/** /**
* 指示灯设备 * 指示灯设备
@ -22,12 +23,12 @@ public class StationDirection extends MapNamedElement {
/** /**
* 发辅助默认倒计时 25s * 发辅助默认倒计时 25s
*/ */
public static final int DEFAULT_DELIVER_DELAY_TIME = 25 * 1000; public static final int DEFAULT_DELIVER_DELAY_TIME = 25;
/** /**
* 接辅助默认倒计时 15s * 接辅助默认倒计时 15s
*/ */
public static final int DEFAULT_RECEIVE_DELAY_TIME = 15 * 1000; public static final int DEFAULT_RECEIVE_DELAY_TIME = 15;
/** /**
* 车站 * 车站
@ -44,10 +45,15 @@ public class StationDirection extends MapNamedElement {
*/ */
private Signal signal; private Signal signal;
/**
* 剩余时间
*/
private AtomicInteger remain = new AtomicInteger(0);
/** /**
* 处于接发状态 * 处于接发状态
*/ */
private ReceiveAndDeliverModel receiveAndDeliver; private ReceiveAndDeliverModel model;
/** /**
* 接车灯状态 * 接车灯状态
@ -104,20 +110,11 @@ public class StationDirection extends MapNamedElement {
*/ */
private List<Section> sectionList; private List<Section> sectionList;
/**
* 按钮集合
*/
private List<Button> buttonList;
/**
* 指示灯集合
*/
private List<Indicator> indicatorList;
public StationDirection(String code, String name, DirectionLabelEnum labelEnum) { public StationDirection(String code, String name, DirectionLabelEnum labelEnum) {
this(code, name); this(code, name);
this.labelEnum = labelEnum; this.labelEnum = labelEnum;
this.receiveAndDeliver = this.getDefaultReceiveAndDeliver(); this.model = this.getDefaultReceiveAndDeliver();
} }
public StationDirection(String code, String name) { public StationDirection(String code, String name) {
@ -126,14 +123,12 @@ public class StationDirection extends MapNamedElement {
this.sectionList = new ArrayList<>(); this.sectionList = new ArrayList<>();
this.receiveRouteList = new ArrayList<>(); this.receiveRouteList = new ArrayList<>();
this.deliverRouteList = new ArrayList<>(); this.deliverRouteList = new ArrayList<>();
this.buttonList = new ArrayList<>();
this.indicatorList = new ArrayList<>();
} }
@Override @Override
public void reset() { public void reset() {
this.setDefaultAttribute(); this.setDefaultAttribute();
this.receiveAndDeliver = this.getDefaultReceiveAndDeliver(); this.model = this.getDefaultReceiveAndDeliver();
} }
/** /**
@ -168,22 +163,22 @@ public class StationDirection extends MapNamedElement {
public void refreshAspectStatus() { public void refreshAspectStatus() {
// 进路锁闭判断接发状态 // 进路锁闭判断接发状态
// 接车进路锁闭 // 接车进路锁闭
boolean receiveRouteBlock = this.receiveRouteList.stream().anyMatch(route -> route.isLock()); boolean receiveRouteBlock = this.receiveRouteList.stream().anyMatch(Route::isLock);
// 发车进路锁闭 // 发车进路锁闭
boolean deliverRouteBlock = this.deliverRouteList.stream().anyMatch(route -> route.isLock()); boolean deliverRouteBlock = this.deliverRouteList.stream().anyMatch(Route::isLock);
// 接发状态 // 接发状态
this.receiveAndDeliver = receiveRouteBlock ? ReceiveAndDeliverModel.RECEIVE : this.receiveAndDeliver; this.model = receiveRouteBlock ? ReceiveAndDeliverModel.RECEIVE : this.model;
this.receiveAndDeliver = deliverRouteBlock ? ReceiveAndDeliverModel.DELIVER : this.receiveAndDeliver; this.model = deliverRouteBlock ? ReceiveAndDeliverModel.DELIVER : this.model;
// 接车进路锁闭亮红灯否则默认 // 接车进路锁闭亮红灯否则默认
IndicatorStatusEnum receiveAspect; IndicatorStatusEnum receiveAspect;
// 发车进路锁闭亮红灯否则默认 // 发车进路锁闭亮红灯否则默认
IndicatorStatusEnum deliverAspect; IndicatorStatusEnum deliverAspect;
// 进路区段占用判断点灯颜色 // 进路区段占用判断点灯颜色
if (ReceiveAndDeliverModel.RECEIVE.equals(this.receiveAndDeliver)) { if (ReceiveAndDeliverModel.RECEIVE.equals(this.model)) {
deliverAspect = IndicatorStatusEnum.No; deliverAspect = IndicatorStatusEnum.No;
// 接车进路锁闭 // 接车进路锁闭
receiveAspect = judgeSignalLock() ? IndicatorStatusEnum.R : IndicatorStatusEnum.Y; receiveAspect = judgeSignalLock() ? IndicatorStatusEnum.R : IndicatorStatusEnum.Y;
} else if (ReceiveAndDeliverModel.DELIVER.equals(this.receiveAndDeliver)) { } else if (ReceiveAndDeliverModel.DELIVER.equals(this.model)) {
receiveAspect = IndicatorStatusEnum.No; receiveAspect = IndicatorStatusEnum.No;
// 发车进路锁闭 // 发车进路锁闭
deliverAspect = judgeSignalLock() ? IndicatorStatusEnum.R : IndicatorStatusEnum.G; deliverAspect = judgeSignalLock() ? IndicatorStatusEnum.R : IndicatorStatusEnum.G;

View File

@ -19,6 +19,11 @@ public class StationDirectionStatus extends DeviceStatus {
private DirectionLabelEnum labelEnum; private DirectionLabelEnum labelEnum;
/**
* 接车发车模式
*/
private StationDirection.ReceiveAndDeliverModel model;
/** /**
* 接车灯状态 * 接车灯状态
*/ */
@ -63,6 +68,7 @@ public class StationDirectionStatus extends DeviceStatus {
super(stationDirection.getCode(), stationDirection.getDeviceType()); super(stationDirection.getCode(), stationDirection.getDeviceType());
this.stationCode = stationDirection.getStation().getCode(); this.stationCode = stationDirection.getStation().getCode();
this.labelEnum = stationDirection.getLabelEnum(); this.labelEnum = stationDirection.getLabelEnum();
this.model = stationDirection.getModel();
this.receiveAspect = stationDirection.getReceiveAspect(); this.receiveAspect = stationDirection.getReceiveAspect();
this.deliverAspect = stationDirection.getDeliverAspect(); this.deliverAspect = stationDirection.getDeliverAspect();
this.sectionAspect = stationDirection.getSectionAspect(); this.sectionAspect = stationDirection.getSectionAspect();
@ -78,13 +84,19 @@ public class StationDirectionStatus extends DeviceStatus {
StationDirection labelEnum = (StationDirection) device; StationDirection labelEnum = (StationDirection) device;
StationDirectionStatusVO status = (StationDirectionStatusVO) statusVO; StationDirectionStatusVO status = (StationDirectionStatusVO) statusVO;
boolean change = false; boolean change = false;
// 接车发车口
if (!Objects.equals(labelEnum.getModel(), model)) {
this.model = labelEnum.getModel();
status.setModel(labelEnum.getModel());
change = true;
}
// 接车 // 接车
if (!Objects.equals(labelEnum.getReceiveAspect(), receiveAspect)) { if (!Objects.equals(labelEnum.getReceiveAspect(), receiveAspect)) {
this.receiveAspect = labelEnum.getReceiveAspect(); this.receiveAspect = labelEnum.getReceiveAspect();
status.setReceiveAspect(receiveAspect); status.setReceiveAspect(receiveAspect);
change = true; change = true;
} }
// //
if (!Objects.equals(labelEnum.getDeliverAspect(), deliverAspect)) { if (!Objects.equals(labelEnum.getDeliverAspect(), deliverAspect)) {
this.deliverAspect = labelEnum.getDeliverAspect(); this.deliverAspect = labelEnum.getDeliverAspect();
status.setDeliverAspect(deliverAspect); status.setDeliverAspect(deliverAspect);

View File

@ -17,6 +17,8 @@ public class StationDirectionStatusVO extends DeviceStatusVO {
private DirectionLabelEnum labelEnum; private DirectionLabelEnum labelEnum;
private StationDirection.ReceiveAndDeliverModel model;
/** /**
* 接车灯状态 * 接车灯状态
*/ */