仿真ats重构-添加为列车更新目的区段逻辑,修改计划车折返进路办理bug,修改信号机接近区段判断bug,添加进路非ATS自动控相关逻辑

This commit is contained in:
walker-sheng 2021-07-23 14:57:07 +08:00
parent 02924c0cb5
commit 8059408d96
7 changed files with 134 additions and 13 deletions

View File

@ -500,6 +500,9 @@ public class AtsPlanTrainRouteSelectServiceImpl extends AtsRouteSelectService {
private List<Route> queryAccordingTbStrategy(SimulationDataRepository repository, TrainInfo trainInfo, TripPlan tripPlan) {
Section standSection = repository.getByCode(trainInfo.getPlanStandTrack(), Section.class);
if (!standSection.isRouteLock()) {
}
Station station = standSection.getStation();
StationTurnBackStrategyOption strategy = station.getCurrentTurnBackStrategy();
Section tbSection = tripPlan.getEndSection();
@ -530,6 +533,9 @@ public class AtsPlanTrainRouteSelectServiceImpl extends AtsRouteSelectService {
List<RoutePath> list = repository.getRoutePaths(standSection, tbSection);
boolean right = list.get(0).isRight();
Signal signal = standSection.getSignalOf(right);
if (!this.isApproachSignal(repository, trainInfo, signal)) {
return null;
}
List<Route> routeList = signal.getRouteList();
List<Route> tbRouteList = new ArrayList<>();
for (Route route : routeList) {

View File

@ -43,7 +43,7 @@ public abstract class AtsRouteSelectService {
public Object[] queryTriggers(SimulationDataRepository repository, TrainInfo trainInfo, List<RoutePath> routePathList,
Boolean right, Section section, Section logicSection) {
Object[] result = new Object[3]; // 结果0为可触发的进路列表1为是否存在未触发的进路,2为是否存在未接近的信号机
Object[] result = new Object[3]; // 结果0为可触发的进路列表1为是否存在未触发的进路,2为是否存在未接近的信号机或无法触发信号机
List<Route> triggerList = new ArrayList<>();
result[0] = triggerList;
result[1] = false;
@ -65,11 +65,15 @@ public abstract class AtsRouteSelectService {
if (!ctcLevel && signal.isVirtual()) {
continue;
}
if ((ctcLevel && signal.isCtcApproachSection(logicSection.getCode())) ||
(!ctcLevel && !signal.isVirtual() && signal.isApproachSection(section.getCode()))) {
if (this.isApproachSignal(repository, trainInfo, signal)) {
// 是信号机接近区段
if (signal.isNormalOpen()) { //如果信号机已经正常开放继续查询下一个
continue;
if (routePath.isPathRoute(signal.getLockedRoute())) {
continue;
} else {
result[2] = true; // 非路径进路办理
break;
}
} else {
result[1] = true;
for (Route route : routePath.getRouteList()) {
@ -94,4 +98,17 @@ public abstract class AtsRouteSelectService {
return result;
}
protected boolean isApproachSignal(SimulationDataRepository repository, TrainInfo trainInfo, Signal signal) {
boolean ctcLevel = trainInfo.isCtcLevel();
Section section = repository.getByCode(trainInfo.getPhysicalSection(), Section.class);
Section logicSection = repository.getByCode(trainInfo.getSection(), Section.class);
if (logicSection.isSwitchAxleCounterSection() || logicSection.isCross()) {
logicSection = section;
}
if ((ctcLevel && signal.isCtcApproachSection(logicSection.getCode())) ||
(!ctcLevel && !signal.isVirtual() && signal.isApproachSection(section.getCode()))) {
return true;
}
return false;
}
}

View File

@ -5,6 +5,7 @@ import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
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.plan.StationPlan;
import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan;
import club.joylink.rtss.simulation.cbtc.data.support.RoutePath;
@ -30,6 +31,7 @@ public class AtsTriggerRouteService {
public void tryTrigger(Simulation simulation, TrainInfo trainInfo) {
Map<String, Route> atsTriggerRouteMap = trainInfo.getAtsTriggerRouteMap();
if (!atsTriggerRouteMap.isEmpty()) {
SimulationDataRepository repository = simulation.getRepository();
for (Route route : atsTriggerRouteMap.values()) {
if (route.isNormalUnlock()) {
if (route.isRouteSection(trainInfo.getPhysicalSection())) {
@ -37,6 +39,14 @@ public class AtsTriggerRouteService {
continue;
}
}
if (!route.isAtsControl()) {
atsTriggerRouteMap.remove(route.getCode());
continue;
}
Signal signal = route.getStart();
if (!this.planTrainRouteSelectService.isApproachSignal(repository, trainInfo, signal)) {
atsTriggerRouteMap.remove(route.getCode());
}
if (route.isSetting()) {
return;
}
@ -47,7 +57,6 @@ public class AtsTriggerRouteService {
continue;
} else if (route.isConflictHandleRunAsPlan()) {
if (trainInfo.isPlanTrain()) {
SimulationDataRepository repository = simulation.getRepository();
TripPlan tripPlan = repository.getTripPlan(trainInfo.getServiceNumber(), trainInfo.getTripNumber());
AtsPlanTrainRouteSelectServiceImpl.ConflictInfo conflictInfo = this.planTrainRouteSelectService.checkConflict(repository, trainInfo, tripPlan, route);
if (conflictInfo != null) {
@ -76,8 +85,10 @@ public class AtsTriggerRouteService {
if (route == null) { // 没有需要触发的进路返回
return;
}
atsTriggerRouteMap.put(route.getCode(), route);
this.trySetRoute(simulation, trainInfo, route);
if (route.isAtsControl()) { // ATS自动排列才处理
atsTriggerRouteMap.put(route.getCode(), route);
this.trySetRoute(simulation, trainInfo, route);
}
}
private void trySetRoute(Simulation simulation, TrainInfo trainInfo, Route route) {

View File

@ -24,6 +24,7 @@ import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
import club.joylink.rtss.simulation.cbtc.fault.FaultGenerator;
import club.joylink.rtss.simulation.cbtc.member.MemberManager;
import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPLogicLoop;
import club.joylink.rtss.simulation.cbtc.onboard.TrainTargetUpdateService;
import club.joylink.rtss.simulation.cbtc.robot.RobotLogicLoop;
import club.joylink.rtss.vo.client.runplan.RunPlanVO;
import club.joylink.rtss.vo.client.schedulingNew.SchedulingPlanNewVO;
@ -96,6 +97,8 @@ public class SimulationLifeCycleServiceImpl implements SimulationLifeCycleServic
@Autowired
private IVirtualRealityPslService iVirtualRealityPslService;
@Autowired
private TrainTargetUpdateService trainTargetUpdateService;
@Override
public Simulation create(SimulationBuildParams params, String group) {
@ -119,6 +122,7 @@ public class SimulationLifeCycleServiceImpl implements SimulationLifeCycleServic
private void addJobs(Simulation simulation) {
atsLogicLoop.addJobs(simulation);
atpLogicLoop.addJobs(simulation);
trainTargetUpdateService.addJobs(simulation);
vrTrainRunningService.addJobs(simulation);
ciLogicLoop.addJobs(simulation);
vrDeviceLogicLoop.addJobs(simulation);

View File

@ -1077,6 +1077,10 @@ public class Section extends MayOutOfOrderDevice {
}
}
public boolean isJustTurnBackTrack() {
return !this.isNormalStandTrack() && this.isTurnBackTrack();
}
public enum SectionRoadType {
/**
* 左行线

View File

@ -299,23 +299,29 @@ public class Signal extends MayOutOfOrderDevice {
List<Section> logicList = path.getLogicList();
if (!CollectionUtils.isEmpty(logicList)) {
for (Section logic : logicList) {
if (logic.isSwitchTrack()) {
Switch relSwitch = logic.getRelSwitch();
SwitchElement switchElement = elementMap.get(relSwitch.getCode());
if (!relSwitch.isOnPosition(switchElement.isNormal())) {
break;
}
}
if (logic.getCode().equals(sectionCode)) {
return true;
}
}
} else {
for (Section approach : path.getSectionList()) {
if (approach.isSamePhysical(sectionCode)) {
return true;
} else if (approach.isSwitchTrack()) {
if (approach.isSwitchTrack()) {
Switch relSwitch = approach.getRelSwitch();
SwitchElement element = elementMap.get(relSwitch.getCode());
if (relSwitch.isOnPosition(element.isNormal())) {
continue;
} else {
if (!relSwitch.isOnPosition(element.isNormal())) {
break;
}
}
if (approach.isSamePhysical(sectionCode)) {
return true;
}
}
}
}

View File

@ -0,0 +1,73 @@
package club.joylink.rtss.simulation.cbtc.onboard;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.map.Section;
import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Objects;
@Component
public class TrainTargetUpdateService {
public static final String Model_Name = "TrainTargetUpdate";
public static final int Rate = 5000;
public void addJobs(Simulation simulation) {
simulation.addJob(Model_Name, () -> this.run(simulation), Rate);
}
public void run(Simulation simulation) {
SimulationDataRepository repository = simulation.getRepository();
List<VirtualRealityTrain> onlineTrain = repository.getOnlineTrainList();
for (VirtualRealityTrain train : onlineTrain) {
if (train.isStop()) {
continue;
}
Section target = train.getTarget();
if (target == null) {
continue;
}
Section newTarget = this.queryArriveTarget(train, target);
if (target.equals(newTarget)) {
continue;
} else {
train.setTarget(newTarget);
}
}
}
private Section queryArriveTarget(VirtualRealityTrain train, Section target) {
SectionPosition headPosition = train.getHeadPosition();
if (Objects.equals(target, headPosition.getSection())) {
return target;
}
Section newTarget = target;
boolean right = train.isRight();
Section temp = headPosition.getSection();
int count = 0;
while (count < 25) {
++count;
Section nextSection = temp.getNextRunningSectionBaseRealSwitch(right);
if (nextSection == null) {
break;
}
if (Objects.equals(nextSection, target)) {// 找到
break;
}
if ((target.isNormalStandTrack() && nextSection.isNormalStandTrack()) ||
(target.isJustTurnBackTrack() && nextSection.isJustTurnBackTrack()) ||
(target.isTransferTrack() && nextSection.isTransferTrack()) &&
target.getStation().equals(nextSection.getStation())) {
newTarget = nextSection;
break;
} else {
temp = nextSection;
}
}
return newTarget;
}
}