【去除多余操作指令,多余代码】

【修改点灯操作与按钮亮灯操作一致】

Signed-off-by: weizhihong <weizhihong@joylink.club>
This commit is contained in:
weizhihong 2022-04-22 17:24:19 +08:00
parent 83b92094c5
commit b5bd2b4035
5 changed files with 31 additions and 132 deletions

View File

@ -839,16 +839,6 @@ public class Operation {
* 按下改方按钮 * 按下改方按钮
*/ */
ASSIST_PRESS_DOWN_TURN_DIRECTION, ASSIST_PRESS_DOWN_TURN_DIRECTION,
/**
* 抬起改方按钮
*/
ASSIST_PRESS_UP_TURN_DIRECTION,
/**
* 邻站办理发车进路
*/
ASSIST_DELIVER_ROUTE_HANDLE
} }
/** /**

View File

@ -31,32 +31,4 @@ public class AssistOperateHandler {
, assistService.turnDirectionPressDownValid , assistService.turnDirectionPressDownValid
, assistService.turnDirectionPressDownDo); , assistService.turnDirectionPressDownDo);
} }
/**
* 改方按钮抬起操作
*
* @param simulation 仿真数据
* @param stationCode 车站编码
* @param label 按钮类型
*/
@OperateHandlerMapping(type = Operation.Type.ASSIST_PRESS_UP_TURN_DIRECTION)
public void pressUpTurnDirection(Simulation simulation, String stationCode, DirectionLabelEnum labelEnum) {
assistService.changeButtonAspect(simulation,
stationCode, labelEnum, ButtonTypeEnum.CHANGE_DIRECTION, Boolean.FALSE
, null
, assistService.turnDirectionPressUpDo);
}
/**
* 邻站办理发车进路
*
* @param simulation 仿真数据
* @param stationCode 车站编码
* @param routeCode 进路编码
*/
@OperateHandlerMapping(type = Operation.Type.ASSIST_DELIVER_ROUTE_HANDLE)
public void deliverRouteHandle(Simulation simulation, String stationCode, String routeCode) {
assistService.deliverRouteHandle(simulation, stationCode, routeCode);
}
} }

View File

@ -98,76 +98,40 @@ public class AssistService {
if (receiveIndicator == null || deliverIndicator == null) { if (receiveIndicator == null || deliverIndicator == null) {
return; return;
} }
// 接车进路
Route receiveRoute = receiveIndicator.getRoute();
// 发车进路
Route deliverRoute = deliverIndicator.getRoute();
IndicatorStatusEnum receiveStatus; IndicatorStatusEnum receiveStatus;
IndicatorStatusEnum deliverStatus; IndicatorStatusEnum deliverStatus;
// 如果处于改方状态,接车灯熄灭发车灯点亮为绿色 // 两个进路都锁闭存在问题
if (receiveIndicator.isChangeDirection()) { if (receiveRoute.isLock() && deliverRoute.isLock()) {
receiveStatus = IndicatorStatusEnum.R; receiveStatus = IndicatorStatusEnum.Y;
deliverStatus = IndicatorStatusEnum.G;
} else if (receiveRoute.isLock() && !deliverRoute.isLock()) { // 亮接灭发
receiveStatus = IndicatorStatusEnum.Y;
deliverStatus = IndicatorStatusEnum.No; deliverStatus = IndicatorStatusEnum.No;
} else { } else if (!receiveRoute.isLock() && deliverRoute.isLock()) { // 亮发灭接
// 接车进路 receiveStatus = IndicatorStatusEnum.No;
Route receiveRoute = receiveIndicator.getRoute(); deliverStatus = IndicatorStatusEnum.G;
// 发车进路 } else { // 复位
Route deliverRoute = deliverIndicator.getRoute(); receiveStatus = receiveIndicator.getDefaultStatus();
// 两个进路都锁闭存在问题 deliverStatus = deliverIndicator.getDefaultStatus();
if (receiveRoute.isLock() && deliverRoute.isLock()) { }
receiveStatus = IndicatorStatusEnum.Y; // 判断状态是否变化
deliverStatus = IndicatorStatusEnum.G; if (deliverStatus.equals(deliverIndicator.getAspect()) || receiveStatus.equals(receiveIndicator.getAspect())) {
} else if (receiveRoute.isLock() && !deliverRoute.isLock()) { // 亮接灭发 // 变化接车灯亮发车灯灭
receiveStatus = IndicatorStatusEnum.Y; if (IndicatorStatusEnum.G.equals(deliverStatus)) {
deliverStatus = IndicatorStatusEnum.No; curStation.getButtonsList()
} else if (!receiveRoute.isLock() && deliverRoute.isLock()) { // 亮发灭接 .stream()
receiveStatus = IndicatorStatusEnum.No; .filter(button -> labelEnum.equals(button.getLabel()) && ButtonTypeEnum.CHANGE_DIRECTION.equals(button.getType()))
deliverStatus = IndicatorStatusEnum.G; .forEach(button -> button.setPressDown(IndicatorStatusEnum.G.equals(deliverStatus)));
} else { // 复位
receiveStatus = receiveIndicator.getDefaultStatus();
deliverStatus = deliverIndicator.getDefaultStatus();
} }
} }
receiveIndicator.setAspect(receiveStatus); receiveIndicator.setAspect(receiveStatus);
deliverIndicator.setAspect(deliverStatus); deliverIndicator.setAspect(deliverStatus);
} }
/**
* 邻站办理发车进路
*
* @param simulation 仿真实体
* @param stationCode 车站编码
* @param routeCode 进路编码
*/
public void deliverRouteHandle(Simulation simulation, String stationCode, String routeCode) {
Station curStation = getStationByCode(simulation, stationCode);
Route route = simulation.getRepository().getByCode(routeCode, Route.class);
List<Station> stationList = simulation.getRepository().getStationList();
// 获取邻站索引
int nextIndex = stationList.indexOf(curStation) + (route.isRight() ? -1 : 1);
if (nextIndex >= 0 && nextIndex < stationList.size()) {
Station nextStation = stationList.get(nextIndex);
// 修改指示灯改方状态
if (!CollectionUtils.isEmpty(nextStation.getIndicatorList())) {
nextStation.getIndicatorList()
.stream()
.filter(indicator -> indicator.getRoute() != null && routeCode.equals(indicator.getRoute().getCode()))
.forEach(indicator -> {
log.info(indicator.getCode() + indicator.getType());
indicator.setChangeDirection(Boolean.FALSE);
});
}
// 抬起改方按钮
if (!CollectionUtils.isEmpty(nextStation.getButtonsList())) {
nextStation.getButtonsList()
.stream()
.filter(button -> button.getStand().isRight() == route.isRight()
&& ButtonTypeEnum.CHANGE_DIRECTION.equals(button.getType()))
.forEach(button -> {
log.info(button.getCode());
button.setPressDown(Boolean.FALSE);
});
}
}
routeService.setRoute(simulation, route);
}
/** /**
* 改方按钮按下校验 * 改方按钮按下校验
*/ */
@ -215,30 +179,12 @@ public class AssistService {
} }
// 列车换端 // 列车换端
atpService.turnDirectionImmediately(train); atpService.turnDirectionImmediately(train);
// 获取接车指示灯
Indicator receiveIndicator = getStationIndicatorByType(button.getStation(), button.getLabel(), IndicatorTypeEnum.RECEIVE);
receiveIndicator.setChangeDirection(Boolean.TRUE);
// 获取发车指示灯 // 获取发车指示灯
Indicator deliverIndicator = getStationIndicatorByType(button.getStation(), button.getLabel(), IndicatorTypeEnum.DELIVER); Indicator deliverIndicator = getStationIndicatorByType(button.getStation(), button.getLabel(), IndicatorTypeEnum.DELIVER);
// 办进路 // 办进路
routeService.setRoute(simulation, deliverIndicator.getRoute()); routeService.setRoute(simulation, deliverIndicator.getRoute());
}; };
/**
* 抬起改方后续动作按钮
*/
public ButtonThenInterface turnDirectionPressUpDo = (simulation, button) -> {
if (button == null) {
throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:按钮不存在");
}
// 获取接车指示灯
Indicator receiveIndicator = getStationIndicatorByType(button.getStation(), button.getLabel(), IndicatorTypeEnum.RECEIVE);
if (receiveIndicator == null) {
throw new SimulationException(SimulationExceptionType.Operation_Cannot_handed, "操作异常:指示灯不存在");
}
receiveIndicator.setChangeDirection(Boolean.FALSE);
};
/** /**
* 获取当前车站实体 * 获取当前车站实体
* *
@ -315,9 +261,9 @@ public class AssistService {
* @return 列车数据 * @return 列车数据
*/ */
private VirtualRealityTrain getSandStopTrain(Simulation simulation, String sectionCode) { private VirtualRealityTrain getSandStopTrain(Simulation simulation, String sectionCode) {
Optional<VirtualRealityTrain> trainOptional = simulation.getRepository().getAllVrTrain() Optional<VirtualRealityTrain> trainOptional = simulation.getRepository().getOnlineTrainList()
.stream() .stream()
.filter(trainInfo -> sectionCode.equals(trainInfo.getHeadPosition().getSection().getCode())) .filter(trainInfo -> trainInfo != null && sectionCode.equals(trainInfo.getHeadPosition().getSection().getCode()))
.findAny(); .findAny();
VirtualRealityTrain train; VirtualRealityTrain train;
if (trainOptional.isPresent()) { if (trainOptional.isPresent()) {

View File

@ -4,13 +4,11 @@ import club.joylink.rtss.simulation.cbtc.data.map.Button;
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.vo.ButtonStatusVO; import club.joylink.rtss.simulation.cbtc.data.vo.ButtonStatusVO;
import club.joylink.rtss.simulation.cbtc.data.vo.DeviceStatusVO; import club.joylink.rtss.simulation.cbtc.data.vo.DeviceStatusVO;
import club.joylink.rtss.util.jsonSerialize.Boolean2NumDeserializer;
import club.joylink.rtss.util.jsonSerialize.Boolean2NumSerializer;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.util.Objects;
/** /**
* 按钮设备状态信息 * 按钮设备状态信息
*/ */
@ -18,8 +16,6 @@ import lombok.Setter;
@Getter @Getter
public class ButtonStatus extends DeviceStatus { public class ButtonStatus extends DeviceStatus {
@JsonSerialize(using = Boolean2NumSerializer.class)
@JsonDeserialize(using = Boolean2NumDeserializer.class)
private boolean pressDown; private boolean pressDown;
public ButtonStatus(Button button) { public ButtonStatus(Button button) {
@ -32,10 +28,10 @@ public class ButtonStatus extends DeviceStatus {
Button button = (Button) device; Button button = (Button) device;
ButtonStatusVO status = (ButtonStatusVO) statusVO; ButtonStatusVO status = (ButtonStatusVO) statusVO;
boolean change = Boolean.FALSE; boolean change = Boolean.FALSE;
if (pressDown != button.isPressDown()) { if (!Objects.equals(pressDown, button.isPressDown())) {
change = Boolean.TRUE; change = Boolean.TRUE;
pressDown = button.isPressDown(); pressDown = button.isPressDown();
status.setPressDown(button.isPressDown()); status.setPressDown(pressDown);
} }
return change; return change;
} }

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.simulation.cbtc.data.map.Button; import club.joylink.rtss.simulation.cbtc.data.map.Button;
import club.joylink.rtss.simulation.cbtc.data.status.ButtonStatus;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@ -14,10 +13,6 @@ public class ButtonStatusVO extends DeviceStatusVO {
private Boolean pressDown; private Boolean pressDown;
public ButtonStatusVO(ButtonStatus buttonStatus) {
super(buttonStatus.getCode(), buttonStatus.getDeviceType());
}
public ButtonStatusVO(Button button) { public ButtonStatusVO(Button button) {
super(button.getCode(), button.getDeviceType()); super(button.getCode(), button.getDeviceType());
} }