【增加辅助按钮、辅助灯操作】

【删除多余代码】
This commit is contained in:
weizhihong 2022-04-29 11:24:23 +08:00
parent bd59012519
commit 0ed54505bc
11 changed files with 178 additions and 394 deletions

View File

@ -1,19 +0,0 @@
package club.joylink.rtss.constants;
/**
* 指标灯枚举
*/
public enum IndicatorStatusEnum {
/** 无显示,灭灯 */
No,
/** 红 */
R,
/** 绿 */
G,
/** 黄 */
Y,
/** 白 */
W,
/** 白闪flashing */
WF
}

View File

@ -7,7 +7,7 @@ import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandler
import club.joylink.rtss.simulation.cbtc.ATS.service.assist.ButtonValidInterface; import club.joylink.rtss.simulation.cbtc.ATS.service.assist.ButtonValidInterface;
import club.joylink.rtss.simulation.cbtc.ATS.service.assist.StationDirectionService; import club.joylink.rtss.simulation.cbtc.ATS.service.assist.StationDirectionService;
import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.map.Button; import club.joylink.rtss.simulation.cbtc.data.map.StationDirection;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -35,7 +35,7 @@ public class StationDirectionOperateHandler {
validInterface = stationDirectionService.turnDirectionPressDownValid; validInterface = stationDirectionService.turnDirectionPressDownValid;
} }
stationDirectionService.changeButtonAspect(simulation, stationCode, labelEnum stationDirectionService.changeButtonAspect(simulation, stationCode, labelEnum
, Button.ButtonTypeEnum.CHANGE_DIRECTION, isPressDown, validInterface, null); , StationDirection.ButtonTypeEnum.CHANGE_DIRECTION, isPressDown, validInterface, null);
} }
/** /**
@ -49,8 +49,8 @@ public class StationDirectionOperateHandler {
@OperateHandlerMapping(type = Operation.Type.ASSIST_PRESS_MAIN_ASSIST) @OperateHandlerMapping(type = Operation.Type.ASSIST_PRESS_MAIN_ASSIST)
public void pressMainAssist(Simulation simulation, String stationCode, DirectionLabelEnum labelEnum public void pressMainAssist(Simulation simulation, String stationCode, DirectionLabelEnum labelEnum
, Integer pressDown) { , Integer pressDown) {
stationDirectionService.changeButtonAspect(simulation, stationCode, labelEnum, Button.ButtonTypeEnum.MAIN_ASSIST stationDirectionService.changeButtonAspect(simulation, stationCode, labelEnum, StationDirection.ButtonTypeEnum.MAIN_ASSIST
, (pressDown == 1), null, null); , (pressDown == 1), null, stationDirectionService.turnAssistThen);
} }
/** /**
@ -62,7 +62,7 @@ public class StationDirectionOperateHandler {
*/ */
@OperateHandlerMapping(type = Operation.Type.ASSIST_PRESS_RECEIVE_ASSIST) @OperateHandlerMapping(type = Operation.Type.ASSIST_PRESS_RECEIVE_ASSIST)
public void pressReceiveAssist(Simulation simulation, String stationCode, DirectionLabelEnum labelEnum) { public void pressReceiveAssist(Simulation simulation, String stationCode, DirectionLabelEnum labelEnum) {
stationDirectionService.changeButtonAspect(simulation, stationCode, labelEnum, Button.ButtonTypeEnum.RECEIVE_ASSIST stationDirectionService.changeButtonAspect(simulation, stationCode, labelEnum, StationDirection.ButtonTypeEnum.RECEIVE_ASSIST
, Boolean.TRUE, stationDirectionService.turnAssistValid, stationDirectionService.receiveAssistThen); , Boolean.TRUE, stationDirectionService.turnAssistValid, stationDirectionService.receiveAssistThen);
} }
@ -75,7 +75,7 @@ public class StationDirectionOperateHandler {
*/ */
@OperateHandlerMapping(type = Operation.Type.ASSIST_PRESS_DELIVER_ASSIST) @OperateHandlerMapping(type = Operation.Type.ASSIST_PRESS_DELIVER_ASSIST)
public void pressDeliverAssist(Simulation simulation, String stationCode, DirectionLabelEnum labelEnum) { public void pressDeliverAssist(Simulation simulation, String stationCode, DirectionLabelEnum labelEnum) {
stationDirectionService.changeButtonAspect(simulation, stationCode, labelEnum, Button.ButtonTypeEnum.DELIVER_ASSIST stationDirectionService.changeButtonAspect(simulation, stationCode, labelEnum, StationDirection.ButtonTypeEnum.DELIVER_ASSIST
, Boolean.TRUE, stationDirectionService.turnAssistValid, stationDirectionService.deliverAssistThen); , Boolean.TRUE, stationDirectionService.turnAssistValid, stationDirectionService.deliverAssistThen);
} }
} }

View File

@ -1,10 +1,12 @@
package club.joylink.rtss.simulation.cbtc.ATS.service.assist; package club.joylink.rtss.simulation.cbtc.ATS.service.assist;
import club.joylink.rtss.constants.DirectionLabelEnum; import club.joylink.rtss.constants.DirectionLabelEnum;
import club.joylink.rtss.constants.IndicatorStatusEnum;
import club.joylink.rtss.entity.DraftMapStationDirection; import club.joylink.rtss.entity.DraftMapStationDirection;
import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.map.*; 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.vr.VirtualRealityTrain; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
import club.joylink.rtss.simulation.cbtc.exception.SimulationException; import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
@ -33,7 +35,7 @@ public class StationDirectionService {
* @param validMethod 操作检验 * @param validMethod 操作检验
* @param buttonDoMethod 操作后触发动作 * @param buttonDoMethod 操作后触发动作
*/ */
public void changeButtonAspect(Simulation simulation, String stationCode, DirectionLabelEnum label, Button.ButtonTypeEnum type, public void changeButtonAspect(Simulation simulation, String stationCode, DirectionLabelEnum label, StationDirection.ButtonTypeEnum type,
boolean pressDown, ButtonValidInterface validMethod, ButtonThenInterface buttonDoMethod) { boolean pressDown, ButtonValidInterface validMethod, ButtonThenInterface buttonDoMethod) {
Station curStation = getStationByCode(simulation, stationCode); Station curStation = getStationByCode(simulation, stationCode);
StationDirection stationDirection = curStation.getStationDirectionMap().get(label); StationDirection stationDirection = curStation.getStationDirectionMap().get(label);
@ -62,14 +64,20 @@ public class StationDirectionService {
stationDirection.refreshAspectStatus(); stationDirection.refreshAspectStatus();
// 刷新区段占用状态 // 刷新区段占用状态
stationDirection.refreshSectionStatus(); stationDirection.refreshSectionStatus();
// 辅助灯状态
stationDirection.refreshAssistStatus();
} }
/** /**
* 改方按钮按下校验 * 改方按钮按下校验
*/ */
public ButtonValidInterface turnDirectionPressDownValid = (simulation, stationDirection) -> { public ButtonValidInterface turnDirectionPressDownValid = (simulation, stationDirection) -> {
// 如果处于发辅助状态说明存在异常情况正在人为处理直接跳过判断
if (stationDirection.isMainAssistStatus() && stationDirection.isDeliverAssistStatus()) {
return;
}
// 区间是否空闲 // 区间是否空闲
if (IndicatorStatusEnum.R.equals(stationDirection.getSectionAspect())) { if (StationDirection.IndicatorStatusEnum.O.equals(stationDirection.getSectionAspect())) {
throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:区段非空闲"); throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:区段非空闲");
} }
// 接车进路有锁闭有车进入 // 接车进路有锁闭有车进入
@ -111,10 +119,24 @@ public class StationDirectionService {
} }
}; };
/**
* 总辅助后续操作
*/
public ButtonThenInterface turnAssistThen = (simulation, stationDirection) -> {
// 总辅助弹起后接发辅助倒计时重置
if (!stationDirection.isMainAssistStatus()) {
stationDirection.setReceiveAssistStatus(false);
stationDirection.setDeliverAssistStatus(false);
stationDirection.getRemain().set(0);
}
};
/** /**
* 接辅助按钮后续操作 * 接辅助按钮后续操作
*/ */
public ButtonThenInterface receiveAssistThen = (simulation, stationDirection) -> { public ButtonThenInterface receiveAssistThen = (simulation, stationDirection) -> {
// 按下接辅助弹起发辅助
stationDirection.setDeliverAssistStatus(false);
// 重新设置倒计时时间 // 重新设置倒计时时间
stationDirection.getRemain().set(StationDirection.DEFAULT_RECEIVE_DELAY_TIME); stationDirection.getRemain().set(StationDirection.DEFAULT_RECEIVE_DELAY_TIME);
}; };
@ -123,6 +145,8 @@ public class StationDirectionService {
* 接辅助按钮后续操作 * 接辅助按钮后续操作
*/ */
public ButtonThenInterface deliverAssistThen = (simulation, stationDirection) -> { public ButtonThenInterface deliverAssistThen = (simulation, stationDirection) -> {
// 按下发辅助弹起发辅助
stationDirection.setReceiveAssistStatus(false);
// 重新设置倒计时时间 // 重新设置倒计时时间
stationDirection.getRemain().set(StationDirection.DEFAULT_DELIVER_DELAY_TIME); stationDirection.getRemain().set(StationDirection.DEFAULT_DELIVER_DELAY_TIME);
}; };

View File

@ -242,8 +242,17 @@ public class CTCLogicLoop {
* @param simulation 仿真信息 * @param simulation 仿真信息
*/ */
private void refreshStationDirection(Simulation simulation) { private void refreshStationDirection(Simulation simulation) {
simulation.getRepository().getStationList().forEach(station -> station.getStationDirectionMap().values().stream() simulation.getRepository().getStationList()
.forEach(station ->
station.getStationDirectionMap().values().stream()
.filter(stationDirection -> stationDirection.getRemain().intValue() != 0) .filter(stationDirection -> stationDirection.getRemain().intValue() != 0)
.forEach(stationDirection -> stationDirection.getRemain().decrementAndGet())); .forEach(stationDirection -> {
// 如果倒数结束弹起接发辅助按钮
if (stationDirection.getRemain().decrementAndGet() == 0) {
stationDirection.setDeliverAssistStatus(false);
stationDirection.setReceiveAssistStatus(false);
}
})
);
} }
} }

View File

@ -699,11 +699,6 @@ public class MapDeviceBuilder {
Map<String, Set<Section>> sectionArriveMap = MapDeviceBuilder.buildNormalStandTrackAdjoinSections(mapDataBuildResult.getDeviceMap()); Map<String, Set<Section>> sectionArriveMap = MapDeviceBuilder.buildNormalStandTrackAdjoinSections(mapDataBuildResult.getDeviceMap());
mapDataBuildResult.setSectionArriveNearMap(sectionArriveMap); mapDataBuildResult.setSectionArriveNearMap(sectionArriveMap);
} }
// 构建接区间辅助指示灯
MapDeviceBuilder.buildIndicatorList(elementMap, errMsgList, graphData.getIndicatorLightList());
// 构建辅助改方按钮
MapDeviceBuilder.buildButtonList(elementMap, errMsgList, graphData.getSignalButtonList());
} }
private static List<MapStationStandNewVO> buildStand(MapGraphDataNewVO graphData, Map<String, MapElement> elementMap, List<String> errMsgList) { private static List<MapStationStandNewVO> buildStand(MapGraphDataNewVO graphData, Map<String, MapElement> elementMap, List<String> errMsgList) {
@ -1505,69 +1500,4 @@ public class MapDeviceBuilder {
private static boolean isCross(String type) { private static boolean isCross(String type) {
return Objects.equals(type, BusinessConsts.Section.SectionType.Type05); return Objects.equals(type, BusinessConsts.Section.SectionType.Type05);
} }
/**
* 构建指示灯
*
* @param elementMap 资源map
* @param indicatorList 指示灯信息
*/
private static void buildIndicatorList(Map<String, MapElement> elementMap, List<String> errMsgList
, List<MapIndicatorLightVO> indicatorList) {
// 区间占用\辅助状态\总辅助\发车辅助\接车辅助\\发车箭头\复原\事故\闭塞
List<String> indicatorTypeList = Arrays.asList(
"SectionOccupied", "AssistStatus", "TotalAssist", "DepartAssist", "PickAssist",
"PickArrow", "DepartArrow", "Recovery", "Accident", "Occlusion"
);
indicatorList
.stream()
.filter(mapIndicatorLightVO -> indicatorTypeList.contains(mapIndicatorLightVO.getType()))
.forEach(mapSignalButtonVO -> {
if (elementMap.containsKey(mapSignalButtonVO.getCode())) {
errMsgList.add("已存在指示灯 " + mapSignalButtonVO.getStationCode());
} else {
Indicator indicator = new Indicator(mapSignalButtonVO.getCode(), mapSignalButtonVO.getName());
indicator.setLabel(mapSignalButtonVO.getLabelEnum());
indicator.setTypeStr(mapSignalButtonVO.getType());
Station station = (Station) elementMap.get(mapSignalButtonVO.getStationCode());
indicator.setStation(station);
station.getIndicatorList().add(indicator);
elementMap.put(mapSignalButtonVO.getCode(), indicator);
}
});
}
/**
* 构建按钮设备
*
* @param elementMap 设备Map
* @param errMsgList 错误日志
* @param signalButtonList 按钮列表
*/
private static void buildButtonList(Map<String, MapElement> elementMap, List<String> errMsgList
, List<MapSignalButtonVO> signalButtonList) {
// 改方
List<MapSignalButtonVO.Type> buttonTypeList = Arrays.asList(
MapSignalButtonVO.Type.ASSIST,
MapSignalButtonVO.Type.PICK_ASSIST,
MapSignalButtonVO.Type.DEPART_ASSIST,
MapSignalButtonVO.Type.CHANGE_DIRECTION
);
signalButtonList
.stream()
.filter(mapSignalButtonVO -> buttonTypeList.contains(mapSignalButtonVO.getType()))
.forEach(mapSignalButtonVO -> {
if (elementMap.containsKey(mapSignalButtonVO.getCode())) {
errMsgList.add("已存在按钮 " + mapSignalButtonVO.getStationCode());
} else {
Button button = new Button(mapSignalButtonVO.getCode(), mapSignalButtonVO.getName());
button.setLabel(mapSignalButtonVO.getLabelEnum());
Station station = (Station) elementMap.get(mapSignalButtonVO.getStationCode());
button.setStation(station);
button.setTypeStr(mapSignalButtonVO.getType());
station.getButtonList().add(button);
elementMap.put(mapSignalButtonVO.getCode(), button);
}
});
}
} }

View File

@ -1,84 +0,0 @@
package club.joylink.rtss.simulation.cbtc.data.map;
import club.joylink.rtss.constants.DirectionLabelEnum;
import club.joylink.rtss.vo.map.graph.MapSignalButtonVO;
import lombok.Getter;
import lombok.Setter;
/**
* 操作按钮
*/
@Setter
@Getter
public class Button extends MapNamedElement {
/**
* 车站
*/
private Station station;
/**
* 当前信号显示
*/
private boolean isPressDown;
/**
* 方向标签
*/
private DirectionLabelEnum label;
/**
* 按钮类型
*/
private ButtonTypeEnum type;
public Button(String code, String name) {
super(code, name, DeviceType.BUTTON);
isPressDown = Boolean.FALSE;
}
protected Button(String code, String name, DeviceType deviceType) {
super(code, name, deviceType);
}
@Override
public void reset() {
isPressDown = Boolean.FALSE;
}
public void setTypeStr(MapSignalButtonVO.Type typeStr) {
this.type = getType(typeStr);
}
/**
* 获取枚举信息
*
* @param type 类型
* @return 枚举
*/
public static ButtonTypeEnum getType(MapSignalButtonVO.Type type) {
switch (type) {
case ASSIST:
return ButtonTypeEnum.MAIN_ASSIST;
case PICK_ASSIST:
return ButtonTypeEnum.DELIVER_ASSIST;
case DEPART_ASSIST:
return ButtonTypeEnum.RECEIVE_ASSIST;
case CHANGE_DIRECTION:
return ButtonTypeEnum.CHANGE_DIRECTION;
default:
return ButtonTypeEnum.NO;
}
}
public enum ButtonTypeEnum {
// 总辅助
MAIN_ASSIST,
// 接辅助
RECEIVE_ASSIST,
// 发辅助
DELIVER_ASSIST,
// 改方
CHANGE_DIRECTION,
NO;
}
}

View File

@ -1,133 +0,0 @@
package club.joylink.rtss.simulation.cbtc.data.map;
import club.joylink.rtss.constants.DirectionLabelEnum;
import club.joylink.rtss.constants.IndicatorStatusEnum;
import lombok.Getter;
import lombok.Setter;
/**
* 指示灯设备
*/
@Setter
@Getter
public class Indicator extends MapNamedElement {
/**
* 车站
*/
private Station station;
/**
* 当前信号显示
*/
private IndicatorStatusEnum aspect;
/**
* 方向标签
*/
private DirectionLabelEnum label;
/**
* 是否开启
*/
private boolean on;
/**
* 灯类型
*/
private IndicatorTypeEnum type;
public Indicator(String code, String name) {
super(code, name, DeviceType.INDICATOR);
on = false;
}
@Override
public void reset() {
on = false;
aspect = getDefaultStatus();
}
/**
* 获取默认状态
*
* @return 默认状态
*/
public IndicatorStatusEnum getDefaultStatus() {
//
if (IndicatorTypeEnum.RECEIVE.equals(type)) {
return IndicatorStatusEnum.Y;
//
} else if (IndicatorTypeEnum.DELIVER.equals(type)) {
return IndicatorStatusEnum.G;
} else {
return IndicatorStatusEnum.No;
}
}
public void setTypeStr(String type) {
this.type = getType(type);
}
/**
* 枚举对应
*
* @param type 前端类型
* @return 枚举值
*/
public static IndicatorTypeEnum getType(String type) {
switch (type) {
//
case "receive":
case "PickArrow":
return IndicatorTypeEnum.RECEIVE;
//
case "deliver":
case "DepartArrow":
return IndicatorTypeEnum.DELIVER;
// 区间
case "section":
case "SectionOccupied":
return IndicatorTypeEnum.SECTION;
//辅助
case "assist":
case "AssistStatus":
case "TotalAssist":
case "DepartAssist":
case "PickAssist":
return IndicatorTypeEnum.ASSIST;
//复原
case "Recovery":
return IndicatorTypeEnum.RECOVERY;
//事故
case "Accident":
return IndicatorTypeEnum.ACCIDENT;
//闭塞
case "Occlusion":
return IndicatorTypeEnum.OCCLUSION;
default:
return IndicatorTypeEnum.NO;
}
}
public enum IndicatorTypeEnum {
//
RECEIVE,
//
DELIVER,
// 区间
SECTION,
// 辅助
ASSIST,
// 恢复
RECOVERY,
// 事故
ACCIDENT,
// 闭塞
OCCLUSION,
// 无类型
NO;
}
}

View File

@ -30,8 +30,6 @@ public class Station extends MayOutOfOrderDevice {
ldStandList = new ArrayList<>(); ldStandList = new ArrayList<>();
controlMode = ControlMode.Center; controlMode = ControlMode.Center;
stationDirectionMap = new HashMap<>(); stationDirectionMap = new HashMap<>();
buttonList = new ArrayList<>();
indicatorList = new ArrayList<>();
} }
/** /**
@ -189,16 +187,6 @@ public class Station extends MayOutOfOrderDevice {
*/ */
private Map<DirectionLabelEnum, StationDirection> stationDirectionMap; private Map<DirectionLabelEnum, StationDirection> stationDirectionMap;
/**
* 按钮列表
*/
private List<Button> buttonList;
/**
* 指示灯列表
*/
private List<Indicator> indicatorList;
@Override @Override
public void reset() { public void reset() {
super.reset(); super.reset();

View File

@ -2,7 +2,6 @@ package club.joylink.rtss.simulation.cbtc.data.map;
import club.joylink.rtss.constants.DirectionLabelEnum; import club.joylink.rtss.constants.DirectionLabelEnum;
import club.joylink.rtss.constants.IndicatorStatusEnum;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -53,7 +52,7 @@ public class StationDirection extends MapNamedElement {
/** /**
* 处于接发状态 * 处于接发状态
*/ */
private ReceiveAndDeliverModel model; private ReceiveAndDeliverModel runStatus;
/** /**
* 接车灯状态 * 接车灯状态
@ -114,7 +113,7 @@ public class StationDirection extends MapNamedElement {
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.model = this.getDefaultReceiveAndDeliver(); this.runStatus = this.getDefaultReceiveAndDeliver();
} }
public StationDirection(String code, String name) { public StationDirection(String code, String name) {
@ -128,33 +127,7 @@ public class StationDirection extends MapNamedElement {
@Override @Override
public void reset() { public void reset() {
this.setDefaultAttribute(); this.setDefaultAttribute();
this.model = this.getDefaultReceiveAndDeliver(); this.runStatus = this.getDefaultReceiveAndDeliver();
}
/**
* 设置默认属性
*/
private void setDefaultAttribute() {
this.changeDirectionStatus = false;
this.mainAssistStatus = false;
this.receiveAssistStatus = false;
this.deliverAssistStatus = false;
this.receiveAspect = IndicatorStatusEnum.No;
this.deliverAspect = IndicatorStatusEnum.No;
this.sectionAspect = IndicatorStatusEnum.No;
this.assistAspect = IndicatorStatusEnum.No;
}
/**
* 默认亮灯设置
*/
private ReceiveAndDeliverModel getDefaultReceiveAndDeliver() {
// XS方向为接车方向默认亮起
if (DirectionLabelEnum.X.equals(labelEnum) || DirectionLabelEnum.S.equals(labelEnum)) {
return ReceiveAndDeliverModel.RECEIVE;
} else { // 其他方向默认发车灯亮起
return ReceiveAndDeliverModel.DELIVER;
}
} }
/** /**
@ -167,21 +140,21 @@ public class StationDirection extends MapNamedElement {
// 发车进路锁闭 // 发车进路锁闭
boolean deliverRouteBlock = this.deliverRouteList.stream().anyMatch(Route::isLock); boolean deliverRouteBlock = this.deliverRouteList.stream().anyMatch(Route::isLock);
// 接发状态 // 接发状态
this.model = receiveRouteBlock ? ReceiveAndDeliverModel.RECEIVE : this.model; this.runStatus = receiveRouteBlock ? ReceiveAndDeliverModel.R : this.runStatus;
this.model = deliverRouteBlock ? ReceiveAndDeliverModel.DELIVER : this.model; this.runStatus = deliverRouteBlock ? ReceiveAndDeliverModel.D : this.runStatus;
// 接车进路锁闭亮红灯否则默认 // 接车进路锁闭亮红灯否则默认
IndicatorStatusEnum receiveAspect; IndicatorStatusEnum receiveAspect;
// 发车进路锁闭亮红灯否则默认 // 发车进路锁闭亮红灯否则默认
IndicatorStatusEnum deliverAspect; IndicatorStatusEnum deliverAspect;
// 进路区段占用判断点灯颜色 // 进路区段占用判断点灯颜色
if (ReceiveAndDeliverModel.RECEIVE.equals(this.model)) { if (ReceiveAndDeliverModel.R.equals(this.runStatus)) {
deliverAspect = IndicatorStatusEnum.No; deliverAspect = IndicatorStatusEnum.F;
// 接车进路锁闭 // 接车进路锁闭
receiveAspect = judgeSignalLock() ? IndicatorStatusEnum.R : IndicatorStatusEnum.Y; receiveAspect = judgeSignalLock() ? IndicatorStatusEnum.O : IndicatorStatusEnum.F;
} else if (ReceiveAndDeliverModel.DELIVER.equals(this.model)) { } else if (ReceiveAndDeliverModel.D.equals(this.runStatus)) {
receiveAspect = IndicatorStatusEnum.No; receiveAspect = IndicatorStatusEnum.F;
// 发车进路锁闭 // 发车进路锁闭
deliverAspect = judgeSignalLock() ? IndicatorStatusEnum.R : IndicatorStatusEnum.G; deliverAspect = judgeSignalLock() ? IndicatorStatusEnum.O : IndicatorStatusEnum.F;
} else { } else {
receiveAspect = this.receiveAspect; receiveAspect = this.receiveAspect;
deliverAspect = this.receiveAspect; deliverAspect = this.receiveAspect;
@ -201,7 +174,28 @@ public class StationDirection extends MapNamedElement {
// 是否被占用,TRUE 占用,FALSE 未占用 // 是否被占用,TRUE 占用,FALSE 未占用
boolean isOccupied = this.sectionList.stream().anyMatch(Section::isOccupied); boolean isOccupied = this.sectionList.stream().anyMatch(Section::isOccupied);
// 占用为红色 // 占用为红色
this.sectionAspect = isOccupied ? IndicatorStatusEnum.R : IndicatorStatusEnum.No; this.sectionAspect = isOccupied ? IndicatorStatusEnum.O : IndicatorStatusEnum.F;
}
/**
* 辅助灯状态
*/
public void refreshAssistStatus() {
// 判断改方动作是否完成
if (judgeChangeDirectionReady()) {
// 倒计时归零
this.remain.set(0);
// 发车辅助按钮弹起
this.deliverAssistStatus = false;
// 接车辅助按钮弹起
this.receiveAssistStatus = false;
}
// 如果总辅助接发任意一方按下为白灯
if (this.mainAssistStatus && (this.deliverAssistStatus || this.receiveAssistStatus)) {
this.assistAspect = IndicatorStatusEnum.O;
} else {
this.assistAspect = IndicatorStatusEnum.F;
}
} }
/** /**
@ -210,7 +204,7 @@ public class StationDirection extends MapNamedElement {
* @param type 按钮类型 * @param type 按钮类型
* @param pressDown 按钮按下抬起 * @param pressDown 按钮按下抬起
*/ */
public void modifyButtonStatus(Button.ButtonTypeEnum type, boolean pressDown) { public void modifyButtonStatus(ButtonTypeEnum type, boolean pressDown) {
switch (type) { switch (type) {
case CHANGE_DIRECTION: case CHANGE_DIRECTION:
this.changeDirectionStatus = pressDown; this.changeDirectionStatus = pressDown;
@ -227,6 +221,32 @@ public class StationDirection extends MapNamedElement {
} }
} }
/**
* 设置默认属性
*/
private void setDefaultAttribute() {
this.changeDirectionStatus = false;
this.mainAssistStatus = false;
this.receiveAssistStatus = false;
this.deliverAssistStatus = false;
this.receiveAspect = IndicatorStatusEnum.F;
this.deliverAspect = IndicatorStatusEnum.F;
this.sectionAspect = IndicatorStatusEnum.F;
this.assistAspect = IndicatorStatusEnum.F;
}
/**
* 默认亮灯设置
*/
private ReceiveAndDeliverModel getDefaultReceiveAndDeliver() {
// XS方向为接车方向默认亮起
if (DirectionLabelEnum.X.equals(labelEnum) || DirectionLabelEnum.S.equals(labelEnum)) {
return ReceiveAndDeliverModel.R;
} else { // 其他方向默认发车灯亮起
return ReceiveAndDeliverModel.D;
}
}
/** /**
* 如果信号灯所在区段任意一边被锁闭 * 如果信号灯所在区段任意一边被锁闭
* *
@ -244,10 +264,48 @@ public class StationDirection extends MapNamedElement {
return isLock; return isLock;
} }
/**
* 判断改方是否完成
*/
private boolean judgeChangeDirectionReady() {
boolean isReady = false;
// 根据接发状态获取进路信息
ReceiveAndDeliverModel defaultModel = getDefaultReceiveAndDeliver();
// 接方向在判断发车进路办理后就会取消辅助状态
if (ReceiveAndDeliverModel.R.equals(defaultModel)) {
// 改方按钮是否按下,代表正在改方
// 进路已锁闭,发车已就绪
isReady = this.changeDirectionStatus && this.deliverRouteList.stream().anyMatch(Route::isLock);
} else {
// 发车进路需要判断接车进路是否办理
isReady = this.receiveRouteList.stream().anyMatch(Route::isLock);
}
return isReady;
}
public enum ReceiveAndDeliverModel { public enum ReceiveAndDeliverModel {
// //
RECEIVE, R,
// //
DELIVER, D,
}
public enum IndicatorStatusEnum {
// 占用
O,
// 空闲
F
}
public enum ButtonTypeEnum {
// 总辅助
MAIN_ASSIST,
// 接辅助
RECEIVE_ASSIST,
// 发辅助
DELIVER_ASSIST,
// 改方
CHANGE_DIRECTION,
NO;
} }
} }

View File

@ -1,7 +1,6 @@
package club.joylink.rtss.simulation.cbtc.data.status; package club.joylink.rtss.simulation.cbtc.data.status;
import club.joylink.rtss.constants.DirectionLabelEnum; import club.joylink.rtss.constants.DirectionLabelEnum;
import club.joylink.rtss.constants.IndicatorStatusEnum;
import club.joylink.rtss.simulation.cbtc.data.map.MapElement; import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
import club.joylink.rtss.simulation.cbtc.data.map.StationDirection; import club.joylink.rtss.simulation.cbtc.data.map.StationDirection;
import club.joylink.rtss.simulation.cbtc.data.vo.DeviceStatusVO; import club.joylink.rtss.simulation.cbtc.data.vo.DeviceStatusVO;
@ -9,6 +8,7 @@ import club.joylink.rtss.simulation.cbtc.data.vo.StationDirectionStatusVO;
import lombok.Getter; import lombok.Getter;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
/** /**
* 车站状态 * 车站状态
@ -22,27 +22,27 @@ public class StationDirectionStatus extends DeviceStatus {
/** /**
* 接车发车模式 * 接车发车模式
*/ */
private StationDirection.ReceiveAndDeliverModel model; private StationDirection.ReceiveAndDeliverModel runStatus;
/** /**
* 接车灯状态 * 接车灯状态
*/ */
private IndicatorStatusEnum receiveAspect; private StationDirection.IndicatorStatusEnum receiveAspect;
/** /**
* 发车灯状态 * 发车灯状态
*/ */
private IndicatorStatusEnum deliverAspect; private StationDirection.IndicatorStatusEnum deliverAspect;
/** /**
* 区间灯状态 * 区间灯状态
*/ */
private IndicatorStatusEnum sectionAspect; private StationDirection.IndicatorStatusEnum sectionAspect;
/** /**
* 辅助灯状态 * 辅助灯状态
*/ */
private IndicatorStatusEnum assistAspect; private StationDirection.IndicatorStatusEnum assistAspect;
/** /**
* 改方按钮状态 * 改方按钮状态
@ -64,11 +64,16 @@ public class StationDirectionStatus extends DeviceStatus {
*/ */
private boolean deliverAssistStatus; private boolean deliverAssistStatus;
/**
* 倒计时
*/
private AtomicInteger remain;
public StationDirectionStatus(StationDirection stationDirection) { public StationDirectionStatus(StationDirection stationDirection) {
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.runStatus = stationDirection.getRunStatus();
this.receiveAspect = stationDirection.getReceiveAspect(); this.receiveAspect = stationDirection.getReceiveAspect();
this.deliverAspect = stationDirection.getDeliverAspect(); this.deliverAspect = stationDirection.getDeliverAspect();
this.sectionAspect = stationDirection.getSectionAspect(); this.sectionAspect = stationDirection.getSectionAspect();
@ -77,6 +82,7 @@ public class StationDirectionStatus extends DeviceStatus {
this.mainAssistStatus = stationDirection.isMainAssistStatus(); this.mainAssistStatus = stationDirection.isMainAssistStatus();
this.receiveAssistStatus = stationDirection.isReceiveAssistStatus(); this.receiveAssistStatus = stationDirection.isReceiveAssistStatus();
this.deliverAssistStatus = stationDirection.isDeliverAssistStatus(); this.deliverAssistStatus = stationDirection.isDeliverAssistStatus();
this.remain = new AtomicInteger(stationDirection.getRemain().intValue());
} }
@Override @Override
@ -85,9 +91,9 @@ public class StationDirectionStatus extends DeviceStatus {
StationDirectionStatusVO status = (StationDirectionStatusVO) statusVO; StationDirectionStatusVO status = (StationDirectionStatusVO) statusVO;
boolean change = false; boolean change = false;
// 接车发车口 // 接车发车口
if (!Objects.equals(labelEnum.getModel(), model)) { if (!Objects.equals(labelEnum.getRunStatus(), runStatus)) {
this.model = labelEnum.getModel(); this.runStatus = labelEnum.getRunStatus();
status.setModel(labelEnum.getModel()); status.setRunStatus(labelEnum.getRunStatus());
change = true; change = true;
} }
// 接车 // 接车
@ -126,23 +132,23 @@ public class StationDirectionStatus extends DeviceStatus {
status.setMainAssistStatus(mainAssistStatus); status.setMainAssistStatus(mainAssistStatus);
change = true; change = true;
} }
// 接辅助按钮 // 接辅助按钮
if (!Objects.equals(labelEnum.isReceiveAssistStatus(), receiveAssistStatus)) { if (!Objects.equals(labelEnum.isReceiveAssistStatus(), receiveAssistStatus)) {
this.receiveAssistStatus = labelEnum.isReceiveAssistStatus(); this.receiveAssistStatus = labelEnum.isReceiveAssistStatus();
status.setReceiveAssistStatus(receiveAssistStatus); status.setReceiveAssistStatus(receiveAssistStatus);
change = true; change = true;
} }
// 发辅助按钮 // 发辅助按钮
if (!Objects.equals(labelEnum.isDeliverAssistStatus(), deliverAssistStatus)) { if (!Objects.equals(labelEnum.isDeliverAssistStatus(), deliverAssistStatus)) {
this.deliverAssistStatus = labelEnum.isDeliverAssistStatus(); this.deliverAssistStatus = labelEnum.isDeliverAssistStatus();
status.setDeliverAssistStatus(deliverAssistStatus); status.setDeliverAssistStatus(deliverAssistStatus);
change = true; change = true;
} }
if (change) { // 倒计时判断
status.setStationCode(labelEnum.getStation().getCode()); if (!Objects.equals(labelEnum.getRemain().intValue(), remain.intValue())) {
status.setLabelEnum(labelEnum.getLabelEnum()); this.remain.set(labelEnum.getRemain().intValue());
status.setRemain(remain.intValue());
change = true;
} }
return change; return change;
} }
@ -150,6 +156,7 @@ public class StationDirectionStatus extends DeviceStatus {
@Override @Override
public DeviceStatusVO convert2VO(MapElement device) { public DeviceStatusVO convert2VO(MapElement device) {
StationDirectionStatusVO statusVO = new StationDirectionStatusVO((StationDirection) device); StationDirectionStatusVO statusVO = new StationDirectionStatusVO((StationDirection) device);
statusVO.setRunStatus(runStatus);
statusVO.setStationCode(stationCode); statusVO.setStationCode(stationCode);
statusVO.setLabelEnum(labelEnum); statusVO.setLabelEnum(labelEnum);
statusVO.setReceiveAspect(receiveAspect); statusVO.setReceiveAspect(receiveAspect);

View File

@ -1,7 +1,6 @@
package club.joylink.rtss.simulation.cbtc.data.vo; package club.joylink.rtss.simulation.cbtc.data.vo;
import club.joylink.rtss.constants.DirectionLabelEnum; import club.joylink.rtss.constants.DirectionLabelEnum;
import club.joylink.rtss.constants.IndicatorStatusEnum;
import club.joylink.rtss.simulation.cbtc.data.map.StationDirection; import club.joylink.rtss.simulation.cbtc.data.map.StationDirection;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@ -17,27 +16,27 @@ public class StationDirectionStatusVO extends DeviceStatusVO {
private DirectionLabelEnum labelEnum; private DirectionLabelEnum labelEnum;
private StationDirection.ReceiveAndDeliverModel model; private StationDirection.ReceiveAndDeliverModel runStatus;
/** /**
* 接车灯状态 * 接车灯状态
*/ */
private IndicatorStatusEnum receiveAspect; private StationDirection.IndicatorStatusEnum receiveAspect;
/** /**
* 发车灯状态 * 发车灯状态
*/ */
private IndicatorStatusEnum deliverAspect; private StationDirection.IndicatorStatusEnum deliverAspect;
/** /**
* 区间灯状态 * 区间灯状态
*/ */
private IndicatorStatusEnum sectionAspect; private StationDirection.IndicatorStatusEnum sectionAspect;
/** /**
* 辅助灯状态 * 辅助灯状态
*/ */
private IndicatorStatusEnum assistAspect; private StationDirection.IndicatorStatusEnum assistAspect;
/** /**
* 改方按钮状态 * 改方按钮状态
@ -59,6 +58,11 @@ public class StationDirectionStatusVO extends DeviceStatusVO {
*/ */
private Boolean deliverAssistStatus; private Boolean deliverAssistStatus;
/**
* 倒计时
*/
private Integer remain;
public StationDirectionStatusVO(StationDirection stationDirection) { public StationDirectionStatusVO(StationDirection stationDirection) {
super(stationDirection.getCode(), stationDirection.getDeviceType()); super(stationDirection.getCode(), stationDirection.getDeviceType());
} }