Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
commit
d656a5071b
@ -21,6 +21,7 @@ import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPService;
|
||||
import club.joylink.rtss.simulation.cbtc.onboard.ATP.OnboardAtpApiService;
|
||||
import club.joylink.rtss.vo.client.map.newmap.MapStationRunLevelVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.tomcat.util.threads.StopPooledThreadException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@ -303,36 +304,36 @@ public class AtsTrainService {
|
||||
BusinessExceptionAssertEnum.INVALID_OPERATION.assertNotNull(path,
|
||||
String.format("列车[%s]无法到达目的地码[%s]对应区段[%s]", groupNumber, destinationCode, destinationSection.getCode()));
|
||||
supervisedTrain.setHeadPath(path);
|
||||
//根据找到的路径更新目标区段---
|
||||
Section nextTarget = null;
|
||||
int index = path.indexOf(headSection);
|
||||
if (index == -1)
|
||||
break;
|
||||
for (int i = index; i < path.size(); i++) {
|
||||
Section section = path.get(i);
|
||||
if (section.isSpecialSection()
|
||||
&& supervisedTrain.isNotArriveAt(repository, new SectionPosition(section, section.getStopPointByDirection(right)))) {
|
||||
List<RoutePath> routePaths = repository.queryRoutePathsByEnd(section);
|
||||
if (routePaths.stream().anyMatch(rp -> rp.containsSection(headSection))) {
|
||||
nextTarget = section;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nextTarget == null) {
|
||||
nextTarget = path.get(path.size() - 1);
|
||||
}
|
||||
if (nextTarget.getCode().equals(estimatedArriveStandTrack)) {
|
||||
break;
|
||||
}
|
||||
MapStationRunLevelVO runLevel = simulation.getBuildParams().getMap().getRunLevelByStartAndEndSection(estimatedArriveStandTrack, nextTarget.getCode());
|
||||
int runningTime = 0;
|
||||
if (runLevel != null) {
|
||||
runningTime = runLevel.getL3();
|
||||
}
|
||||
supervisedTrain.updateEstimatedArriveInfo(nextTarget, simulation.getSystemTime().plusSeconds(runningTime).toLocalTime());
|
||||
this.onboardAtpApiService.updateNextStation(simulation, supervisedTrain.getGroupNumber(),
|
||||
nextTarget.getStation().getCode(), nextTarget.getCode(), runningTime, true);
|
||||
// //根据找到的路径更新目标区段---
|
||||
// Section nextTarget = null;
|
||||
// int index = path.indexOf(headSection);
|
||||
// if (index == -1)
|
||||
// break;
|
||||
// for (int i = index; i < path.size(); i++) {
|
||||
// Section section = path.get(i);
|
||||
// if (section.isSpecialSection()
|
||||
// && supervisedTrain.isNotArriveAt(repository, new SectionPosition(section, section.getStopPointByDirection(right)))) {
|
||||
// List<RoutePath> routePaths = repository.queryRoutePathsByEnd(section);
|
||||
// if (routePaths.stream().anyMatch(rp -> rp.containsSection(headSection))) {
|
||||
// nextTarget = section;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (nextTarget == null) {
|
||||
// nextTarget = path.get(path.size() - 1);
|
||||
// }
|
||||
// if (nextTarget.getCode().equals(estimatedArriveStandTrack)) {
|
||||
// break;
|
||||
// }
|
||||
// MapStationRunLevelVO runLevel = simulation.getBuildParams().getMap().getRunLevelByStartAndEndSection(estimatedArriveStandTrack, nextTarget.getCode());
|
||||
// int runningTime = 0;
|
||||
// if (runLevel != null) {
|
||||
// runningTime = runLevel.getL3();
|
||||
// }
|
||||
// supervisedTrain.updateEstimatedArriveInfo(nextTarget, simulation.getSystemTime().plusSeconds(runningTime).toLocalTime());
|
||||
// this.onboardAtpApiService.updateNextStation(simulation, supervisedTrain.getGroupNumber(),
|
||||
// nextTarget.getStation().getCode(), nextTarget.getCode(), runningTime, true);
|
||||
break;
|
||||
default:
|
||||
throw new SimulationException(SimulationExceptionType.System_Fault, String.format("无法识别的目的地码类型[%s]", destinationCodeDefinition.getType()));
|
||||
@ -630,19 +631,19 @@ public class AtsTrainService {
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (nextTarget != null) {
|
||||
if (nextTarget.getCode().equals(estimatedArriveStandTrack)) {
|
||||
return;
|
||||
}
|
||||
SectionPosition stopPosition = new SectionPosition(nextTarget, nextTarget.getStopPointByDirection(trainRight));
|
||||
Float distance = CalculateService.calculateDistance(headPosition, stopPosition, trainRight);
|
||||
if (distance != null) {
|
||||
runningTime = (int) (distance / (45 / 3.6));
|
||||
}
|
||||
train.updateEstimatedArriveInfo(nextTarget, simulation.getSystemTime().plusSeconds(runningTime).toLocalTime());
|
||||
this.onboardAtpApiService.updateNextStation(simulation, train.getGroupNumber(),
|
||||
nextTarget.getStation().getCode(), nextTarget.getCode(), runningTime, true);
|
||||
}
|
||||
// if (nextTarget != null) {
|
||||
// if (nextTarget.getCode().equals(estimatedArriveStandTrack)) {
|
||||
// return;
|
||||
// }
|
||||
// SectionPosition stopPosition = new SectionPosition(nextTarget, nextTarget.getStopPointByDirection(trainRight));
|
||||
// Float distance = CalculateService.calculateDistance(headPosition, stopPosition, trainRight);
|
||||
// if (distance != null) {
|
||||
// runningTime = (int) (distance / (45 / 3.6));
|
||||
// }
|
||||
// train.updateEstimatedArriveInfo(nextTarget, simulation.getSystemTime().plusSeconds(runningTime).toLocalTime());
|
||||
// this.onboardAtpApiService.updateNextStation(simulation, train.getGroupNumber(),
|
||||
// nextTarget.getStation().getCode(), nextTarget.getCode(), runningTime, true);
|
||||
// }
|
||||
} else { //没有目的地码定义数据
|
||||
Section prePassed = null;
|
||||
List<Routing> routingList = repository.queryRoutingByDestCode(destinationCode);
|
||||
@ -667,39 +668,64 @@ public class AtsTrainService {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (Objects.nonNull(nextTarget)) {
|
||||
if (Objects.nonNull(prePassed)) {
|
||||
MapStationRunLevelVO runLevel = simulation.getBuildParams().getMap().getRunLevelByStartAndEndSection(prePassed.getCode(), nextTarget.getCode());
|
||||
if (Objects.nonNull(runLevel)) {
|
||||
runningTime = runLevel.getL3();
|
||||
// if (Objects.nonNull(nextTarget)) {
|
||||
// if (Objects.nonNull(prePassed)) {
|
||||
// MapStationRunLevelVO runLevel = simulation.getBuildParams().getMap().getRunLevelByStartAndEndSection(prePassed.getCode(), nextTarget.getCode());
|
||||
// if (Objects.nonNull(runLevel)) {
|
||||
// runningTime = runLevel.getL3();
|
||||
// }
|
||||
// }
|
||||
// if (!Objects.equals(estimatedArriveStandTrack, nextTarget.getCode())) {
|
||||
// boolean isPark = true;
|
||||
// if (repository.getConfig().isNoParkingServiceNumber(train.getServiceNumber())) {
|
||||
// isPark = false;
|
||||
// } else if (repository.getConfig().isParkingServiceNumber(train.getServiceNumber())) {
|
||||
// isPark = true;
|
||||
// }
|
||||
// train.updateEstimatedArriveInfo(nextTarget, LocalTime.now().plusSeconds(runningTime));
|
||||
// //默认
|
||||
// this.onboardAtpApiService.updateNextStation(simulation, train.getGroupNumber(),
|
||||
// nextTarget.getStation().getCode(), nextTarget.getCode(), runningTime, isPark);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
// else {
|
||||
// nextTarget = this.queryNextTargetByStartSectionAndRoutings(simulation, routingList, headSection);
|
||||
// if (Objects.nonNull(nextTarget) && !Objects.equals(estimatedArriveStandTrack, nextTarget.getCode())) {
|
||||
// if (Objects.equals(train.getActualLeaveStandTrack(), nextTarget.getCode())) {
|
||||
// log.warn(String.format("列车[%s]刚离开的站台,不更新", train.getGroupNumber()));
|
||||
// return;
|
||||
// }
|
||||
// train.updateEstimatedArriveInfo(nextTarget, train.getEstimatedArriveTime());
|
||||
// this.onboardAtpApiService.updateNextSection(simulation,
|
||||
// train.getGroupNumber(), nextTarget.getCode());
|
||||
// }
|
||||
// }
|
||||
}
|
||||
if (nextTarget != null) {
|
||||
if (nextTarget.getCode().equals(estimatedArriveStandTrack)) {
|
||||
return;
|
||||
}
|
||||
if (!Objects.equals(estimatedArriveStandTrack, nextTarget.getCode())) {
|
||||
boolean isPark = true;
|
||||
if (repository.getConfig().isNoParkingServiceNumber(train.getServiceNumber())) {
|
||||
isPark = false;
|
||||
} else if (repository.getConfig().isParkingServiceNumber(train.getServiceNumber())) {
|
||||
isPark = true;
|
||||
}
|
||||
train.updateEstimatedArriveInfo(nextTarget, LocalTime.now().plusSeconds(runningTime));
|
||||
//默认
|
||||
if (!nextTarget.isAheadOf(headSection, trainRight)) {
|
||||
atpService.turnDirectionImmediately(repository.getOnlineTrainBy(train.getGroupNumber()));
|
||||
}
|
||||
SectionPosition stopPosition = new SectionPosition(nextTarget, nextTarget.getStopPointByDirection(trainRight));
|
||||
Float distance = CalculateService.calculateDistance(headPosition, stopPosition, trainRight);
|
||||
if (distance == null) {
|
||||
distance = CalculateService.calculateDistance(headPosition, stopPosition, !trainRight);
|
||||
|
||||
}
|
||||
if (distance != null) {
|
||||
runningTime = (int) (distance / (45 / 3.6));
|
||||
}
|
||||
train.updateEstimatedArriveInfo(nextTarget, simulation.getSystemTime().plusSeconds(runningTime).toLocalTime());
|
||||
this.onboardAtpApiService.updateNextStation(simulation, train.getGroupNumber(),
|
||||
nextTarget.getStation().getCode(), nextTarget.getCode(), runningTime, isPark);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
nextTarget = this.queryNextTargetByStartSectionAndRoutings(simulation, routingList, headSection);
|
||||
if (Objects.nonNull(nextTarget) && !Objects.equals(estimatedArriveStandTrack, nextTarget.getCode())) {
|
||||
if (Objects.equals(train.getActualLeaveStandTrack(), nextTarget.getCode())) {
|
||||
log.warn(String.format("列车[%s]刚离开的站台,不更新", train.getGroupNumber()));
|
||||
return;
|
||||
}
|
||||
train.updateEstimatedArriveInfo(nextTarget, train.getEstimatedArriveTime());
|
||||
this.onboardAtpApiService.updateNextSection(simulation,
|
||||
train.getGroupNumber(), nextTarget.getCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -43,11 +43,11 @@ public class RouteService {
|
||||
if (Objects.nonNull(failMessage)) {
|
||||
return failMessage;
|
||||
}
|
||||
// 区间运行方向检查
|
||||
failMessage = this.directionRodCheck(simulation, route);
|
||||
if (Objects.nonNull(failMessage)) {
|
||||
return failMessage;
|
||||
}
|
||||
// // 区间运行方向检查
|
||||
// failMessage = this.directionRodCheck(simulation, route);
|
||||
// if (Objects.nonNull(failMessage)) {
|
||||
// return failMessage;
|
||||
// }
|
||||
// 共用道岔的冲突进路检查
|
||||
failMessage = this.switchUseCheck(simulation, route);
|
||||
if (Objects.nonNull(failMessage)) {
|
||||
|
@ -24,6 +24,7 @@ import club.joylink.rtss.simulation.cbtc.ATS.operation.AtsOperationDispatcher;
|
||||
import club.joylink.rtss.simulation.cbtc.ATS.service.AtsTrainLoadService;
|
||||
import club.joylink.rtss.simulation.cbtc.build.SimulationBuildParams;
|
||||
import club.joylink.rtss.simulation.cbtc.command.CommandBO;
|
||||
import club.joylink.rtss.simulation.cbtc.command.CommandExecuteService;
|
||||
import club.joylink.rtss.simulation.cbtc.command.CommandInitiateVO;
|
||||
import club.joylink.rtss.simulation.cbtc.communication.vo.fault.DeviceFaultInfo;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
|
||||
@ -138,6 +139,8 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
|
||||
private IRunPlanRunlevelService iRunPlanRunlevelService;
|
||||
@Autowired
|
||||
private IRunPlanParktimeService iRunPlanParktimeService;
|
||||
@Autowired
|
||||
private CommandExecuteService commandExecuteService;
|
||||
// /**
|
||||
// * 创建仿真并进行缓存
|
||||
// *
|
||||
@ -931,6 +934,7 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
|
||||
}
|
||||
CommandBO commandBO = new CommandBO(initiateVO.getCommandType(), member, targetMember, initiateVO.getParams(), steps);
|
||||
targetMember.setCommand(commandBO);
|
||||
commandExecuteService.addJobs(simulation);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -645,5 +645,6 @@ public class Simulation extends club.joylink.rtss.simulation.Simulation<Simulati
|
||||
String controlDevice = "controlDevice";
|
||||
String queryDeviceStatus = "queryDeviceStatus";
|
||||
String UpdateDeviceStatusByCollection = "UpdateDeviceStatusByCollection";
|
||||
String commandExecuteRun = "commandExecuteRun";
|
||||
}
|
||||
}
|
||||
|
@ -2,12 +2,14 @@ package club.joylink.rtss.simulation.cbtc.command;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.ATS.operation.AtsOperationDispatcher;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
|
||||
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.OnboardAtpApiService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@ -25,6 +27,8 @@ public class CommandExecuteService {
|
||||
public void run(Simulation simulation) {
|
||||
List<SimulationMember> haveCommandMember =
|
||||
simulation.getSimulationMembers().stream().filter(member -> member.getCommand() != null).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(haveCommandMember))
|
||||
removeJobs(simulation);
|
||||
for (SimulationMember member : haveCommandMember) {
|
||||
CommandBO command = member.getCommand();
|
||||
if (!member.isRobot()) {
|
||||
@ -59,4 +63,12 @@ public class CommandExecuteService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addJobs(Simulation simulation) {
|
||||
simulation.addJobIfAbsent(Simulation.JobName.commandExecuteRun, () -> this.run(simulation), SimulationConstants.COMMAND_EXECUTE_RATE);
|
||||
}
|
||||
|
||||
public void removeJobs(Simulation simulation) {
|
||||
simulation.removeJob(Simulation.JobName.commandExecuteRun);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package club.joylink.rtss.simulation.cbtc.data.map;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.data.CalculateService;
|
||||
import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySectionAxleCounter;
|
||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
|
||||
@ -998,6 +999,12 @@ public class Section extends MayOutOfOrderDevice {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAheadOf(Section other, boolean right) {
|
||||
if (this.equals(other))
|
||||
return false;
|
||||
return CalculateService.isTargetSectionOnDirectionExist(other, right, this);
|
||||
}
|
||||
|
||||
public enum SectionRoadType {
|
||||
/**
|
||||
* 左行线
|
||||
|
Loading…
Reference in New Issue
Block a user