按计划行车时,<办理ats选择的进路>逻辑迁移

This commit is contained in:
joylink_zhangsai 2021-09-28 15:26:10 +08:00
parent ec640aafc4
commit 7ba23fb272

View File

@ -404,6 +404,8 @@ public class AtsTrainLoadService {
this.updateTripPlanStatus(simulation); this.updateTripPlanStatus(simulation);
// 列车上线并构建ATS监控列车信息 // 列车上线并构建ATS监控列车信息
this.trainOnlineAndBuildSupervise(simulation, loadedList); this.trainOnlineAndBuildSupervise(simulation, loadedList);
// 办理ats选择的进路
this.setRoutesThatSelectedByAts(simulation);
// 计算移动授权 // 计算移动授权
// this.maService.calculateMaOfCtcTrains(simulation); // this.maService.calculateMaOfCtcTrains(simulation);
// this.zcLogicLoop.run(simulation); // this.zcLogicLoop.run(simulation);
@ -431,6 +433,51 @@ public class AtsTrainLoadService {
// memberManager.addOnlineDriverRobots(simulation, loadedList); // memberManager.addOnlineDriverRobots(simulation, loadedList);
} }
private void setRoutesThatSelectedByAts(Simulation simulation) {
Map<Route, VirtualRealityTrain> map = new HashMap<>(); //ats为列车选择的进路
SimulationDataRepository repository = simulation.getRepository();
for (TrainInfo trainInfo : repository.getSuperviseTrainList()) {
VirtualRealityTrain train = repository.getOnlineTrainBy(trainInfo.getGroupNumber());
//筛选其它进路
Route route = atsRouteSelectService.select(simulation, trainInfo);
if (route == null)
continue;
VirtualRealityTrain thatTrain = map.get(route);
if (thatTrain != null) {
if (train.isRight() == thatTrain.isRight()) {
boolean thisTrainIsAhead = train.getHeadPosition().isAheadOf(thatTrain.getHeadPosition(), train.isRight());
if (thisTrainIsAhead) {
map.put(route, train);
}
}
} else {
List<Route> conflictList = route.getConflictingRouteList();
boolean add = true;
for (Route conflict : conflictList) {
thatTrain = map.get(conflict);
if (thatTrain == null)
continue;
if (train.isRight() == thatTrain.isRight()) {
boolean thisTrainIsAhead = train.getHeadPosition().isAheadOf(thatTrain.getHeadPosition(), train.isRight());
if (thisTrainIsAhead) {
map.remove(conflict);
} else {
add = false;
break;
}
}
}
if (add) {
map.put(route, train);
}
}
}
//排列进路
for (Route route : map.keySet()) {
this.deviceStatusModifyTool.openRouteDirect(simulation, route);
}
}
private void updateTrainSpeed(Simulation simulation) { private void updateTrainSpeed(Simulation simulation) {
for (VirtualRealityTrain train : simulation.getRepository().getOnlineTrainList()) { for (VirtualRealityTrain train : simulation.getRepository().getOnlineTrainList()) {
if (train.getMa() == null) if (train.getMa() == null)
@ -447,7 +494,6 @@ public class AtsTrainLoadService {
private void trainOnlineAndBuildSupervise(Simulation simulation, List<VirtualRealityTrain> loadedList) { private void trainOnlineAndBuildSupervise(Simulation simulation, List<VirtualRealityTrain> loadedList) {
SimulationDataRepository repository = simulation.getRepository(); SimulationDataRepository repository = simulation.getRepository();
Map<Route, VirtualRealityTrain> map = new HashMap<>(); //ats为列车选择的进路
for (VirtualRealityTrain train : loadedList) { for (VirtualRealityTrain train : loadedList) {
// 构建监控列车信息 // 构建监控列车信息
TrainInfo trainInfo = new TrainInfo(train.getGroupNumber()); TrainInfo trainInfo = new TrainInfo(train.getGroupNumber());
@ -498,43 +544,6 @@ public class AtsTrainLoadService {
} }
trainInfo.tracking(train); trainInfo.tracking(train);
repository.addTrainInfo(trainInfo); repository.addTrainInfo(trainInfo);
//筛选其它进路
Route route = atsRouteSelectService.select(simulation, trainInfo);
if (route == null)
continue;
VirtualRealityTrain thatTrain = map.get(route);
if (thatTrain != null) {
if (train.isRight() == thatTrain.isRight()) {
boolean thisTrainIsAhead = train.getHeadPosition().isAheadOf(thatTrain.getHeadPosition(), train.isRight());
if (thisTrainIsAhead) {
map.put(route, train);
}
}
} else {
List<Route> conflictList = route.getConflictingRouteList();
boolean add = true;
for (Route conflict : conflictList) {
thatTrain = map.get(conflict);
if (thatTrain == null)
continue;
if (train.isRight() == thatTrain.isRight()) {
boolean thisTrainIsAhead = train.getHeadPosition().isAheadOf(thatTrain.getHeadPosition(), train.isRight());
if (thisTrainIsAhead) {
map.remove(conflict);
} else {
add = false;
break;
}
}
}
if (add) {
map.put(route, train);
}
}
}
//排列进路
for (Route route : map.keySet()) {
this.deviceStatusModifyTool.openRouteDirect(simulation, route);
} }
repository.addOnlineTrainList(loadedList); repository.addOnlineTrainList(loadedList);
} }