车辆段逻辑
This commit is contained in:
parent
690acdba5f
commit
6b7a36aeed
@ -17,6 +17,7 @@ import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vo.TdtStatusVO;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.*;
|
||||
import club.joylink.rtss.simulation.cbtc.depot.DepotService;
|
||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
|
||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
|
||||
import club.joylink.rtss.util.StrUtils;
|
||||
@ -227,9 +228,9 @@ public class SimulationDataRepository {
|
||||
*/
|
||||
private Map<Station, List<Section>> parkingTracksMap = new HashMap<>();
|
||||
|
||||
private List<SchedulingTrainPlan> outboundPlanList = new ArrayList<>();
|
||||
private List<DepotService.DepotInfo> outboundInfoList = new ArrayList<>();
|
||||
|
||||
private List<VirtualRealityTrain> inboundTrainList = new ArrayList<>();
|
||||
private List<DepotService.DepotInfo> inboundInfoList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 间隔时间/s
|
||||
|
@ -19,10 +19,12 @@ 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.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
@ -102,10 +104,15 @@ public class DepotService {
|
||||
continue;
|
||||
}
|
||||
if (schedulingTrainPlan.getOutDepotTrip().getStartTime().minusMinutes(10).isBefore(systemTime.toLocalTime())) {
|
||||
if (!simulation.getRepository().getOutboundPlanList().contains(schedulingTrainPlan)) {
|
||||
simulation.getRepository().getOutboundPlanList().add(schedulingTrainPlan);
|
||||
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);
|
||||
DepotInfo depotInfo = new DepotInfo(endSection, train, routePath);
|
||||
simulation.getRepository().getOutboundInfoList().add(depotInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -116,10 +123,15 @@ public class DepotService {
|
||||
*/
|
||||
private void backToParking(Simulation simulation) {
|
||||
for (TrainInfo trainInfo : simulation.getRepository().getTrainInfoMap().values()) {
|
||||
next:
|
||||
if (trainInfo.isInbound() && trainInfo.isParking()) {
|
||||
VirtualRealityTrain train = simulation.getRepository().getVRByCode(trainInfo.getGroupNumber(), VirtualRealityTrain.class);
|
||||
if (train.getHeadPosition().getSection().isTransferTrack() && train.getTailPosition().getSection().isTransferTrack()) {
|
||||
simulation.getRepository().getInboundTrainList().add(train);
|
||||
for (DepotInfo depotInfo : simulation.getRepository().getInboundInfoList()) {
|
||||
if (depotInfo.getTrain().equals(train)) {
|
||||
break next;
|
||||
}
|
||||
}
|
||||
train.initAsRM();
|
||||
Section startSection = train.getHeadPosition().getSection();
|
||||
Section endSection = null;
|
||||
@ -139,6 +151,13 @@ public class DepotService {
|
||||
break;
|
||||
}
|
||||
train.setTarget(endSection);
|
||||
List<RoutePath> routePaths = simulation.getRepository().queryRoutePaths(startSection, endSection);
|
||||
if (routePaths == null || routePaths.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
RoutePath routePath = routePaths.get(0);
|
||||
DepotInfo depotInfo = new DepotInfo(endSection, train, routePath);
|
||||
simulation.getRepository().getInboundInfoList().add(depotInfo);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -150,36 +169,24 @@ public class DepotService {
|
||||
* @param simulation
|
||||
*/
|
||||
private void settingRouteAndMoving(Simulation simulation) {
|
||||
for (SchedulingTrainPlan schedulingTrainPlan : simulation.getRepository().getOutboundPlanList()) {
|
||||
VirtualRealityTrain train = simulation.getRepository().getVRByCode(schedulingTrainPlan.getGroupNumber(), VirtualRealityTrain.class);
|
||||
moving(simulation, train, schedulingTrainPlan.getOutDepotTrip().getStartSection());
|
||||
for (DepotInfo depotInfo : simulation.getRepository().getOutboundInfoList()) {
|
||||
moving(simulation, depotInfo);
|
||||
}
|
||||
for (VirtualRealityTrain train : simulation.getRepository().getInboundTrainList()) {
|
||||
moving(simulation, train, train.getTarget());
|
||||
for (DepotInfo depotInfo : simulation.getRepository().getInboundInfoList()) {
|
||||
moving(simulation, depotInfo);
|
||||
}
|
||||
}
|
||||
|
||||
private void moving(Simulation simulation, VirtualRealityTrain train, Section endSection) {
|
||||
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 pathEnd = routePath.getEnd();
|
||||
train.setRobotTargetPosition(new SectionPosition(pathEnd, pathEnd.getStopPointByDirection(routePath.isRight())));
|
||||
for (Signal signal : routePath.getSignalList()) {
|
||||
for (Route route : signal.getRouteList()) {
|
||||
if (routePath.getRouteList().contains(route)) {
|
||||
if (route.isSetting()) {
|
||||
return;
|
||||
}
|
||||
private void moving(Simulation simulation, DepotInfo depotInfo) {
|
||||
SectionPosition position = new SectionPosition(depotInfo.endSection, depotInfo.endSection.getStopPointByDirection(depotInfo.getRight()));
|
||||
depotInfo.getTrain().setRobotTargetPosition(position);
|
||||
if (!depotInfo.getRouteList().isEmpty()) {
|
||||
Route route = depotInfo.getRouteList().get(0);
|
||||
if (route.isLock()) {
|
||||
break;
|
||||
depotInfo.getRouteList().remove(0);
|
||||
}
|
||||
if (!route.isSetting()) {
|
||||
ciRouteService.setRoute(simulation, route);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -189,13 +196,11 @@ public class DepotService {
|
||||
* @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())) {
|
||||
for (Iterator<DepotInfo> iterator = simulation.getRepository().getOutboundInfoList().iterator(); iterator.hasNext(); ) {
|
||||
DepotInfo depotInfo = iterator.next();
|
||||
VirtualRealityTrain train = depotInfo.getTrain();
|
||||
if (train.getSpeed() == 0 && train.getHeadPosition().getSection().equals(depotInfo.getEndSection())
|
||||
&& train.getTailPosition().getSection().equals(depotInfo.getEndSection())) {
|
||||
// 到达
|
||||
iterator.remove();
|
||||
// 升级
|
||||
@ -207,8 +212,9 @@ public class DepotService {
|
||||
groupSimulationService.command(simulation, commandInitiateVO, member);
|
||||
}
|
||||
}
|
||||
for (Iterator<VirtualRealityTrain> iterator = simulation.getRepository().getInboundTrainList().iterator(); iterator.hasNext(); ) {
|
||||
VirtualRealityTrain train = iterator.next();
|
||||
for (Iterator<DepotInfo> iterator = simulation.getRepository().getInboundInfoList().iterator(); iterator.hasNext(); ) {
|
||||
DepotInfo depotInfo = iterator.next();
|
||||
VirtualRealityTrain train = depotInfo.getTrain();
|
||||
if (train.getSpeed() == 0 && train.getHeadPosition().getSection().isParkingTrack()
|
||||
&& train.getTailPosition().getSection().isParkingTrack()) {
|
||||
// 到达
|
||||
@ -217,4 +223,29 @@ public class DepotService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
public static class DepotInfo {
|
||||
|
||||
private final List<Route> routeList = new ArrayList<>();
|
||||
|
||||
private final Section endSection;
|
||||
|
||||
private final VirtualRealityTrain train;
|
||||
|
||||
private final Boolean right;
|
||||
|
||||
public DepotInfo(Section endSection, VirtualRealityTrain train, RoutePath routePath) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user