每次开始触发办理进路时设置开放信号显示
This commit is contained in:
parent
4073382b85
commit
112ab6cbab
@ -1,318 +1,319 @@
|
||||
package club.joylink.rtss.simulation.cbtc.ATS.service;
|
||||
|
||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||
import club.joylink.rtss.simulation.cbtc.ATS.data.AtsAlarm;
|
||||
import club.joylink.rtss.simulation.cbtc.CI.CiApiService;
|
||||
import club.joylink.rtss.simulation.cbtc.CI.device.CiRouteService;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Cycle;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Route;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Signal;
|
||||
import club.joylink.rtss.simulation.cbtc.data.status.RouteStatus;
|
||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
|
||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
|
||||
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||
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.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class AtsRouteService {
|
||||
|
||||
@Autowired
|
||||
private CiRouteService routeService;
|
||||
|
||||
@Autowired
|
||||
private CiApiService ciApiService;
|
||||
|
||||
/**
|
||||
* 进路收人工控
|
||||
*
|
||||
* @param simulation
|
||||
* @param signalCode
|
||||
* @param routeCodeList
|
||||
*/
|
||||
public void setRouteHumanControl(Simulation simulation, String signalCode, List<String> routeCodeList) {
|
||||
if (!CollectionUtils.isEmpty(routeCodeList)) {
|
||||
routeCodeList.forEach(routeCode -> {
|
||||
Route route = simulation.getRepository().getByCode(routeCode, Route.class);
|
||||
route.setAtsControl(false);
|
||||
});
|
||||
} else if (StringUtils.hasText(signalCode)) {
|
||||
Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class);
|
||||
List<Route> routeList = signal.getRouteList();
|
||||
if (!CollectionUtils.isEmpty(routeList)) {
|
||||
routeList.forEach(route -> route.setAtsControl(false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 进路交自动控
|
||||
*/
|
||||
public void setRouteAtsControl(Simulation simulation, String signalCode,
|
||||
List<String> routeCodeList, List<Boolean> checkConflictList) {
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
if (!CollectionUtils.isEmpty(routeCodeList)) {
|
||||
if (!CollectionUtils.isEmpty(checkConflictList)) {
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(routeCodeList.size() == checkConflictList.size(),
|
||||
String.format("进路数和是否检查冲突数量不一致:[%s], [%s]",
|
||||
String.join(",", routeCodeList),
|
||||
String.join(",", checkConflictList.stream().map(String::valueOf).collect(Collectors.toList()))));
|
||||
}
|
||||
List<Route> routes = routeCodeList.stream().map(routeCode -> repository.getByCode(routeCode, Route.class)).collect(Collectors.toList());
|
||||
if (repository.getConfig().isSignalHumanControlBeforeSetAtsControlOrCIAutoTrigger()) {
|
||||
routes.stream()
|
||||
.map(Route::getStart)
|
||||
.distinct()
|
||||
.forEach(signal ->
|
||||
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED
|
||||
.assertNotTrue(signal.isCiControl(),
|
||||
String.format("信号机[%s]需处于人工控状态", signal.getCode())));
|
||||
}
|
||||
if (CollectionUtils.isEmpty(checkConflictList)) {
|
||||
routes.forEach(route -> route.setAtsControl(true));
|
||||
} else {
|
||||
for (int i = 0; i < routeCodeList.size(); i++) {
|
||||
Route route = repository.getByCode(routeCodeList.get(i), Route.class);
|
||||
boolean checkConflict = checkConflictList.get(i);
|
||||
route.setAtsControl(true);
|
||||
route.setCheckConflict(checkConflict);
|
||||
}
|
||||
}
|
||||
} else if (StringUtils.hasText(signalCode)) {
|
||||
Signal signal = repository.getByCode(signalCode, Signal.class);
|
||||
if (repository.getConfig().isSignalHumanControlBeforeSetAtsControlOrCIAutoTrigger()) {
|
||||
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(signal.isCiControl(), String.format("信号机[%s]需处于人工控状态", signal.getCode()));
|
||||
}
|
||||
List<Route> routeList = signal.getRouteList();
|
||||
if (!CollectionUtils.isEmpty(routeList)) {
|
||||
routeList.forEach(route -> route.setAtsControl(true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询进路状态/模式
|
||||
*/
|
||||
public List<RouteStatus> findRoutesStatus(Simulation simulation, String signalCode) {
|
||||
Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class);
|
||||
List<Route> routeList = signal.getRouteList();
|
||||
return routeList.stream().map(RouteStatus::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置联锁自动进路
|
||||
*/
|
||||
public void setCiAuto(Simulation simulation, String signalCode) {
|
||||
Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class);
|
||||
if (simulation.getRepository().getConfig().isSetRouteBeforeSetFlt()) {
|
||||
Route lockedRoute = signal.getLockedRoute();
|
||||
if (lockedRoute == null) {
|
||||
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
|
||||
String.format("信号机[%s(%s)]没有已锁闭进路,不能设置联锁自动进路", signal.getName(), signal.getCode()));
|
||||
}
|
||||
if (!lockedRoute.isFlt()) {
|
||||
throw new SimulationException(SimulationExceptionType.Unsupported_Operation,
|
||||
String.format("进路[%s]不能设置车队进路", lockedRoute.getCode()));
|
||||
}
|
||||
if (lockedRoute.isCiControl()) {
|
||||
throw new SimulationException(SimulationExceptionType.Operation_Conflict,
|
||||
String.format("进路[%s(%s)]自动追踪已开启,不能设置联锁自动进路", lockedRoute.getName(), lockedRoute.getCode()));
|
||||
}
|
||||
lockedRoute.setFleetMode(true);
|
||||
} else {
|
||||
List<Route> routeList = signal.getRouteList();
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(routeList, signal.debugStr() + "不是进路始端信号机");
|
||||
// 筛选最适合的进路,筛选逻辑与办理引导时筛选逻辑类似
|
||||
List<Route> fltRoutes = routeList.stream().filter(Route::isFlt).collect(Collectors.toList());
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(fltRoutes, signal.debugStr() + "下没有可设置的车队进路");
|
||||
List<Route> collect = fltRoutes.stream()
|
||||
.filter(r -> !r.isTurnBack() && CollectionUtils.isEmpty(r.getSwitchList()))
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(collect)) {
|
||||
collect = fltRoutes.stream().filter(r -> !r.isTurnBack()).collect(Collectors.toList());
|
||||
}
|
||||
if (CollectionUtils.isEmpty(collect)) {
|
||||
collect = fltRoutes;
|
||||
}
|
||||
Route route = collect.get(0);
|
||||
Route.CheckFailMessage message = routeService.setRoute(simulation, route);
|
||||
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNull(message, route.debugStr() + "无法办理");
|
||||
route.setFleetMode(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消联锁自动进路
|
||||
*/
|
||||
public void cancelCiAuto(Simulation simulation, String signalCode) {
|
||||
Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class);
|
||||
Route lockedRoute = signal.getLockedRoute();
|
||||
if (Objects.isNull(lockedRoute)) {
|
||||
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
|
||||
String.format("信号机[%s(%s)]没有已锁闭进路,不能执行取消联锁自动进路", signal.getName(), signal.getCode()));
|
||||
}
|
||||
if (!lockedRoute.isFleetMode()) {
|
||||
throw new SimulationException(SimulationExceptionType.Operation_Repetition, String.format("信号机[%s(%s)]没有打开连锁自动进路,不能取消联锁自动进路", signal.getName(), signal.getCode()));
|
||||
}
|
||||
lockedRoute.setFleetMode(false);
|
||||
if (simulation.getRepository().getConfig().isCancelRouteWhenCancelFlt()) {
|
||||
routeService.unlockRoute(simulation, lockedRoute);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置联锁自动触发
|
||||
*/
|
||||
public void setCiAutoTrigger(Simulation simulation, String signalCode, List<String> routeCodeList) {
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
List<Route> routeList;
|
||||
if (StringUtils.hasText(signalCode)) {
|
||||
Signal signal = repository.getByCode(signalCode, Signal.class);
|
||||
if (repository.getConfig().isSignalHumanControlBeforeSetAtsControlOrCIAutoTrigger()) {
|
||||
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(signal.isAtsControl(), String.format("信号机[%s]需处于人工控", signal.getCode()));
|
||||
}
|
||||
routeList = signal.getRouteList();
|
||||
} else {
|
||||
routeList = routeCodeList.stream()
|
||||
.map(code -> repository.getByCode(code, Route.class))
|
||||
.collect(Collectors.toList());
|
||||
if (repository.getConfig().isSignalHumanControlBeforeSetAtsControlOrCIAutoTrigger()) {
|
||||
routeList.stream()
|
||||
.map(Route::getStart)
|
||||
.distinct()
|
||||
.forEach(signal ->
|
||||
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED
|
||||
.assertNotTrue(signal.isAtsControl(),
|
||||
String.format("信号机[%s]需处于人工控", signal.getCode())));
|
||||
}
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(routeList)) {
|
||||
routeList.stream().filter(Route::isArs).forEach(route -> {
|
||||
if (route.isFleetMode()) {
|
||||
throw new SimulationException(SimulationExceptionType.Operation_Conflict,
|
||||
String.format("进路[%s(%s)]自动通过已开启,不能设置自动追踪", route.getName(), route.getCode()));
|
||||
}
|
||||
// if (route.isCiControl()) {
|
||||
// throw new SimulationException(SimulationExceptionType.Operation_Repetition, String.format("进路[%s(%s)]自动追踪/连锁自动触发已开启,无需重复设置", route.getName(), route.getCode()));
|
||||
// }
|
||||
});
|
||||
for (Route route : routeList) {
|
||||
// route.setAtsControl(false);
|
||||
if (route.isArs())
|
||||
route.setCiControl(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消联锁自动触发
|
||||
*/
|
||||
public void cancelCiAutoTrigger(Simulation simulation, String signalCode, List<String> routeCodes) {
|
||||
List<Route> routeList;
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
if (StringUtils.hasText(signalCode)) {
|
||||
Signal signal = repository.getByCode(signalCode, Signal.class);
|
||||
routeList = signal.getRouteList();
|
||||
} else {
|
||||
routeList = routeCodes.stream()
|
||||
.map(code -> repository.getByCode(code, Route.class))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(routeList)) {
|
||||
for (Route route : routeList) {
|
||||
if (route.isCiControl()) {
|
||||
route.setCiControl(false);
|
||||
route.setAtsControl(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置自动折返进路
|
||||
*
|
||||
* @param simulation
|
||||
* @param cycleCode
|
||||
*/
|
||||
public void setAutoTurnBack(Simulation simulation, String cycleCode) {
|
||||
Cycle cycle = simulation.getRepository().getByCode(cycleCode, Cycle.class);
|
||||
cycle.setSetUp(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消自动折返进路
|
||||
*/
|
||||
public void cancelAutoTurnBack(Simulation simulation, String cycleCode) {
|
||||
Cycle cycle = simulation.getRepository().getByCode(cycleCode, Cycle.class);
|
||||
cycle.setSetUp(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 总取消
|
||||
*/
|
||||
public void totalCancel(Simulation simulation, String signalCode) {
|
||||
// todo 总取消操作有很多种操作方式,对应不同的按钮,此处都用信号机编号可能不妥
|
||||
Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class);
|
||||
Route lockedRoute = signal.getLockedRoute();
|
||||
if (lockedRoute == null) {
|
||||
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
|
||||
String.format("信号机[%s(%s)]没有已锁闭进路,无需取消进路", signal.getName(), signal.getCode()));
|
||||
}
|
||||
if (!signal.isApproachLock()) { //当接近区段未被占用
|
||||
this.cancelRoute(simulation, signalCode);
|
||||
} else {
|
||||
this.routeService.unlockRoute(simulation, lockedRoute);
|
||||
this.ciApiService.cancelFleetRoute(simulation, lockedRoute.getCode());
|
||||
// if (signal.isGuideAspect()) { //如果引导信号开启中
|
||||
// this.ciApiService.closeGuideSignal(simulation, signalCode);
|
||||
// } else if (signal.isClose()) { //如果信号灯关了
|
||||
// } else {
|
||||
// this.ciApiService.closeSignal(simulation, signalCode);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
public void cancelRoute(Simulation simulation, String signalCode) {
|
||||
Route route = this.ciApiService.findLockedRouteByStartSignal(simulation, signalCode);
|
||||
if (Objects.nonNull(route)) {
|
||||
BusinessExceptionAssertEnum.OPERATION_FAIL.assertNotTrue(
|
||||
route.isApproachLock(), "进路接近锁闭,无法取消");
|
||||
BusinessExceptionAssertEnum.OPERATION_FAIL.assertNotTrue(
|
||||
route.getStart().isGuideAspect(), "引导进路,需要人解进路");
|
||||
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(route.isFleetMode(),
|
||||
String.format("进路[%s]已开启自动通过进路,无法取消", route.debugStr()));
|
||||
this.ciApiService.unlockRoute(simulation, route.getCode());
|
||||
}
|
||||
}
|
||||
|
||||
public void setOverlap(Simulation simulation, String signalCode, String overlapCode) {
|
||||
if (signalCode == null || overlapCode == null) {
|
||||
throw new SimulationException(SimulationExceptionType.Illegal_Argument);
|
||||
}
|
||||
this.ciApiService.setOverlap(simulation, signalCode, overlapCode);
|
||||
}
|
||||
|
||||
public void conflictRouteSetConfirm(Simulation simulation, SimulationMember member, String routeCode, int way) {
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(
|
||||
Route.Conflict_Handle_Way_1 == way || Route.Conflict_Handle_Way_2 == way
|
||||
);
|
||||
Route route = simulation.getRepository().getByCode(routeCode, Route.class);
|
||||
AtsAlarm conflictAlarm = route.getConflictAlarm();
|
||||
if (conflictAlarm != null) {
|
||||
LocalDateTime systemTime = simulation.getCorrectSystemTime();
|
||||
conflictAlarm.confirm(systemTime, member, way);
|
||||
conflictAlarm.recover(systemTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
package club.joylink.rtss.simulation.cbtc.ATS.service;
|
||||
|
||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||
import club.joylink.rtss.simulation.cbtc.ATS.data.AtsAlarm;
|
||||
import club.joylink.rtss.simulation.cbtc.CI.CiApiService;
|
||||
import club.joylink.rtss.simulation.cbtc.CI.device.CiRouteService;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Cycle;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Route;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Signal;
|
||||
import club.joylink.rtss.simulation.cbtc.data.status.RouteStatus;
|
||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
|
||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
|
||||
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||
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.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class AtsRouteService {
|
||||
|
||||
@Autowired
|
||||
private CiRouteService routeService;
|
||||
|
||||
@Autowired
|
||||
private CiApiService ciApiService;
|
||||
|
||||
/**
|
||||
* 进路收人工控
|
||||
*
|
||||
* @param simulation
|
||||
* @param signalCode
|
||||
* @param routeCodeList
|
||||
*/
|
||||
public void setRouteHumanControl(Simulation simulation, String signalCode, List<String> routeCodeList) {
|
||||
if (!CollectionUtils.isEmpty(routeCodeList)) {
|
||||
routeCodeList.forEach(routeCode -> {
|
||||
Route route = simulation.getRepository().getByCode(routeCode, Route.class);
|
||||
route.setAtsControl(false);
|
||||
});
|
||||
} else if (StringUtils.hasText(signalCode)) {
|
||||
Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class);
|
||||
List<Route> routeList = signal.getRouteList();
|
||||
if (!CollectionUtils.isEmpty(routeList)) {
|
||||
routeList.forEach(route -> route.setAtsControl(false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 进路交自动控
|
||||
*/
|
||||
public void setRouteAtsControl(Simulation simulation, String signalCode,
|
||||
List<String> routeCodeList, List<Boolean> checkConflictList) {
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
if (!CollectionUtils.isEmpty(routeCodeList)) {
|
||||
if (!CollectionUtils.isEmpty(checkConflictList)) {
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(routeCodeList.size() == checkConflictList.size(),
|
||||
String.format("进路数和是否检查冲突数量不一致:[%s], [%s]",
|
||||
String.join(",", routeCodeList),
|
||||
String.join(",", checkConflictList.stream().map(String::valueOf).collect(Collectors.toList()))));
|
||||
}
|
||||
List<Route> routes = routeCodeList.stream().map(routeCode -> repository.getByCode(routeCode, Route.class)).collect(Collectors.toList());
|
||||
if (repository.getConfig().isSignalHumanControlBeforeSetAtsControlOrCIAutoTrigger()) {
|
||||
routes.stream()
|
||||
.map(Route::getStart)
|
||||
.distinct()
|
||||
.forEach(signal ->
|
||||
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED
|
||||
.assertNotTrue(signal.isCiControl(),
|
||||
String.format("信号机[%s]需处于人工控状态", signal.getCode())));
|
||||
}
|
||||
if (CollectionUtils.isEmpty(checkConflictList)) {
|
||||
routes.forEach(route -> route.setAtsControl(true));
|
||||
} else {
|
||||
for (int i = 0; i < routeCodeList.size(); i++) {
|
||||
Route route = repository.getByCode(routeCodeList.get(i), Route.class);
|
||||
boolean checkConflict = checkConflictList.get(i);
|
||||
route.setAtsControl(true);
|
||||
route.setCheckConflict(checkConflict);
|
||||
}
|
||||
}
|
||||
} else if (StringUtils.hasText(signalCode)) {
|
||||
Signal signal = repository.getByCode(signalCode, Signal.class);
|
||||
if (repository.getConfig().isSignalHumanControlBeforeSetAtsControlOrCIAutoTrigger()) {
|
||||
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(signal.isCiControl(), String.format("信号机[%s]需处于人工控状态", signal.getCode()));
|
||||
}
|
||||
List<Route> routeList = signal.getRouteList();
|
||||
if (!CollectionUtils.isEmpty(routeList)) {
|
||||
routeList.forEach(route -> route.setAtsControl(true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询进路状态/模式
|
||||
*/
|
||||
public List<RouteStatus> findRoutesStatus(Simulation simulation, String signalCode) {
|
||||
Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class);
|
||||
List<Route> routeList = signal.getRouteList();
|
||||
return routeList.stream().map(RouteStatus::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置联锁自动进路
|
||||
*/
|
||||
public void setCiAuto(Simulation simulation, String signalCode) {
|
||||
Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class);
|
||||
if (simulation.getRepository().getConfig().isSetRouteBeforeSetFlt()) {
|
||||
Route lockedRoute = signal.getLockedRoute();
|
||||
if (lockedRoute == null) {
|
||||
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
|
||||
String.format("信号机[%s(%s)]没有已锁闭进路,不能设置联锁自动进路", signal.getName(), signal.getCode()));
|
||||
}
|
||||
if (!lockedRoute.isFlt()) {
|
||||
throw new SimulationException(SimulationExceptionType.Unsupported_Operation,
|
||||
String.format("进路[%s]不能设置车队进路", lockedRoute.getCode()));
|
||||
}
|
||||
if (lockedRoute.isCiControl()) {
|
||||
throw new SimulationException(SimulationExceptionType.Operation_Conflict,
|
||||
String.format("进路[%s(%s)]自动追踪已开启,不能设置联锁自动进路", lockedRoute.getName(), lockedRoute.getCode()));
|
||||
}
|
||||
lockedRoute.setFleetMode(true);
|
||||
} else {
|
||||
List<Route> routeList = signal.getRouteList();
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(routeList, signal.debugStr() + "不是进路始端信号机");
|
||||
// 筛选最适合的进路,筛选逻辑与办理引导时筛选逻辑类似
|
||||
List<Route> fltRoutes = routeList.stream().filter(Route::isFlt).collect(Collectors.toList());
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(fltRoutes, signal.debugStr() + "下没有可设置的车队进路");
|
||||
List<Route> collect = fltRoutes.stream()
|
||||
.filter(r -> !r.isTurnBack() && CollectionUtils.isEmpty(r.getSwitchList()))
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(collect)) {
|
||||
collect = fltRoutes.stream().filter(r -> !r.isTurnBack()).collect(Collectors.toList());
|
||||
}
|
||||
if (CollectionUtils.isEmpty(collect)) {
|
||||
collect = fltRoutes;
|
||||
}
|
||||
Route route = collect.get(0);
|
||||
route.setSettedAspect(route.getAspect());
|
||||
Route.CheckFailMessage message = routeService.setRoute(simulation, route);
|
||||
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNull(message, route.debugStr() + "无法办理");
|
||||
route.setFleetMode(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消联锁自动进路
|
||||
*/
|
||||
public void cancelCiAuto(Simulation simulation, String signalCode) {
|
||||
Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class);
|
||||
Route lockedRoute = signal.getLockedRoute();
|
||||
if (Objects.isNull(lockedRoute)) {
|
||||
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
|
||||
String.format("信号机[%s(%s)]没有已锁闭进路,不能执行取消联锁自动进路", signal.getName(), signal.getCode()));
|
||||
}
|
||||
if (!lockedRoute.isFleetMode()) {
|
||||
throw new SimulationException(SimulationExceptionType.Operation_Repetition, String.format("信号机[%s(%s)]没有打开连锁自动进路,不能取消联锁自动进路", signal.getName(), signal.getCode()));
|
||||
}
|
||||
lockedRoute.setFleetMode(false);
|
||||
if (simulation.getRepository().getConfig().isCancelRouteWhenCancelFlt()) {
|
||||
routeService.unlockRoute(simulation, lockedRoute);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置联锁自动触发
|
||||
*/
|
||||
public void setCiAutoTrigger(Simulation simulation, String signalCode, List<String> routeCodeList) {
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
List<Route> routeList;
|
||||
if (StringUtils.hasText(signalCode)) {
|
||||
Signal signal = repository.getByCode(signalCode, Signal.class);
|
||||
if (repository.getConfig().isSignalHumanControlBeforeSetAtsControlOrCIAutoTrigger()) {
|
||||
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(signal.isAtsControl(), String.format("信号机[%s]需处于人工控", signal.getCode()));
|
||||
}
|
||||
routeList = signal.getRouteList();
|
||||
} else {
|
||||
routeList = routeCodeList.stream()
|
||||
.map(code -> repository.getByCode(code, Route.class))
|
||||
.collect(Collectors.toList());
|
||||
if (repository.getConfig().isSignalHumanControlBeforeSetAtsControlOrCIAutoTrigger()) {
|
||||
routeList.stream()
|
||||
.map(Route::getStart)
|
||||
.distinct()
|
||||
.forEach(signal ->
|
||||
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED
|
||||
.assertNotTrue(signal.isAtsControl(),
|
||||
String.format("信号机[%s]需处于人工控", signal.getCode())));
|
||||
}
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(routeList)) {
|
||||
routeList.stream().filter(Route::isArs).forEach(route -> {
|
||||
if (route.isFleetMode()) {
|
||||
throw new SimulationException(SimulationExceptionType.Operation_Conflict,
|
||||
String.format("进路[%s(%s)]自动通过已开启,不能设置自动追踪", route.getName(), route.getCode()));
|
||||
}
|
||||
// if (route.isCiControl()) {
|
||||
// throw new SimulationException(SimulationExceptionType.Operation_Repetition, String.format("进路[%s(%s)]自动追踪/连锁自动触发已开启,无需重复设置", route.getName(), route.getCode()));
|
||||
// }
|
||||
});
|
||||
for (Route route : routeList) {
|
||||
// route.setAtsControl(false);
|
||||
if (route.isArs())
|
||||
route.setCiControl(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消联锁自动触发
|
||||
*/
|
||||
public void cancelCiAutoTrigger(Simulation simulation, String signalCode, List<String> routeCodes) {
|
||||
List<Route> routeList;
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
if (StringUtils.hasText(signalCode)) {
|
||||
Signal signal = repository.getByCode(signalCode, Signal.class);
|
||||
routeList = signal.getRouteList();
|
||||
} else {
|
||||
routeList = routeCodes.stream()
|
||||
.map(code -> repository.getByCode(code, Route.class))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(routeList)) {
|
||||
for (Route route : routeList) {
|
||||
if (route.isCiControl()) {
|
||||
route.setCiControl(false);
|
||||
route.setAtsControl(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置自动折返进路
|
||||
*
|
||||
* @param simulation
|
||||
* @param cycleCode
|
||||
*/
|
||||
public void setAutoTurnBack(Simulation simulation, String cycleCode) {
|
||||
Cycle cycle = simulation.getRepository().getByCode(cycleCode, Cycle.class);
|
||||
cycle.setSetUp(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消自动折返进路
|
||||
*/
|
||||
public void cancelAutoTurnBack(Simulation simulation, String cycleCode) {
|
||||
Cycle cycle = simulation.getRepository().getByCode(cycleCode, Cycle.class);
|
||||
cycle.setSetUp(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 总取消
|
||||
*/
|
||||
public void totalCancel(Simulation simulation, String signalCode) {
|
||||
// todo 总取消操作有很多种操作方式,对应不同的按钮,此处都用信号机编号可能不妥
|
||||
Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class);
|
||||
Route lockedRoute = signal.getLockedRoute();
|
||||
if (lockedRoute == null) {
|
||||
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
|
||||
String.format("信号机[%s(%s)]没有已锁闭进路,无需取消进路", signal.getName(), signal.getCode()));
|
||||
}
|
||||
if (!signal.isApproachLock()) { //当接近区段未被占用
|
||||
this.cancelRoute(simulation, signalCode);
|
||||
} else {
|
||||
this.routeService.unlockRoute(simulation, lockedRoute);
|
||||
this.ciApiService.cancelFleetRoute(simulation, lockedRoute.getCode());
|
||||
// if (signal.isGuideAspect()) { //如果引导信号开启中
|
||||
// this.ciApiService.closeGuideSignal(simulation, signalCode);
|
||||
// } else if (signal.isClose()) { //如果信号灯关了
|
||||
// } else {
|
||||
// this.ciApiService.closeSignal(simulation, signalCode);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
public void cancelRoute(Simulation simulation, String signalCode) {
|
||||
Route route = this.ciApiService.findLockedRouteByStartSignal(simulation, signalCode);
|
||||
if (Objects.nonNull(route)) {
|
||||
BusinessExceptionAssertEnum.OPERATION_FAIL.assertNotTrue(
|
||||
route.isApproachLock(), "进路接近锁闭,无法取消");
|
||||
BusinessExceptionAssertEnum.OPERATION_FAIL.assertNotTrue(
|
||||
route.getStart().isGuideAspect(), "引导进路,需要人解进路");
|
||||
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(route.isFleetMode(),
|
||||
String.format("进路[%s]已开启自动通过进路,无法取消", route.debugStr()));
|
||||
this.ciApiService.unlockRoute(simulation, route.getCode());
|
||||
}
|
||||
}
|
||||
|
||||
public void setOverlap(Simulation simulation, String signalCode, String overlapCode) {
|
||||
if (signalCode == null || overlapCode == null) {
|
||||
throw new SimulationException(SimulationExceptionType.Illegal_Argument);
|
||||
}
|
||||
this.ciApiService.setOverlap(simulation, signalCode, overlapCode);
|
||||
}
|
||||
|
||||
public void conflictRouteSetConfirm(Simulation simulation, SimulationMember member, String routeCode, int way) {
|
||||
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertTrue(
|
||||
Route.Conflict_Handle_Way_1 == way || Route.Conflict_Handle_Way_2 == way
|
||||
);
|
||||
Route route = simulation.getRepository().getByCode(routeCode, Route.class);
|
||||
AtsAlarm conflictAlarm = route.getConflictAlarm();
|
||||
if (conflictAlarm != null) {
|
||||
LocalDateTime systemTime = simulation.getCorrectSystemTime();
|
||||
conflictAlarm.confirm(systemTime, member, way);
|
||||
conflictAlarm.recover(systemTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -33,7 +33,6 @@ public class CiLogic {
|
||||
private StationDirectionService stationDirectionService;
|
||||
|
||||
public void run(Simulation simulation) {
|
||||
|
||||
// 采集真实设备状态
|
||||
deviceStatusCollector.collect(simulation);
|
||||
// 信号机监控控制
|
||||
@ -119,6 +118,7 @@ public class CiLogic {
|
||||
MapConfig config = simulation.getRepository().getConfig();
|
||||
if (route.isCiControl()) { // 进路联锁自动触发
|
||||
if (!route.isLock() && !route.isSetting() && ciService.isCiRouteTrigger(simulation, route)) {
|
||||
route.setSettedAspect(route.getAspect());
|
||||
routeService.setRoute(simulation, route);
|
||||
}
|
||||
} else if (route.isFleetMode()) { // 联锁自动进路
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,177 +1,191 @@
|
||||
package club.joylink.rtss.simulation.cbtc.data.storage.device;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.DelayUnlockDevice;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Route;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Section;
|
||||
import club.joylink.rtss.util.jsonSerialize.Boolean2NumDeserializer;
|
||||
import club.joylink.rtss.util.jsonSerialize.Boolean2NumSerializer;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public class StorageRoute extends StorageDevice {
|
||||
|
||||
/**
|
||||
* 是否CBTC模式
|
||||
*/
|
||||
@JsonSerialize(using = Boolean2NumSerializer.class)
|
||||
@JsonDeserialize(using = Boolean2NumDeserializer.class)
|
||||
private Boolean cbtcMode;
|
||||
|
||||
/**
|
||||
* ats自动控制
|
||||
*/
|
||||
@JsonSerialize(using = Boolean2NumSerializer.class)
|
||||
@JsonDeserialize(using = Boolean2NumDeserializer.class)
|
||||
private Boolean atsControl;
|
||||
|
||||
/**
|
||||
* 连续通过进路模式(联锁自动进路)开启
|
||||
*/
|
||||
@JsonSerialize(using = Boolean2NumSerializer.class)
|
||||
@JsonDeserialize(using = Boolean2NumDeserializer.class)
|
||||
private Boolean fleetMode;
|
||||
|
||||
/**
|
||||
* 自动追踪/联锁自动触发模式开启
|
||||
*/
|
||||
@JsonSerialize(using = Boolean2NumSerializer.class)
|
||||
@JsonDeserialize(using = Boolean2NumDeserializer.class)
|
||||
private Boolean ciControl;
|
||||
|
||||
/**
|
||||
* 进路是否排列中
|
||||
*/
|
||||
@JsonSerialize(using = Boolean2NumSerializer.class)
|
||||
@JsonDeserialize(using = Boolean2NumDeserializer.class)
|
||||
private Boolean setting;
|
||||
|
||||
private LocalDateTime settingStartTime;
|
||||
|
||||
/**
|
||||
* 是否引导进路排列
|
||||
*/
|
||||
@JsonSerialize(using = Boolean2NumSerializer.class)
|
||||
@JsonDeserialize(using = Boolean2NumDeserializer.class)
|
||||
private Boolean settingGuide;
|
||||
|
||||
/**
|
||||
* 进路是否锁闭
|
||||
*/
|
||||
@JsonSerialize(using = Boolean2NumSerializer.class)
|
||||
@JsonDeserialize(using = Boolean2NumDeserializer.class)
|
||||
private Boolean lock;
|
||||
|
||||
/** 进路延时解锁设备 */
|
||||
private String delayUnlockDevice;
|
||||
|
||||
/**
|
||||
* 是否正常解锁中
|
||||
*/
|
||||
@JsonSerialize(using = Boolean2NumSerializer.class)
|
||||
@JsonDeserialize(using = Boolean2NumDeserializer.class)
|
||||
private Boolean normalUnlock;
|
||||
|
||||
private String unlockedSection;
|
||||
|
||||
// public StorageRoute(Route route) {
|
||||
// super(route.getCode());
|
||||
// cbtcMode = route.isCbtcMode();
|
||||
// turnBackMode = route.isTurnBackMode();
|
||||
// atsControl = route.isAtsControl();
|
||||
// fleetMode = route.isFleetMode();
|
||||
// ciControl = route.isCiControl();
|
||||
// setting = route.isSetting();
|
||||
// settingGuide = route.isSettingGuide();
|
||||
// lock = route.isLock();
|
||||
// canceling = route.isCanceling();
|
||||
// normalUnlock = route.isNormalUnlock();
|
||||
// }
|
||||
|
||||
public StorageRoute(String code) {
|
||||
super(code);
|
||||
}
|
||||
|
||||
public static StorageRoute convert2Storage(Route route) {
|
||||
StorageRoute storageRoute = new StorageRoute(route.getCode());
|
||||
if (storageRoute.convert(route)) {
|
||||
return storageRoute;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean convert(MapElement element) {
|
||||
boolean change = false;
|
||||
Route route = (Route) element;
|
||||
if (!route.isAtsControl()) {
|
||||
change = true;
|
||||
this.setAtsControl(route.isAtsControl());
|
||||
}
|
||||
if (route.isFleetMode()) {
|
||||
change = true;
|
||||
this.setFleetMode(route.isFleetMode());
|
||||
}
|
||||
if (route.isCiControl()) {
|
||||
change = true;
|
||||
this.setCiControl(route.isCiControl());
|
||||
}
|
||||
if (route.isSetting()) {
|
||||
change = true;
|
||||
this.setSetting(route.isSetting());
|
||||
this.setSettingStartTime(route.getSettingStartTime());
|
||||
}
|
||||
if (route.isGuideSetting()) {
|
||||
change = true;
|
||||
this.setSettingGuide(route.isGuideSetting());
|
||||
}
|
||||
if (route.isLock()) {
|
||||
change = true;
|
||||
this.setLock(route.isLock());
|
||||
}
|
||||
if (route.getDelayUnlockDevice() != null) {
|
||||
change = true;
|
||||
this.setDelayUnlockDevice(route.getDelayUnlockDevice().getCode());
|
||||
}
|
||||
if (route.isNormalUnlock()) {
|
||||
change = true;
|
||||
this.setNormalUnlock(route.isNormalUnlock());
|
||||
}
|
||||
if (Objects.nonNull(route.getUnlockedSection())) {
|
||||
change = true;
|
||||
this.setUnlockedSection(route.getUnlockedSection().getCode());
|
||||
}
|
||||
return change;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recover2Simulation(MapElement element, Simulation simulation, SimulationDataRepository repository) {
|
||||
Route route = (Route) element;
|
||||
route.setAtsControl(atsControl != null ? atsControl : true);
|
||||
route.setFleetMode(fleetMode != null ? fleetMode : false);
|
||||
route.setCiControl(ciControl != null ? ciControl : false);
|
||||
route.setSetting(setting != null? setting : false);
|
||||
route.setSettingStartTime(this.settingStartTime);
|
||||
route.setGuideSetting(settingGuide != null? settingGuide : false);
|
||||
route.setLock(lock != null ? lock : false);
|
||||
if (this.delayUnlockDevice != null) {
|
||||
route.setDelayUnlockDevice((DelayUnlockDevice) repository.getByCode(this.delayUnlockDevice));
|
||||
}
|
||||
route.setNormalUnlock(normalUnlock != null ? normalUnlock : false);
|
||||
if (Objects.nonNull(this.unlockedSection)) {
|
||||
route.setUnlockedSection(repository.getByCode(this.unlockedSection, Section.class));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
package club.joylink.rtss.simulation.cbtc.data.storage.device;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SignalAspect;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.DelayUnlockDevice;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Route;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Section;
|
||||
import club.joylink.rtss.util.jsonSerialize.Boolean2NumDeserializer;
|
||||
import club.joylink.rtss.util.jsonSerialize.Boolean2NumSerializer;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public class StorageRoute extends StorageDevice {
|
||||
|
||||
/**
|
||||
* 是否CBTC模式
|
||||
*/
|
||||
@JsonSerialize(using = Boolean2NumSerializer.class)
|
||||
@JsonDeserialize(using = Boolean2NumDeserializer.class)
|
||||
private Boolean cbtcMode;
|
||||
|
||||
/**
|
||||
* ats自动控制
|
||||
*/
|
||||
@JsonSerialize(using = Boolean2NumSerializer.class)
|
||||
@JsonDeserialize(using = Boolean2NumDeserializer.class)
|
||||
private Boolean atsControl;
|
||||
|
||||
/**
|
||||
* 连续通过进路模式(联锁自动进路)开启
|
||||
*/
|
||||
@JsonSerialize(using = Boolean2NumSerializer.class)
|
||||
@JsonDeserialize(using = Boolean2NumDeserializer.class)
|
||||
private Boolean fleetMode;
|
||||
|
||||
/**
|
||||
* 自动追踪/联锁自动触发模式开启
|
||||
*/
|
||||
@JsonSerialize(using = Boolean2NumSerializer.class)
|
||||
@JsonDeserialize(using = Boolean2NumDeserializer.class)
|
||||
private Boolean ciControl;
|
||||
|
||||
/**
|
||||
* 进路是否排列中
|
||||
*/
|
||||
@JsonSerialize(using = Boolean2NumSerializer.class)
|
||||
@JsonDeserialize(using = Boolean2NumDeserializer.class)
|
||||
private Boolean setting;
|
||||
|
||||
private LocalDateTime settingStartTime;
|
||||
|
||||
/**
|
||||
* 是否引导进路排列
|
||||
*/
|
||||
@JsonSerialize(using = Boolean2NumSerializer.class)
|
||||
@JsonDeserialize(using = Boolean2NumDeserializer.class)
|
||||
private Boolean settingGuide;
|
||||
|
||||
/**
|
||||
* 进路是否锁闭
|
||||
*/
|
||||
@JsonSerialize(using = Boolean2NumSerializer.class)
|
||||
@JsonDeserialize(using = Boolean2NumDeserializer.class)
|
||||
private Boolean lock;
|
||||
|
||||
/** 进路延时解锁设备 */
|
||||
private String delayUnlockDevice;
|
||||
|
||||
/**
|
||||
* 是否正常解锁中
|
||||
*/
|
||||
@JsonSerialize(using = Boolean2NumSerializer.class)
|
||||
@JsonDeserialize(using = Boolean2NumDeserializer.class)
|
||||
private Boolean normalUnlock;
|
||||
|
||||
private String unlockedSection;
|
||||
|
||||
/**
|
||||
* 该进路办理成功后要开放的信号
|
||||
* <p>
|
||||
* 注意:每次开始触发办理进路时设置
|
||||
*/
|
||||
private SignalAspect settedAspect;
|
||||
|
||||
// public StorageRoute(Route route) {
|
||||
// super(route.getCode());
|
||||
// cbtcMode = route.isCbtcMode();
|
||||
// turnBackMode = route.isTurnBackMode();
|
||||
// atsControl = route.isAtsControl();
|
||||
// fleetMode = route.isFleetMode();
|
||||
// ciControl = route.isCiControl();
|
||||
// setting = route.isSetting();
|
||||
// settingGuide = route.isSettingGuide();
|
||||
// lock = route.isLock();
|
||||
// canceling = route.isCanceling();
|
||||
// normalUnlock = route.isNormalUnlock();
|
||||
// }
|
||||
|
||||
public StorageRoute(String code) {
|
||||
super(code);
|
||||
}
|
||||
|
||||
public static StorageRoute convert2Storage(Route route) {
|
||||
StorageRoute storageRoute = new StorageRoute(route.getCode());
|
||||
if (storageRoute.convert(route)) {
|
||||
return storageRoute;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean convert(MapElement element) {
|
||||
boolean change = false;
|
||||
Route route = (Route) element;
|
||||
if (!route.isAtsControl()) {
|
||||
change = true;
|
||||
this.setAtsControl(route.isAtsControl());
|
||||
}
|
||||
if (route.isFleetMode()) {
|
||||
change = true;
|
||||
this.setFleetMode(route.isFleetMode());
|
||||
}
|
||||
if (route.isCiControl()) {
|
||||
change = true;
|
||||
this.setCiControl(route.isCiControl());
|
||||
}
|
||||
if (route.isSetting()) {
|
||||
change = true;
|
||||
this.setSetting(route.isSetting());
|
||||
this.setSettingStartTime(route.getSettingStartTime());
|
||||
}
|
||||
if (route.isGuideSetting()) {
|
||||
change = true;
|
||||
this.setSettingGuide(route.isGuideSetting());
|
||||
}
|
||||
if (route.isLock()) {
|
||||
change = true;
|
||||
this.setLock(route.isLock());
|
||||
}
|
||||
if (route.getDelayUnlockDevice() != null) {
|
||||
change = true;
|
||||
this.setDelayUnlockDevice(route.getDelayUnlockDevice().getCode());
|
||||
}
|
||||
if (route.isNormalUnlock()) {
|
||||
change = true;
|
||||
this.setNormalUnlock(route.isNormalUnlock());
|
||||
}
|
||||
if (Objects.nonNull(route.getUnlockedSection())) {
|
||||
change = true;
|
||||
this.setUnlockedSection(route.getUnlockedSection().getCode());
|
||||
}
|
||||
if (Objects.nonNull(route.getSettedAspect())) {
|
||||
change = true;
|
||||
this.setSettedAspect(route.getSettedAspect());
|
||||
}
|
||||
|
||||
return change;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recover2Simulation(MapElement element, Simulation simulation, SimulationDataRepository repository) {
|
||||
Route route = (Route) element;
|
||||
route.setAtsControl(atsControl != null ? atsControl : true);
|
||||
route.setFleetMode(fleetMode != null ? fleetMode : false);
|
||||
route.setCiControl(ciControl != null ? ciControl : false);
|
||||
route.setSetting(setting != null? setting : false);
|
||||
route.setSettingStartTime(this.settingStartTime);
|
||||
route.setGuideSetting(settingGuide != null? settingGuide : false);
|
||||
route.setLock(lock != null ? lock : false);
|
||||
if (this.delayUnlockDevice != null) {
|
||||
route.setDelayUnlockDevice((DelayUnlockDevice) repository.getByCode(this.delayUnlockDevice));
|
||||
}
|
||||
route.setNormalUnlock(normalUnlock != null ? normalUnlock : false);
|
||||
if (Objects.nonNull(this.unlockedSection)) {
|
||||
route.setUnlockedSection(repository.getByCode(this.unlockedSection, Section.class));
|
||||
}
|
||||
route.setSettedAspect(settedAspect);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,236 +1,237 @@
|
||||
package club.joylink.rtss.simulation.cbtc.depot;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.ATS.tools.TrainOutboundLoadTool;
|
||||
import club.joylink.rtss.simulation.cbtc.CI.device.CiRouteService;
|
||||
import club.joylink.rtss.simulation.cbtc.GroupSimulationService;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.command.CommandBO;
|
||||
import club.joylink.rtss.simulation.cbtc.command.CommandInitiateVO;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SimulationModule;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Route;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Section;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Signal;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Station;
|
||||
import club.joylink.rtss.simulation.cbtc.data.plan.SchedulingTrainPlan;
|
||||
import club.joylink.rtss.simulation.cbtc.data.support.RoutePath;
|
||||
import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
|
||||
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||
import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPService;
|
||||
import lombok.Getter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class DepotService {
|
||||
|
||||
@Autowired
|
||||
private CiRouteService ciRouteService;
|
||||
|
||||
@Autowired
|
||||
private TrainOutboundLoadTool trainOutboundLoadTool;
|
||||
|
||||
@Autowired
|
||||
private GroupSimulationService groupSimulationService;
|
||||
|
||||
@Autowired
|
||||
private ATPService atpService;
|
||||
|
||||
public void loadDepotTrain(Simulation simulation) {
|
||||
if (!simulation.getRepository().getConfig().isHandleDepot()) {
|
||||
return;
|
||||
}
|
||||
Map<Station, List<Section>> parkingTracksMap = simulation.getRepository().getParkingTracksMap();
|
||||
simulation.getRepository().getAllVrTrain().stream()
|
||||
.collect(Collectors.groupingBy(VirtualRealityTrain::getDepotStation))
|
||||
.forEach((station, trainList) -> {
|
||||
List<Section> sections = parkingTracksMap.get(station);
|
||||
// 先加载内侧的停车轨
|
||||
sections.sort(Comparator.comparing(section ->
|
||||
Objects.isNull(section.getLeftSection()) || Objects.isNull(section.getRightSection())));
|
||||
boolean right = sections.get(sections.size() - 1).getLeftSection() == null;
|
||||
for (int i = 0, trainListSize = trainList.size(); i < trainListSize; i++) {
|
||||
VirtualRealityTrain train = trainList.get(i);
|
||||
Section section = sections.get(i);
|
||||
train.initManualTrain(new SectionPosition(section, section.getStopPointByDirection(right)), right);
|
||||
train.parkingAt(section);
|
||||
train.initAsRM();
|
||||
TrainInfo trainInfo = TrainInfo.constructManualTrain(train);
|
||||
trainInfo.tracking(train);
|
||||
simulation.getRepository().addOnlineTrain(train);
|
||||
simulation.getRepository().addTrainInfo(trainInfo);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void addJobs(Simulation simulation) {
|
||||
simulation.addJob(SimulationModule.DEPOT.name(), () -> this.run(simulation), SimulationConstants.DEPOT_LOOP_RATE);
|
||||
}
|
||||
|
||||
private void run(Simulation simulation) {
|
||||
if (!simulation.isPlanRunning()) {
|
||||
return;
|
||||
}
|
||||
if (!simulation.getRepository().getConfig().isHandleDepot()) {
|
||||
trainOutboundLoadTool.loadOutboundTrain(simulation);
|
||||
} else {
|
||||
timeToDeparture(simulation);
|
||||
backToParking(simulation);
|
||||
settingRouteAndMoving(simulation);
|
||||
arriveDestination(simulation);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据时间筛选,从停车轨自动发车
|
||||
*/
|
||||
private void timeToDeparture(Simulation simulation) {
|
||||
LocalDateTime systemTime = simulation.getSystemTime();
|
||||
for (SchedulingTrainPlan schedulingTrainPlan : simulation.getRepository().getSchedulingTrainPlanList()) {
|
||||
if (schedulingTrainPlan.getOutDepotTrip().isDispatched()) {
|
||||
continue;
|
||||
}
|
||||
if (schedulingTrainPlan.getOutDepotTrip().getStartTime().minusMinutes(10).isBefore(systemTime.toLocalTime())) {
|
||||
schedulingTrainPlan.getOutDepotTrip().dispatched();
|
||||
// 保存信息
|
||||
VirtualRealityTrain train = simulation.getRepository().getVRByCode(schedulingTrainPlan.getGroupNumber(), VirtualRealityTrain.class);
|
||||
Section startSection = train.getHeadPosition().getSection();
|
||||
Section endSection = schedulingTrainPlan.getOutDepotTrip().getStartSection();
|
||||
List<RoutePath> routePaths = simulation.getRepository().queryRoutePaths(startSection, endSection);
|
||||
RoutePath routePath = routePaths.get(0);
|
||||
DepotRunningInfo depotRunningInfo = new DepotRunningInfo(endSection, train, routePath, false);
|
||||
simulation.getRepository().getDepotRunningInfoList().add(depotRunningInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 筛选入库
|
||||
*/
|
||||
private void backToParking(Simulation simulation) {
|
||||
for (TrainInfo trainInfo : simulation.getRepository().getTrainInfoMap().values()) {
|
||||
if (trainInfo.isInbound() && trainInfo.isParking()) {
|
||||
VirtualRealityTrain train = simulation.getRepository().getVRByCode(trainInfo.getGroupNumber(), VirtualRealityTrain.class);
|
||||
if (train.getHeadPosition().getSection().isTransferTrack()
|
||||
&& train.getTailPosition().getSection().isTransferTrack()) {
|
||||
if (simulation.getRepository().getDepotRunningInfoList().stream()
|
||||
.anyMatch(depotRunningInfo -> depotRunningInfo.getTrain().equals(train))) {
|
||||
continue;
|
||||
}
|
||||
train.initAsRM();
|
||||
Section startSection = train.getHeadPosition().getSection();
|
||||
Section endSection = null;
|
||||
for (Section section : simulation.getRepository().getParkingTracksMap().get(startSection.getStation())) {
|
||||
if (section.isOccupied()) {
|
||||
continue;
|
||||
}
|
||||
if (section.getLeftSection() == null || section.getRightSection() == null) {
|
||||
endSection = section;
|
||||
} else if (section.getLeftSection().isParkingTrack() && !section.getLeftSection().isOccupied()) {
|
||||
endSection = section.getLeftSection();
|
||||
} else if (section.getRightSection().isParkingTrack() && !section.getRightSection().isOccupied()) {
|
||||
endSection = section.getRightSection();
|
||||
} else {
|
||||
endSection = section;
|
||||
}
|
||||
break;
|
||||
}
|
||||
// train.setTarget(endSection);
|
||||
List<RoutePath> routePaths = simulation.getRepository().queryRoutePaths(startSection, endSection);
|
||||
if (routePaths == null || routePaths.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
RoutePath routePath = routePaths.get(0);
|
||||
DepotRunningInfo depotRunningInfo = new DepotRunningInfo(endSection, train, routePath, true);
|
||||
simulation.getRepository().getDepotRunningInfoList().add(depotRunningInfo);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 列车排进路并运行
|
||||
*/
|
||||
private void settingRouteAndMoving(Simulation simulation) {
|
||||
for (DepotRunningInfo depotRunningInfo : simulation.getRepository().getDepotRunningInfoList()) {
|
||||
Section endSection = depotRunningInfo.getEndSection();
|
||||
SectionPosition position = new SectionPosition(endSection, endSection.getStopPointByDirection(depotRunningInfo.getRight()));
|
||||
depotRunningInfo.getTrain().setRobotTargetPosition(position);
|
||||
if (!depotRunningInfo.getRouteList().isEmpty()) {
|
||||
Route route = depotRunningInfo.getRouteList().get(0);
|
||||
if (route.isLock()) {
|
||||
depotRunningInfo.getRouteList().remove(0);
|
||||
}
|
||||
if (!route.isSetting()) {
|
||||
ciRouteService.setRoute(simulation, route);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断运行列车是否到达转换轨并升级
|
||||
*/
|
||||
private void arriveDestination(Simulation simulation) {
|
||||
for (Iterator<DepotRunningInfo> iterator = simulation.getRepository().getDepotRunningInfoList().iterator(); iterator.hasNext(); ) {
|
||||
DepotRunningInfo depotRunningInfo = iterator.next();
|
||||
VirtualRealityTrain train = depotRunningInfo.getTrain();
|
||||
if (depotRunningInfo.isArrival()) {
|
||||
// 到达
|
||||
iterator.remove();
|
||||
if (depotRunningInfo.in) {
|
||||
atpService.turnDirectionImmediately(train);
|
||||
} else {
|
||||
// 升级
|
||||
SimulationMember member = simulation.getSimulationMember(train, SimulationMember.Type.DRIVER);
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("preselectionMode", "AM_C");
|
||||
CommandInitiateVO commandInitiateVO = new CommandInitiateVO(CommandBO.CommandType.Change_Preselection_Mode,
|
||||
member.getId(), param);
|
||||
groupSimulationService.command(simulation, commandInitiateVO, member);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
public static class DepotRunningInfo {
|
||||
|
||||
private final List<Route> routeList = new ArrayList<>();
|
||||
|
||||
private final Section endSection;
|
||||
|
||||
private final VirtualRealityTrain train;
|
||||
|
||||
private final Boolean right;
|
||||
|
||||
private final Boolean in;
|
||||
|
||||
public DepotRunningInfo(Section endSection, VirtualRealityTrain train, RoutePath routePath, boolean in) {
|
||||
this.endSection = endSection;
|
||||
this.train = train;
|
||||
for (Signal signal : routePath.getSignalList()) {
|
||||
for (Route route : signal.getRouteList()) {
|
||||
if (routePath.getRouteList().contains(route)) {
|
||||
routeList.add(route);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.right = routePath.isRight();
|
||||
this.in = in;
|
||||
}
|
||||
|
||||
// 列车是否到达终点
|
||||
public boolean isArrival() {
|
||||
return train.getSpeed() == 0 && train.getHeadPosition().getSection().equals(endSection)
|
||||
&& train.getTailPosition().getSection().equals(endSection);
|
||||
}
|
||||
}
|
||||
}
|
||||
package club.joylink.rtss.simulation.cbtc.depot;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.ATS.tools.TrainOutboundLoadTool;
|
||||
import club.joylink.rtss.simulation.cbtc.CI.device.CiRouteService;
|
||||
import club.joylink.rtss.simulation.cbtc.GroupSimulationService;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.command.CommandBO;
|
||||
import club.joylink.rtss.simulation.cbtc.command.CommandInitiateVO;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SimulationModule;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Route;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Section;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Signal;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Station;
|
||||
import club.joylink.rtss.simulation.cbtc.data.plan.SchedulingTrainPlan;
|
||||
import club.joylink.rtss.simulation.cbtc.data.support.RoutePath;
|
||||
import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
|
||||
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||
import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPService;
|
||||
import lombok.Getter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class DepotService {
|
||||
|
||||
@Autowired
|
||||
private CiRouteService ciRouteService;
|
||||
|
||||
@Autowired
|
||||
private TrainOutboundLoadTool trainOutboundLoadTool;
|
||||
|
||||
@Autowired
|
||||
private GroupSimulationService groupSimulationService;
|
||||
|
||||
@Autowired
|
||||
private ATPService atpService;
|
||||
|
||||
public void loadDepotTrain(Simulation simulation) {
|
||||
if (!simulation.getRepository().getConfig().isHandleDepot()) {
|
||||
return;
|
||||
}
|
||||
Map<Station, List<Section>> parkingTracksMap = simulation.getRepository().getParkingTracksMap();
|
||||
simulation.getRepository().getAllVrTrain().stream()
|
||||
.collect(Collectors.groupingBy(VirtualRealityTrain::getDepotStation))
|
||||
.forEach((station, trainList) -> {
|
||||
List<Section> sections = parkingTracksMap.get(station);
|
||||
// 先加载内侧的停车轨
|
||||
sections.sort(Comparator.comparing(section ->
|
||||
Objects.isNull(section.getLeftSection()) || Objects.isNull(section.getRightSection())));
|
||||
boolean right = sections.get(sections.size() - 1).getLeftSection() == null;
|
||||
for (int i = 0, trainListSize = trainList.size(); i < trainListSize; i++) {
|
||||
VirtualRealityTrain train = trainList.get(i);
|
||||
Section section = sections.get(i);
|
||||
train.initManualTrain(new SectionPosition(section, section.getStopPointByDirection(right)), right);
|
||||
train.parkingAt(section);
|
||||
train.initAsRM();
|
||||
TrainInfo trainInfo = TrainInfo.constructManualTrain(train);
|
||||
trainInfo.tracking(train);
|
||||
simulation.getRepository().addOnlineTrain(train);
|
||||
simulation.getRepository().addTrainInfo(trainInfo);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void addJobs(Simulation simulation) {
|
||||
simulation.addJob(SimulationModule.DEPOT.name(), () -> this.run(simulation), SimulationConstants.DEPOT_LOOP_RATE);
|
||||
}
|
||||
|
||||
private void run(Simulation simulation) {
|
||||
if (!simulation.isPlanRunning()) {
|
||||
return;
|
||||
}
|
||||
if (!simulation.getRepository().getConfig().isHandleDepot()) {
|
||||
trainOutboundLoadTool.loadOutboundTrain(simulation);
|
||||
} else {
|
||||
timeToDeparture(simulation);
|
||||
backToParking(simulation);
|
||||
settingRouteAndMoving(simulation);
|
||||
arriveDestination(simulation);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据时间筛选,从停车轨自动发车
|
||||
*/
|
||||
private void timeToDeparture(Simulation simulation) {
|
||||
LocalDateTime systemTime = simulation.getSystemTime();
|
||||
for (SchedulingTrainPlan schedulingTrainPlan : simulation.getRepository().getSchedulingTrainPlanList()) {
|
||||
if (schedulingTrainPlan.getOutDepotTrip().isDispatched()) {
|
||||
continue;
|
||||
}
|
||||
if (schedulingTrainPlan.getOutDepotTrip().getStartTime().minusMinutes(10).isBefore(systemTime.toLocalTime())) {
|
||||
schedulingTrainPlan.getOutDepotTrip().dispatched();
|
||||
// 保存信息
|
||||
VirtualRealityTrain train = simulation.getRepository().getVRByCode(schedulingTrainPlan.getGroupNumber(), VirtualRealityTrain.class);
|
||||
Section startSection = train.getHeadPosition().getSection();
|
||||
Section endSection = schedulingTrainPlan.getOutDepotTrip().getStartSection();
|
||||
List<RoutePath> routePaths = simulation.getRepository().queryRoutePaths(startSection, endSection);
|
||||
RoutePath routePath = routePaths.get(0);
|
||||
DepotRunningInfo depotRunningInfo = new DepotRunningInfo(endSection, train, routePath, false);
|
||||
simulation.getRepository().getDepotRunningInfoList().add(depotRunningInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 筛选入库
|
||||
*/
|
||||
private void backToParking(Simulation simulation) {
|
||||
for (TrainInfo trainInfo : simulation.getRepository().getTrainInfoMap().values()) {
|
||||
if (trainInfo.isInbound() && trainInfo.isParking()) {
|
||||
VirtualRealityTrain train = simulation.getRepository().getVRByCode(trainInfo.getGroupNumber(), VirtualRealityTrain.class);
|
||||
if (train.getHeadPosition().getSection().isTransferTrack()
|
||||
&& train.getTailPosition().getSection().isTransferTrack()) {
|
||||
if (simulation.getRepository().getDepotRunningInfoList().stream()
|
||||
.anyMatch(depotRunningInfo -> depotRunningInfo.getTrain().equals(train))) {
|
||||
continue;
|
||||
}
|
||||
train.initAsRM();
|
||||
Section startSection = train.getHeadPosition().getSection();
|
||||
Section endSection = null;
|
||||
for (Section section : simulation.getRepository().getParkingTracksMap().get(startSection.getStation())) {
|
||||
if (section.isOccupied()) {
|
||||
continue;
|
||||
}
|
||||
if (section.getLeftSection() == null || section.getRightSection() == null) {
|
||||
endSection = section;
|
||||
} else if (section.getLeftSection().isParkingTrack() && !section.getLeftSection().isOccupied()) {
|
||||
endSection = section.getLeftSection();
|
||||
} else if (section.getRightSection().isParkingTrack() && !section.getRightSection().isOccupied()) {
|
||||
endSection = section.getRightSection();
|
||||
} else {
|
||||
endSection = section;
|
||||
}
|
||||
break;
|
||||
}
|
||||
// train.setTarget(endSection);
|
||||
List<RoutePath> routePaths = simulation.getRepository().queryRoutePaths(startSection, endSection);
|
||||
if (routePaths == null || routePaths.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
RoutePath routePath = routePaths.get(0);
|
||||
DepotRunningInfo depotRunningInfo = new DepotRunningInfo(endSection, train, routePath, true);
|
||||
simulation.getRepository().getDepotRunningInfoList().add(depotRunningInfo);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 列车排进路并运行
|
||||
*/
|
||||
private void settingRouteAndMoving(Simulation simulation) {
|
||||
for (DepotRunningInfo depotRunningInfo : simulation.getRepository().getDepotRunningInfoList()) {
|
||||
Section endSection = depotRunningInfo.getEndSection();
|
||||
SectionPosition position = new SectionPosition(endSection, endSection.getStopPointByDirection(depotRunningInfo.getRight()));
|
||||
depotRunningInfo.getTrain().setRobotTargetPosition(position);
|
||||
if (!depotRunningInfo.getRouteList().isEmpty()) {
|
||||
Route route = depotRunningInfo.getRouteList().get(0);
|
||||
if (route.isLock()) {
|
||||
depotRunningInfo.getRouteList().remove(0);
|
||||
}
|
||||
if (!route.isSetting()) {
|
||||
route.setSettedAspect(route.getAspect());
|
||||
ciRouteService.setRoute(simulation, route);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断运行列车是否到达转换轨并升级
|
||||
*/
|
||||
private void arriveDestination(Simulation simulation) {
|
||||
for (Iterator<DepotRunningInfo> iterator = simulation.getRepository().getDepotRunningInfoList().iterator(); iterator.hasNext(); ) {
|
||||
DepotRunningInfo depotRunningInfo = iterator.next();
|
||||
VirtualRealityTrain train = depotRunningInfo.getTrain();
|
||||
if (depotRunningInfo.isArrival()) {
|
||||
// 到达
|
||||
iterator.remove();
|
||||
if (depotRunningInfo.in) {
|
||||
atpService.turnDirectionImmediately(train);
|
||||
} else {
|
||||
// 升级
|
||||
SimulationMember member = simulation.getSimulationMember(train, SimulationMember.Type.DRIVER);
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("preselectionMode", "AM_C");
|
||||
CommandInitiateVO commandInitiateVO = new CommandInitiateVO(CommandBO.CommandType.Change_Preselection_Mode,
|
||||
member.getId(), param);
|
||||
groupSimulationService.command(simulation, commandInitiateVO, member);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
public static class DepotRunningInfo {
|
||||
|
||||
private final List<Route> routeList = new ArrayList<>();
|
||||
|
||||
private final Section endSection;
|
||||
|
||||
private final VirtualRealityTrain train;
|
||||
|
||||
private final Boolean right;
|
||||
|
||||
private final Boolean in;
|
||||
|
||||
public DepotRunningInfo(Section endSection, VirtualRealityTrain train, RoutePath routePath, boolean in) {
|
||||
this.endSection = endSection;
|
||||
this.train = train;
|
||||
for (Signal signal : routePath.getSignalList()) {
|
||||
for (Route route : signal.getRouteList()) {
|
||||
if (routePath.getRouteList().contains(route)) {
|
||||
routeList.add(route);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.right = routePath.isRight();
|
||||
this.in = in;
|
||||
}
|
||||
|
||||
// 列车是否到达终点
|
||||
public boolean isArrival() {
|
||||
return train.getSpeed() == 0 && train.getHeadPosition().getSection().equals(endSection)
|
||||
&& train.getTailPosition().getSection().equals(endSection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user