Merge branch 'test' of https://git.code.tencent.com/lian-cbtc/rtss-server into test
This commit is contained in:
commit
7ae2e6fa6a
@ -89,9 +89,9 @@ public class MaService {
|
||||
public float calculateDistanceToEoa() {
|
||||
SectionPosition headPosition = train.getHeadPosition();
|
||||
boolean right = train.isRight();
|
||||
Float distance = CalculateService.calculateDistance(headPosition, this.eoaPosition, right);
|
||||
Float distance = CalculateService.calculateDistance(headPosition, this.eoaPosition, right, false);
|
||||
if (distance == null) {
|
||||
distance = CalculateService.calculateDistance(headPosition, this.eoaPosition, !right);
|
||||
distance = CalculateService.calculateDistance(headPosition, this.eoaPosition, !right, false);
|
||||
if (distance == null) {
|
||||
distance = 0f;
|
||||
} else if (distance > 0) {
|
||||
@ -137,7 +137,7 @@ public class MaService {
|
||||
SectionPosition sectionPosition = new SectionPosition(signal.getSection(), signal.getOffset());
|
||||
end = CalculateService.calculateNextPositionByStartAndLen(sectionPosition, !right, 5, false);
|
||||
}
|
||||
Float distance = CalculateService.calculateDistance(this.train.getHeadPosition(), end, right);
|
||||
Float distance = CalculateService.calculateDistance(this.train.getHeadPosition(), end, right, false);
|
||||
if (distance == null) {
|
||||
return 0;
|
||||
} else if (distance < standard) {
|
||||
@ -146,7 +146,7 @@ public class MaService {
|
||||
} else if (this.type.equals(MaType.Front_Train)) {
|
||||
VirtualRealityTrain frontTrain = (VirtualRealityTrain) this.device;
|
||||
if (frontTrain.isParkingAt()) {
|
||||
Float distance = CalculateService.calculateDistance(this.train.getHeadPosition(), this.eoaPosition, right);
|
||||
Float distance = CalculateService.calculateDistance(this.train.getHeadPosition(), this.eoaPosition, right, false);
|
||||
if (distance == null)
|
||||
return 0;
|
||||
return distance - EB_Trigger;
|
||||
@ -382,7 +382,7 @@ public class MaService {
|
||||
Signal signal = section.getSignalOf(right);
|
||||
if (signal != null) { // 车头所在区段前方信号机开放
|
||||
if (signal.isMainAspect()) {
|
||||
Float distance = CalculateService.calculateDistance(headPosition, new SectionPosition(section, signal.getOffset()), right);
|
||||
Float distance = CalculateService.calculateDistance(headPosition, new SectionPosition(section, signal.getOffset()), right, false);
|
||||
if (distance != null) { // 此处距离为暂时的估计值,
|
||||
Route lockedRoute = signal.getLockedRoute();
|
||||
if (lockedRoute != null) { // 进路存在,取进路终端信号机,结束
|
||||
|
@ -317,6 +317,16 @@ public class Operation {
|
||||
*/
|
||||
Signal_Set_Guide,
|
||||
|
||||
/**
|
||||
* 点灯
|
||||
*/
|
||||
Signal_Turn_On,
|
||||
|
||||
/**
|
||||
* 灭灯
|
||||
*/
|
||||
Signal_Turn_Off,
|
||||
|
||||
//--------------------------- 站台操作 ---------------------------
|
||||
/**
|
||||
* 设置跳停
|
||||
|
@ -316,4 +316,20 @@ public class SignalOperateHandler {
|
||||
ciApiService.setGuide(simulation, signalCode, routeCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 信号机点灯
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Signal_Turn_On)
|
||||
public void signalTurnOn(Simulation simulation, String signalCode) {
|
||||
ciApiService.signalTurnOn(simulation, signalCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 信号机灭灯
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Signal_Turn_Off)
|
||||
public void signalTurnOff(Simulation simulation, String signalCode) {
|
||||
ciApiService.signalTurnOff(simulation, signalCode);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -431,7 +431,7 @@ public class AtsTrainService {
|
||||
Section linkTrainTargetSection = section.getNextRunningSectionOf(right);
|
||||
if (linkTrainTargetSection.isStandTrack()) {
|
||||
SectionPosition linkTrainTargetPosition = new SectionPosition(linkTrainTargetSection, linkTrainTargetSection.getStopPointByDirection(right));
|
||||
Float distance = CalculateService.calculateDistance(linkTrain.getHeadPosition(), linkTrainTargetPosition, right);
|
||||
Float distance = CalculateService.calculateDistance(linkTrain.getHeadPosition(), linkTrainTargetPosition, right, false);
|
||||
if (distance == null) {
|
||||
throw new SimulationException(SimulationExceptionType.Illegal_Argument, "无法到达的位置");
|
||||
}
|
||||
@ -464,7 +464,7 @@ public class AtsTrainService {
|
||||
}
|
||||
SectionPosition headPosition = activeTrain.getHeadPosition();
|
||||
SectionPosition tailPosition = passiveTrain.calculateTailPosition();
|
||||
Float distance = CalculateService.calculateDistance(headPosition, tailPosition, activeTrain.isRight());
|
||||
Float distance = CalculateService.calculateDistance(headPosition, tailPosition, activeTrain.isRight(), false);
|
||||
if (distance == null || distance > 3) {
|
||||
throw new SimulationException(SimulationExceptionType.Invalid_Operation, String.format("列车[%s][%s]距离过远", groupNumber, groupNumber2));
|
||||
}
|
||||
|
@ -359,4 +359,8 @@ public interface CiApiService {
|
||||
void switchMasterLock(Simulation simulation, String stationCode, Station.Throat throat);
|
||||
|
||||
void switchMasterUnlock(Simulation simulation, String stationCode, Station.Throat throat);
|
||||
|
||||
void signalTurnOn(Simulation simulation, String signalCode);
|
||||
|
||||
void signalTurnOff(Simulation simulation, String signalCode);
|
||||
}
|
||||
|
@ -3,9 +3,12 @@ package club.joylink.rtss.simulation.cbtc.CI;
|
||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||
import club.joylink.rtss.simulation.cbtc.CI.device.*;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SignalAspect;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.*;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySectionAxleCounter;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal;
|
||||
import club.joylink.rtss.simulation.cbtc.device.virtual.VirtualRealityDeviceService;
|
||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
|
||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -36,6 +39,9 @@ public class CiApiServiceImpl2 implements CiApiService {
|
||||
private CiService ciService;
|
||||
@Autowired
|
||||
private CiStandService standService;
|
||||
@Autowired
|
||||
private VirtualRealityDeviceService virtualRealityDeviceService;
|
||||
|
||||
|
||||
@Override
|
||||
public void blockadeSection(Simulation simulation, String sectionCode) {
|
||||
@ -692,6 +698,27 @@ public class CiApiServiceImpl2 implements CiApiService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void signalTurnOn(Simulation simulation, String signalCode) {
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
Signal signal = repository.getByCode(signalCode, Signal.class);
|
||||
BusinessExceptionAssertEnum.OPERATION_FAIL.assertNull(signal.getLockedRoute(), "信号机有锁闭进路,禁止点灯");
|
||||
VirtualRealitySignal vrSignal = signal.getVirtualSignal();
|
||||
BusinessExceptionAssertEnum.OPERATION_FAIL.assertNotNull(vrSignal, signal.debugStr() + "无实体信号机");
|
||||
virtualRealityDeviceService.control(simulation, vrSignal, vrSignal.getModel().getDefaultAspect());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void signalTurnOff(Simulation simulation, String signalCode) {
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
Signal signal = repository.getByCode(signalCode, Signal.class);
|
||||
BusinessExceptionAssertEnum.OPERATION_FAIL.assertNotTrue(signal.isShunting(), "调车信号机无法灭灯");
|
||||
BusinessExceptionAssertEnum.OPERATION_FAIL.assertNull(signal.getLockedRoute(), "信号机有锁闭进路,禁止灭灯");
|
||||
VirtualRealitySignal vrSignal = signal.getVirtualSignal();
|
||||
BusinessExceptionAssertEnum.OPERATION_FAIL.assertNotNull(vrSignal, signal.debugStr() + "无实体信号机");
|
||||
virtualRealityDeviceService.control(simulation, vrSignal, SignalAspect.No);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取计轴器并为预复位/复位操作检查设备状态
|
||||
*/
|
||||
|
@ -68,6 +68,7 @@ public class CiSignalControlService {
|
||||
* @param signal
|
||||
*/
|
||||
public void controlLightOfSignal(Simulation simulation, Signal signal) {
|
||||
if (!simulation.getRepository().getConfig().isRailway()) {
|
||||
VirtualRealitySignal vrSignal = signal.getVirtualSignal();
|
||||
if (signal.isCbtcMode() && !signal.isForcePhysical() && !signal.isLogicLight()) {
|
||||
if (vrSignal != null) {
|
||||
@ -81,6 +82,7 @@ public class CiSignalControlService {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 封锁(封锁后,包含信号机的进路不能排列)
|
||||
|
@ -22,13 +22,13 @@ public class DeviceStatusServiceImpl implements DeviceStatusService {
|
||||
@Override
|
||||
public void init(Simulation simulation) {
|
||||
simulation.reset(); //这个初始化现在不可或缺,有一些数据在仿真构建时没有,仅在初始化时构建
|
||||
// 虚拟真实设备初始化
|
||||
virtualRealityDeviceService.reset(simulation);
|
||||
// 信号机状态初始化
|
||||
this.initSignal(simulation);
|
||||
this.buildSingleLockedSwitch(simulation);
|
||||
this.initRoute(simulation);
|
||||
this.initStationControlMode(simulation);
|
||||
// 虚拟真实设备初始化
|
||||
virtualRealityDeviceService.reset(simulation);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -54,8 +54,9 @@ public class DeviceStatusServiceImpl implements DeviceStatusService {
|
||||
|
||||
private void initSignal(Simulation simulation) {
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
// 初始化非ctc虚拟真实信号机点红灯
|
||||
List<Signal> signalList = repository.getSignalList();
|
||||
if (!repository.getConfig().isRailway()) {
|
||||
// 初始化非ctc虚拟真实信号机点红灯
|
||||
for (Signal signal : signalList) {
|
||||
if (!signal.isCtc()) {
|
||||
VirtualRealitySignal vrSignal = repository.getVRByCode(signal.getCode(), VirtualRealitySignal.class);
|
||||
@ -63,6 +64,13 @@ public class DeviceStatusServiceImpl implements DeviceStatusService {
|
||||
vrSignal.finish();
|
||||
}
|
||||
}
|
||||
} else { //大铁线路暂时默认点灯
|
||||
for (Signal signal : signalList) {
|
||||
VirtualRealitySignal vrSignal = repository.getVRByCode(signal.getCode(), VirtualRealitySignal.class);
|
||||
vrSignal.control(vrSignal.getModel().getDefaultAspect());
|
||||
vrSignal.finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buildSingleLockedSwitch(Simulation simulation) {
|
||||
|
@ -621,7 +621,9 @@ public class CommandBO {
|
||||
command.getTargetMember().setCommand(null);
|
||||
return null;
|
||||
}
|
||||
if (train.isStop()) {
|
||||
targetMember.setCommand(null);
|
||||
}
|
||||
// 设置目标位置
|
||||
return buildDriveStep(train.getHeadPosition());
|
||||
}
|
||||
@ -886,7 +888,8 @@ public class CommandBO {
|
||||
|
||||
SectionPosition sectionPosition = null;
|
||||
for (int i = 0; i < 30; i++) {
|
||||
section = section.getNextRunningSectionOf(right);
|
||||
section = section.findNextRunningSectionBaseRealSwitch(right);
|
||||
BusinessExceptionAssertEnum.OPERATION_FAIL.assertNotNull(section, "引导信号前方未找到停车位置");
|
||||
Signal signal = section.getSignalOf(right);
|
||||
if (section.isStandTrack() || section.isTurnBackTrack()) {
|
||||
sectionPosition = new SectionPosition(section, section.getStopPointByDirection(right));
|
||||
|
@ -1,6 +1,7 @@
|
||||
package club.joylink.rtss.simulation.cbtc.competition;
|
||||
|
||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||
import club.joylink.rtss.services.voice.IVoiceService;
|
||||
import club.joylink.rtss.simulation.cbtc.ATS.operation.AtsOperationDispatcher;
|
||||
import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
@ -17,7 +18,6 @@ import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
|
||||
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||
import club.joylink.rtss.simulation.cbtc.script.ScriptActionBO;
|
||||
import club.joylink.rtss.simulation.cbtc.script.ScriptBO;
|
||||
import club.joylink.rtss.services.voice.IVoiceService;
|
||||
import club.joylink.rtss.util.StrUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -276,7 +276,7 @@ public class ScriptExecuteService {
|
||||
if (train.getLeverPosition() <= 0 && train.isStop()) { //控制杆空挡或制动并且列车停止
|
||||
return;
|
||||
}
|
||||
Float distance = CalculateService.calculateDistance(train.getHeadPosition(), action.getTargetPosition(), train.isRight());
|
||||
Float distance = CalculateService.calculateDistance(train.getHeadPosition(), action.getTargetPosition(), train.isRight(), false);
|
||||
if (distance == null) { //目标位置在列车前方
|
||||
return;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public class CalculateService {
|
||||
if (offset < 0) { // 向左
|
||||
Section leftSection;
|
||||
if (baseReal) {
|
||||
leftSection = baseSection.getNextRunningSectionBaseRealSwitch(false);
|
||||
leftSection = baseSection.findNextRunningSectionBaseRealSwitch(false);
|
||||
} else {
|
||||
leftSection = baseSection.getNextRunningSectionOf(false);
|
||||
}
|
||||
@ -41,7 +41,7 @@ public class CalculateService {
|
||||
} else { // 向右
|
||||
Section rightSection;
|
||||
if (baseReal) {
|
||||
rightSection = baseSection.getNextRunningSectionBaseRealSwitch(true);
|
||||
rightSection = baseSection.findNextRunningSectionBaseRealSwitch(true);
|
||||
} else {
|
||||
rightSection = baseSection.getNextRunningSectionOf(true);
|
||||
}
|
||||
@ -84,17 +84,18 @@ public class CalculateService {
|
||||
* 计算起点到终点的距离(双方向)(有正负)
|
||||
*/
|
||||
public static Float calculateDistanceDoubleDirection(SectionPosition startPosition, SectionPosition endPosition, boolean right) {
|
||||
Float distance = calculateDistance(startPosition, endPosition, right);
|
||||
Float distance = calculateDistance(startPosition, endPosition, right, false);
|
||||
if (distance == null) {
|
||||
distance = calculateDistance(startPosition, endPosition, !right);
|
||||
distance = calculateDistance(startPosition, endPosition, !right, false);
|
||||
}
|
||||
return distance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算从起点到终点距离(单方向)
|
||||
* @param baseReal 是否基于实体设备
|
||||
*/
|
||||
public static Float calculateDistance(SectionPosition startPosition, SectionPosition endPosition, boolean right) {
|
||||
public static Float calculateDistance(SectionPosition startPosition, SectionPosition endPosition, boolean right, boolean baseReal) {
|
||||
Section startSection = startPosition.getSection();
|
||||
Section endSection = endPosition.getSection();
|
||||
float distance = 0;
|
||||
@ -103,7 +104,12 @@ public class CalculateService {
|
||||
int iter = 0;
|
||||
while (!baseSection.equals(endSection)) {
|
||||
++iter;
|
||||
Section nextSection = baseSection.getNextRunningSectionOf(right);
|
||||
Section nextSection;
|
||||
if (baseReal) {
|
||||
nextSection = baseSection.findNextRunningSectionBaseRealSwitch(right);
|
||||
} else {
|
||||
nextSection = baseSection.getNextRunningSectionOf(right);
|
||||
}
|
||||
if (Objects.isNull(nextSection)) { // 下一个区段不存在,未找到,返回null
|
||||
return null;
|
||||
} else { // 存在,累加距离,更新基础区段和偏移量
|
||||
@ -519,7 +525,7 @@ public class CalculateService {
|
||||
Section section = source;
|
||||
while (!section.getCode().equals(target.getCode()) && loop < 20) {
|
||||
loop++;
|
||||
Section temp = section.getNextRunningSectionBaseRealSwitch(right);
|
||||
Section temp = section.findNextRunningSectionBaseRealSwitch(right);
|
||||
if (Objects.nonNull(temp)) { // 不为空
|
||||
section = temp;
|
||||
occupySectionList.add(section);
|
||||
@ -628,7 +634,7 @@ public class CalculateService {
|
||||
int count = 0;
|
||||
while (count < 100) {
|
||||
++count;
|
||||
Section nextSection = temp.getNextRunningSectionBaseRealSwitch(right);
|
||||
Section nextSection = temp.findNextRunningSectionBaseRealSwitch(right);
|
||||
if (Objects.equals(nextSection, front)) {// 找到
|
||||
return true;
|
||||
}
|
||||
|
@ -403,7 +403,7 @@ public class Section extends DelayUnlockDevice {
|
||||
/**
|
||||
* 基于真实道岔找下一个可运行到的区段
|
||||
*/
|
||||
public Section getNextRunningSectionBaseRealSwitch(boolean right) {
|
||||
public Section findNextRunningSectionBaseRealSwitch(boolean right) {
|
||||
if (right && Objects.nonNull(this.rightSection)) {
|
||||
return this.rightSection;
|
||||
} else if (!right && Objects.nonNull(this.leftSection)) {
|
||||
|
@ -847,7 +847,7 @@ public class VirtualRealityTrain extends VirtualRealityDevice {
|
||||
boolean right = this.right;
|
||||
Section section = headPosition.getSection();
|
||||
for (int i = 0; i < 100; i++) {
|
||||
section = section.getNextRunningSectionOf(right);
|
||||
section = section.findNextRunningSectionBaseRealSwitch(right);
|
||||
if (section == null) {
|
||||
break;
|
||||
}
|
||||
@ -871,7 +871,7 @@ public class VirtualRealityTrain extends VirtualRealityDevice {
|
||||
}
|
||||
|
||||
for (int i = 0; i < 30; i++) {
|
||||
Section nextSection = section.getNextRunningSectionBaseRealSwitch(right);
|
||||
Section nextSection = section.findNextRunningSectionBaseRealSwitch(right);
|
||||
if (nextSection == null) {
|
||||
throw new SimulationException(SimulationExceptionType.Invalid_Operation,
|
||||
String.format("信号机[%s]前方未找到站台轨或折返轨", signal.getName()));
|
||||
@ -899,7 +899,7 @@ public class VirtualRealityTrain extends VirtualRealityDevice {
|
||||
Signal signal = section.getSignalOf(right);
|
||||
if (signal != null && signal.isMainAspect()) { //如果车头区段的同向信号机正常开放
|
||||
SectionPosition signalPosition = new SectionPosition(section, signal.getOffset());
|
||||
return CalculateService.calculateDistance(headPosition, signalPosition, right);
|
||||
return CalculateService.calculateDistance(headPosition, signalPosition, right, false);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ public class SrTrainServiceImpl implements UDPRealDeviceService {
|
||||
} else {
|
||||
recommendedSpeedMax = 0;
|
||||
}
|
||||
Float distance = CalculateService.calculateDistance(headPosition, targetPosition, right);
|
||||
Float distance = CalculateService.calculateDistance(headPosition, targetPosition, right, false);
|
||||
if (distance == null || distance <= SimulationConstants.PARK_POINT_MAX_OFFSET) { //如果列车已经抵达或越过目标位置
|
||||
newSpeed = 0;
|
||||
} else {
|
||||
|
@ -134,7 +134,7 @@ public class VRTrainRunningService {
|
||||
*/
|
||||
private void axleCounterCount(Simulation simulation, VirtualRealityTrain train, SectionPosition headPosition, SectionPosition headPositionNew) {
|
||||
boolean trainRight = train.isRight();
|
||||
Float distance = CalculateService.calculateDistance(headPosition, headPositionNew, trainRight); //列车移动的距离
|
||||
Float distance = CalculateService.calculateDistance(headPosition, headPositionNew, trainRight, false); //列车移动的距离
|
||||
if (distance == null)
|
||||
return;
|
||||
|
||||
|
@ -116,7 +116,7 @@ public class SpeedCurve {
|
||||
float speedMax = Math.min(train.getAtoSpeedMax(), train.getSpeedLimit() * 0.9f);
|
||||
SpeedCurve atoStopCurve;
|
||||
if (stopPosition != null) {
|
||||
Float stopPointDistance = CalculateService.calculateDistance(headPosition, stopPosition, right);
|
||||
Float stopPointDistance = CalculateService.calculateDistance(headPosition, stopPosition, right, false);
|
||||
float ebTriggerDistance = ma.calculateDistanceOfEbTriggerEnd();
|
||||
if (stopPointDistance != null && stopPointDistance <= ebTriggerDistance) {
|
||||
// 列车停车位置距离小于eb触发距离
|
||||
@ -316,7 +316,7 @@ public class SpeedCurve {
|
||||
Float needLimitSpeed = logic.getNeedLimitSpeed();
|
||||
if (needLimitSpeed != null && needLimitSpeed * 0.9f < limitSpeed) { //新的限速更小
|
||||
endPosition = new SectionPosition(base, logic.getEndOffsetByDirection(!right)); //限速起始点
|
||||
distance = CalculateService.calculateDistance(headPosition, endPosition, right);
|
||||
distance = CalculateService.calculateDistance(headPosition, endPosition, right, false);
|
||||
if (distance != null && (distance > 500 || distance > totalLen)) //限速点在车头前方;限速点距车头不超过500m(过早考虑限速没有意义)
|
||||
break;
|
||||
if (distance != null && distance > 0) {
|
||||
|
@ -147,7 +147,7 @@ public class ATOService {
|
||||
Objects.requireNonNull(ma);
|
||||
// ATP安全防护最远可达到位置
|
||||
SectionPosition endPosition = ma.getEnd().getEndPosition();
|
||||
return CalculateService.calculateDistance(headPosition, endPosition, right);
|
||||
return CalculateService.calculateDistance(headPosition, endPosition, right, false);
|
||||
}
|
||||
|
||||
// /**
|
||||
|
@ -431,7 +431,7 @@ public class ATPLogicLoop {
|
||||
if (target != null) {
|
||||
float stopPoint = target.getStopPointByDirection(right);
|
||||
SectionPosition targetStopPosition = new SectionPosition(target, stopPoint);
|
||||
Float distance2NextStation = CalculateService.calculateDistance(headPosition, targetStopPosition, right);
|
||||
Float distance2NextStation = CalculateService.calculateDistance(headPosition, targetStopPosition, right, false);
|
||||
//距下一站的距离小于200视为即将到站
|
||||
boolean old = train.isBeAbout2Arrive();
|
||||
train.setBeAbout2Arrive(distance2NextStation != null && distance2NextStation < 200);
|
||||
|
@ -88,9 +88,9 @@ public class ATPService {
|
||||
SectionPosition headPosition = train.getHeadPosition();
|
||||
boolean right = train.isRight();
|
||||
SectionPosition endPosition = end.getEndPosition();
|
||||
Float distance = CalculateService.calculateDistance(headPosition, endPosition, right);
|
||||
Float distance = CalculateService.calculateDistance(headPosition, endPosition, right, false);
|
||||
if (Objects.isNull(distance)) { // 正向找未找到,则反向找
|
||||
distance = CalculateService.calculateDistance(headPosition, endPosition, !right);
|
||||
distance = CalculateService.calculateDistance(headPosition, endPosition, !right, false);
|
||||
if (Objects.nonNull(distance)) {
|
||||
distance = -distance;
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class TrainTargetUpdateService {
|
||||
if (temp == null)
|
||||
break;
|
||||
if (!temp.isFunctionTrack()) {
|
||||
temp = temp.getNextRunningSectionBaseRealSwitch(right);
|
||||
temp = temp.findNextRunningSectionBaseRealSwitch(right);
|
||||
continue;
|
||||
}
|
||||
Signal signal = temp.getSignalOf(right);
|
||||
@ -61,7 +61,7 @@ public class TrainTargetUpdateService {
|
||||
if (temp.isNormalStandTrack() || temp.isTransferTrack()) {
|
||||
if (temp.isNormalStandTrack()) {
|
||||
if (temp.getStandList().stream().anyMatch(stand -> stand.isJumpStop(train.getGroupNumber()))) { //该列车应在站台跳停
|
||||
temp = temp.getNextRunningSectionBaseRealSwitch(right);
|
||||
temp = temp.findNextRunningSectionBaseRealSwitch(right);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -80,7 +80,7 @@ public class TrainTargetUpdateService {
|
||||
}
|
||||
}
|
||||
}
|
||||
temp = temp.getNextRunningSectionBaseRealSwitch(right);
|
||||
temp = temp.findNextRunningSectionBaseRealSwitch(right);
|
||||
}
|
||||
return newTarget;
|
||||
}
|
||||
@ -115,7 +115,7 @@ public class TrainTargetUpdateService {
|
||||
newTarget = section;
|
||||
}
|
||||
}
|
||||
section = section.getNextRunningSectionBaseRealSwitch(right);
|
||||
section = section.findNextRunningSectionBaseRealSwitch(right);
|
||||
if (section == null) {
|
||||
break;
|
||||
} else {
|
||||
|
@ -157,7 +157,7 @@ public class RobotLogicLoop {
|
||||
//准备发车
|
||||
robotReadyForDeparture(simulation, train);
|
||||
//机器人驾驶
|
||||
if (train.getRobotTargetPosition() != null) {
|
||||
if (driver.getCommand() != null) { //如果有和驾驶行为不冲突的指令,这里需要做修改
|
||||
robotDriveByCommand(simulation, driver, train);
|
||||
} else if (railway) {
|
||||
railRobotDrive(simulation, train);
|
||||
@ -166,7 +166,7 @@ public class RobotLogicLoop {
|
||||
}
|
||||
|
||||
/**
|
||||
* 大铁机器人自动驾驶。
|
||||
* 大铁机器人自动驾驶。(目前的驾驶逻辑是针对RM/NRM模式驾驶)
|
||||
* 在确认列车自身状态正确的情况下(车门是关闭状态等),如果是没有计划的车次,则只看信号;如果是有计划的车次,还需要看计划
|
||||
*/
|
||||
private void railRobotDrive(Simulation simulation, VirtualRealityTrain train) {
|
||||
@ -208,7 +208,7 @@ public class RobotLogicLoop {
|
||||
}
|
||||
}
|
||||
}
|
||||
Section next = nextSection.getNextRunningSectionOf(right);
|
||||
Section next = nextSection.findNextRunningSectionBaseRealSwitch(right);
|
||||
if (next == null) {
|
||||
targetPosition = new SectionPosition(nextSection, right ? nextSection.getLen() - 10 : 10); //轨道尽头10m处
|
||||
break;
|
||||
@ -264,7 +264,7 @@ public class RobotLogicLoop {
|
||||
break;
|
||||
}
|
||||
}
|
||||
nextSection = nextSection.getNextRunningSectionBaseRealSwitch(right);
|
||||
nextSection = nextSection.findNextRunningSectionBaseRealSwitch(right);
|
||||
if (nextSection == null)
|
||||
break;
|
||||
}
|
||||
@ -289,7 +289,7 @@ public class RobotLogicLoop {
|
||||
boolean right = train.isRight();
|
||||
float speed = train.getSpeed();
|
||||
|
||||
Float distance = CalculateService.calculateDistance(headPosition, targetPosition, right);
|
||||
Float distance = CalculateService.calculateDistance(headPosition, targetPosition, right, true);
|
||||
if (distance == null || distance <= SimulationConstants.PARK_POINT_MAX_OFFSET) { //如果列车已经抵达或越过目标位置
|
||||
atoService.doBreakMax(train);
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user