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

This commit is contained in:
joylink_zhangsai 2021-12-09 16:33:36 +08:00
commit f681f3a20f
4 changed files with 44 additions and 57 deletions

View File

@ -838,7 +838,7 @@ public class AtsTrainLoadService {
*/ */
public void loadSpareTrain(Simulation simulation, String groupNumber, String sectionCode, boolean right) { public void loadSpareTrain(Simulation simulation, String groupNumber, String sectionCode, boolean right) {
SimulationDataRepository repository = simulation.getRepository(); SimulationDataRepository repository = simulation.getRepository();
if (repository.isVrTrainOnline(groupNumber)) { if (!simulation.getRepository().getConfig().isHandleDepot() && repository.isVrTrainOnline(groupNumber)) {
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL,
String.format("车组号[%s]的列车已经在运行中", groupNumber)); String.format("车组号[%s]的列车已经在运行中", groupNumber));
} else { } else {
@ -877,9 +877,11 @@ public class AtsTrainLoadService {
train.initAsRM(); train.initAsRM();
} }
} }
TrainInfo trainInfo = TrainInfo.constructManualTrain(train); if (!repository.getConfig().isHandleDepot()) {
trainInfo.tracking(train); TrainInfo trainInfo = TrainInfo.constructManualTrain(train);
repository.addOnlineTrain(train); trainInfo.tracking(train);
repository.addTrainInfo(trainInfo); repository.addOnlineTrain(train);
repository.addTrainInfo(trainInfo);
}
} }
} }

View File

@ -100,7 +100,7 @@ public class SimulationBuilder {
// 停车轨到转换轨 // 停车轨到转换轨
secs.forEach(parkSec -> { secs.forEach(parkSec -> {
final String rpKey = RoutePath.buildKey(parkSec, transSec); final String rpKey = RoutePath.buildKey(parkSec, transSec);
List<RoutePath> nrp = tryFindRoutePathForOutByDirection(parkSec, transSec, 20); List<RoutePath> nrp = tryFindRoutePathForOutByDirection(parkSec, transSec, 5);
List<RoutePath> srp = srps.get(rpKey); List<RoutePath> srp = srps.get(rpKey);
if (null == srp) { if (null == srp) {
srp = new ArrayList<RoutePath>(); srp = new ArrayList<RoutePath>();
@ -113,7 +113,7 @@ public class SimulationBuilder {
// 转换轨到停车轨 // 转换轨到停车轨
secs.forEach(parkSec -> { secs.forEach(parkSec -> {
final String rpKey = RoutePath.buildKey(transSec, parkSec); final String rpKey = RoutePath.buildKey(transSec, parkSec);
List<RoutePath> nrp = tryFindRoutePathByDirection(transSec, parkSec, 20); List<RoutePath> nrp = tryFindRoutePathByDirection(transSec, parkSec, 1);
List<RoutePath> srp = srps.get(rpKey); List<RoutePath> srp = srps.get(rpKey);
if (null == srp) { if (null == srp) {
srp = new ArrayList<RoutePath>(); srp = new ArrayList<RoutePath>();
@ -135,7 +135,7 @@ public class SimulationBuilder {
* 当方向未知时起点终点不变不同方向搜索route path * 当方向未知时起点终点不变不同方向搜索route path
*/ */
private static List<RoutePath> tryFindRoutePathForOutByDirection(Section start, Section end, int iterTimes) { private static List<RoutePath> tryFindRoutePathForOutByDirection(Section start, Section end, int iterTimes) {
List<RoutePath> r = tryFindRoutePathByDirection(start, end, iterTimes); List<RoutePath> r = tryFindRoutePathByDirection(start, end, iterTimes);
if (r.size() == 2) { if (r.size() == 2) {
return r.stream().sorted((RoutePath r1, RoutePath r2) -> { return r.stream().sorted((RoutePath r1, RoutePath r2) -> {
return r1.getSignalList().size() - r2.getSignalList().size(); return r1.getSignalList().size() - r2.getSignalList().size();
@ -143,7 +143,7 @@ public class SimulationBuilder {
} else if (r.size() > 2) { } else if (r.size() > 2) {
log.warn("获取车辆段从停车轨到转换轨的路径, routeKey = {} , 路径数量大于2异常 "); log.warn("获取车辆段从停车轨到转换轨的路径, routeKey = {} , 路径数量大于2异常 ");
} }
return r; return r;
} }

View File

@ -229,7 +229,7 @@ public class SimulationDataRepository {
private List<SchedulingTrainPlan> outboundPlanList = new ArrayList<>(); private List<SchedulingTrainPlan> outboundPlanList = new ArrayList<>();
private List<SchedulingTrainPlan> inboundPlanList = new ArrayList<>(); private List<VirtualRealityTrain> inboundTrainList = new ArrayList<>();
/** /**
* 间隔时间/s * 间隔时间/s

View File

@ -115,28 +115,30 @@ public class DepotService {
* @param simulation * @param simulation
*/ */
private void backToParking(Simulation simulation) { private void backToParking(Simulation simulation) {
for (VirtualRealityTrain train : simulation.getRepository().getOnlineTrainList()) { for (TrainInfo trainInfo : simulation.getRepository().getTrainInfoMap().values()) {
if (!train.isParkingAt()) { if (trainInfo.isInbound() && trainInfo.isParking()) {
continue; VirtualRealityTrain train = simulation.getRepository().getVRByCode(trainInfo.getGroupNumber(), VirtualRealityTrain.class);
} if (train.getHeadPosition().getSection().isTransferTrack() && train.getTailPosition().getSection().isTransferTrack()) {
Section section = train.getHeadPosition().getSection(); simulation.getRepository().getInboundTrainList().add(train);
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(); train.initAsRM();
simulation.getRepository().getInboundPlanList().add(schedulingTrainPlan); 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);
break; break;
} }
} }
@ -149,38 +151,23 @@ public class DepotService {
*/ */
private void settingRouteAndMoving(Simulation simulation) { private void settingRouteAndMoving(Simulation simulation) {
for (SchedulingTrainPlan schedulingTrainPlan : simulation.getRepository().getOutboundPlanList()) { for (SchedulingTrainPlan schedulingTrainPlan : simulation.getRepository().getOutboundPlanList()) {
moving(simulation, schedulingTrainPlan.getGroupNumber(), schedulingTrainPlan.getOutDepotTrip().getStartSection()); VirtualRealityTrain train = simulation.getRepository().getVRByCode(schedulingTrainPlan.getGroupNumber(), VirtualRealityTrain.class);
moving(simulation, train, schedulingTrainPlan.getOutDepotTrip().getStartSection());
} }
for (SchedulingTrainPlan schedulingTrainPlan : simulation.getRepository().getInboundPlanList()) { for (VirtualRealityTrain train : simulation.getRepository().getInboundTrainList()) {
Section endSection = schedulingTrainPlan.getInDepotTrip().getEndSection(); moving(simulation, train, train.getTarget());
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) { private void moving(Simulation simulation, VirtualRealityTrain train, Section endSection) {
VirtualRealityTrain train = simulation.getRepository().getVRByCode(groupNumber, VirtualRealityTrain.class);
Section startSection = train.getHeadPosition().getSection(); Section startSection = train.getHeadPosition().getSection();
List<RoutePath> routePaths = simulation.getRepository().queryRoutePaths(startSection, endSection); List<RoutePath> routePaths = simulation.getRepository().queryRoutePaths(startSection, endSection);
if (routePaths == null || routePaths.isEmpty()) { if (routePaths == null || routePaths.isEmpty()) {
return; return;
} }
RoutePath routePath = routePaths.get(0); RoutePath routePath = routePaths.get(0);
Section lastSection = routePath.getEnd(); Section pathEnd = routePath.getEnd();
train.setRobotTargetPosition(new SectionPosition(lastSection, lastSection.getStopPointByDirection(routePath.isRight()))); train.setRobotTargetPosition(new SectionPosition(pathEnd, pathEnd.getStopPointByDirection(routePath.isRight())));
for (Signal signal : routePath.getSignalList()) { for (Signal signal : routePath.getSignalList()) {
for (Route route : signal.getRouteList()) { for (Route route : signal.getRouteList()) {
if (routePath.getRouteList().contains(route)) { if (routePath.getRouteList().contains(route)) {
@ -220,10 +207,8 @@ public class DepotService {
groupSimulationService.command(simulation, commandInitiateVO, member); groupSimulationService.command(simulation, commandInitiateVO, member);
} }
} }
for (Iterator<SchedulingTrainPlan> iterator = simulation.getRepository().getInboundPlanList().iterator(); iterator.hasNext(); ) { for (Iterator<VirtualRealityTrain> iterator = simulation.getRepository().getInboundTrainList().iterator(); iterator.hasNext(); ) {
SchedulingTrainPlan schedulingTrainPlan = iterator.next(); VirtualRealityTrain train = iterator.next();
String groupNumber = schedulingTrainPlan.getGroupNumber();
VirtualRealityTrain train = simulation.getRepository().getVRByCode(groupNumber, VirtualRealityTrain.class);
if (train.getSpeed() == 0 && train.getHeadPosition().getSection().isParkingTrack() if (train.getSpeed() == 0 && train.getHeadPosition().getSection().isParkingTrack()
&& train.getTailPosition().getSection().isParkingTrack()) { && train.getTailPosition().getSection().isParkingTrack()) {
// 到达 // 到达