【去除多余操作指令,多余代码】
【修改点灯操作与按钮亮灯操作一致】 Signed-off-by: weizhihong <weizhihong@joylink.club>
This commit is contained in:
parent
83b92094c5
commit
b5bd2b4035
@ -839,16 +839,6 @@ public class Operation {
|
||||
* 按下改方按钮
|
||||
*/
|
||||
ASSIST_PRESS_DOWN_TURN_DIRECTION,
|
||||
|
||||
/**
|
||||
* 抬起改方按钮
|
||||
*/
|
||||
ASSIST_PRESS_UP_TURN_DIRECTION,
|
||||
|
||||
/**
|
||||
* 邻站办理发车进路
|
||||
*/
|
||||
ASSIST_DELIVER_ROUTE_HANDLE
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31,32 +31,4 @@ public class AssistOperateHandler {
|
||||
, assistService.turnDirectionPressDownValid
|
||||
, 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);
|
||||
}
|
||||
}
|
||||
|
@ -98,17 +98,12 @@ public class AssistService {
|
||||
if (receiveIndicator == null || deliverIndicator == null) {
|
||||
return;
|
||||
}
|
||||
IndicatorStatusEnum receiveStatus;
|
||||
IndicatorStatusEnum deliverStatus;
|
||||
// 如果处于改方状态,接车灯熄灭、发车灯点亮为绿色
|
||||
if (receiveIndicator.isChangeDirection()) {
|
||||
receiveStatus = IndicatorStatusEnum.R;
|
||||
deliverStatus = IndicatorStatusEnum.No;
|
||||
} else {
|
||||
// 接车进路
|
||||
Route receiveRoute = receiveIndicator.getRoute();
|
||||
// 发车进路
|
||||
Route deliverRoute = deliverIndicator.getRoute();
|
||||
IndicatorStatusEnum receiveStatus;
|
||||
IndicatorStatusEnum deliverStatus;
|
||||
// 两个进路都锁闭存在问题
|
||||
if (receiveRoute.isLock() && deliverRoute.isLock()) {
|
||||
receiveStatus = IndicatorStatusEnum.Y;
|
||||
@ -123,51 +118,20 @@ public class AssistService {
|
||||
receiveStatus = receiveIndicator.getDefaultStatus();
|
||||
deliverStatus = deliverIndicator.getDefaultStatus();
|
||||
}
|
||||
// 判断状态是否变化
|
||||
if (deliverStatus.equals(deliverIndicator.getAspect()) || receiveStatus.equals(receiveIndicator.getAspect())) {
|
||||
// 变化接车灯亮、发车灯灭
|
||||
if (IndicatorStatusEnum.G.equals(deliverStatus)) {
|
||||
curStation.getButtonsList()
|
||||
.stream()
|
||||
.filter(button -> labelEnum.equals(button.getLabel()) && ButtonTypeEnum.CHANGE_DIRECTION.equals(button.getType()))
|
||||
.forEach(button -> button.setPressDown(IndicatorStatusEnum.G.equals(deliverStatus)));
|
||||
}
|
||||
}
|
||||
receiveIndicator.setAspect(receiveStatus);
|
||||
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);
|
||||
// 获取接车指示灯
|
||||
Indicator receiveIndicator = getStationIndicatorByType(button.getStation(), button.getLabel(), IndicatorTypeEnum.RECEIVE);
|
||||
receiveIndicator.setChangeDirection(Boolean.TRUE);
|
||||
// 获取发车指示灯
|
||||
Indicator deliverIndicator = getStationIndicatorByType(button.getStation(), button.getLabel(), IndicatorTypeEnum.DELIVER);
|
||||
// 办进路
|
||||
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 列车数据
|
||||
*/
|
||||
private VirtualRealityTrain getSandStopTrain(Simulation simulation, String sectionCode) {
|
||||
Optional<VirtualRealityTrain> trainOptional = simulation.getRepository().getAllVrTrain()
|
||||
Optional<VirtualRealityTrain> trainOptional = simulation.getRepository().getOnlineTrainList()
|
||||
.stream()
|
||||
.filter(trainInfo -> sectionCode.equals(trainInfo.getHeadPosition().getSection().getCode()))
|
||||
.filter(trainInfo -> trainInfo != null && sectionCode.equals(trainInfo.getHeadPosition().getSection().getCode()))
|
||||
.findAny();
|
||||
VirtualRealityTrain train;
|
||||
if (trainOptional.isPresent()) {
|
||||
|
@ -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.vo.ButtonStatusVO;
|
||||
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.Setter;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 按钮设备状态信息
|
||||
*/
|
||||
@ -18,8 +16,6 @@ import lombok.Setter;
|
||||
@Getter
|
||||
public class ButtonStatus extends DeviceStatus {
|
||||
|
||||
@JsonSerialize(using = Boolean2NumSerializer.class)
|
||||
@JsonDeserialize(using = Boolean2NumDeserializer.class)
|
||||
private boolean pressDown;
|
||||
|
||||
public ButtonStatus(Button button) {
|
||||
@ -32,10 +28,10 @@ public class ButtonStatus extends DeviceStatus {
|
||||
Button button = (Button) device;
|
||||
ButtonStatusVO status = (ButtonStatusVO) statusVO;
|
||||
boolean change = Boolean.FALSE;
|
||||
if (pressDown != button.isPressDown()) {
|
||||
if (!Objects.equals(pressDown, button.isPressDown())) {
|
||||
change = Boolean.TRUE;
|
||||
pressDown = button.isPressDown();
|
||||
status.setPressDown(button.isPressDown());
|
||||
status.setPressDown(pressDown);
|
||||
}
|
||||
return change;
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package club.joylink.rtss.simulation.cbtc.data.vo;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Button;
|
||||
import club.joylink.rtss.simulation.cbtc.data.status.ButtonStatus;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@ -14,10 +13,6 @@ public class ButtonStatusVO extends DeviceStatusVO {
|
||||
|
||||
private Boolean pressDown;
|
||||
|
||||
public ButtonStatusVO(ButtonStatus buttonStatus) {
|
||||
super(buttonStatus.getCode(), buttonStatus.getDeviceType());
|
||||
}
|
||||
|
||||
public ButtonStatusVO(Button button) {
|
||||
super(button.getCode(), button.getDeviceType());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user