Merge remote-tracking branch 'origin/test' into test

This commit is contained in:
joylink_zhangsai 2022-05-25 13:05:36 +08:00
commit adba252b96
7 changed files with 150 additions and 29 deletions

View File

@ -109,7 +109,11 @@ public class AtpSectionService {
for (Section section : sectionList) { for (Section section : sectionList) {
if (section.isSwitchAxleCounterSection()) { if (section.isSwitchAxleCounterSection()) {
Section switchSection = section.getLogicList().get(0); Section switchSection = section.getLogicList().get(0);
if (switchSingleHandle) {
atpSectionList.addAll(switchSection.getSwitchAxleSectionsBySwitchPositionBySwitchSingleHandle());
} else {
atpSectionList.addAll(switchSection.getSwitchAxleSectionsBySwitchPosition()); atpSectionList.addAll(switchSection.getSwitchAxleSectionsBySwitchPosition());
}
continue; continue;
} }
if (CollectionUtils.isEmpty(section.getLogicList())) { if (CollectionUtils.isEmpty(section.getLogicList())) {

View File

@ -399,8 +399,8 @@ public class TrainOperateHandler {
* 大铁加载指定车次列车 * 大铁加载指定车次列车
*/ */
@OperateHandlerMapping(type = Operation.Type.Train_Load_Trip_Number_Train) @OperateHandlerMapping(type = Operation.Type.Train_Load_Trip_Number_Train)
public void loadServiceNumberTrain(Simulation simulation, String tripNumber, String sectionCode) { public void loadServiceNumberTrain(Simulation simulation, String tripNumber, String sectionCode, boolean right) {
atsTrainLoadService.loadTripNumberTrain(simulation, tripNumber, sectionCode); atsTrainLoadService.loadTripNumberTrain(simulation, tripNumber, sectionCode, right);
} }
/** /**

View File

@ -864,11 +864,9 @@ public class AtsTrainLoadService {
* @param tripNumber 车次号 * @param tripNumber 车次号
* @param sectionCode 区段编号 * @param sectionCode 区段编号
*/ */
public void loadTripNumberTrain(Simulation simulation, String tripNumber, String sectionCode) { public void loadTripNumberTrain(Simulation simulation, String tripNumber, String sectionCode, boolean right) {
SimulationDataRepository repository = simulation.getRepository(); SimulationDataRepository repository = simulation.getRepository();
validServiceNumber(simulation, tripNumber); validServiceNumber(simulation, tripNumber, right);
// 最后一位数字:偶数上行奇数下行
boolean right = (tripNumber.charAt(tripNumber.length() - 1) - 48) % 2 == 0;
Optional<VirtualRealityTrain> virtualRealityTrainOptional = repository.getAllVrTrain().stream() Optional<VirtualRealityTrain> virtualRealityTrainOptional = repository.getAllVrTrain().stream()
.filter(trainInfo -> !repository.isVrTrainOnline(trainInfo.getGroupNumber())) .filter(trainInfo -> !repository.isVrTrainOnline(trainInfo.getGroupNumber()))
.findFirst(); .findFirst();
@ -890,13 +888,13 @@ public class AtsTrainLoadService {
*/ */
public void updateServiceNumberTrain(Simulation simulation, String tripNumber, String groupNumber) { public void updateServiceNumberTrain(Simulation simulation, String tripNumber, String groupNumber) {
SimulationDataRepository repository = simulation.getRepository(); SimulationDataRepository repository = simulation.getRepository();
validServiceNumber(simulation, tripNumber); // 最后一位数字:偶数上行奇数下行
boolean right = (tripNumber.charAt(tripNumber.length() - 1) - 48) % 2 == 0;
validServiceNumber(simulation, tripNumber, right);
if (!repository.isVrTrainOnline(groupNumber)) { if (!repository.isVrTrainOnline(groupNumber)) {
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, String.format("车组号[%s]的列车不存在", groupNumber)); throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, String.format("车组号[%s]的列车不存在", groupNumber));
} }
VirtualRealityTrain virtualRealityTrain = repository.getVRByCode(groupNumber, VirtualRealityTrain.class); VirtualRealityTrain virtualRealityTrain = repository.getVRByCode(groupNumber, VirtualRealityTrain.class);
// 最后一位数字:偶数上行奇数下行
boolean right = (tripNumber.charAt(tripNumber.length() - 1) - 48) % 2 == 0;
if (!Objects.equals(right, virtualRealityTrain.isRight())) { if (!Objects.equals(right, virtualRealityTrain.isRight())) {
atpService.turnDirectionImmediately(virtualRealityTrain); atpService.turnDirectionImmediately(virtualRealityTrain);
} }
@ -913,7 +911,7 @@ public class AtsTrainLoadService {
* @param simulation 仿真实体 * @param simulation 仿真实体
* @param tripNumber 车次号 * @param tripNumber 车次号
*/ */
private void validServiceNumber(Simulation simulation, String tripNumber) { private void validServiceNumber(Simulation simulation, String tripNumber, boolean right) {
SimulationDataRepository repository = simulation.getRepository(); SimulationDataRepository repository = simulation.getRepository();
boolean isExist = repository.getTrainInfoMap().values().stream() boolean isExist = repository.getTrainInfoMap().values().stream()
.anyMatch(trainInfo -> tripNumber.equals(trainInfo.getTripNumber())); .anyMatch(trainInfo -> tripNumber.equals(trainInfo.getTripNumber()));
@ -926,6 +924,11 @@ public class AtsTrainLoadService {
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
String.format("车次[%s]要以数字结尾", tripNumber)); String.format("车次[%s]要以数字结尾", tripNumber));
} }
// 最后一位数字:偶数上行奇数下行
boolean checkRight = lastNum % 2 == 0;
if (!Objects.equals(right, checkRight)) {
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "列车车次与上下行不匹配");
}
} }
/** /**

View File

@ -418,8 +418,10 @@ public class CiApiServiceImpl2 implements CiApiService {
} else { } else {
throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception("signalCode和routeCode不能都为空"); throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception("signalCode和routeCode不能都为空");
} }
// 判断是否要进行进路判断大铁可以不对进路判断
boolean firstCheck = config.isHasCTC() ? false : config.isGuideNeedRouteSettingFirst();
//条件检查 //条件检查
if (config.isGuideNeedRouteSettingFirst()) { if (firstCheck) {
List<Route> routeList = signal.getRouteList(); List<Route> routeList = signal.getRouteList();
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(routeList, String.format("信号机[%s]非进路始端信号机", signal.getCode())); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(routeList, String.format("信号机[%s]非进路始端信号机", signal.getCode()));
if (route != null) { if (route != null) {
@ -442,7 +444,7 @@ public class CiApiServiceImpl2 implements CiApiService {
String.format("对%s开放引导操作失败接近区段没有列车占用", signal.getName())); String.format("对%s开放引导操作失败接近区段没有列车占用", signal.getName()));
} }
//办理引导进路或开放引导信号 //办理引导进路或开放引导信号
if (config.isGuideNeedRouteSettingFirst()) { if (firstCheck) {
this.signalService.tryControlSignalAspectAccordingLevel(simulation, signal, signal.getSignalModel().getGuideAspect()); this.signalService.tryControlSignalAspectAccordingLevel(simulation, signal, signal.getSignalModel().getGuideAspect());
} else { } else {
if (route != null) { if (route != null) {
@ -454,10 +456,18 @@ public class CiApiServiceImpl2 implements CiApiService {
} else { } else {
if (signal.getLockedRoute() != null) { //如果有已锁闭进路 if (signal.getLockedRoute() != null) { //如果有已锁闭进路
this.signalService.tryControlSignalAspectAccordingLevel(simulation, signal, signal.getSignalModel().getGuideAspect()); this.signalService.tryControlSignalAspectAccordingLevel(simulation, signal, signal.getSignalModel().getGuideAspect());
} else if (!CollectionUtils.isEmpty(signal.getRouteList())) { //如果signal锁闭进路为null筛选最合适的进路直线进路>分叉进路>折返进路 } else if (!CollectionUtils.isEmpty(signal.getRouteList())) {
List<Route> collect = signal.getRouteList().stream() List<Route> collect;
if (config.isHasCTC()) { // 大铁配置引导进路
collect = getCtcGuideRouteList(repository, signal);
if (collect == null) {
return;
}
} else { //如果signal锁闭进路为null筛选最合适的进路直线进路>分叉进路>折返进路
collect = signal.getRouteList().stream()
.filter(r -> !r.isTurnBack() && CollectionUtils.isEmpty(r.getSwitchList())) .filter(r -> !r.isTurnBack() && CollectionUtils.isEmpty(r.getSwitchList()))
.collect(Collectors.toList()); .collect(Collectors.toList());
}
if (CollectionUtils.isEmpty(collect)) { if (CollectionUtils.isEmpty(collect)) {
collect = signal.getRouteList().stream().filter(r -> !r.isTurnBack()).collect(Collectors.toList()); collect = signal.getRouteList().stream().filter(r -> !r.isTurnBack()).collect(Collectors.toList());
} }
@ -479,6 +489,7 @@ public class CiApiServiceImpl2 implements CiApiService {
} }
} }
@Override @Override
public void setEst(Simulation simulation, ESP esp) { public void setEst(Simulation simulation, ESP esp) {
esp.update(true); esp.update(true);
@ -711,4 +722,61 @@ public class CiApiServiceImpl2 implements CiApiService {
} }
return virtualAxleCounter; return virtualAxleCounter;
} }
/**
* 大铁办理引导时获取进路列表
*
* @param repository 仿真实体
* @param signal 信号机
*/
private List<Route> getCtcGuideRouteList(SimulationDataRepository repository, Signal signal) {
// 获取已信号机开头的进路集合
List<Route> routeList = repository.getRouteList().stream()
.filter(routePojo -> routePojo.isTrainRoute() && routePojo.getStart().getCode().equals(signal.getCode()))
.collect(Collectors.toList());
// 进路走向
boolean isRight = routeList.stream().anyMatch(Route::isRight);
// 终端信号机类型信号机类型匹配时停止循环
List<Signal.SignalType> endTypeList = Signal.SignalType.SHUNTING2.equals(signal.getType()) ?
Arrays.asList(Signal.SignalType.RECEIVING, Signal.SignalType.DEPARTURE) : Arrays.asList(Signal.SignalType.SHUNTING2);
// 终止索引最多循环20次防止死循环
int endIndex = 0;
Section nextSection = signal.getSection();
Signal endSignal; // 终端信号机
do {
if (nextSection.isSwitchTrack()) { // 如果是计轴区段
nextSection = nextSection.getNextRunningSectionOf(isRight);
} else { // 下一区段
nextSection = nextSection.getNextSection(isRight);
}
if (nextSection == null) { // 道岔不连续不能办理进路直接返回结果
log.error("进路不连续");
return null;
}
// 获取信号机
if (isRight) {
endSignal = nextSection.getSignalToLeft();
} else {
endSignal = nextSection.getSignalToRight();
}
endIndex++;
} while (endIndex < 20 && !(endSignal != null && endTypeList.contains(endSignal.getType())));
// 过滤符合条件的进路
if (endSignal != null && endIndex < 20) {
String endSignalCode = endSignal.getCode();
routeList = routeList.stream()
.filter(routePojo -> routePojo.getDestination().getCode().equals(endSignalCode))
.collect(Collectors.toList());
} else {
// 如果是超过第限制停下获取第endIndex个元素对比
String routeSectionCode = nextSection.getCode();
final int sectionIndex = endIndex;
routeList = routeList.stream()
.filter(routePojo -> routePojo.getSectionList().size() >= sectionIndex
&& routePojo.getSectionList().get(sectionIndex).getCode().equals(routeSectionCode))
.collect(Collectors.toList());
}
return routeList;
}
} }

View File

@ -30,6 +30,7 @@ public class CiRouteService {
/** /**
* 进路排列检查 * 进路排列检查
*
* @param simulation * @param simulation
* @param route * @param route
* @return * @return
@ -174,10 +175,18 @@ public class CiRouteService {
/** /**
* 排列引导进路 * 排列引导进路
*
* @param simulation * @param simulation
* @param route * @param route
*/ */
public void setGuide(Simulation simulation, Route route) { public void setGuide(Simulation simulation, Route route) {
// 进路检查
Route.CheckFailMessage failMessage = routeSetCheck(simulation, route);
if (failMessage == null) {
if (route.isLock() && !route.isFleetMode()) {
log.info("进路[{}]已经锁闭", route.debugStr());
return;
}
// 引导进路开始办理 // 引导进路开始办理
LocalDateTime systemTime = simulation.getSystemTime(); LocalDateTime systemTime = simulation.getSystemTime();
route.startGuideSetting(systemTime); route.startGuideSetting(systemTime);
@ -187,9 +196,14 @@ public class CiRouteService {
} }
simulation.getRepository().addSettingRoute(route); simulation.getRepository().addSettingRoute(route);
} }
if (Objects.nonNull(failMessage)) {
log.info(String.format("进路[%s]排列检查失败,无法排列:%s", route.debugStr(), failMessage.debugStr()));
}
}
/** /**
* 排列进路 * 排列进路
*
* @param simulation * @param simulation
* @param route * @param route
* @return * @return
@ -220,6 +234,7 @@ public class CiRouteService {
/** /**
* 排列进路过程控制 * 排列进路过程控制
*
* @param simulation * @param simulation
* @param route * @param route
*/ */
@ -295,6 +310,7 @@ public class CiRouteService {
/** /**
* 检查并锁闭主进路不包含侧防和延续保护 * 检查并锁闭主进路不包含侧防和延续保护
*
* @param route * @param route
*/ */
private void checkAndLockRouteMain(Route route) { private void checkAndLockRouteMain(Route route) {
@ -319,6 +335,7 @@ public class CiRouteService {
/** /**
* 解锁进路 * 解锁进路
*
* @param simulation * @param simulation
* @param route * @param route
*/ */
@ -380,6 +397,7 @@ public class CiRouteService {
/** /**
* 延时解锁进路 * 延时解锁进路
*
* @param simulation * @param simulation
* @param route * @param route
*/ */
@ -416,6 +434,7 @@ public class CiRouteService {
/** /**
* 道岔区段故障解锁 * 道岔区段故障解锁
*
* @param simulation * @param simulation
* @param aSwitch * @param aSwitch
* @param route * @param route
@ -460,6 +479,7 @@ public class CiRouteService {
/** /**
* 列车逐段解锁进路 * 列车逐段解锁进路
*
* @param simulation * @param simulation
* @param route * @param route
*/ */
@ -564,6 +584,7 @@ public class CiRouteService {
/** /**
* 延续保护办理 * 延续保护办理
*
* @param simulation * @param simulation
* @param overlap * @param overlap
*/ */
@ -589,6 +610,7 @@ public class CiRouteService {
/** /**
* 延续保护办理过程 * 延续保护办理过程
*
* @param simulation * @param simulation
* @param overlap * @param overlap
*/ */
@ -666,6 +688,7 @@ public class CiRouteService {
/** /**
* 取消自动进路 * 取消自动进路
*
* @param route * @param route
*/ */
public void cancelFleet(Route route) { public void cancelFleet(Route route) {
@ -676,6 +699,7 @@ public class CiRouteService {
/** /**
* 设置联锁自动触发 * 设置联锁自动触发
*
* @param route * @param route
*/ */
public void setCIAutoTrigger(Route route) { public void setCIAutoTrigger(Route route) {
@ -690,6 +714,7 @@ public class CiRouteService {
/** /**
* 取消联锁自动触发 * 取消联锁自动触发
*
* @param route * @param route
*/ */
public void cancelCIAutoTrigger(Route route) { public void cancelCIAutoTrigger(Route route) {

View File

@ -589,6 +589,8 @@ public class CommandBO {
// 存在锁闭进路获取进路末端 // 存在锁闭进路获取进路末端
if (signal != null && signal.getLockedRoute() != null) { if (signal != null && signal.getLockedRoute() != null) {
nextSection = signal.getLockedRoute().getDestination().getSection(); nextSection = signal.getLockedRoute().getDestination().getSection();
} else if (nextSection.isRouteLock()) { // 如果当前区段进路锁闭
nextSection = nextSection.getRoute().getDestination().getSection();
} else if (nextSection.isSwitchTrack()) { // 是邻近岔道 } else if (nextSection.isSwitchTrack()) { // 是邻近岔道
nextSection = nextSection.getNextRunningSectionOf(isRight); nextSection = nextSection.getNextRunningSectionOf(isRight);
} else { } else {
@ -624,9 +626,10 @@ public class CommandBO {
@Override @Override
public Step execute(Simulation simulation, CommandBO command) { public Step execute(Simulation simulation, CommandBO command) {
SimulationMember targetMember = command.getTargetMember(); SimulationMember targetMember = command.getTargetMember();
VirtualRealityTrain train = (VirtualRealityTrain) targetMember.getDevice();
targetMember.setCommand(null); targetMember.setCommand(null);
// 设置目标位置 // 设置目标位置
return buildDriveStep(null); return buildDriveStep(train.getHeadPosition());
} }
}; };

View File

@ -822,6 +822,24 @@ public class Section extends DelayUnlockDevice {
return atpSectionList; return atpSectionList;
} }
/**
* isSwitchSingleHandle 为TRUE的情况下获取区段列表
*
* @return 区段列表
*/
public List<Section> getSwitchAxleSectionsBySwitchPositionBySwitchSingleHandle() {
List<Section> atpSectionList = new ArrayList<>();
Section parent = this.getParent();
List<Switch> relSwitchList = parent.getRelSwitchList();
// 反位情况下
if (relSwitchList.stream().anyMatch(Switch::isPosR)) {
relSwitchList.stream().filter(Switch::isPosR).forEach(relSwitch -> atpSectionList.addAll(relSwitch.getSectionsByPosition()));
} else {
relSwitchList.forEach(relSwitch -> atpSectionList.addAll(relSwitch.getSectionsByPosition()));
}
return atpSectionList;
}
/** /**
* 判定为非通信车占用 * 判定为非通信车占用
* *