【指示灯逻辑】

Signed-off-by: weizhihong <weizhihong@joylink.club>
This commit is contained in:
weizhihong 2022-04-24 13:45:08 +08:00
parent 25413f0f58
commit 3d59d32db7
2 changed files with 47 additions and 42 deletions

View File

@ -9,7 +9,6 @@ import club.joylink.rtss.simulation.cbtc.CI.device.CiRouteService;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.map.Button;
import club.joylink.rtss.simulation.cbtc.data.map.Indicator;
import club.joylink.rtss.simulation.cbtc.data.map.Route;
import club.joylink.rtss.simulation.cbtc.data.map.Station;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
@ -100,48 +99,25 @@ public class AssistService {
Indicator receiveIndicator = getStationIndicatorByType(curStation, labelEnum, IndicatorTypeEnum.RECEIVE);
// 获取发车指示灯
Indicator deliverIndicator = getStationIndicatorByType(curStation, labelEnum, IndicatorTypeEnum.DELIVER);
if (receiveIndicator == null || deliverIndicator == null) {
return;
}
// 接车进路
Route receiveRoute = receiveIndicator.getRoute();
// 发车进路
Route deliverRoute = deliverIndicator.getRoute();
IndicatorStatusEnum receiveStatus;
IndicatorStatusEnum deliverStatus;
// XS 优先判断发车灯
if (DirectionLabelEnum.X.equals(labelEnum) || DirectionLabelEnum.S.equals(labelEnum)) {
// 当发车进路办理时必须亮起发车灯
if (deliverRoute.isLock()) {
deliverIndicator.setOn(true);
receiveIndicator.setOn(false);
deliverStatus = IndicatorStatusEnum.R;
receiveStatus = IndicatorStatusEnum.No;
// 如果都没有亮
if (deliverIndicator != null && receiveIndicator != null && !deliverIndicator.isOn() && !receiveIndicator.isOn()) {
if (DirectionLabelEnum.X.equals(labelEnum) || DirectionLabelEnum.S.equals(labelEnum)) {
receiveIndicator.setOn(true);
} else {
// 发车灯自身亮并且发车进路并没锁闭接车进路也没办理说明刚完成改方操作
if (deliverIndicator.isOn() && !deliverRoute.isLock() && !receiveRoute.isLock()) {
deliverIndicator.setOn(true);
receiveIndicator.setOn(false);
deliverStatus = IndicatorStatusEnum.G;
receiveStatus = IndicatorStatusEnum.No;
} else { // 其他操作均已接车灯为主
deliverIndicator.setOn(false);
receiveIndicator.setOn(true);
deliverStatus = IndicatorStatusEnum.No;
receiveStatus = IndicatorStatusEnum.Y;
}
deliverIndicator.setOn(true);
}
} else {
// 如果接车灯不亮就发车灯亮
receiveIndicator.setOn(receiveRoute.isLock());
deliverIndicator.setOn(!receiveRoute.isLock());
deliverStatus = deliverIndicator.isOn() ? IndicatorStatusEnum.G : IndicatorStatusEnum.No;
receiveStatus = receiveIndicator.isOn() ? IndicatorStatusEnum.Y : IndicatorStatusEnum.No;
}
receiveIndicator.setAspect(receiveStatus);
deliverIndicator.setAspect(deliverStatus);
IndicatorStatusEnum receiveStatus = getRDIndicatorStatusEnum(receiveIndicator, deliverIndicator);
IndicatorStatusEnum deliverStatus = getRDIndicatorStatusEnum(deliverIndicator, receiveIndicator);
if (receiveIndicator != null) {
receiveIndicator.setAspect(receiveStatus);
}
if (deliverIndicator != null) {
deliverIndicator.setAspect(deliverStatus);
}
}
/**
* 改方按钮按下校验
*/
@ -162,6 +138,11 @@ public class AssistService {
if (IndicatorStatusEnum.R.equals(sectionIndicator.getAspect())) {
throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:区段非空闲");
}
// 判断接车灯进路是否办理
Indicator receiveIndicator = getStationIndicatorByType(button.getStation(), button.getLabel(), IndicatorTypeEnum.RECEIVE);
if (receiveIndicator.getRoute().isLock()) {
throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:进路冲突");
}
// 获取靠停列车
VirtualRealityTrain train = getSandStopTrain(simulation, button.getStand().getSection().getCode());
if (train == null || !train.isStop()) {
@ -283,4 +264,28 @@ public class AssistService {
}
return train;
}
/**
* 获取接发车指示灯状态
*
* @param indicator 指示灯
* @param mutexIndicator 同组指示灯-
* @return 点灯状态
*/
private IndicatorStatusEnum getRDIndicatorStatusEnum(Indicator indicator, Indicator mutexIndicator) {
if (indicator == null) {
return IndicatorStatusEnum.No;
}
boolean isLock = indicator.getRoute() != null && indicator.getRoute().isLock();
if (isLock) {
indicator.setOn(true);
if (mutexIndicator != null) {
mutexIndicator.setOn(false);
}
}
IndicatorStatusEnum statusEnum = indicator.isOn() ?
(isLock ? IndicatorStatusEnum.R : indicator.getDefaultStatus())
: IndicatorStatusEnum.No;
return statusEnum;
}
}

View File

@ -57,7 +57,7 @@ public class Indicator extends MapNamedElement {
public Indicator(String code, String name) {
super(code, name, DeviceType.INDICATOR);
on = Boolean.FALSE;
on = false;
}
protected Indicator(String code, String name, DeviceType deviceType) {
@ -66,7 +66,7 @@ public class Indicator extends MapNamedElement {
@Override
public void reset() {
on = Boolean.FALSE;
on = false;
aspect = getDefaultStatus();
}
@ -77,10 +77,10 @@ public class Indicator extends MapNamedElement {
*/
public IndicatorStatusEnum getDefaultStatus() {
//
if ((DirectionLabelEnum.S.equals(label) || DirectionLabelEnum.X.equals(label)) && IndicatorTypeEnum.RECEIVE.equals(type)) {
if (IndicatorTypeEnum.RECEIVE.equals(type)) {
return IndicatorStatusEnum.Y;
//
} else if ((DirectionLabelEnum.XF.equals(label) || DirectionLabelEnum.SF.equals(label)) && IndicatorTypeEnum.DELIVER.equals(type)) {
} else if (IndicatorTypeEnum.DELIVER.equals(type)) {
return IndicatorStatusEnum.G;
} else {
return IndicatorStatusEnum.No;