仿真ats重构-ATS触发计划车进路逻辑修改(计划时间前50s才选进路),添加冲突检测相关状态和逻辑
This commit is contained in:
parent
0f141664f1
commit
9df1c00929
@ -12,6 +12,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -32,22 +33,24 @@ public class AtsPlanTrainRouteSelectServiceImpl implements AtsRouteSelectService
|
||||
}
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
TripPlan tripPlan = repository.getTripPlan(trainInfo.getServiceNumber(), trainInfo.getTripNumber());
|
||||
LocalDateTime systemTime = simulation.getSystemTime();
|
||||
// 根据车次计划查找可触发进路列表
|
||||
Object[] results = this.queryByStationPlan(repository, trainInfo, tripPlan);
|
||||
Object[] results = this.queryByStationPlan(repository, systemTime, trainInfo, tripPlan);
|
||||
// 根据计划筛选需触发进路
|
||||
Route route = filterRoutes(repository, trainInfo, tripPlan, results);
|
||||
Route route = filterRoutes(repository, systemTime, trainInfo, tripPlan, results);
|
||||
return route;
|
||||
}
|
||||
|
||||
/**
|
||||
* 先选取需要征用的进路,再根据计划判断是否存在冲突的未完成计划
|
||||
* @param repository
|
||||
* @param systemTime
|
||||
* @param trainInfo
|
||||
* @param tripPlan
|
||||
* @param results
|
||||
* @return
|
||||
*/
|
||||
private Route filterRoutes(SimulationDataRepository repository,
|
||||
private Route filterRoutes(SimulationDataRepository repository, LocalDateTime systemTime,
|
||||
TrainInfo trainInfo, TripPlan tripPlan, Object[] results) {
|
||||
if (results == null) {
|
||||
return null;
|
||||
@ -64,11 +67,28 @@ public class AtsPlanTrainRouteSelectServiceImpl implements AtsRouteSelectService
|
||||
}
|
||||
log.debug(String.format("列车[%s]筛选出的进路为:[%s]", trainInfo.getGroupNumber(), route.getName()));
|
||||
boolean conflict = this.checkConflict(repository, trainInfo, tripPlan, route, turnBack);
|
||||
if (conflict) {
|
||||
route.setConflict(true);
|
||||
} else {
|
||||
route.setConflict(false);
|
||||
if (route.isCheckConflict()) {
|
||||
if (conflict) {
|
||||
route.setConflict(true);
|
||||
} else {
|
||||
route.setConflict(false);
|
||||
}
|
||||
}
|
||||
// else {
|
||||
// // 进路冲突,看计划时间
|
||||
// List<StationPlan> planList = tripPlan.getPlanList();
|
||||
// LocalTime startTime = tripPlan.getStartTime();
|
||||
// for (StationPlan stationPlan : planList) {
|
||||
// if (stationPlan.getSection().getCode().equals(trainInfo.getPlanStandTrack())) {
|
||||
// break;
|
||||
// }
|
||||
// startTime = stationPlan.getLeaveTime();
|
||||
// }
|
||||
// if (!systemTime.toLocalTime().plusSeconds(60).isAfter(startTime)) {
|
||||
// log.debug(String.format("列车[%s]未到发车时间,不触发进路", trainInfo.getGroupNumber()));
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
return route;
|
||||
}
|
||||
|
||||
@ -252,7 +272,7 @@ public class AtsPlanTrainRouteSelectServiceImpl implements AtsRouteSelectService
|
||||
/**
|
||||
* @return (List<Route>)[0]: 可触发的进路;(Boolean)[1]:是否需要折返
|
||||
*/
|
||||
private Object[] queryByStationPlan(SimulationDataRepository repository, TrainInfo trainInfo, TripPlan tripPlan) {
|
||||
private Object[] queryByStationPlan(SimulationDataRepository repository, LocalDateTime systemTime, TrainInfo trainInfo, TripPlan tripPlan) {
|
||||
Route route = null;
|
||||
Object[] result = new Object[3];
|
||||
result[1] = false;
|
||||
@ -262,6 +282,19 @@ public class AtsPlanTrainRouteSelectServiceImpl implements AtsRouteSelectService
|
||||
if (trainInfo.getPlanStandTrack() == null) { // 列车下一计划存在
|
||||
return null;
|
||||
}
|
||||
// 计划时间
|
||||
List<StationPlan> planList = tripPlan.getPlanList();
|
||||
LocalTime startTime = tripPlan.getStartTime();
|
||||
for (StationPlan stationPlan : planList) {
|
||||
if (stationPlan.getSection().getCode().equals(trainInfo.getPlanStandTrack())) {
|
||||
break;
|
||||
}
|
||||
startTime = stationPlan.getLeaveTime();
|
||||
}
|
||||
if (!systemTime.toLocalTime().plusSeconds(50).isAfter(startTime)) {
|
||||
log.debug(String.format("列车[%s]未到发车时间,不触发进路", trainInfo.getGroupNumber()));
|
||||
return null;
|
||||
}
|
||||
Section planTrack = repository.getByCode(trainInfo.getPlanStandTrack(), Section.class);//下一计划
|
||||
Section section = repository.getByCode(trainInfo.getPhysicalSection(), Section.class); // 列车所在区段
|
||||
if (!planTrack.isSamePhysical(section.getCode())) {
|
||||
|
@ -53,7 +53,7 @@ public class AtsTriggerRouteService {
|
||||
if (!route.isAtsControl()) {
|
||||
return;
|
||||
}
|
||||
if (route.isConflict()) {
|
||||
if (route.isConflict() && route.isCheckConflict()) {
|
||||
return;
|
||||
}
|
||||
this.ciApiService.settingRoute(simulation, route.getCode());
|
||||
|
@ -261,7 +261,7 @@ public class VoiceCommandBO {
|
||||
return null;
|
||||
}
|
||||
List<String> params = replyParamIndexes.stream().map(matcher::group).collect(Collectors.toList());
|
||||
String[] strings = params.toArray(new String[]{});
|
||||
Object[] strings = params.toArray(new Object[]{});
|
||||
return String.format(reply, strings);
|
||||
}
|
||||
|
||||
|
@ -995,7 +995,7 @@ public class SimulationDataRepository {
|
||||
if (route.isConflict()) {
|
||||
continue;
|
||||
}
|
||||
if (route.getStart().equals(theRoute.getStart()) || route.isConflictWith(theRoute)) {
|
||||
if (route.getStart().equals(theRoute.getStart())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -130,7 +130,9 @@ public class Route extends MapNamedElement {
|
||||
|
||||
/** 进路将要或上一次为哪辆列车排列 */
|
||||
private TrainInfo train;
|
||||
/** */
|
||||
/** 检查冲突功能是否开启 */
|
||||
private boolean checkConflict;
|
||||
/** 是否冲突 */
|
||||
private boolean conflict;
|
||||
|
||||
@Override
|
||||
@ -148,6 +150,7 @@ public class Route extends MapNamedElement {
|
||||
this.normalUnlock = false;
|
||||
this.unlockedSection = null;
|
||||
this.train = null;
|
||||
this.checkConflict = false;
|
||||
this.conflict = false;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package club.joylink.rtss.simulation.cbtc.data.support;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
|
||||
import club.joylink.rtss.simulation.cbtc.data.CalculateService;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.MapNamedElement;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Section;
|
||||
|
Loading…
Reference in New Issue
Block a user