添加进路序列生成逻辑
This commit is contained in:
parent
867a59ecbd
commit
8ffb5efa59
@ -1439,7 +1439,7 @@ public class DraftMapService implements IDraftMapService {
|
|||||||
String logicData = entity.getLogicData();
|
String logicData = entity.getLogicData();
|
||||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(StringUtils.hasText(logicData));
|
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(StringUtils.hasText(logicData));
|
||||||
List<MapDestinationCodeDefinitionVO> vos = JsonUtils.read(logicData, JsonUtils.getCollectionType(ArrayList.class, MapDestinationCodeDefinitionVO.class));
|
List<MapDestinationCodeDefinitionVO> vos = JsonUtils.read(logicData, JsonUtils.getCollectionType(ArrayList.class, MapDestinationCodeDefinitionVO.class));
|
||||||
Optional<MapDestinationCodeDefinitionVO> first = vos.stream().filter(vo -> Objects.equals(vo.getCode(), code)).limit(1).findFirst();
|
Optional<MapDestinationCodeDefinitionVO> first = vos.stream().filter(vo -> Objects.equals(vo.getCode(), code)).findFirst();
|
||||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(first.isPresent());
|
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(first.isPresent());
|
||||||
return first.get();
|
return first.get();
|
||||||
}
|
}
|
||||||
@ -1482,7 +1482,7 @@ public class DraftMapService implements IDraftMapService {
|
|||||||
String logicData = entity.getLogicData();
|
String logicData = entity.getLogicData();
|
||||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(StringUtils.hasText(logicData));
|
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(StringUtils.hasText(logicData));
|
||||||
List<MapDestinationCodeDefinitionVO> vos = JsonUtils.read(logicData, JsonUtils.getCollectionType(ArrayList.class, MapDestinationCodeDefinitionVO.class));
|
List<MapDestinationCodeDefinitionVO> vos = JsonUtils.read(logicData, JsonUtils.getCollectionType(ArrayList.class, MapDestinationCodeDefinitionVO.class));
|
||||||
Optional<MapDestinationCodeDefinitionVO> first = vos.stream().filter(vo -> vo.getCode().equals(definitionVO.getCode())).limit(1).findFirst();
|
Optional<MapDestinationCodeDefinitionVO> first = vos.stream().filter(vo -> vo.getCode().equals(definitionVO.getCode())).findFirst();
|
||||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(first.isPresent());
|
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(first.isPresent());
|
||||||
MapDestinationCodeDefinitionVO old = first.get();
|
MapDestinationCodeDefinitionVO old = first.get();
|
||||||
vos.set(vos.indexOf(old), definitionVO);
|
vos.set(vos.indexOf(old), definitionVO);
|
||||||
|
@ -510,7 +510,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
|
|||||||
} else {
|
} else {
|
||||||
sn = station.getSn() + 1;
|
sn = station.getSn() + 1;
|
||||||
}
|
}
|
||||||
Station adjacentStation = stations.stream().filter(sta -> sta.getSn() == sn).limit(1).findAny().get();
|
Station adjacentStation = stations.stream().filter(sta -> sta.getSn() == sn).findAny().get();
|
||||||
if (CollectionUtils.isEmpty(adjacentStation.getAllNormalStands())) {
|
if (CollectionUtils.isEmpty(adjacentStation.getAllNormalStands())) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
@ -463,7 +463,7 @@ public class DraftMapRouteServiceImpl implements DraftMapRouteService {
|
|||||||
routeVO.setEndSectionCode(departureRoute.getEndSectionCode());
|
routeVO.setEndSectionCode(departureRoute.getEndSectionCode());
|
||||||
List<MapSignalButtonVO> buttons = signalCode_button_map.get(destination.getCode());
|
List<MapSignalButtonVO> buttons = signalCode_button_map.get(destination.getCode());
|
||||||
MapSignalButtonVO endButton = buttons.stream().filter(vo -> MapSignalButtonVO.Type.PICK.equals(vo.getType()))
|
MapSignalButtonVO endButton = buttons.stream().filter(vo -> MapSignalButtonVO.Type.PICK.equals(vo.getType()))
|
||||||
.limit(1).findAny().orElse(null);
|
.findAny().orElse(null);
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(endButton,
|
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(endButton,
|
||||||
String.format("以信号机[%s]、[%s]为始终端的通过进路,终端信号机无列车信号按钮", signal.getCode(), destination.getCode()));
|
String.format("以信号机[%s]、[%s]为始终端的通过进路,终端信号机无列车信号按钮", signal.getCode(), destination.getCode()));
|
||||||
routeVO.setBtnCodeList(Arrays.asList(buttonVO.getCode(), endButton.getCode()));
|
routeVO.setBtnCodeList(Arrays.asList(buttonVO.getCode(), endButton.getCode()));
|
||||||
@ -534,7 +534,7 @@ public class DraftMapRouteServiceImpl implements DraftMapRouteService {
|
|||||||
if (!CollectionUtils.isEmpty(buttons)) {
|
if (!CollectionUtils.isEmpty(buttons)) {
|
||||||
Optional<MapSignalButtonVO> pickButtonOptional = buttons.stream()
|
Optional<MapSignalButtonVO> pickButtonOptional = buttons.stream()
|
||||||
.filter(vo -> MapSignalButtonVO.Type.PICK.equals(vo.getType()))
|
.filter(vo -> MapSignalButtonVO.Type.PICK.equals(vo.getType()))
|
||||||
.limit(1).findAny();
|
.findAny();
|
||||||
if (pickButtonOptional.isPresent()) {
|
if (pickButtonOptional.isPresent()) {
|
||||||
MapSignalButtonVO endButton = pickButtonOptional.get();
|
MapSignalButtonVO endButton = pickButtonOptional.get();
|
||||||
Route route = new Route(routeCodeGenerator.next(), "L_" + startSignal.getShowName() + "-" + endSignal.getShowName());
|
Route route = new Route(routeCodeGenerator.next(), "L_" + startSignal.getShowName() + "-" + endSignal.getShowName());
|
||||||
|
@ -151,12 +151,12 @@ public class OrgScoringRuleService implements IOrgScoringRuleService {
|
|||||||
if (CollectionUtils.isEmpty(rels)) {
|
if (CollectionUtils.isEmpty(rels)) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
OrgScoringRuleRel rel = rels.stream().filter(orgRuleRel -> orgRuleRel.getOrgId().equals(orgId)).limit(1).findAny().orElse(null);
|
OrgScoringRuleRel rel = rels.stream().filter(orgRuleRel -> orgRuleRel.getOrgId().equals(orgId)).findAny().orElse(null);
|
||||||
if (rel == null) {
|
if (rel == null) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
OrgScoringRuleWithBLOBs rule = rules.stream().filter(orgRule -> orgRule.getId().equals(rel.getRuleId()))
|
OrgScoringRuleWithBLOBs rule = rules.stream().filter(orgRule -> orgRule.getId().equals(rel.getRuleId()))
|
||||||
.limit(1).findAny().orElse(null);
|
.findAny().orElse(null);
|
||||||
if (rule == null) {
|
if (rule == null) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
|
@ -733,7 +733,6 @@ public class TrainingV1Service implements ITrainingV1Service {
|
|||||||
if (!CollectionUtils.isEmpty(graphDataNew.getCycleButtonList())) {
|
if (!CollectionUtils.isEmpty(graphDataNew.getCycleButtonList())) {
|
||||||
Optional<MapCycleButtonVO> any = graphDataNew.getCycleButtonList().stream()
|
Optional<MapCycleButtonVO> any = graphDataNew.getCycleButtonList().stream()
|
||||||
.filter(b -> b.getCode().equals(code))
|
.filter(b -> b.getCode().equals(code))
|
||||||
.limit(1)
|
|
||||||
.findAny();
|
.findAny();
|
||||||
if (any.isPresent()) {
|
if (any.isPresent()) {
|
||||||
deviceCode = any.get().getStationCode();
|
deviceCode = any.get().getStationCode();
|
||||||
@ -742,7 +741,6 @@ public class TrainingV1Service implements ITrainingV1Service {
|
|||||||
if (deviceCode == null && !CollectionUtils.isEmpty(graphDataNew.getAutomaticRouteButtonList())) {
|
if (deviceCode == null && !CollectionUtils.isEmpty(graphDataNew.getAutomaticRouteButtonList())) {
|
||||||
Optional<MapAutomaticRouteButtonVO> any = graphDataNew.getAutomaticRouteButtonList().stream()
|
Optional<MapAutomaticRouteButtonVO> any = graphDataNew.getAutomaticRouteButtonList().stream()
|
||||||
.filter(b -> b.getCode().equals(code))
|
.filter(b -> b.getCode().equals(code))
|
||||||
.limit(1)
|
|
||||||
.findAny();
|
.findAny();
|
||||||
if (any.isPresent()) {
|
if (any.isPresent()) {
|
||||||
deviceCode = any.get().getStationCode();
|
deviceCode = any.get().getStationCode();
|
||||||
@ -751,7 +749,6 @@ public class TrainingV1Service implements ITrainingV1Service {
|
|||||||
if (deviceCode == null && !CollectionUtils.isEmpty(graphDataNew.getTbStrategyList())) {
|
if (deviceCode == null && !CollectionUtils.isEmpty(graphDataNew.getTbStrategyList())) {
|
||||||
Optional<MapTurnBackStrategyVO> any = graphDataNew.getTbStrategyList().stream()
|
Optional<MapTurnBackStrategyVO> any = graphDataNew.getTbStrategyList().stream()
|
||||||
.filter(b -> b.getCode().equals(code))
|
.filter(b -> b.getCode().equals(code))
|
||||||
.limit(1)
|
|
||||||
.findAny();
|
.findAny();
|
||||||
if (any.isPresent()) {
|
if (any.isPresent()) {
|
||||||
deviceCode = any.get().getStationCode();
|
deviceCode = any.get().getStationCode();
|
||||||
@ -760,7 +757,6 @@ public class TrainingV1Service implements ITrainingV1Service {
|
|||||||
if (deviceCode == null && !CollectionUtils.isEmpty(graphDataNew.getTotalGuideLockButtonVOList())) {
|
if (deviceCode == null && !CollectionUtils.isEmpty(graphDataNew.getTotalGuideLockButtonVOList())) {
|
||||||
Optional<MapTotalGuideLockButtonVO> any = graphDataNew.getTotalGuideLockButtonVOList().stream()
|
Optional<MapTotalGuideLockButtonVO> any = graphDataNew.getTotalGuideLockButtonVOList().stream()
|
||||||
.filter(b -> b.getCode().equals(code))
|
.filter(b -> b.getCode().equals(code))
|
||||||
.limit(1)
|
|
||||||
.findAny();
|
.findAny();
|
||||||
if (any.isPresent()) {
|
if (any.isPresent()) {
|
||||||
deviceCode = any.get().getStationCode();
|
deviceCode = any.get().getStationCode();
|
||||||
|
@ -1,385 +0,0 @@
|
|||||||
//package club.joylink.rtss.simulation.cbtc.CI;
|
|
||||||
//
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.ATP.ground.GroundAtpApiService;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.ATS.AtsApiService;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.CI.service.*;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.Simulation;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.constant.SimulationModule;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.map.*;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySectionAxleCounter;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch;
|
|
||||||
//import lombok.extern.slf4j.Slf4j;
|
|
||||||
//import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
//import org.springframework.stereotype.Component;
|
|
||||||
//import org.springframework.util.CollectionUtils;
|
|
||||||
//
|
|
||||||
//import java.util.List;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * CI主线逻辑循环
|
|
||||||
// */
|
|
||||||
//@Slf4j
|
|
||||||
//@Component
|
|
||||||
//public class CILogicLoop {
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private RouteService routeService;
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private AutoSignalService autoSignalService;
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private SectionService sectionService;
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private SignalService signalService;
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private SwitchService switchService;
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private GroundAtpApiService groundAtpApiService;
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private AtsApiService atsApiService;
|
|
||||||
//
|
|
||||||
// public void run(Simulation simulation) {
|
|
||||||
//// long start = System.currentTimeMillis();
|
|
||||||
// // 设备状态采集(从虚拟真实设备采集)
|
|
||||||
// this.getStatusFromVRDevice(simulation);
|
|
||||||
// // 进路逻辑
|
|
||||||
// this.routeLogic(simulation);
|
|
||||||
//
|
|
||||||
// // 自动信号逻辑
|
|
||||||
// this.autoSignalLogic(simulation);
|
|
||||||
//
|
|
||||||
// // 延时解锁设备逻辑
|
|
||||||
// this.deviceDelayUnlockLogic(simulation);
|
|
||||||
//
|
|
||||||
//// long end = System.currentTimeMillis();
|
|
||||||
//// System.out.println(String.format("------------CI逻辑耗时: %s ms", (end-start)));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void autoSignalLogic(Simulation simulation) {
|
|
||||||
// List<AutoSignal> autoSignalList = simulation.getRepository().getAutoSignalList();
|
|
||||||
// if (!CollectionUtils.isEmpty(autoSignalList)) {
|
|
||||||
// autoSignalList.forEach(autoSignal ->
|
|
||||||
// this.autoSignalService.updateSignalDisplay(simulation, autoSignal));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private void deviceDelayUnlockLogic(Simulation simulation) {
|
|
||||||
// SimulationDataRepository repository = simulation.getRepository();
|
|
||||||
// List<Section> sectionList = repository.getSectionList();
|
|
||||||
// for (Section section : sectionList) {
|
|
||||||
// this.sectionService.delayUnlock(simulation, section);
|
|
||||||
// }
|
|
||||||
// List<Switch> switchList = repository.getSwitchList();
|
|
||||||
// for (Switch aSwitch : switchList) {
|
|
||||||
// this.switchService.delayUnlock(simulation, aSwitch);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 从虚拟真实设备采集状态
|
|
||||||
// *
|
|
||||||
// * @param simulation
|
|
||||||
// */
|
|
||||||
// public void getStatusFromVRDevice(Simulation simulation) {
|
|
||||||
// SimulationDataRepository repository = simulation.getRepository();
|
|
||||||
// List<Signal> signalList = getSignalsStatusFromVRDevice(simulation);
|
|
||||||
// List<Switch> switchList = getSwitchesStatusFromVRDevice(repository);
|
|
||||||
// getSectionsStatusFromVRDevice(repository);
|
|
||||||
// getPsdStatusFromVRDevice(repository);
|
|
||||||
// // 道岔状态发送ATS
|
|
||||||
// this.atsApiService.handleDeviceStatus(simulation, signalList);
|
|
||||||
// this.atsApiService.handleDeviceStatus(simulation, switchList);
|
|
||||||
//
|
|
||||||
// // 计轴区段状态发送地面ATP
|
|
||||||
// this.groundAtpApiService.receiveAndHandleAxleSectionStatus(simulation);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 进路相关逻辑
|
|
||||||
// */
|
|
||||||
// public void routeLogic(Simulation simulation) {
|
|
||||||
// SimulationDataRepository repository = simulation.getRepository();
|
|
||||||
// List<Route> routeList = repository.getRouteList();
|
|
||||||
// for (Route route : routeList) {
|
|
||||||
// //联锁机故障逻辑
|
|
||||||
// Station deviceStation = route.getStart().getDeviceStation();
|
|
||||||
// if (deviceStation != null) {
|
|
||||||
// if (Station.Fault.INTERLOCK_MACHINE_FAULT.equals(deviceStation.getFault())) {
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//// Route.CheckFailMessage result = this.routeService.check(simulation, route);
|
|
||||||
//// if (Objects.nonNull(result)) {
|
|
||||||
//// route.setSettable(false);
|
|
||||||
//// } else {
|
|
||||||
//// route.setSettable(true);
|
|
||||||
//// }
|
|
||||||
// // 联锁自动触发判断处理
|
|
||||||
// if (route.isCiControl() && !repository.isSettingRoute(route) &&
|
|
||||||
// !route.isNormalUnlock() && route.isCiTrigger()) {
|
|
||||||
// this.routeService.setting(simulation, route);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// List<Route> settingRoutes = repository.getSettingRoutes();
|
|
||||||
// if (!CollectionUtils.isEmpty(settingRoutes)) {
|
|
||||||
// // 获取所有列车方向速度位置信息用以解锁进路
|
|
||||||
// for (Route route : settingRoutes) {
|
|
||||||
// //联锁机故障逻辑
|
|
||||||
// Station deviceStation = route.getStart().getDeviceStation();
|
|
||||||
// if (deviceStation != null) {
|
|
||||||
// if (Station.Fault.INTERLOCK_MACHINE_FAULT.equals(deviceStation.getFault())) {
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (route.isNormalUnlock()) { // 进路锁闭,若进路内存在列车,执行正常解锁
|
|
||||||
// this.routeService.normalUnlock(simulation, route);
|
|
||||||
// }
|
|
||||||
// if (route.isSetting()) { // 进路排列过程
|
|
||||||
// this.routeService.settingProgress(simulation, route);
|
|
||||||
// }
|
|
||||||
// if (route.isDelayUnlocking()) { // 进路延时解锁过程
|
|
||||||
// this.routeService.humanCancelProgress(simulation, route);
|
|
||||||
// }
|
|
||||||
// if (route.isLock()) { // 进路信号开放,始终检查联锁条件是否满足
|
|
||||||
// this.routeService.lockedRouteCheck(simulation, route);
|
|
||||||
// }
|
|
||||||
//// if (route.isLock()) {
|
|
||||||
// // 进路第一个区段是否占用
|
|
||||||
//// Section firstRouteSection = route.getFirstRouteLogicSection();
|
|
||||||
//// if (firstRouteSection.isRouteLock() &&
|
|
||||||
//// firstRouteSection.isOccupied()) {
|
|
||||||
//// route.getStart().setReblockade(true);
|
|
||||||
//// log.debug(String.format("[%s]因[%s]第一个子区段[%s]进路锁闭且占用而重复封锁",
|
|
||||||
//// route.getStart().debugStr(), route.debugStr(), firstRouteSection.debugStr()));
|
|
||||||
//// }
|
|
||||||
//// if (route.isOpen() && !firstRouteSection.isOccupied()) {
|
|
||||||
//// route.getStart().setReblockade(false);
|
|
||||||
//// }
|
|
||||||
//// }
|
|
||||||
//// else if (route.isLock() && !route.isNormalUnlock() && !route.isOpen()) {
|
|
||||||
//// this.routeService.openedRouteCheck(simulation, route);
|
|
||||||
//// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// // 延续保护进路解锁
|
|
||||||
// List<RouteOverlap> overlapList = repository.getListByType(MapElement.DeviceType.OVERLAP, RouteOverlap.class);
|
|
||||||
// for (RouteOverlap overlap : overlapList) {
|
|
||||||
// if (overlap.isLock()) {// 延续保护已锁闭
|
|
||||||
// this.routeService.overlapUnlock(simulation, overlap);
|
|
||||||
// this.routeService.overlapCancelLock(overlap);
|
|
||||||
// } else {
|
|
||||||
// // 延续保护锁闭禁止条件释放
|
|
||||||
// this.routeService.checkAndAllowOverlap(simulation, overlap);
|
|
||||||
// }
|
|
||||||
// if (overlap.isSetting()) { // 延续保护办理中
|
|
||||||
// this.routeService.overlapSettingProcess(simulation, overlap);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// // 延续保护触发
|
|
||||||
// if (repository.getConfig().isOverlapSettingByTrigger()) {
|
|
||||||
// for (RouteOverlap overlap : overlapList) {
|
|
||||||
// this.routeService.checkLockOverlap(simulation, overlap);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 从真实设置获取屏蔽门的状态
|
|
||||||
// */
|
|
||||||
// private void getPsdStatusFromVRDevice(SimulationDataRepository repository) {
|
|
||||||
// // 站台屏蔽门开关门等状态
|
|
||||||
// List<PSD> psdList = repository.getListByType(MapElement.DeviceType.PSD, PSD.class);
|
|
||||||
// psdList.forEach(psd -> {
|
|
||||||
// //联锁机故障
|
|
||||||
// Stand stand = psd.getStand();
|
|
||||||
// Station deviceStation = stand.getDeviceStation();
|
|
||||||
// if (deviceStation != null) {
|
|
||||||
// if (Station.Fault.INTERLOCK_MACHINE_FAULT.equals(deviceStation.getFault())) {
|
|
||||||
// stand.setNoStatus(true);
|
|
||||||
// psd.setNoStatus(true);
|
|
||||||
// return;
|
|
||||||
// } else {
|
|
||||||
// stand.setNoStatus(false);
|
|
||||||
// psd.setNoStatus(false);
|
|
||||||
// }
|
|
||||||
// if (deviceStation.isInterlockMachineStarting())
|
|
||||||
// return;
|
|
||||||
// } else {
|
|
||||||
// stand.setNoStatus(false);
|
|
||||||
// psd.setNoStatus(false);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// VirtualRealityScreenDoor vrScreenDoor = psd.getVirtualScreenDoor();
|
|
||||||
// psd.apply(vrScreenDoor.isClose(), vrScreenDoor.isLock(), vrScreenDoor.isInterlockRelease());
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 更新区段逻辑
|
|
||||||
// */
|
|
||||||
// private void getSectionsStatusFromVRDevice(SimulationDataRepository repository) {
|
|
||||||
// // 区段占用
|
|
||||||
// List<Section> axleSectionList = repository.getAxleSectionList();
|
|
||||||
// axleSectionList.forEach(section -> {
|
|
||||||
// //联锁机故障
|
|
||||||
// boolean interlockMachineFault = false;
|
|
||||||
// boolean interlockMachineStarting = false;
|
|
||||||
// Station deviceStation = section.getDeviceStation();
|
|
||||||
// if (deviceStation != null) {
|
|
||||||
// if (deviceStation.isInterlockMachineStarting())
|
|
||||||
// interlockMachineStarting = true;
|
|
||||||
// if (Station.Fault.INTERLOCK_MACHINE_FAULT.equals(deviceStation.getFault()))
|
|
||||||
// interlockMachineFault = true;
|
|
||||||
// }
|
|
||||||
// if (interlockMachineFault) {
|
|
||||||
// section.setNoStatus(true);
|
|
||||||
// if (section.isSwitchAxleCounterSection()) {
|
|
||||||
// section.getLogicList().forEach(switchSection -> switchSection.setNoStatus(true));
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// section.setNoStatus(false);
|
|
||||||
// if (section.isSwitchAxleCounterSection()) {
|
|
||||||
// section.getLogicList().forEach(switchSection -> switchSection.setNoStatus(false));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (interlockMachineStarting)
|
|
||||||
// return;
|
|
||||||
//// if (section.isInvalid() && section.isFault()) {
|
|
||||||
//// section.setNctOccupied(false);
|
|
||||||
//// return;
|
|
||||||
//// }
|
|
||||||
//// if (section.isFault()) {
|
|
||||||
//// section.setNctOccupied(true);
|
|
||||||
//// return;
|
|
||||||
//// }
|
|
||||||
// if (Section.AxleFault.UNABLE_COLLECT_STATUS.equals(section.getFault()))
|
|
||||||
// return;
|
|
||||||
// VirtualRealitySectionAxleCounter virtualAxleCounter = section.getVirtualAxleCounter();
|
|
||||||
// //更新区段故障状态
|
|
||||||
// if (!VirtualRealitySectionAxleCounter.Fault.FAULT.equals(virtualAxleCounter.getFault())) {
|
|
||||||
// if (Section.AxleFault.FAULT.equals(section.getFault())){
|
|
||||||
// section.setFault(null);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// //更新区段占用状态
|
|
||||||
// if (virtualAxleCounter.isOccupy()) {
|
|
||||||
// section.axleCounterOccupy(virtualAxleCounter.isRight());
|
|
||||||
// } else {
|
|
||||||
// section.clearOccupy();
|
|
||||||
// section.judgeAsValid();
|
|
||||||
// }
|
|
||||||
// //预复位
|
|
||||||
// if (!virtualAxleCounter.isPreReset()) {
|
|
||||||
// List<Switch> switchList = section.getRelSwitchList();
|
|
||||||
// if (!CollectionUtils.isEmpty(switchList)) {
|
|
||||||
// switchList.forEach(aSwitch -> aSwitch.setPreReset(false));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 从真实设备获取道岔状态
|
|
||||||
// */
|
|
||||||
// private List<Switch> getSwitchesStatusFromVRDevice(SimulationDataRepository repository) {
|
|
||||||
// // 道岔位置状态
|
|
||||||
// List<Switch> switchList = repository.getListByType(MapElement.DeviceType.SWITCH, Switch.class);
|
|
||||||
// switchList.forEach(aSwitch -> {
|
|
||||||
// //联锁机故障逻辑
|
|
||||||
// Station deviceStation = aSwitch.getDeviceStation();
|
|
||||||
// if (deviceStation != null) {
|
|
||||||
// if (Station.Fault.INTERLOCK_MACHINE_FAULT.equals(deviceStation.getFault())) {
|
|
||||||
// aSwitch.setNoStatus(true);
|
|
||||||
// return;
|
|
||||||
// } else {
|
|
||||||
// aSwitch.setNoStatus(false);
|
|
||||||
// }
|
|
||||||
// if (deviceStation.isInterlockMachineStarting())
|
|
||||||
// return;
|
|
||||||
// } else {
|
|
||||||
// aSwitch.setNoStatus(false);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// Switch.SwitchFault fault = (Switch.SwitchFault) aSwitch.getFault();
|
|
||||||
// if (fault != null) {
|
|
||||||
// switch (fault) {
|
|
||||||
// case SPLIT:
|
|
||||||
// case SQUEEZE:
|
|
||||||
// break;
|
|
||||||
// case NORMAL_SPLIT: {
|
|
||||||
// VirtualRealitySwitch virtualSwitch = aSwitch.getVirtualSwitch();
|
|
||||||
// aSwitch.apply(false, virtualSwitch.isReverse());
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// case REVERSE_SPLIT: {
|
|
||||||
// VirtualRealitySwitch virtualSwitch = aSwitch.getVirtualSwitch();
|
|
||||||
// aSwitch.apply(virtualSwitch.isNormal(), false);
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// VirtualRealitySwitch virtualSwitch = aSwitch.getVirtualSwitch();
|
|
||||||
// aSwitch.apply(virtualSwitch.isNormal(), virtualSwitch.isReverse());
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// return switchList;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 从真实设备获取信号机状态
|
|
||||||
// */
|
|
||||||
// private List<Signal> getSignalsStatusFromVRDevice(Simulation simulation) {
|
|
||||||
// SimulationDataRepository repository = simulation.getRepository();
|
|
||||||
// List<Signal> signalList = repository.getSignalList();
|
|
||||||
// for (Signal signal : signalList) {
|
|
||||||
// //联锁机故障逻辑
|
|
||||||
// Station deviceStation = signal.getDeviceStation();
|
|
||||||
// if (deviceStation != null) {
|
|
||||||
// if (Station.Fault.INTERLOCK_MACHINE_FAULT.equals(deviceStation.getFault())) {
|
|
||||||
// signal.setNoStatus(true);
|
|
||||||
// continue;
|
|
||||||
// } else {
|
|
||||||
// signal.setNoStatus(false);
|
|
||||||
// }
|
|
||||||
// if (deviceStation.isInterlockMachineStarting())
|
|
||||||
// continue;
|
|
||||||
// } else {
|
|
||||||
// signal.setNoStatus(false);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (signal.isLogicLight() || signal.isVirtual()) {
|
|
||||||
// continue;
|
|
||||||
// } else if (signal.isGuideOpen()) {
|
|
||||||
// int guideRemain = signal.getGuideRemain();
|
|
||||||
// if (guideRemain != -1) { // 非无限开放
|
|
||||||
// guideRemain -= SimulationModule.CI.getRateMs();
|
|
||||||
// if (guideRemain <= 0) {
|
|
||||||
// // 关闭引导信号
|
|
||||||
// this.signalService.close(simulation, signal);
|
|
||||||
// signal.updateGuideRemain(0);
|
|
||||||
// } else {
|
|
||||||
// signal.updateGuideRemain(guideRemain);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// VirtualRealitySignal virtualSignal = signal.getVirtualSignal();
|
|
||||||
// signal.apply(virtualSignal.isGreenOpen(), virtualSignal.isYellowOpen(), virtualSignal.isRedOpen());
|
|
||||||
// }
|
|
||||||
// return signalList;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void addJobs(Simulation simulation) {
|
|
||||||
// simulation.addJob(SimulationModule.CI.name(), () -> this.run(simulation), SimulationConstants.CI_LOOP_RATE);
|
|
||||||
// }
|
|
||||||
//}
|
|
@ -1,672 +0,0 @@
|
|||||||
//package club.joylink.rtss.simulation.cbtc.CI;
|
|
||||||
//
|
|
||||||
//import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.CI.service.*;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.Simulation;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.map.*;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.support.SignalApproachMessage;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySectionAxleCounter;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
|
|
||||||
//import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
|
|
||||||
//import lombok.extern.slf4j.Slf4j;
|
|
||||||
//import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
//import org.springframework.stereotype.Component;
|
|
||||||
//import org.springframework.util.CollectionUtils;
|
|
||||||
//import org.springframework.util.StringUtils;
|
|
||||||
//
|
|
||||||
//import java.time.LocalTime;
|
|
||||||
//import java.util.List;
|
|
||||||
//import java.util.Objects;
|
|
||||||
//import java.util.Optional;
|
|
||||||
//import java.util.stream.Collectors;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * CI子系统
|
|
||||||
// */
|
|
||||||
//@Slf4j
|
|
||||||
//@Component
|
|
||||||
//public class CiApiServiceImpl implements CiApiService {
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private SignalService signalService;
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private SectionService sectionService;
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private SwitchService switchService;
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private RouteService routeService;
|
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private StandService standService;
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void blockadeSection(Simulation simulation, String sectionCode) {
|
|
||||||
// Section section = simulation.getRepository().getByCode(sectionCode, Section.class);
|
|
||||||
// this.sectionService.blockade(section);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void unblockSection(Simulation simulation, String sectionCode) {
|
|
||||||
// Section section = simulation.getRepository().getByCode(sectionCode, Section.class);
|
|
||||||
// this.sectionService.unblock(section);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void blockadeSignal(Simulation simulation, String signalCode) {
|
|
||||||
// Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class);
|
|
||||||
// this.signalService.blockade(simulation, signal);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void unblockSignal(Simulation simulation, String signalCode) {
|
|
||||||
// Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class);
|
|
||||||
// this.signalService.unblock(signal);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void closeSignal(Simulation simulation, String signalCode) {
|
|
||||||
// Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class);
|
|
||||||
// this.signalService.close(simulation, signal);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void reopenSignal(Simulation simulation, String signalCode) {
|
|
||||||
// // 判断信号机是否是关闭状态、进路是否锁闭、联锁关系是否满足
|
|
||||||
// Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class);
|
|
||||||
// if (signal.isMainAspect()) {
|
|
||||||
// throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
|
|
||||||
// "信号机已经开启,无需重开信号机");
|
|
||||||
// }
|
|
||||||
// Optional<Route> routeOptional = simulation.getRepository().getSettingRoutes().stream()
|
|
||||||
// .filter(route -> route.getStart().equals(signal)).limit(1).findAny();
|
|
||||||
// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(routeOptional.isPresent(), "信号机不是已排进路的始端信号机");
|
|
||||||
//// settingRoute(simulation, routeOptional.get().getCode());
|
|
||||||
// Route lockedRoute = signal.getLockedRoute();
|
|
||||||
// if (Objects.isNull(lockedRoute)) {
|
|
||||||
// throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
|
|
||||||
// "进路未锁闭,不能重开信号机");
|
|
||||||
// }
|
|
||||||
// if (!this.routeService.isInterlocked(lockedRoute)) {
|
|
||||||
// throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
|
|
||||||
// String.format("进路[%s(%s)]联锁关系不满足,不能重开信号机", lockedRoute.getName(), lockedRoute.getCode()));
|
|
||||||
// }
|
|
||||||
// this.routeService.routeOpen(simulation, lockedRoute);
|
|
||||||
// if (lockedRoute.isDelayUnlocking()) {
|
|
||||||
// lockedRoute.cancelDelayUnlocking();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void turn(Simulation simulation, String switchCode) {
|
|
||||||
// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
|
||||||
// boolean toNormal = aSwitch.judgeTurnToNormal();
|
|
||||||
// aSwitch.setLastTurnToNormal(toNormal);
|
|
||||||
// if (toNormal) {
|
|
||||||
// if (!this.switchService.turn2NormalPosition(simulation, aSwitch)) {
|
|
||||||
// log.info(String.format("道岔[%s(%s)]锁闭,不能进行定操", aSwitch.getName(), aSwitch.getCode()));
|
|
||||||
// throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "道岔锁闭,不能进行定操");
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// if (!this.switchService.turn2ReversePosition(simulation, aSwitch)) {
|
|
||||||
// log.info(String.format("道岔[%s(%s)]锁闭,不能进行反操", aSwitch.getName(), aSwitch.getCode()));
|
|
||||||
// throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "道岔锁闭,不能进行反操");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void turn2NormalPosition(Simulation simulation, String switchCode) {
|
|
||||||
// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
|
||||||
// if (!this.switchService.turn2NormalPosition(simulation, aSwitch)) {
|
|
||||||
// log.info(String.format("道岔[%s(%s)]锁闭,不能进行定操", aSwitch.getName(), aSwitch.getCode()));
|
|
||||||
// throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "道岔锁闭,不能进行定操");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void turn2ReversePosition(Simulation simulation, String switchCode) {
|
|
||||||
// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
|
||||||
// if (!this.switchService.turn2ReversePosition(simulation, aSwitch)) {
|
|
||||||
// log.info(String.format("道岔[%s(%s)]锁闭,不能进行反操", aSwitch.getName(), aSwitch.getCode()));
|
|
||||||
// throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "道岔锁闭,不能进行反操");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void singleLockSwitch(Simulation simulation, String switchCode) {
|
|
||||||
// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
|
||||||
// this.switchService.singleLock(aSwitch);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void singleUnlockSwitch(Simulation simulation, String switchCode) {
|
|
||||||
// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
|
||||||
// this.switchService.singleUnlock(aSwitch);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void blockadeSwitch(Simulation simulation, String switchCode) {
|
|
||||||
// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
|
||||||
// //条件检查
|
|
||||||
// MapConfig config = simulation.getRepository().getConfig();
|
|
||||||
// if (config.isBlockadeCommandOnlyValidInStandbyMode()) {
|
|
||||||
// boolean standbyMode = simulation.getRepository().getRouteList()
|
|
||||||
// .stream().filter(route -> route.isRouteSwitch(aSwitch)).anyMatch(route -> !route.isCbtcMode()); //包含该道岔的进路是否有处于后备模式的
|
|
||||||
// if (!standbyMode) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//// if (config.isSomeCommandNeedInit()) {
|
|
||||||
//// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(aSwitch.isInit(), aSwitch.debugStr() + "未初始化");
|
|
||||||
//// }
|
|
||||||
//
|
|
||||||
// this.switchService.blockade(aSwitch);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void unblockSwitch(Simulation simulation, String switchCode) {
|
|
||||||
// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
|
||||||
// this.switchService.unblock(aSwitch);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void blockadeSwitchSection(Simulation simulation, String switchCode) {
|
|
||||||
// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
|
||||||
// this.switchService.blockade(aSwitch);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void unblockSwitchSection(Simulation simulation, String switchCode) {
|
|
||||||
// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
|
||||||
// this.switchService.unblock(aSwitch);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public Route.CheckFailMessage routeSettingCheck(Simulation simulation, String routeCode) {
|
|
||||||
// Route route = simulation.getRepository().getByCode(routeCode, Route.class);
|
|
||||||
// return this.routeService.check(simulation, route);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void settingRoute(Simulation simulation, String routeCode) {
|
|
||||||
// Route route = simulation.getRepository().getByCode(routeCode, Route.class);
|
|
||||||
// this.routeService.setting(simulation, route);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void unlockRoute(Simulation simulation, String routeCode) {
|
|
||||||
// Route route = simulation.getRepository().getByCode(routeCode, Route.class);
|
|
||||||
// if (simulation.getRepository().getConfig().isDelayWhenCancelRouteWithAbnormalInterlock()) {
|
|
||||||
// if (!routeService.isInterlocked(route)) {
|
|
||||||
// routeService.humanCancel(simulation, route);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// this.routeService.cancelNoApproachLock(simulation, route);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void forceUnlockRoute(Simulation simulation, String routeCode) {
|
|
||||||
// Route route = simulation.getRepository().getByCode(routeCode, Route.class);
|
|
||||||
// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(route.isFleetMode(),
|
|
||||||
// String.format("进路[%s]已开启自动通过进路,无法取消", route.debugStr()));
|
|
||||||
// SimulationDataRepository repository = simulation.getRepository();
|
|
||||||
// if (routeService.isApproachLock(repository, route)) {
|
|
||||||
// routeService.humanCancel(simulation, route);
|
|
||||||
// } else {
|
|
||||||
// unlockRoute(simulation, route.getCode());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void humanCancel(Simulation simulation, String routeCode) {
|
|
||||||
// Route route = simulation.getRepository().getByCode(routeCode, Route.class);
|
|
||||||
// this.routeService.humanCancel(simulation, route);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void sectionFaultUnlock(Simulation simulation, String sectionCode) {
|
|
||||||
// Section section = simulation.getRepository().getByCode(sectionCode, Section.class);
|
|
||||||
// if (section.isCross()) {
|
|
||||||
// Optional<Section> crossLockedSectionOptional = section.getLogicList().stream().filter(Section::isLocked).findAny();
|
|
||||||
// if (crossLockedSectionOptional.isEmpty()) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
//// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(crossLockedSectionOptional.isPresent(),
|
|
||||||
//// section.debugStr() + "未锁闭,无需解锁");
|
|
||||||
// section = crossLockedSectionOptional.get();
|
|
||||||
// }
|
|
||||||
// if (!section.isLocked()) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
//// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(section.isLocked(),
|
|
||||||
//// section.debugStr() + "未锁闭,无需解锁");
|
|
||||||
// List<Route> lockedRouteList = simulation.getRepository().queryAllLockedRoute();
|
|
||||||
// Route lockedRoute = null;
|
|
||||||
// if (section.isRouteLock()) {
|
|
||||||
// lockedRoute = section.getRoute();
|
|
||||||
//// for (Route route : lockedRouteList) {
|
|
||||||
//// if (route.containSection(section)) {
|
|
||||||
//// lockedRoute = route;
|
|
||||||
//// break;
|
|
||||||
//// }
|
|
||||||
//// }
|
|
||||||
// } else if (section.isOverlapLock()) {
|
|
||||||
// for (Route route : lockedRouteList) {
|
|
||||||
// if (route.overlapContainSection(section)) {
|
|
||||||
// lockedRoute = route;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// this.sectionService.sectionFaultUnlock(simulation, section, lockedRoute);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void switchSectionFaultUnlock(Simulation simulation, String switchCode) {
|
|
||||||
// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
|
||||||
// if (!aSwitch.isLocked())
|
|
||||||
// return;
|
|
||||||
// List<Route> lockedRouteList = simulation.getRepository().queryAllLockedRoute();
|
|
||||||
// Route lockedRoute = null;
|
|
||||||
// if (aSwitch.isRouteLock()) {
|
|
||||||
// lockedRoute = aSwitch.getRoute();
|
|
||||||
//// for (Route route : lockedRouteList) {
|
|
||||||
//// if (route.isRouteSwitch(aSwitch)) {
|
|
||||||
//// lockedRoute = route;
|
|
||||||
//// break;
|
|
||||||
//// }
|
|
||||||
//// }
|
|
||||||
// } else if (aSwitch.isOverlapLock()) {
|
|
||||||
// for (Route route : lockedRouteList) {
|
|
||||||
// if (route.overlapContainSwitch(aSwitch)) {
|
|
||||||
// lockedRoute = route;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// this.switchService.switchFaultUnlock(simulation, aSwitch, lockedRoute);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void setFleetRoute(Simulation simulation, String routeCode) {
|
|
||||||
// Route route = simulation.getRepository().getByCode(routeCode, Route.class);
|
|
||||||
// this.routeService.setFleet(route);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void cancelFleetRoute(Simulation simulation, String routeCode) {
|
|
||||||
// Route route = simulation.getRepository().getByCode(routeCode, Route.class);
|
|
||||||
// this.routeService.cancelFleet(route);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void setCIAutoTriggerRoute(Simulation simulation, String routeCode) {
|
|
||||||
// Route route = simulation.getRepository().getByCode(routeCode, Route.class);
|
|
||||||
// this.routeService.setCIAutoTrigger(route);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void cancelCIAutoTriggerRoute(Simulation simulation, String routeCode) {
|
|
||||||
// Route route = simulation.getRepository().getByCode(routeCode, Route.class);
|
|
||||||
// this.routeService.cancelCIAutoTrigger(route);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public Route findLockedRouteByStartSignal(Simulation simulation, String signalCode) {
|
|
||||||
// Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class);
|
|
||||||
// return signal.getLockedRoute();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public Route findRouteByStartAndEndSignal(Simulation simulation, String startSignalCode, String endSignalCode) {
|
|
||||||
// Signal start = simulation.getRepository().getByCode(startSignalCode, Signal.class);
|
|
||||||
// List<Route> routeList = start.getRouteList();
|
|
||||||
// if (!CollectionUtils.isEmpty(routeList)) {
|
|
||||||
// for (Route route : routeList) {
|
|
||||||
// if (Objects.equals(route.getDestination().getCode(), endSignalCode)) {
|
|
||||||
// return route;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void settingGuideRoute(Simulation simulation, String routeCode) {
|
|
||||||
// Route route = simulation.getRepository().getByCode(routeCode, Route.class);
|
|
||||||
// this.routeService.settingGuideRoute(simulation, route);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void closeGuideSignal(Simulation simulation, String signalCode) {
|
|
||||||
// Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class);
|
|
||||||
// this.signalService.close(simulation, signal);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void openScreenDoor(Simulation simulation, String standCode) {
|
|
||||||
// Stand stand = simulation.getRepository().getByCode(standCode, Stand.class);
|
|
||||||
// if (Objects.nonNull(stand.getPsd())) {
|
|
||||||
// this.standService.openScreenDoor(simulation, stand.getPsd());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void closeScreenDoor(Simulation simulation, String standCode) {
|
|
||||||
// Stand stand = simulation.getRepository().getByCode(standCode, Stand.class);
|
|
||||||
// if (Objects.nonNull(stand.getPsd())) {
|
|
||||||
// this.standService.closeScreenDoor(simulation, stand.getPsd());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void standHoldTrain(Simulation simulation, String standCode, boolean center) {
|
|
||||||
// Stand stand = simulation.getRepository().getByCode(standCode, Stand.class);
|
|
||||||
// this.standService.holdTrain(simulation, stand, center);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void sysHoldTrain(Simulation simulation, String standCode) {
|
|
||||||
// Stand stand = simulation.getRepository().getByCode(standCode, Stand.class);
|
|
||||||
// this.standService.sysHoldTrain(simulation, stand);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void standHoldTrainCancel(Simulation simulation, String standCode, boolean center) {
|
|
||||||
// Stand stand = simulation.getRepository().getByCode(standCode, Stand.class);
|
|
||||||
// this.standService.cancelHoldTrain(simulation, stand, center);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void sysHoldTrainCancel(Simulation simulation, String standCode) {
|
|
||||||
// Stand stand = simulation.getRepository().getByCode(standCode, Stand.class);
|
|
||||||
// this.standService.cancelSysHoldTrain(simulation, stand);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void ibpHoldTrain(Simulation simulation, String standCode) {
|
|
||||||
// Stand stand = simulation.getRepository().getByCode(standCode, Stand.class);
|
|
||||||
// this.standService.ibpHoldTrain(simulation, stand);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void ibpHoldTrainCancel(Simulation simulation, String standCode) {
|
|
||||||
// Stand stand = simulation.getRepository().getByCode(standCode, Stand.class);
|
|
||||||
// this.standService.cancelIbpHoldTrain(simulation, stand);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void standHoldTrainCancelAll(Simulation simulation, String standCode) {
|
|
||||||
// Stand stand = simulation.getRepository().getByCode(standCode, Stand.class);
|
|
||||||
// this.standService.cancelAllHoldTrain(simulation, stand);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void handleSignalApproachMessage(Simulation simulation,
|
|
||||||
// List<SignalApproachMessage> approachMessageList) {
|
|
||||||
// approachMessageList.forEach(approachMessage -> {
|
|
||||||
// Signal signal = simulation.getRepository().getByCode(approachMessage.getSignalCode(), Signal.class);
|
|
||||||
// this.signalService.handleApproachMessage(simulation, signal, approachMessage);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void handleTrainStopMessage(Simulation simulation, VirtualRealityTrain train) {
|
|
||||||
// this.routeService.handleTrainStopMessage(simulation, train);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 办理引导
|
|
||||||
// */
|
|
||||||
// @Override
|
|
||||||
// public void setGuide(Simulation simulation, String signalCode, String routeCode) {
|
|
||||||
// SimulationDataRepository repository = simulation.getRepository();
|
|
||||||
// MapConfig config = repository.getConfig();
|
|
||||||
// Signal signal;
|
|
||||||
// Route route = null;
|
|
||||||
// if (StringUtils.hasText(signalCode)) {
|
|
||||||
// signal = repository.getByCode(signalCode, Signal.class);
|
|
||||||
// } else if (StringUtils.hasText(routeCode)) {
|
|
||||||
// route = repository.getByCode(routeCode, Route.class);
|
|
||||||
// signal = route.getStart();
|
|
||||||
// } else {
|
|
||||||
// throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception("signalCode和routeCode不能都为空");
|
|
||||||
// }
|
|
||||||
// //条件检查
|
|
||||||
// if (config.isGuideNeedRouteSettingFirst()) {
|
|
||||||
// List<Route> routeList = signal.getRouteList();
|
|
||||||
// BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(routeList, String.format("信号机[%s]非进路始端信号机", signal.getCode()));
|
|
||||||
// if (route != null) {
|
|
||||||
// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(route.isLock(), String.format("进路[%s]未办理", route.getCode()));
|
|
||||||
// } else {
|
|
||||||
// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotNull(signal.getLockedRoute(), String.format("信号机[%s]无已办理进路", signal.getCode()));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//// if (config.isSomeCommandNeedInit()) {
|
|
||||||
//// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(signal.isInit(), signal.debugStr() + "未初始化");
|
|
||||||
//// }
|
|
||||||
// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(signal.isClose(), String.format("信号机[%s]需处于关闭状态", signal.getCode()));
|
|
||||||
// boolean signalApproachOccupied = signal.getApproachPathList()
|
|
||||||
// .stream().anyMatch(sectionPath -> sectionPath.getSectionList().stream().anyMatch(Section::isOccupied));
|
|
||||||
// if (config.isNeedApproachLockBeforeSetGuide()) {
|
|
||||||
// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(signalApproachOccupied,
|
|
||||||
// String.format("对%s开放引导操作失败,接近区段没有列车占用", signal.getName()));
|
|
||||||
// }
|
|
||||||
// //办理引导进路或开放引导信号
|
|
||||||
// if (config.isGuideNeedRouteSettingFirst()) {
|
|
||||||
// signalService.openGuideSignal(simulation, signal);
|
|
||||||
// } else {
|
|
||||||
// if (route != null) {
|
|
||||||
// if (route.isLock()) {
|
|
||||||
// signalService.openGuideSignal(simulation, route.getStart());
|
|
||||||
// } else {
|
|
||||||
// routeService.settingGuideRoute(simulation, route);
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// if (signal.getLockedRoute() != null) { //如果有已锁闭进路
|
|
||||||
// signalService.openGuideSignal(simulation, signal);
|
|
||||||
// } else if (!CollectionUtils.isEmpty(signal.getRouteList())) { //如果signal锁闭进路为null,筛选最合适的进路(直线进路>分叉进路>折返进路)
|
|
||||||
// List<Route> collect = signal.getRouteList().stream()
|
|
||||||
// .filter(r -> !r.isTurnBack() && CollectionUtils.isEmpty(r.getSwitchList()))
|
|
||||||
// .collect(Collectors.toList());
|
|
||||||
// if (CollectionUtils.isEmpty(collect)) {
|
|
||||||
// collect = signal.getRouteList().stream().filter(r -> !r.isTurnBack()).collect(Collectors.toList());
|
|
||||||
// }
|
|
||||||
// if (CollectionUtils.isEmpty(collect)) {
|
|
||||||
// collect = signal.getRouteList();
|
|
||||||
// }
|
|
||||||
// route = collect.get(0);
|
|
||||||
// routeService.settingGuideRoute(simulation, route);
|
|
||||||
// } else { //如果信号机没有关联进路
|
|
||||||
// signalService.openGuideSignal(simulation, signal);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 取消引导
|
|
||||||
// */
|
|
||||||
// @Override
|
|
||||||
// public void cancelGuide(Simulation simulation, String signalCode) {
|
|
||||||
// Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class);
|
|
||||||
// signalService.close(simulation, signal);
|
|
||||||
// if (signal.getLockedRoute() != null) {
|
|
||||||
// routeService.cancelGuideRoute(simulation, signal.getLockedRoute());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void setEst(Simulation simulation, ESP esp) {
|
|
||||||
// esp.update(true);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void cancelEst(Simulation simulation, ESP esp) {
|
|
||||||
// esp.update(false);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void restart(Simulation simulation, Station station) {
|
|
||||||
// Station deviceStation;
|
|
||||||
// if (station.isCentralized()) {
|
|
||||||
// deviceStation = station;
|
|
||||||
// } else {
|
|
||||||
// deviceStation = station.getDeviceStation();
|
|
||||||
// }
|
|
||||||
// deviceStation.setInterlockMachineStarting(false);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void release(Simulation simulation, Station station) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void powerOnUnlock(Simulation simulation, Station station) {
|
|
||||||
// if (!station.isCentralized()) {
|
|
||||||
// station = station.getDeviceStation();
|
|
||||||
// }
|
|
||||||
// Station deviceStation = station;
|
|
||||||
// if (Objects.nonNull(deviceStation.getRestartTime())
|
|
||||||
// && deviceStation.getRestartTime().isBefore(LocalTime.now())
|
|
||||||
// && ((Simulation.FunctionalType.LESSON.equals(simulation.getBuildParams().getFunctionalType())
|
|
||||||
// || Simulation.FunctionalType.EXAM.equals(simulation.getBuildParams().getFunctionalType()))
|
|
||||||
// ? true : deviceStation.getRestartTime().plusMinutes(8).isAfter(LocalTime.now()))) {
|
|
||||||
// List<Section> sections = simulation.getRepository().getSectionList();
|
|
||||||
// sections.stream().filter(section -> Objects.equals(section.getDeviceStation(), deviceStation)).forEach(Section::faultUnlock);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// throw BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.exception("无效操作或连锁机重启过8分钟需手动解锁");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void standEC(Simulation simulation, Stand stand) {
|
|
||||||
// if (stand.getEsp() == null)
|
|
||||||
// return;
|
|
||||||
// stand.getEsp().update(true);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void cancelStandEC(Simulation simulation, Stand stand) {
|
|
||||||
// if (stand.getEsp() == null)
|
|
||||||
// return;
|
|
||||||
// stand.getEsp().update(false);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void switchForceTurn(Simulation simulation, String switchCode, Boolean normal) {
|
|
||||||
// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
|
||||||
// BusinessExceptionAssertEnum.SIMULATION_EXCEPTION_FOR_SHOW.assertTrue(!aSwitch.isLocked() && aSwitch.isSectionOccupied(),
|
|
||||||
// String.format("对%s强行转岔操作被联锁逻辑取消", aSwitch.getName()));
|
|
||||||
// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(!aSwitch.isLocked(), String.format("道岔[%s]锁闭,无法转动", aSwitch.getCode()));
|
|
||||||
// if (normal == null) {
|
|
||||||
// normal = aSwitch.judgeTurnToNormal();
|
|
||||||
// }
|
|
||||||
// switchService.controlSwitch(simulation, aSwitch, normal);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void axlePreReset(Simulation simulation, String sectionCode) {
|
|
||||||
// Section section = simulation.getRepository().getByCode(sectionCode, Section.class);
|
|
||||||
// Section axleSection = section.findAxleCounterSection();
|
|
||||||
// //条件检查
|
|
||||||
// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(axleSection != null && axleSection.isAxleCounter(),
|
|
||||||
// section.debugStr() + "不是计轴区段也不归属于任何计轴区段");
|
|
||||||
// VirtualRealitySectionAxleCounter virtualAxleCounter = axleSection.getVirtualAxleCounter();
|
|
||||||
// if (!virtualAxleCounter.isOccupy())
|
|
||||||
// Section.AxleFault.ARB.apply(axleSection);
|
|
||||||
// else
|
|
||||||
// virtualAxleCounter.preReset();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void switchAxlePreReset(Simulation simulation, String switchCode) {
|
|
||||||
// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
|
||||||
// aSwitch.setPreReset(true);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void switchSqueezeRecovery(Simulation simulation, String switchCode) {
|
|
||||||
// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
|
||||||
// Switch.SwitchFault.SQUEEZE.fix(aSwitch);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void switchCommand(Simulation simulation, String switchCode, Boolean auto, Boolean reserve, Boolean normal) {
|
|
||||||
// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
|
||||||
// if (auto != null) {
|
|
||||||
// aSwitch.setAuto(auto);
|
|
||||||
// } else {
|
|
||||||
// if (normal != null) {
|
|
||||||
// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(!aSwitch.isAuto(), "道岔未处于人工模式");
|
|
||||||
// if (normal) {
|
|
||||||
// switchService.turn2NormalPosition(simulation, aSwitch);
|
|
||||||
// } else {
|
|
||||||
// switchService.turn2ReversePosition(simulation, aSwitch);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (reserve != null) {
|
|
||||||
// aSwitch.setDispatcherReserve(reserve);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void initializeBlock(Simulation simulation, String switchCode) {
|
|
||||||
// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class);
|
|
||||||
// aSwitch.setInit(true);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void initializeGuide(Simulation simulation, String signalCode) {
|
|
||||||
// Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class);
|
|
||||||
// signal.setInit(true);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void cancelGuideInitialization(Simulation simulation, String signalCode) {
|
|
||||||
// Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class);
|
|
||||||
// signal.setInit(false);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void axleReset(Simulation simulation, String sectionCode) {
|
|
||||||
// VirtualRealitySectionAxleCounter axle = getAxleCounterAndCheck4Reset(simulation, sectionCode);
|
|
||||||
// if (!axle.isOccupy())
|
|
||||||
// return;
|
|
||||||
// axle.axleReset();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void setOverlap(Simulation simulation, String signalCode, String overlapCode) {
|
|
||||||
// SimulationDataRepository repository = simulation.getRepository();
|
|
||||||
// Signal signal = repository.getByCode(signalCode, Signal.class);
|
|
||||||
// RouteOverlap overlap = repository.getByCode(overlapCode, RouteOverlap.class);
|
|
||||||
// this.routeService.setOverlap(simulation, signal, overlap);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 获取计轴器并为预复位/复位操作检查设备状态
|
|
||||||
// */
|
|
||||||
// private VirtualRealitySectionAxleCounter getAxleCounterAndCheck4Reset(Simulation simulation, String sectionCode) {
|
|
||||||
// Section section = simulation.getRepository().getByCode(sectionCode, Section.class);
|
|
||||||
// Section axleSection = section.findAxleCounterSection();
|
|
||||||
// //条件检查
|
|
||||||
// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(axleSection != null && axleSection.isAxleCounter(),
|
|
||||||
// section.debugStr() + "不是计轴区段也不归属于任何计轴区段");
|
|
||||||
// VirtualRealitySectionAxleCounter virtualAxleCounter = axleSection.getVirtualAxleCounter();
|
|
||||||
// if (simulation.getRepository().getConfig().isStationPreResetBeforeAxlePreReset()) {
|
|
||||||
// Station deviceStation = axleSection.getDeviceStation();
|
|
||||||
// BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(deviceStation, section.debugStr() + "没有所属集中站");
|
|
||||||
// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(deviceStation.isPreReset(), deviceStation.debugStr() + "需处于预复位状态");
|
|
||||||
// }
|
|
||||||
// return virtualAxleCounter;
|
|
||||||
// }
|
|
||||||
//}
|
|
@ -76,7 +76,7 @@ public class CiApiServiceImpl2 implements CiApiService {
|
|||||||
"信号机已经开启,无需重开信号机");
|
"信号机已经开启,无需重开信号机");
|
||||||
}
|
}
|
||||||
Optional<Route> routeOptional = simulation.getRepository().getSettingRoutes().stream()
|
Optional<Route> routeOptional = simulation.getRepository().getSettingRoutes().stream()
|
||||||
.filter(route -> route.getStart().equals(signal)).limit(1).findAny();
|
.filter(route -> route.getStart().equals(signal)).findAny();
|
||||||
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(routeOptional.isPresent(), "信号机不是已排进路的始端信号机");
|
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(routeOptional.isPresent(), "信号机不是已排进路的始端信号机");
|
||||||
// settingRoute(simulation, routeOptional.get().getCode());
|
// settingRoute(simulation, routeOptional.get().getCode());
|
||||||
Route lockedRoute = signal.getLockedRoute();
|
Route lockedRoute = signal.getLockedRoute();
|
||||||
|
@ -10,12 +10,13 @@ public class CtcRepository {
|
|||||||
/**
|
/**
|
||||||
* key : stationCode
|
* key : stationCode
|
||||||
*/
|
*/
|
||||||
private List<CtcStationRunPlanLog> ctcStationRunPlanLogList = new ArrayList<>();
|
private final List<CtcStationRunPlanLog> ctcStationRunPlanLogList = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 进路序列
|
* 进路序列
|
||||||
*/
|
*/
|
||||||
private final Map<String, RouteSequence> routeSequenceMap = new HashMap<>();
|
private final Map<String, RouteSequence> routeSequenceMap = new HashMap<>();
|
||||||
|
private final Map<String, RouteSequenceVO> routeSequenceVOMap = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 增加ctc行车日志信息
|
* 增加ctc行车日志信息
|
||||||
@ -24,6 +25,7 @@ public class CtcRepository {
|
|||||||
*/
|
*/
|
||||||
public void addCtcStationRunPlanLoList(List<CtcStationRunPlanLog> ctcStationRunPlanLogList) {
|
public void addCtcStationRunPlanLoList(List<CtcStationRunPlanLog> ctcStationRunPlanLogList) {
|
||||||
this.ctcStationRunPlanLogList.addAll(ctcStationRunPlanLogList);
|
this.ctcStationRunPlanLogList.addAll(ctcStationRunPlanLogList);
|
||||||
|
generateRouteSequence();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,11 +45,40 @@ public class CtcRepository {
|
|||||||
public CtcStationRunPlanLog getRunPlan(String stationCode, String tripNumber) {
|
public CtcStationRunPlanLog getRunPlan(String stationCode, String tripNumber) {
|
||||||
CtcStationRunPlanLog plan = ctcStationRunPlanLogList.stream()
|
CtcStationRunPlanLog plan = ctcStationRunPlanLogList.stream()
|
||||||
.filter(p -> Objects.equals(p.getStation().getCode(), stationCode) && Objects.equals(p.getTripNumber(), tripNumber))
|
.filter(p -> Objects.equals(p.getStation().getCode(), stationCode) && Objects.equals(p.getTripNumber(), tripNumber))
|
||||||
.limit(1).findAny().orElse(null);
|
.findAny().orElse(null);
|
||||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(plan);
|
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(plan);
|
||||||
return plan;
|
return plan;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用行车日志生成进路序列
|
||||||
|
*/
|
||||||
|
public void generateRouteSequence() {
|
||||||
|
Map<String, List<RouteSequence.Line>> stationLineMap = new HashMap<>();
|
||||||
|
List<RouteSequence.Line> lines = new ArrayList<>();
|
||||||
|
for (CtcStationRunPlanLog plan : ctcStationRunPlanLogList) {
|
||||||
|
String stationCode = plan.getStation().getCode();
|
||||||
|
CtcStationRunPlanLog.RunPlanItem arriveRunPlan = plan.getArriveRunPlan();
|
||||||
|
if (arriveRunPlan != null) {
|
||||||
|
RouteSequence.Line line = new RouteSequence.Line(arriveRunPlan, false);
|
||||||
|
List<RouteSequence.Line> stationLines = stationLineMap.computeIfAbsent(stationCode, (k) -> new ArrayList<>());
|
||||||
|
stationLines.add(line);
|
||||||
|
lines.add(line);
|
||||||
|
}
|
||||||
|
CtcStationRunPlanLog.RunPlanItem departRunPlan = plan.getDepartRunPlan();
|
||||||
|
if (departRunPlan != null) {
|
||||||
|
RouteSequence.Line line = new RouteSequence.Line(departRunPlan, true);
|
||||||
|
List<RouteSequence.Line> stationLines = stationLineMap.computeIfAbsent(stationCode, (k) -> new ArrayList<>());
|
||||||
|
stationLines.add(line);
|
||||||
|
lines.add(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Map.Entry<String, List<RouteSequence.Line>> entry : stationLineMap.entrySet()) {
|
||||||
|
routeSequenceMap.put(entry.getKey(), new RouteSequence(stationLineMap, lines));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public RouteSequence.Line getRouteSequenceLine(String stationCode, String tripNumber, boolean departure) {
|
public RouteSequence.Line getRouteSequenceLine(String stationCode, String tripNumber, boolean departure) {
|
||||||
RouteSequence routeSequence = routeSequenceMap.get(stationCode);
|
RouteSequence routeSequence = routeSequenceMap.get(stationCode);
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(routeSequence);
|
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(routeSequence);
|
||||||
@ -56,5 +87,6 @@ public class CtcRepository {
|
|||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
this.ctcStationRunPlanLogList.forEach(ctcStationRunPlanLog -> ctcStationRunPlanLog.reset());
|
this.ctcStationRunPlanLogList.forEach(ctcStationRunPlanLog -> ctcStationRunPlanLog.reset());
|
||||||
|
generateRouteSequence();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,7 @@ import lombok.Getter;
|
|||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 进路序列
|
* 进路序列
|
||||||
@ -18,17 +15,38 @@ import java.util.Map;
|
|||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class RouteSequence {
|
public class RouteSequence {
|
||||||
private boolean onlyRead;
|
private boolean readOnly;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* k - tripNumber
|
* k - tripNumber
|
||||||
*/
|
*/
|
||||||
private final Map<String, List<Line>> tripLineMap = new HashMap<>();
|
private final Map<String, List<Line>> tripLineMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 按时间排序
|
* 按时间排序
|
||||||
*/
|
*/
|
||||||
private final List<Line> lines = new LinkedList<>();
|
private final List<Line> lines;
|
||||||
|
|
||||||
|
public RouteSequence(Map<String, List<Line>> tripLineMap, List<Line> lines) {
|
||||||
|
class LineComparator implements Comparator<RouteSequence.Line> {
|
||||||
|
@Override
|
||||||
|
public int compare(RouteSequence.Line line, RouteSequence.Line t1) {
|
||||||
|
if (line == null)
|
||||||
|
return 1;
|
||||||
|
if (t1 == null)
|
||||||
|
return -1;
|
||||||
|
if (line.getPlanTime().isBefore(t1.getPlanTime()))
|
||||||
|
return -1;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (List<Line> list : tripLineMap.values()) {
|
||||||
|
list.sort(new LineComparator());
|
||||||
|
}
|
||||||
|
this.tripLineMap = tripLineMap;
|
||||||
|
lines.sort(new LineComparator());
|
||||||
|
this.lines = lines;
|
||||||
|
}
|
||||||
|
|
||||||
public void addLine(Line line) {
|
public void addLine(Line line) {
|
||||||
List<Line> tripLines = tripLineMap.computeIfAbsent(line.getTripNumber(), (k) -> new LinkedList<>());
|
List<Line> tripLines = tripLineMap.computeIfAbsent(line.getTripNumber(), (k) -> new LinkedList<>());
|
||||||
@ -43,7 +61,7 @@ public class RouteSequence {
|
|||||||
List<Line> lines = tripLineMap.get(tripNumber);
|
List<Line> lines = tripLineMap.get(tripNumber);
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertCollectionNotEmpty(lines);
|
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertCollectionNotEmpty(lines);
|
||||||
Line l = lines.stream().filter(line -> departure == line.isDeparture())
|
Line l = lines.stream().filter(line -> departure == line.isDeparture())
|
||||||
.limit(1).findAny().orElse(null);
|
.findAny().orElse(null);
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(l);
|
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(l);
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
@ -69,9 +87,8 @@ public class RouteSequence {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public static class Line {
|
public static class Line implements Comparable<Line>{
|
||||||
private String tripNumber;
|
CtcStationRunPlanLog.RunPlanItem item;
|
||||||
private Section track;
|
|
||||||
/**
|
/**
|
||||||
* 是自触?
|
* 是自触?
|
||||||
*/
|
*/
|
||||||
@ -83,5 +100,31 @@ public class RouteSequence {
|
|||||||
private LocalTime startTime;
|
private LocalTime startTime;
|
||||||
private LocalTime planTime;
|
private LocalTime planTime;
|
||||||
private Route route;
|
private Route route;
|
||||||
|
|
||||||
|
public Line(CtcStationRunPlanLog.RunPlanItem item, boolean departure) {
|
||||||
|
this.item = item;
|
||||||
|
this.departure = departure;
|
||||||
|
this.planTime = item.getStationPlan().getArriveTime().minusMinutes(9);
|
||||||
|
Section track = getTrack();
|
||||||
|
Route route = item.getStationDirection().getSignal().getRouteList().stream()
|
||||||
|
.filter(r -> Objects.equals(track, r.getLastRouteSection()))
|
||||||
|
.findAny().orElse(null);
|
||||||
|
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(route,
|
||||||
|
String .format("车次[%s]的[%s]进路找不到", getTripNumber(), departure ? "发车" : "接车"));
|
||||||
|
this.route = route;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTripNumber() {
|
||||||
|
return this.item.getTripNumber();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Section getTrack() {
|
||||||
|
return this.item.getTrackSection();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(Line line) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ public class PowerSupplyService {
|
|||||||
train.updatePowerSupplyStatus(true);
|
train.updatePowerSupplyStatus(true);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Optional<Catenary> first = catenaries.stream().filter(catenary -> catenary.isWithinRange(headPosition)).limit(1).findFirst();
|
Optional<Catenary> first = catenaries.stream().filter(catenary -> catenary.isWithinRange(headPosition)).findFirst();
|
||||||
if (first.isPresent()) {
|
if (first.isPresent()) {
|
||||||
Catenary catenary = first.get();
|
Catenary catenary = first.get();
|
||||||
train.updatePowerSupplyStatus(catenary.isOn());
|
train.updatePowerSupplyStatus(catenary.isOn());
|
||||||
|
@ -441,7 +441,7 @@ public class Simulation extends club.joylink.rtss.simulation.Simulation<Simulati
|
|||||||
public SimulationMember findMemberByDeviceCode(String deviceCode) {
|
public SimulationMember findMemberByDeviceCode(String deviceCode) {
|
||||||
Optional<SimulationMember> any = this.getSimulationMembers().stream()
|
Optional<SimulationMember> any = this.getSimulationMembers().stream()
|
||||||
.filter(member -> member.getDevice() != null && Objects.equals(member.getDevice().getCode(), deviceCode))
|
.filter(member -> member.getDevice() != null && Objects.equals(member.getDevice().getCode(), deviceCode))
|
||||||
.limit(1).findAny();
|
.findAny();
|
||||||
return any.orElse(null);
|
return any.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -952,7 +952,7 @@ public class InterlockBuilder2 {
|
|||||||
Section section;
|
Section section;
|
||||||
if (ftb) {
|
if (ftb) {
|
||||||
Optional<Section> selectedSectionOptional = preferredSections.stream()
|
Optional<Section> selectedSectionOptional = preferredSections.stream()
|
||||||
.filter(ns -> ns.isNormalStandTrack() && station.equals(ns.getStation())).limit(1).findAny(); //查询指定的站台轨
|
.filter(ns -> ns.isNormalStandTrack() && station.equals(ns.getStation())).findAny(); //查询指定的站台轨
|
||||||
if (selectedSectionOptional.isPresent()) {
|
if (selectedSectionOptional.isPresent()) {
|
||||||
section = selectedSectionOptional.get();
|
section = selectedSectionOptional.get();
|
||||||
} else { //没有指定折返轨
|
} else { //没有指定折返轨
|
||||||
@ -965,7 +965,7 @@ public class InterlockBuilder2 {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Optional<Section> selectedSectionOptional = preferredSections.stream()
|
Optional<Section> selectedSectionOptional = preferredSections.stream()
|
||||||
.filter(ns -> ns.isTurnBackTrack() && station.equals(ns.getStation())).limit(1).findAny();
|
.filter(ns -> ns.isTurnBackTrack() && station.equals(ns.getStation())).findAny();
|
||||||
section = selectedSectionOptional.orElseGet(() -> station.getTurnBackList().get(0));
|
section = selectedSectionOptional.orElseGet(() -> station.getTurnBackList().get(0));
|
||||||
}
|
}
|
||||||
return section;
|
return section;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package club.joylink.rtss.simulation.cbtc.competition;
|
package club.joylink.rtss.simulation.cbtc.competition;
|
||||||
|
|
||||||
import club.joylink.rtss.simulation.cbtc.script.ScriptBO;
|
|
||||||
import club.joylink.rtss.constants.Client;
|
import club.joylink.rtss.constants.Client;
|
||||||
import club.joylink.rtss.entity.CompetitionWithBLOBs;
|
import club.joylink.rtss.entity.CompetitionWithBLOBs;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.script.ScriptBO;
|
||||||
import club.joylink.rtss.util.JsonUtils;
|
import club.joylink.rtss.util.JsonUtils;
|
||||||
import club.joylink.rtss.vo.client.competition.*;
|
import club.joylink.rtss.vo.client.competition.*;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@ -116,7 +116,7 @@ public class CompetitionBO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public OperationStatisticVO.ItemVO findOperationStatisticItemByActionId(String actionId) {
|
public OperationStatisticVO.ItemVO findOperationStatisticItemByActionId(String actionId) {
|
||||||
Optional<OperationStatisticVO.ItemVO> itemOptional = this.operationStatistic.getItems().stream().filter(item -> actionId.equals(item.getActionId())).limit(1).findFirst();
|
Optional<OperationStatisticVO.ItemVO> itemOptional = this.operationStatistic.getItems().stream().filter(item -> actionId.equals(item.getActionId())).findFirst();
|
||||||
if (itemOptional.isPresent()) {
|
if (itemOptional.isPresent()) {
|
||||||
return itemOptional.get();
|
return itemOptional.get();
|
||||||
}
|
}
|
||||||
|
@ -657,7 +657,6 @@ public class SimulationDataRepository {
|
|||||||
List<TrainInfo> collect = this.getSuperviseTrainList()
|
List<TrainInfo> collect = this.getSuperviseTrainList()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(trainInfo -> trainInfo.getTripNumber().equals(tripNumber))
|
.filter(trainInfo -> trainInfo.getTripNumber().equals(tripNumber))
|
||||||
.limit(1)
|
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
if (CollectionUtils.isEmpty(collect)) {
|
if (CollectionUtils.isEmpty(collect)) {
|
||||||
throw new SimulationException(SimulationExceptionType.System_Fault);
|
throw new SimulationException(SimulationExceptionType.System_Fault);
|
||||||
|
@ -945,7 +945,7 @@ public class Section extends DelayUnlockDevice {
|
|||||||
* 查询道岔计轴区段关联的岔心
|
* 查询道岔计轴区段关联的岔心
|
||||||
*/
|
*/
|
||||||
private Section queryCross() {
|
private Section queryCross() {
|
||||||
return this.logicList.stream().filter(Section::isCross).limit(1).findAny().orElse(null);
|
return this.logicList.stream().filter(Section::isCross).findAny().orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -51,7 +51,7 @@ public class UserSimulationStatsManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Set<SimulationUseInfo> useInfos = userAndUseInfosMap.computeIfAbsent(userId, k -> new HashSet<>());
|
Set<SimulationUseInfo> useInfos = userAndUseInfosMap.computeIfAbsent(userId, k -> new HashSet<>());
|
||||||
Optional<SimulationUseInfo> infoOptional = useInfos.stream().filter(info -> group.equals(info.getGroup())).limit(1).findFirst();
|
Optional<SimulationUseInfo> infoOptional = useInfos.stream().filter(info -> group.equals(info.getGroup())).findFirst();
|
||||||
if (infoOptional.isPresent()) { //如果记录已经存在
|
if (infoOptional.isPresent()) { //如果记录已经存在
|
||||||
SimulationUseInfo useInfo = infoOptional.get();
|
SimulationUseInfo useInfo = infoOptional.get();
|
||||||
useInfo.restart();
|
useInfo.restart();
|
||||||
@ -127,7 +127,7 @@ public class UserSimulationStatsManager {
|
|||||||
if (CollectionUtils.isEmpty(infos)) {
|
if (CollectionUtils.isEmpty(infos)) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
Optional<SimulationUseInfo> optional = infos.stream().filter(info -> group.equals(info.getGroup())).limit(1).findFirst();
|
Optional<SimulationUseInfo> optional = infos.stream().filter(info -> group.equals(info.getGroup())).findFirst();
|
||||||
return optional.orElse(null);
|
return optional.orElse(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -421,7 +421,7 @@ public class ScriptBO {
|
|||||||
|
|
||||||
public ScriptActionBO.Condition getActionCondition(String actionId) {
|
public ScriptActionBO.Condition getActionCondition(String actionId) {
|
||||||
if (!CollectionUtils.isEmpty(actionList)) {
|
if (!CollectionUtils.isEmpty(actionList)) {
|
||||||
Optional<ScriptActionBO> first = actionList.stream().filter(actionBO -> actionBO.getId().equals(actionId)).limit(1).findFirst();
|
Optional<ScriptActionBO> first = actionList.stream().filter(actionBO -> actionBO.getId().equals(actionId)).findFirst();
|
||||||
if (first.isPresent()) {
|
if (first.isPresent()) {
|
||||||
return first.get().getCondition();
|
return first.get().getCondition();
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ public class CilRouteLogicService {
|
|||||||
if (CollectionUtils.isEmpty(spList))
|
if (CollectionUtils.isEmpty(spList))
|
||||||
return true;
|
return true;
|
||||||
return spList.stream().allMatch(sp -> cilRepository.getSwitchById(sp.getCommonSwitch().getId()).getPosition() == sp.getPosition());
|
return spList.stream().allMatch(sp -> cilRepository.getSwitchById(sp.getCommonSwitch().getId()).getPosition() == sp.getPosition());
|
||||||
}).limit(1).findAny();
|
}).findAny();
|
||||||
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(routeOptional.isPresent(), "无能够办理的进路");
|
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(routeOptional.isPresent(), "无能够办理的进路");
|
||||||
commonRoute = routeOptional.get();
|
commonRoute = routeOptional.get();
|
||||||
check4SetGuide(cilRepository, commonRoute);
|
check4SetGuide(cilRepository, commonRoute);
|
||||||
|
Loading…
Reference in New Issue
Block a user