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

This commit is contained in:
Jade 2021-12-09 09:13:11 +08:00
commit 7f2b12dd9f
20 changed files with 884 additions and 542 deletions

View File

@ -3,7 +3,6 @@ package club.joylink.rtss.simulation.cbtc.ATS;
import club.joylink.rtss.simulation.cbtc.ATS.service.AtsStandService; import club.joylink.rtss.simulation.cbtc.ATS.service.AtsStandService;
import club.joylink.rtss.simulation.cbtc.ATS.service.AtsStationService; import club.joylink.rtss.simulation.cbtc.ATS.service.AtsStationService;
import club.joylink.rtss.simulation.cbtc.ATS.service.AtsTrainMonitorService; import club.joylink.rtss.simulation.cbtc.ATS.service.AtsTrainMonitorService;
import club.joylink.rtss.simulation.cbtc.ATS.tools.TrainOutboundLoadTool;
import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
import club.joylink.rtss.simulation.cbtc.constant.SimulationModule; import club.joylink.rtss.simulation.cbtc.constant.SimulationModule;
@ -24,11 +23,8 @@ public class ATSLogicLoop {
private AtsStationService atsStationService; private AtsStationService atsStationService;
@Autowired @Autowired
private AtsTrainMonitorService atsTrainMonitorService; private AtsTrainMonitorService atsTrainMonitorService;
@Autowired
private TrainOutboundLoadTool trainOutboundLoadTool;
public void run(Simulation simulation) { public void run(Simulation simulation) {
this.trainOutboundLoadTool.loadOutboundTrain(simulation);
this.atsStandService.countDown(simulation); this.atsStandService.countDown(simulation);
this.atsTrainMonitorService.monitor(simulation); this.atsTrainMonitorService.monitor(simulation);
this.atsStationService.updateFieldThatChangeOverTime(simulation); this.atsStationService.updateFieldThatChangeOverTime(simulation);

View File

@ -50,7 +50,7 @@ public class TrainOperateHandler {
SimulationDataRepository repository = simulation.getRepository(); SimulationDataRepository repository = simulation.getRepository();
List<VirtualRealityTrain> onlineTrainList = repository.getOnlineTrainList(); List<VirtualRealityTrain> onlineTrainList = repository.getOnlineTrainList();
VirtualRealityTrain train = repository VirtualRealityTrain train = repository
.getTrain(serviceNumber, tripNumber); .getTrain(simulation, serviceNumber, tripNumber);
for (VirtualRealityTrain online : onlineTrainList) { for (VirtualRealityTrain online : onlineTrainList) {
if (Objects.equals(train, online)) { if (Objects.equals(train, online)) {
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,

View File

@ -510,7 +510,10 @@ public class AtsTrainLoadService {
SimulationDataRepository repository = simulation.getRepository(); SimulationDataRepository repository = simulation.getRepository();
for (VirtualRealityTrain train : loadedList) { for (VirtualRealityTrain train : loadedList) {
// 构建监控列车信息 // 构建监控列车信息
TrainInfo trainInfo = new TrainInfo(train.getGroupNumber()); TrainInfo trainInfo = simulation.getRepository().getTrainInfoMap().get(train.getGroupNumber());
if (trainInfo == null) {
trainInfo = new TrainInfo(train.getGroupNumber());
}
TripPlan tripPlan = repository.getTripPlan(train.getServiceNumber(), train.getTripNumber()); TripPlan tripPlan = repository.getTripPlan(train.getServiceNumber(), train.getTripNumber());
trainInfo.init(tripPlan, repository.getConfig()); trainInfo.init(tripPlan, repository.getConfig());
List<StationPlan> stationPlanList = tripPlan.getPlanList(); List<StationPlan> stationPlanList = tripPlan.getPlanList();
@ -739,7 +742,7 @@ public class AtsTrainLoadService {
break; break;
} }
TripPlan tripPlan = trainLoadParam2.getTripPlan(); TripPlan tripPlan = trainLoadParam2.getTripPlan();
VirtualRealityTrain train = repository.getTrain(tripPlan.getServiceNumber(), tripPlan.getTripNumber()); VirtualRealityTrain train = repository.getTrain(simulation, tripPlan.getServiceNumber(), tripPlan.getTripNumber());
if (loadedTrainList.contains(train)) { if (loadedTrainList.contains(train)) {
throw new SimulationException(SimulationExceptionType.System_Fault, throw new SimulationException(SimulationExceptionType.System_Fault,
String.format("加载计划[%s|%s|%s]和[%s|%s|%s]使用列车重复", String.format("加载计划[%s|%s|%s]和[%s|%s|%s]使用列车重复",
@ -824,7 +827,7 @@ public class AtsTrainLoadService {
List<TripPlan> allTripPlanList = repository.getAllTripPlanList(); List<TripPlan> allTripPlanList = repository.getAllTripPlanList();
allTripPlanList.forEach(tripPlan -> { allTripPlanList.forEach(tripPlan -> {
if (!systemTime.isBefore(tripPlan.getStartTime())) { if (!systemTime.isBefore(tripPlan.getStartTime())) {
tripPlan.dispatch(); tripPlan.departure();
tripPlan.finishStationPlanOf(systemTime); tripPlan.finishStationPlanOf(systemTime);
} }
}); });

View File

@ -3,9 +3,11 @@ package club.joylink.rtss.simulation.cbtc.ATS.service.stage;
import club.joylink.rtss.simulation.cbtc.ATS.service.AtsStandService; import club.joylink.rtss.simulation.cbtc.ATS.service.AtsStandService;
import club.joylink.rtss.simulation.cbtc.ATS.service.AtsTrainService; import club.joylink.rtss.simulation.cbtc.ATS.service.AtsTrainService;
import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.CalculateService;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.map.*; import club.joylink.rtss.simulation.cbtc.data.map.DestinationCodeDefinition;
import club.joylink.rtss.simulation.cbtc.data.map.Section;
import club.joylink.rtss.simulation.cbtc.data.map.Stand;
import club.joylink.rtss.simulation.cbtc.data.map.StationRunLevel;
import club.joylink.rtss.simulation.cbtc.data.support.RoutePath; 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.support.SectionPosition;
import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo; import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo;
@ -13,9 +15,7 @@ import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPService;
import club.joylink.rtss.simulation.cbtc.onboard.ATP.OnboardAtpApiService; import club.joylink.rtss.simulation.cbtc.onboard.ATP.OnboardAtpApiService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
@ -87,7 +87,11 @@ public class AtsHeadTrainStageService implements AtsStageService {
*/ */
private void handleArriveDestination(Simulation simulation, TrainInfo trainInfo) { private void handleArriveDestination(Simulation simulation, TrainInfo trainInfo) {
// 先回库后设置为人工车 // 先回库后设置为人工车
trainInfo.finishPlanPrepareInbound(); if (simulation.getRepository().getConfig().isHandleDepot()) {
trainInfo.finishPlanPrepareEnterDepot();
} else {
trainInfo.finishPlanPrepareInbound();
}
if (simulation.getRepository().getConfig().isSetManualWhenHeadTrainArriveTarget()) { if (simulation.getRepository().getConfig().isSetManualWhenHeadTrainArriveTarget()) {
atsTrainService.setManualTrain(simulation, trainInfo.getGroupNumber()); atsTrainService.setManualTrain(simulation, trainInfo.getGroupNumber());
} }

View File

@ -4,7 +4,6 @@ import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.map.Section; import club.joylink.rtss.simulation.cbtc.data.map.Section;
import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan; import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan;
import club.joylink.rtss.simulation.cbtc.data.support.RoutePath;
import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo; import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -25,12 +24,12 @@ public class AtsManualTrainStageService implements AtsStageService {
@Override @Override
public void handleTransferTrackParking(Simulation simulation, TrainInfo trainInfo, Section parkSection) { public void handleTransferTrackParking(Simulation simulation, TrainInfo trainInfo, Section parkSection) {
SimulationDataRepository repository = simulation.getRepository(); // SimulationDataRepository repository = simulation.getRepository();
List<RoutePath> routePathList = repository.queryRoutePathsByEnd(parkSection); // List<RoutePath> routePathList = repository.queryRoutePathsByEnd(parkSection);
boolean in = false; // 回库?出库? boolean in = trainInfo.isInbound(); // 回库?
if (routePathList.get(0).isRight() == trainInfo.getRight().booleanValue()) { // if (routePathList.get(0).isRight() == trainInfo.getRight().booleanValue()) {
in = true; // in = true;
} // }
if (!in) { // 出库查询计划是否此轨道有出库计划 if (!in) { // 出库查询计划是否此轨道有出库计划
if (simulation.isPlanRunning()) { if (simulation.isPlanRunning()) {
this.checkAndApplyTripPlan(simulation, trainInfo, parkSection); this.checkAndApplyTripPlan(simulation, trainInfo, parkSection);
@ -69,7 +68,7 @@ public class AtsManualTrainStageService implements AtsStageService {
} }
if (systemTime.toLocalTime().plusMinutes(10).isAfter(tripPlan.getStartTime())) { if (systemTime.toLocalTime().plusMinutes(10).isAfter(tripPlan.getStartTime())) {
this.planTrainStageService.updateTripPlan(simulation, trainInfo, tripPlan); this.planTrainStageService.updateTripPlan(simulation, trainInfo, tripPlan);
tripPlan.dispatch(); tripPlan.departure();
this.realRunRecordService.recordTrainRealRun(simulation, trainInfo, parkSection.getStation(), this.realRunRecordService.recordTrainRealRun(simulation, trainInfo, parkSection.getStation(),
parkSection, true); parkSection, true);
break; break;

View File

@ -2,6 +2,7 @@ package club.joylink.rtss.simulation.cbtc.ATS.service.stage;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.ATS.service.AtsStandService; import club.joylink.rtss.simulation.cbtc.ATS.service.AtsStandService;
import club.joylink.rtss.simulation.cbtc.ATS.service.AtsTrainService;
import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.map.*; import club.joylink.rtss.simulation.cbtc.data.map.*;
@ -34,22 +35,31 @@ public class AtsPlanTrainStageService implements AtsStageService {
private AtsStandService atsStandService; private AtsStandService atsStandService;
@Autowired @Autowired
private OnboardAtpApiService onboardAtpApiService; private OnboardAtpApiService onboardAtpApiService;
@Autowired
private AtsTrainService atsTrainService;
@Override @Override
public void handleTransferTrackParking(Simulation simulation, TrainInfo trainInfo, Section parkSection) { public void handleTransferTrackParking(Simulation simulation, TrainInfo trainInfo, Section parkSection) {
SimulationDataRepository repository = simulation.getRepository(); SimulationDataRepository repository = simulation.getRepository();
TripPlan tripPlan = repository.getTripPlan(trainInfo.getServiceNumber(), trainInfo.getTripNumber()); TripPlan tripPlan = repository.getTripPlan(trainInfo.getServiceNumber(), trainInfo.getTripNumber());
List<RoutePath> routePathList = repository.queryRoutePathsByEnd(parkSection); // List<RoutePath> routePathList = repository.queryRoutePathsByEnd(parkSection);
if (routePathList.get(0).isRight() == trainInfo.getRight()) { //准备回库 // if (routePathList.get(0).isRight() == trainInfo.getRight()) { //准备回库
if (!parkSection.isTurnBackTrack()) { //针对上饶沙盘 // if (!parkSection.isTurnBackTrack()) { //针对上饶沙盘
trainInfo.finishPlanPrepareInbound(); // trainInfo.finishPlanPrepareInbound();
} // }
} else if (tripPlan.getEndSection().equals(parkSection) || // } else 没看懂为啥有这部分逻辑先注掉
if (tripPlan.getEndSection().equals(parkSection) ||
tripPlan.getEndSection().getStation().equals(parkSection.getStation())) { tripPlan.getEndSection().getStation().equals(parkSection.getStation())) {
// 列车到达计划终点准备回库 // 列车到达计划终点准备回库
if (!parkSection.isTurnBackTrack()) { //针对上饶沙盘 if (simulation.getRepository().getConfig().isHandleDepot()) {
trainInfo.finishPlanPrepareInbound(); trainInfo.finishPlanPrepareEnterDepot();
} else {
if (!parkSection.isTurnBackTrack()) { //针对上饶沙盘
trainInfo.finishPlanPrepareInbound();
}
} }
//转人工车
atsTrainService.setManualTrain(simulation, trainInfo.getGroupNumber());
} else if (tripPlan.getStartSection().equals(parkSection)) { } else if (tripPlan.getStartSection().equals(parkSection)) {
// 出库列车 // 出库列车
if (trainInfo.getPlanStandTrack() != null) { if (trainInfo.getPlanStandTrack() != null) {

View File

@ -39,6 +39,8 @@ public class AtsTrainStageHandler {
public void handleInbound(Simulation simulation, TrainInfo train) { public void handleInbound(Simulation simulation, TrainInfo train) {
SimulationDataRepository repository = simulation.getRepository(); SimulationDataRepository repository = simulation.getRepository();
int deleteRemain = train.getDeleteRemain(); int deleteRemain = train.getDeleteRemain();
if (deleteRemain < 0) //以该条件作为列车入库是要进入车辆段而不是消失的标记
return;
deleteRemain -= SimulationModule.ATS.getRateMs(); deleteRemain -= SimulationModule.ATS.getRateMs();
if (deleteRemain <= 0) { // 删除列车 if (deleteRemain <= 0) { // 删除列车
repository.deleteOnlineTrain(train.getGroupNumber()); repository.deleteOnlineTrain(train.getGroupNumber());

View File

@ -14,15 +14,18 @@ import club.joylink.rtss.simulation.cbtc.build.SimulationBuilder;
import club.joylink.rtss.simulation.cbtc.command.VoiceCommandBO; import club.joylink.rtss.simulation.cbtc.command.VoiceCommandBO;
import club.joylink.rtss.simulation.cbtc.communication.Joylink3DMessageService; import club.joylink.rtss.simulation.cbtc.communication.Joylink3DMessageService;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
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.plan.SchedulingTrainPlan;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityIbp;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
import club.joylink.rtss.simulation.cbtc.depot.DepotLoadService; import club.joylink.rtss.simulation.cbtc.depot.DepotService;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.SimulationRealDeviceConnectManager; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.SimulationRealDeviceConnectManager;
import club.joylink.rtss.simulation.cbtc.device.virtual.VRDeviceLogicLoop; import club.joylink.rtss.simulation.cbtc.device.virtual.VRDeviceLogicLoop;
import club.joylink.rtss.simulation.cbtc.device.virtual.VRTrainRunningService; import club.joylink.rtss.simulation.cbtc.device.virtual.VRTrainRunningService;
import club.joylink.rtss.simulation.cbtc.event.*; import club.joylink.rtss.simulation.cbtc.event.SimulationCreateSuccessEvent;
import club.joylink.rtss.simulation.cbtc.event.SimulationErrorEvent;
import club.joylink.rtss.simulation.cbtc.event.SimulationPauseEvent;
import club.joylink.rtss.simulation.cbtc.event.SimulationResetEvent;
import club.joylink.rtss.simulation.cbtc.event.SimulationResumeEvent;
import club.joylink.rtss.simulation.cbtc.event.SimulationRunPlanReloadEvent;
import club.joylink.rtss.simulation.cbtc.exception.SimulationException; import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
import club.joylink.rtss.simulation.cbtc.fault.FaultGenerator; import club.joylink.rtss.simulation.cbtc.fault.FaultGenerator;
@ -31,10 +34,6 @@ import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPLogicLoop;
import club.joylink.rtss.simulation.cbtc.onboard.TrainTargetUpdateService; import club.joylink.rtss.simulation.cbtc.onboard.TrainTargetUpdateService;
import club.joylink.rtss.simulation.cbtc.robot.RobotLogicLoop; import club.joylink.rtss.simulation.cbtc.robot.RobotLogicLoop;
import club.joylink.rtss.simulation.rt.iscs.IscsStatusPublisher; import club.joylink.rtss.simulation.rt.iscs.IscsStatusPublisher;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.client.ibp.IbpData;
import club.joylink.rtss.vo.client.ibp.IbpQueryVO;
import club.joylink.rtss.vo.client.ibp.IbpVO;
import club.joylink.rtss.vo.client.runplan.RunPlanVO; import club.joylink.rtss.vo.client.runplan.RunPlanVO;
import club.joylink.rtss.vo.client.schedulingNew.SchedulingPlanNewVO; import club.joylink.rtss.vo.client.schedulingNew.SchedulingPlanNewVO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -112,7 +111,7 @@ public class SimulationLifeCycleServiceImpl implements SimulationLifeCycleServic
private IbpService ibpService; private IbpService ibpService;
@Autowired @Autowired
private DepotLoadService depotLoadService; private DepotService depotService;
@Override @Override
public Simulation create(SimulationBuildParams params, String group) { public Simulation create(SimulationBuildParams params, String group) {
@ -126,7 +125,7 @@ public class SimulationLifeCycleServiceImpl implements SimulationLifeCycleServic
simulation.addMessagePublisher(new IscsStatusPublisher(simulation)); simulation.addMessagePublisher(new IscsStatusPublisher(simulation));
// 初始化设备状态 // 初始化设备状态
this.deviceStatusService.init(simulation); this.deviceStatusService.init(simulation);
depotLoadService.loadDepotTrain(simulation); depotService.loadDepotTrain(simulation);
// 初始化成员 // 初始化成员
this.memberManager.init(simulation); this.memberManager.init(simulation);
// 初始化语音指令 // 初始化语音指令
@ -141,6 +140,7 @@ public class SimulationLifeCycleServiceImpl implements SimulationLifeCycleServic
private void addJobs(Simulation simulation) { private void addJobs(Simulation simulation) {
atsLogicLoop.addJobs(simulation); atsLogicLoop.addJobs(simulation);
atpLogicLoop.addJobs(simulation); atpLogicLoop.addJobs(simulation);
depotService.addJobs(simulation);
trainTargetUpdateService.addJobs(simulation); trainTargetUpdateService.addJobs(simulation);
vrTrainRunningService.addJobs(simulation); vrTrainRunningService.addJobs(simulation);
this.ciLogic.addJobs(simulation); this.ciLogic.addJobs(simulation);
@ -220,7 +220,7 @@ public class SimulationLifeCycleServiceImpl implements SimulationLifeCycleServic
// } // }
// 初始化设备状态 // 初始化设备状态
this.deviceStatusService.init(simulation); this.deviceStatusService.init(simulation);
depotLoadService.loadDepotTrain(simulation); depotService.loadDepotTrain(simulation);
// Map<String, SimulationMember> oldMemberMap = simulation.getMemberMap(); // Map<String, SimulationMember> oldMemberMap = simulation.getMemberMap();
// Simulation build = SimulationBuilder.build(simulation.getBuildParams()); // Simulation build = SimulationBuilder.build(simulation.getBuildParams());
// simulation.resetFrom(build); // simulation.resetFrom(build);

View File

@ -318,13 +318,22 @@ public class MapDeviceBuilder {
}); });
/* ZC和区段相互赋值 */ /* ZC和区段相互赋值 */
// ZC // ZC
if (graphData.getZcList().size() == 1) { if (graphData.getZcList().size() == 1 && CollectionUtils.isEmpty(graphData.getZcList().get(0).getManagedSectionList())) {
//线路的ZC只有一个ZC没有设置关联区段自动关联全线计轴区段
MapZcVO mapZcVO = graphData.getZcList().get(0); MapZcVO mapZcVO = graphData.getZcList().get(0);
ZC zc = (ZC) elementMap.get(mapZcVO.getCode()); ZC zc = (ZC) elementMap.get(mapZcVO.getCode());
physicalSectionList.forEach(section -> { elementMap.values().stream()
zc.addSection(section); .filter(element -> element instanceof Section)
section.addZc(zc); .map(element -> (Section) element)
}); .filter(Section::isAxleCounter)
.forEach(section -> {
zc.addSection(section);
section.addZc(zc);
});
// physicalSectionList.forEach(section -> {
// zc.addSection(section);
// section.addZc(zc);
// });
} else { } else {
graphData.getZcList().forEach(mapZcVO -> { graphData.getZcList().forEach(mapZcVO -> {
if (mapZcVO.isNoService()) if (mapZcVO.isNoService())
@ -338,15 +347,20 @@ public class MapDeviceBuilder {
Section section = (Section) elementMap.get(sectionCode); Section section = (Section) elementMap.get(sectionCode);
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(section, BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(section,
String.format("ZC[%s]关联的区段[%s]不存在", zc.getCode(), sectionCode)); String.format("ZC[%s]关联的区段[%s]不存在", zc.getCode(), sectionCode));
if (section.isPhysical()) { Section axleCounterSection = section.findAxleCounterSection();
section.addZc(zc); if (axleCounterSection != null) {
zc.addSection(section); axleCounterSection.addZc(zc);
} else if (section.isSwitchAxleCounterSection() || section.isCross()) { zc.addSection(axleCounterSection);
section.getLogicList().forEach(logic -> {
logic.addZc(zc);
zc.addSection(logic);
});
} }
// if (section.isPhysical()) {
// section.addZc(zc);
// zc.addSection(section);
// } else if (section.isSwitchAxleCounterSection() || section.isCross()) {
// section.getLogicList().forEach(logic -> {
// logic.addZc(zc);
// zc.addSection(logic);
// });
// }
} }
} }
}); });

View File

@ -3,6 +3,7 @@ package club.joylink.rtss.simulation.cbtc.build;
import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.map.MapElement; import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
import club.joylink.rtss.simulation.cbtc.data.map.Station;
import club.joylink.rtss.simulation.cbtc.data.plan.SchedulingTrainPlan; import club.joylink.rtss.simulation.cbtc.data.plan.SchedulingTrainPlan;
import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan; import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
@ -72,19 +73,34 @@ public class SchedulingBuilder {
trainList.size(), schedulingPlanList.size())); trainList.size(), schedulingPlanList.size()));
} }
// 分配列车到派班计划 // 分配列车到派班计划
LinkedList<VirtualRealityTrain> trainQueue = new LinkedList<>(trainList); if (simulation.getRepository().getConfig().isHandleDepot()) {
Map<String, VirtualRealityTrain> serverTrainMap = new HashMap<>(); Map<Station, Queue<VirtualRealityTrain>> map = new HashMap<>();
for (int i = 0; i < schedulingPlanList.size(); i++) { for (VirtualRealityTrain train : trainList) {
SchedulingTrainPlan schedulingTrainPlan = schedulingPlanList.get(i); Queue<VirtualRealityTrain> queue = map.computeIfAbsent(train.getDepotStation(), key -> new LinkedList<>());
String serviceNumber = schedulingTrainPlan.getOutDepotTrip().getServiceNumber(); queue.add(train);
VirtualRealityTrain train = serverTrainMap.get(serviceNumber); }
if (Objects.nonNull(train)) { Map<String, VirtualRealityTrain> serverTrainMap = new HashMap<>();
schedulingTrainPlan.setGroupNumber(train.getGroupNumber()); for (SchedulingTrainPlan schedulingTrainPlan : schedulingPlanList) {
} else { String serviceNumber = schedulingTrainPlan.getOutDepotTrip().getServiceNumber();
train = trainQueue.poll(); VirtualRealityTrain train = serverTrainMap.get(serviceNumber);
serverTrainMap.put(serviceNumber, train); if (Objects.isNull(train)) {
train = map.get(schedulingTrainPlan.getOutDepotTrip().getStartSection().getStation()).poll();
serverTrainMap.put(serviceNumber, train);
}
schedulingTrainPlan.setGroupNumber(train.getGroupNumber());
}
} else {
LinkedList<VirtualRealityTrain> trainQueue = new LinkedList<>(trainList);
Map<String, VirtualRealityTrain> serverTrainMap = new HashMap<>();
for (SchedulingTrainPlan schedulingTrainPlan : schedulingPlanList) {
String serviceNumber = schedulingTrainPlan.getOutDepotTrip().getServiceNumber();
VirtualRealityTrain train = serverTrainMap.get(serviceNumber);
if (Objects.isNull(train)) {
train = trainQueue.poll();
serverTrainMap.put(serviceNumber, train);
}
schedulingTrainPlan.setGroupNumber(train.getGroupNumber());
} }
schedulingTrainPlan.setGroupNumber(train.getGroupNumber());
} }
repository.setSchedulingTrainPlanList(schedulingPlanList); repository.setSchedulingTrainPlanList(schedulingPlanList);
return schedulingPlanList; return schedulingPlanList;

View File

@ -21,12 +21,10 @@ import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import javax.swing.text.Element;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
@Slf4j @Slf4j
public class SimulationBuilder { public class SimulationBuilder {
@ -79,9 +77,87 @@ public class SimulationBuilder {
checkAndLoadRunPlan(simulation, buildParams.getRunPlan()); checkAndLoadRunPlan(simulation, buildParams.getRunPlan());
// 加载派班计划 // 加载派班计划
checkAndLoadSchedulingPlan(simulation, buildParams.getSchedulingPlan()); checkAndLoadSchedulingPlan(simulation, buildParams.getSchedulingPlan());
// 加载车辆段route path
loadDepotInOutRoutePath(simulation);
return simulation; return simulation;
} }
/**
* 加载进出depot的route path
*/
private static void loadDepotInOutRoutePath(Simulation simulation) {
// 仿真车辆段站台停车轨列表
Map<Station, List<Section>> parkingTracksMap = simulation.getRepository().getParkingTracksMap();
if (CollectionUtils.isEmpty(parkingTracksMap)) {
return;
}
final Map<String, List<RoutePath>> srps = simulation.getRepository().getRoutePathMap();
parkingTracksMap.forEach((station, secs) -> {
if (station.isDepot()) {// 车站为车辆段
List<Section> transferList = station.getTransferList();// 转换轨列表
if (!CollectionUtils.isEmpty(transferList)) {
transferList.forEach(transSec -> {
// 停车轨到转换轨
secs.forEach(parkSec -> {
final String rpKey = RoutePath.buildKey(parkSec, transSec);
List<RoutePath> nrp = tryFindRoutePathForOutByDirection(parkSec, transSec, 20);
List<RoutePath> srp = srps.get(rpKey);
if (null == srp) {
srp = new ArrayList<RoutePath>();
srps.put(rpKey, srp);
}
if (!CollectionUtils.isEmpty(nrp)) {
srp.addAll(nrp);
}
});
// 转换轨到停车轨
secs.forEach(parkSec -> {
final String rpKey = RoutePath.buildKey(transSec, parkSec);
List<RoutePath> nrp = tryFindRoutePathByDirection(transSec, parkSec, 20);
List<RoutePath> srp = srps.get(rpKey);
if (null == srp) {
srp = new ArrayList<RoutePath>();
srps.put(rpKey, srp);
}
if (!CollectionUtils.isEmpty(nrp)) {
srp.addAll(nrp);
}
});
});
} else {
log.info("仿真数据有问题,车辆段[{}]没有转换轨", station.getName());
}
}
});
}
/**
* 当方向未知时起点终点不变不同方向搜索route path
*/
private static List<RoutePath> tryFindRoutePathForOutByDirection(Section start, Section end, int iterTimes) {
List<RoutePath> r = tryFindRoutePathByDirection(start, end, iterTimes);
if (r.size() == 2) {
return r.stream().sorted((RoutePath r1, RoutePath r2) -> {
return r1.getSignalList().size() - r2.getSignalList().size();
}).findFirst().stream().collect(Collectors.toList());
} else if (r.size() > 2) {
log.warn("获取车辆段从停车轨到转换轨的路径, routeKey = {} , 路径数量大于2异常 ");
}
return r;
}
/**
* 当方向未知时起点终点不变不同方向搜索route path
*/
private static List<RoutePath> tryFindRoutePathByDirection(Section start, Section end, int iterTimes) {
List<RoutePath> r = CalculateService.queryRoutePathsOnDirection(start, end, true, iterTimes);
if (!CollectionUtils.isEmpty(r)) {
return r;
} else {
return CalculateService.queryRoutePathsOnDirection(start, end, false, iterTimes);
}
}
private static void buildIbpData(SimulationDeviceBuildResult mapDataBuildResult, List<Ibp> ibpList) { private static void buildIbpData(SimulationDeviceBuildResult mapDataBuildResult, List<Ibp> ibpList) {
if (CollectionUtils.isEmpty(ibpList)) if (CollectionUtils.isEmpty(ibpList))
return; return;

View File

@ -105,6 +105,9 @@ public interface SimulationConstants {
*/ */
int ROUTE_SETTING_TIMEOUT = 20; int ROUTE_SETTING_TIMEOUT = 20;
/** 停车场/车辆段循环逻辑频率单位ms */
int DEPOT_LOOP_RATE = 1000;
/** /**
* 获取仿真运行计划日期运营日 * 获取仿真运行计划日期运营日
* @return * @return

View File

@ -43,6 +43,8 @@ public enum SimulationModule {
DRIVE_POSITION(SimulationConstants.TRAIN_DRIVE_POSITION_SYNC_RATE), DRIVE_POSITION(SimulationConstants.TRAIN_DRIVE_POSITION_SYNC_RATE),
/** 剧本演出模块 */ /** 剧本演出模块 */
SCRIPT(SimulationConstants.SCRIPT_LOOP_RATE), SCRIPT(SimulationConstants.SCRIPT_LOOP_RATE),
/** 停车场/车辆段模块 */
DEPOT(SimulationConstants.DEPOT_LOOP_RATE),
/** 故障模块 */ /** 故障模块 */
FAULT(SimulationConstants.FAULT_GENERATE_RATE), FAULT(SimulationConstants.FAULT_GENERATE_RATE),

View File

@ -2,6 +2,7 @@ package club.joylink.rtss.simulation.cbtc.data;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.ATS.data.AtsAlarm; import club.joylink.rtss.simulation.cbtc.ATS.data.AtsAlarm;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.communication.vo.TrainHmiDisplay; import club.joylink.rtss.simulation.cbtc.communication.vo.TrainHmiDisplay;
import club.joylink.rtss.simulation.cbtc.data.map.*; import club.joylink.rtss.simulation.cbtc.data.map.*;
import club.joylink.rtss.simulation.cbtc.data.plan.RealRun; import club.joylink.rtss.simulation.cbtc.data.plan.RealRun;
@ -226,6 +227,10 @@ public class SimulationDataRepository {
*/ */
private Map<Station, List<Section>> parkingTracksMap = new HashMap<>(); private Map<Station, List<Section>> parkingTracksMap = new HashMap<>();
private List<SchedulingTrainPlan> outboundPlanList = new ArrayList<>();
private List<SchedulingTrainPlan> inboundPlanList = new ArrayList<>();
/** /**
* 间隔时间/s * 间隔时间/s
*/ */
@ -586,12 +591,13 @@ public class SimulationDataRepository {
return this.serviceTripsMap.get(serviceNumber); return this.serviceTripsMap.get(serviceNumber);
} }
public VirtualRealityTrain getTrain(String serviceNumber, String tripNumber) { public VirtualRealityTrain getTrain(Simulation simulation, String serviceNumber, String tripNumber) {
VirtualRealityTrain train = this.queryTrain(serviceNumber, tripNumber); VirtualRealityTrain train = this.queryTrain(serviceNumber, tripNumber);
if (Objects.isNull(train)) { if (Objects.isNull(train)) {
throw new SimulationException(SimulationExceptionType.System_Fault, throw new SimulationException(SimulationExceptionType.System_Fault,
String.format("服务车次[%s|%s]找不到派班的列车", serviceNumber, tripNumber)); String.format("服务车次[%s|%s]找不到派班的列车", serviceNumber, tripNumber));
} else if (this.usedTrainMap.containsKey(train.getGroupNumber())) { } else if (!simulation.getRepository().getConfig().isHandleDepot()
&& this.usedTrainMap.containsKey(train.getGroupNumber())) {
throw new SimulationException(SimulationExceptionType.System_Fault, throw new SimulationException(SimulationExceptionType.System_Fault,
String.format("列车[%s]已经被使用", train.getGroupNumber())); String.format("列车[%s]已经被使用", train.getGroupNumber()));
} }

View File

@ -12,10 +12,7 @@ import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.util.ArrayList; import java.util.*;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
/** /**
* 区段 * 区段
@ -165,7 +162,7 @@ public class Section extends DelayUnlockDevice {
/** /**
* 所属zc * 所属zc
*/ */
private List<ZC> zcs = new ArrayList<>(); private Set<ZC> zcs = new HashSet<>();
// ------------------状态属性--------------------- // ------------------状态属性---------------------
@ -1148,10 +1145,15 @@ public class Section extends DelayUnlockDevice {
* 任意一个zc正常工作 * 任意一个zc正常工作
*/ */
public boolean anyZcWorking() { public boolean anyZcWorking() {
if (!CollectionUtils.isEmpty(zcs)) { Section axleCounterSection = this.findAxleCounterSection();
return zcs.stream().anyMatch(zc -> !zc.isFault()); if (axleCounterSection != null && !CollectionUtils.isEmpty(axleCounterSection.getZcs())) {
return axleCounterSection.getZcs().stream().anyMatch(zc -> !zc.isFault());
} }
return false; return false;
// if (!CollectionUtils.isEmpty(zcs)) {
// return zcs.stream().anyMatch(zc -> !zc.isFault());
// }
// return false;
} }
public void setInvalid(boolean invalid) { public void setInvalid(boolean invalid) {

View File

@ -1,11 +1,10 @@
package club.joylink.rtss.simulation.cbtc.data.map; package club.joylink.rtss.simulation.cbtc.data.map;
import lombok.Getter; import lombok.Getter;
import lombok.Setter;
import java.util.ArrayList; import java.util.HashSet;
import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.Set;
/** /**
* 区域控制器 * 区域控制器
@ -13,7 +12,7 @@ import java.util.Objects;
@Getter @Getter
public class ZC extends MayOutOfOrderDevice { public class ZC extends MayOutOfOrderDevice {
private List<Section> sections = new ArrayList<>(); private Set<Section> sections = new HashSet<>();
public ZC(String code, String name) { public ZC(String code, String name) {
super(code, name, DeviceType.ZC); super(code, name, DeviceType.ZC);

View File

@ -232,11 +232,20 @@ public class TripPlan {
return false; return false;
} }
/**
* 按计划发车
*/
public void departure() {
this.departure = true;
if (this.isOutbound()) {
this.dispatched = true;
}
}
/** /**
* 按计划派发 * 按计划派发
*/ */
public void dispatch() { public void dispatched() {
this.departure = true;
if (this.isOutbound()) { if (this.isOutbound()) {
this.dispatched = true; this.dispatched = true;
} }

View File

@ -532,7 +532,7 @@ public class TrainInfo extends MapElement {
} }
public synchronized void applyNewTripPlan(TripPlan tripPlan) { public synchronized void applyNewTripPlan(TripPlan tripPlan) {
tripPlan.dispatch(); tripPlan.departure();
this.serviceNumber = tripPlan.getServiceNumber(); this.serviceNumber = tripPlan.getServiceNumber();
this.tripNumber = tripPlan.getTripNumber(); this.tripNumber = tripPlan.getTripNumber();
this.destinationCode = tripPlan.getDestinationCode(); this.destinationCode = tripPlan.getDestinationCode();
@ -586,11 +586,22 @@ public class TrainInfo extends MapElement {
this.routing = routing; this.routing = routing;
} }
/**
* 准备回库消失
*/
public void finishPlanPrepareInbound() { public void finishPlanPrepareInbound() {
this.inbound = true; this.inbound = true;
this.deleteRemain = 5 * 1000; this.deleteRemain = 5 * 1000;
} }
/**
* 准备进入车辆段
*/
public void finishPlanPrepareEnterDepot() {
this.inbound = true;
this.deleteRemain = -1;
}
public void updateDeleteRemain(int deleteRemain) { public void updateDeleteRemain(int deleteRemain) {
this.deleteRemain = deleteRemain; this.deleteRemain = deleteRemain;
} }

View File

@ -1,45 +0,0 @@
package club.joylink.rtss.simulation.cbtc.depot;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.map.Section;
import club.joylink.rtss.simulation.cbtc.data.map.Station;
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 org.springframework.stereotype.Component;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
@Component
public class DepotLoadService {
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);
TrainInfo trainInfo = TrainInfo.constructManualTrain(train);
trainInfo.tracking(train);
simulation.getRepository().addOnlineTrain(train);
simulation.getRepository().addTrainInfo(trainInfo);
}
});
}
}

View File

@ -0,0 +1,235 @@
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
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);
}
}
/**
* 根据时间筛选从停车轨自动发车
* @param 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())) {
if (!simulation.getRepository().getOutboundPlanList().contains(schedulingTrainPlan)) {
simulation.getRepository().getOutboundPlanList().add(schedulingTrainPlan);
schedulingTrainPlan.getOutDepotTrip().dispatched();
}
}
}
}
/**
* 筛选入库
* @param simulation
*/
private void backToParking(Simulation simulation) {
for (VirtualRealityTrain train : simulation.getRepository().getOnlineTrainList()) {
if (!train.isParkingAt()) {
continue;
}
Section section = train.getHeadPosition().getSection();
if (!section.isTransferTrack()) {
continue;
}
for (SchedulingTrainPlan schedulingTrainPlan : simulation.getRepository().getSchedulingTrainPlanList()) {
if (!schedulingTrainPlan.getInDepotTrip().getEndSection().equals(section)) {
continue;
}
if (!train.getGroupNumber().equals(schedulingTrainPlan.getGroupNumber())) {
continue;
}
if (!schedulingTrainPlan.getInDepotTrip().getEndTime().minusMinutes(10)
.isBefore(simulation.getSystemTime().toLocalTime())) {
continue;
}
if (!simulation.getRepository().getInboundPlanList().contains(schedulingTrainPlan)) {
train.initAsRM();
simulation.getRepository().getInboundPlanList().add(schedulingTrainPlan);
break;
}
}
}
}
/**
* 列车排进路并运行
* @param simulation
*/
private void settingRouteAndMoving(Simulation simulation) {
for (SchedulingTrainPlan schedulingTrainPlan : simulation.getRepository().getOutboundPlanList()) {
moving(simulation, schedulingTrainPlan.getGroupNumber(), schedulingTrainPlan.getOutDepotTrip().getStartSection());
}
for (SchedulingTrainPlan schedulingTrainPlan : simulation.getRepository().getInboundPlanList()) {
Section endSection = schedulingTrainPlan.getInDepotTrip().getEndSection();
for (Section section : simulation.getRepository().getParkingTracksMap().get(endSection.getStation())) {
if (section.isOccupied()) {
continue;
}
if (section.getLeftSection() == null || section.getRightSection() == null) {
moving(simulation, schedulingTrainPlan.getGroupNumber(), section);
} else if (section.getLeftSection().isParkingTrack() && !section.getLeftSection().isOccupied()) {
moving(simulation, schedulingTrainPlan.getGroupNumber(), section.getLeftSection());
} else if (section.getRightSection().isParkingTrack() && !section.getRightSection().isOccupied()) {
moving(simulation, schedulingTrainPlan.getGroupNumber(), section.getRightSection());
} else {
moving(simulation, schedulingTrainPlan.getGroupNumber(), section);
}
break;
}
}
}
private void moving(Simulation simulation, String groupNumber, Section endSection) {
VirtualRealityTrain train = simulation.getRepository().getVRByCode(groupNumber, VirtualRealityTrain.class);
Section startSection = train.getHeadPosition().getSection();
List<RoutePath> routePaths = simulation.getRepository().queryRoutePaths(startSection, endSection);
if (routePaths == null || routePaths.isEmpty()) {
return;
}
RoutePath routePath = routePaths.get(0);
Section lastSection = routePath.getEnd();
train.setRobotTargetPosition(new SectionPosition(lastSection, lastSection.getStopPointByDirection(routePath.isRight())));
for (Signal signal : routePath.getSignalList()) {
for (Route route : signal.getRouteList()) {
if (routePath.getRouteList().contains(route)) {
if (route.isSetting()) {
return;
}
if (route.isLock()) {
break;
}
ciRouteService.setRoute(simulation, route);
return;
}
}
}
}
/**
* 判断运行列车是否到达转换轨并升级
* @param simulation
*/
private void arriveDestination(Simulation simulation) {
for (Iterator<SchedulingTrainPlan> iterator = simulation.getRepository().getOutboundPlanList().iterator(); iterator.hasNext(); ) {
SchedulingTrainPlan schedulingTrainPlan = iterator.next();
String groupNumber = schedulingTrainPlan.getGroupNumber();
VirtualRealityTrain train = simulation.getRepository().getVRByCode(groupNumber, VirtualRealityTrain.class);
if (train.getSpeed() == 0
&& train.getHeadPosition().getSection().equals(schedulingTrainPlan.getOutDepotTrip().getStartSection())
&& train.getTailPosition().getSection().equals(schedulingTrainPlan.getOutDepotTrip().getStartSection())) {
// 到达
iterator.remove();
// 升级
SimulationMember member = simulation.getSimulationMembersByDevice(train).get(0);
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);
}
}
for (Iterator<SchedulingTrainPlan> iterator = simulation.getRepository().getInboundPlanList().iterator(); iterator.hasNext(); ) {
SchedulingTrainPlan schedulingTrainPlan = iterator.next();
String groupNumber = schedulingTrainPlan.getGroupNumber();
VirtualRealityTrain train = simulation.getRepository().getVRByCode(groupNumber, VirtualRealityTrain.class);
if (train.getSpeed() == 0 && train.getHeadPosition().getSection().isParkingTrack()
&& train.getTailPosition().getSection().isParkingTrack()) {
// 到达
iterator.remove();
atpService.turnDirectionImmediately(train);
}
}
}
}