This commit is contained in:
weizhihong 2022-07-22 19:46:45 +08:00
commit 7ae2e6fa6a
21 changed files with 131 additions and 55 deletions

View File

@ -89,9 +89,9 @@ public class MaService {
public float calculateDistanceToEoa() { public float calculateDistanceToEoa() {
SectionPosition headPosition = train.getHeadPosition(); SectionPosition headPosition = train.getHeadPosition();
boolean right = train.isRight(); boolean right = train.isRight();
Float distance = CalculateService.calculateDistance(headPosition, this.eoaPosition, right); Float distance = CalculateService.calculateDistance(headPosition, this.eoaPosition, right, false);
if (distance == null) { if (distance == null) {
distance = CalculateService.calculateDistance(headPosition, this.eoaPosition, !right); distance = CalculateService.calculateDistance(headPosition, this.eoaPosition, !right, false);
if (distance == null) { if (distance == null) {
distance = 0f; distance = 0f;
} else if (distance > 0) { } else if (distance > 0) {
@ -137,7 +137,7 @@ public class MaService {
SectionPosition sectionPosition = new SectionPosition(signal.getSection(), signal.getOffset()); SectionPosition sectionPosition = new SectionPosition(signal.getSection(), signal.getOffset());
end = CalculateService.calculateNextPositionByStartAndLen(sectionPosition, !right, 5, false); 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) { if (distance == null) {
return 0; return 0;
} else if (distance < standard) { } else if (distance < standard) {
@ -146,7 +146,7 @@ public class MaService {
} else if (this.type.equals(MaType.Front_Train)) { } else if (this.type.equals(MaType.Front_Train)) {
VirtualRealityTrain frontTrain = (VirtualRealityTrain) this.device; VirtualRealityTrain frontTrain = (VirtualRealityTrain) this.device;
if (frontTrain.isParkingAt()) { 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) if (distance == null)
return 0; return 0;
return distance - EB_Trigger; return distance - EB_Trigger;
@ -382,7 +382,7 @@ public class MaService {
Signal signal = section.getSignalOf(right); Signal signal = section.getSignalOf(right);
if (signal != null) { // 车头所在区段前方信号机开放 if (signal != null) { // 车头所在区段前方信号机开放
if (signal.isMainAspect()) { 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) { // 此处距离为暂时的估计值 if (distance != null) { // 此处距离为暂时的估计值
Route lockedRoute = signal.getLockedRoute(); Route lockedRoute = signal.getLockedRoute();
if (lockedRoute != null) { // 进路存在取进路终端信号机结束 if (lockedRoute != null) { // 进路存在取进路终端信号机结束

View File

@ -317,6 +317,16 @@ public class Operation {
*/ */
Signal_Set_Guide, Signal_Set_Guide,
/**
* 点灯
*/
Signal_Turn_On,
/**
* 灭灯
*/
Signal_Turn_Off,
//--------------------------- 站台操作 --------------------------- //--------------------------- 站台操作 ---------------------------
/** /**
* 设置跳停 * 设置跳停

View File

@ -316,4 +316,20 @@ public class SignalOperateHandler {
ciApiService.setGuide(simulation, signalCode, routeCode); 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);
}
} }

View File

@ -431,7 +431,7 @@ public class AtsTrainService {
Section linkTrainTargetSection = section.getNextRunningSectionOf(right); Section linkTrainTargetSection = section.getNextRunningSectionOf(right);
if (linkTrainTargetSection.isStandTrack()) { if (linkTrainTargetSection.isStandTrack()) {
SectionPosition linkTrainTargetPosition = new SectionPosition(linkTrainTargetSection, linkTrainTargetSection.getStopPointByDirection(right)); 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) { if (distance == null) {
throw new SimulationException(SimulationExceptionType.Illegal_Argument, "无法到达的位置"); throw new SimulationException(SimulationExceptionType.Illegal_Argument, "无法到达的位置");
} }
@ -464,7 +464,7 @@ public class AtsTrainService {
} }
SectionPosition headPosition = activeTrain.getHeadPosition(); SectionPosition headPosition = activeTrain.getHeadPosition();
SectionPosition tailPosition = passiveTrain.calculateTailPosition(); 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) { if (distance == null || distance > 3) {
throw new SimulationException(SimulationExceptionType.Invalid_Operation, String.format("列车[%s][%s]距离过远", groupNumber, groupNumber2)); throw new SimulationException(SimulationExceptionType.Invalid_Operation, String.format("列车[%s][%s]距离过远", groupNumber, groupNumber2));
} }

View File

@ -359,4 +359,8 @@ public interface CiApiService {
void switchMasterLock(Simulation simulation, String stationCode, Station.Throat throat); void switchMasterLock(Simulation simulation, String stationCode, Station.Throat throat);
void switchMasterUnlock(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);
} }

View File

@ -3,9 +3,12 @@ package club.joylink.rtss.simulation.cbtc.CI;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.CI.device.*; import club.joylink.rtss.simulation.cbtc.CI.device.*;
import club.joylink.rtss.simulation.cbtc.Simulation; 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.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.map.*; 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.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.SimulationException;
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -36,6 +39,9 @@ public class CiApiServiceImpl2 implements CiApiService {
private CiService ciService; private CiService ciService;
@Autowired @Autowired
private CiStandService standService; private CiStandService standService;
@Autowired
private VirtualRealityDeviceService virtualRealityDeviceService;
@Override @Override
public void blockadeSection(Simulation simulation, String sectionCode) { 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);
}
/** /**
* 获取计轴器并为预复位/复位操作检查设备状态 * 获取计轴器并为预复位/复位操作检查设备状态
*/ */

View File

@ -68,16 +68,18 @@ public class CiSignalControlService {
* @param signal * @param signal
*/ */
public void controlLightOfSignal(Simulation simulation, Signal signal) { public void controlLightOfSignal(Simulation simulation, Signal signal) {
VirtualRealitySignal vrSignal = signal.getVirtualSignal(); if (!simulation.getRepository().getConfig().isRailway()) {
if (signal.isCbtcMode() && !signal.isForcePhysical() && !signal.isLogicLight()) { VirtualRealitySignal vrSignal = signal.getVirtualSignal();
if (vrSignal != null) { if (signal.isCbtcMode() && !signal.isForcePhysical() && !signal.isLogicLight()) {
this.virtualRealityDeviceService.control(simulation, vrSignal, SignalAspect.No); if (vrSignal != null) {
} else { this.virtualRealityDeviceService.control(simulation, vrSignal, SignalAspect.No);
signal.setLogicLight(true); } else {
} signal.setLogicLight(true);
} else if ((!signal.isCbtcMode() || signal.isForcePhysical()) && signal.isLogicLight()) { }
if (vrSignal != null) { } else if ((!signal.isCbtcMode() || signal.isForcePhysical()) && signal.isLogicLight()) {
this.virtualRealityDeviceService.control(simulation, vrSignal, vrSignal.getModel().getDefaultAspect()); if (vrSignal != null) {
this.virtualRealityDeviceService.control(simulation, vrSignal, vrSignal.getModel().getDefaultAspect());
}
} }
} }
} }

View File

@ -22,13 +22,13 @@ public class DeviceStatusServiceImpl implements DeviceStatusService {
@Override @Override
public void init(Simulation simulation) { public void init(Simulation simulation) {
simulation.reset(); //这个初始化现在不可或缺有一些数据在仿真构建时没有仅在初始化时构建 simulation.reset(); //这个初始化现在不可或缺有一些数据在仿真构建时没有仅在初始化时构建
// 虚拟真实设备初始化
virtualRealityDeviceService.reset(simulation);
// 信号机状态初始化 // 信号机状态初始化
this.initSignal(simulation); this.initSignal(simulation);
this.buildSingleLockedSwitch(simulation); this.buildSingleLockedSwitch(simulation);
this.initRoute(simulation); this.initRoute(simulation);
this.initStationControlMode(simulation); this.initStationControlMode(simulation);
// 虚拟真实设备初始化
virtualRealityDeviceService.reset(simulation);
} }
/** /**
@ -54,10 +54,18 @@ public class DeviceStatusServiceImpl implements DeviceStatusService {
private void initSignal(Simulation simulation) { private void initSignal(Simulation simulation) {
SimulationDataRepository repository = simulation.getRepository(); SimulationDataRepository repository = simulation.getRepository();
// 初始化非ctc虚拟真实信号机点红灯
List<Signal> signalList = repository.getSignalList(); List<Signal> signalList = repository.getSignalList();
for (Signal signal : signalList) { if (!repository.getConfig().isRailway()) {
if (!signal.isCtc()) { // 初始化非ctc虚拟真实信号机点红灯
for (Signal signal : signalList) {
if (!signal.isCtc()) {
VirtualRealitySignal vrSignal = repository.getVRByCode(signal.getCode(), VirtualRealitySignal.class);
vrSignal.control(vrSignal.getModel().getDefaultAspect());
vrSignal.finish();
}
}
} else { //大铁线路暂时默认点灯
for (Signal signal : signalList) {
VirtualRealitySignal vrSignal = repository.getVRByCode(signal.getCode(), VirtualRealitySignal.class); VirtualRealitySignal vrSignal = repository.getVRByCode(signal.getCode(), VirtualRealitySignal.class);
vrSignal.control(vrSignal.getModel().getDefaultAspect()); vrSignal.control(vrSignal.getModel().getDefaultAspect());
vrSignal.finish(); vrSignal.finish();

View File

@ -621,7 +621,9 @@ public class CommandBO {
command.getTargetMember().setCommand(null); command.getTargetMember().setCommand(null);
return null; return null;
} }
targetMember.setCommand(null); if (train.isStop()) {
targetMember.setCommand(null);
}
// 设置目标位置 // 设置目标位置
return buildDriveStep(train.getHeadPosition()); return buildDriveStep(train.getHeadPosition());
} }
@ -886,7 +888,8 @@ public class CommandBO {
SectionPosition sectionPosition = null; SectionPosition sectionPosition = null;
for (int i = 0; i < 30; i++) { 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); Signal signal = section.getSignalOf(right);
if (section.isStandTrack() || section.isTurnBackTrack()) { if (section.isStandTrack() || section.isTurnBackTrack()) {
sectionPosition = new SectionPosition(section, section.getStopPointByDirection(right)); sectionPosition = new SectionPosition(section, section.getStopPointByDirection(right));

View File

@ -1,6 +1,7 @@
package club.joylink.rtss.simulation.cbtc.competition; package club.joylink.rtss.simulation.cbtc.competition;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum; 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.AtsOperationDispatcher;
import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation; import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation;
import club.joylink.rtss.simulation.cbtc.Simulation; 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.member.SimulationMember;
import club.joylink.rtss.simulation.cbtc.script.ScriptActionBO; import club.joylink.rtss.simulation.cbtc.script.ScriptActionBO;
import club.joylink.rtss.simulation.cbtc.script.ScriptBO; import club.joylink.rtss.simulation.cbtc.script.ScriptBO;
import club.joylink.rtss.services.voice.IVoiceService;
import club.joylink.rtss.util.StrUtils; import club.joylink.rtss.util.StrUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -276,7 +276,7 @@ public class ScriptExecuteService {
if (train.getLeverPosition() <= 0 && train.isStop()) { //控制杆空挡或制动并且列车停止 if (train.getLeverPosition() <= 0 && train.isStop()) { //控制杆空挡或制动并且列车停止
return; 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) { //目标位置在列车前方 if (distance == null) { //目标位置在列车前方
return; return;
} }

View File

@ -27,7 +27,7 @@ public class CalculateService {
if (offset < 0) { // 向左 if (offset < 0) { // 向左
Section leftSection; Section leftSection;
if (baseReal) { if (baseReal) {
leftSection = baseSection.getNextRunningSectionBaseRealSwitch(false); leftSection = baseSection.findNextRunningSectionBaseRealSwitch(false);
} else { } else {
leftSection = baseSection.getNextRunningSectionOf(false); leftSection = baseSection.getNextRunningSectionOf(false);
} }
@ -41,7 +41,7 @@ public class CalculateService {
} else { // 向右 } else { // 向右
Section rightSection; Section rightSection;
if (baseReal) { if (baseReal) {
rightSection = baseSection.getNextRunningSectionBaseRealSwitch(true); rightSection = baseSection.findNextRunningSectionBaseRealSwitch(true);
} else { } else {
rightSection = baseSection.getNextRunningSectionOf(true); rightSection = baseSection.getNextRunningSectionOf(true);
} }
@ -84,17 +84,18 @@ public class CalculateService {
* 计算起点到终点的距离双方向有正负 * 计算起点到终点的距离双方向有正负
*/ */
public static Float calculateDistanceDoubleDirection(SectionPosition startPosition, SectionPosition endPosition, boolean right) { 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) { if (distance == null) {
distance = calculateDistance(startPosition, endPosition, !right); distance = calculateDistance(startPosition, endPosition, !right, false);
} }
return distance; 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 startSection = startPosition.getSection();
Section endSection = endPosition.getSection(); Section endSection = endPosition.getSection();
float distance = 0; float distance = 0;
@ -103,7 +104,12 @@ public class CalculateService {
int iter = 0; int iter = 0;
while (!baseSection.equals(endSection)) { while (!baseSection.equals(endSection)) {
++iter; ++iter;
Section nextSection = baseSection.getNextRunningSectionOf(right); Section nextSection;
if (baseReal) {
nextSection = baseSection.findNextRunningSectionBaseRealSwitch(right);
} else {
nextSection = baseSection.getNextRunningSectionOf(right);
}
if (Objects.isNull(nextSection)) { // 下一个区段不存在,未找到,返回null if (Objects.isNull(nextSection)) { // 下一个区段不存在,未找到,返回null
return null; return null;
} else { // 存在,累加距离,更新基础区段和偏移量 } else { // 存在,累加距离,更新基础区段和偏移量
@ -519,7 +525,7 @@ public class CalculateService {
Section section = source; Section section = source;
while (!section.getCode().equals(target.getCode()) && loop < 20) { while (!section.getCode().equals(target.getCode()) && loop < 20) {
loop++; loop++;
Section temp = section.getNextRunningSectionBaseRealSwitch(right); Section temp = section.findNextRunningSectionBaseRealSwitch(right);
if (Objects.nonNull(temp)) { // 不为空 if (Objects.nonNull(temp)) { // 不为空
section = temp; section = temp;
occupySectionList.add(section); occupySectionList.add(section);
@ -628,7 +634,7 @@ public class CalculateService {
int count = 0; int count = 0;
while (count < 100) { while (count < 100) {
++count; ++count;
Section nextSection = temp.getNextRunningSectionBaseRealSwitch(right); Section nextSection = temp.findNextRunningSectionBaseRealSwitch(right);
if (Objects.equals(nextSection, front)) {// 找到 if (Objects.equals(nextSection, front)) {// 找到
return true; return true;
} }

View File

@ -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)) { if (right && Objects.nonNull(this.rightSection)) {
return this.rightSection; return this.rightSection;
} else if (!right && Objects.nonNull(this.leftSection)) { } else if (!right && Objects.nonNull(this.leftSection)) {

View File

@ -847,7 +847,7 @@ public class VirtualRealityTrain extends VirtualRealityDevice {
boolean right = this.right; boolean right = this.right;
Section section = headPosition.getSection(); Section section = headPosition.getSection();
for (int i = 0; i < 100; i++) { for (int i = 0; i < 100; i++) {
section = section.getNextRunningSectionOf(right); section = section.findNextRunningSectionBaseRealSwitch(right);
if (section == null) { if (section == null) {
break; break;
} }
@ -871,7 +871,7 @@ public class VirtualRealityTrain extends VirtualRealityDevice {
} }
for (int i = 0; i < 30; i++) { for (int i = 0; i < 30; i++) {
Section nextSection = section.getNextRunningSectionBaseRealSwitch(right); Section nextSection = section.findNextRunningSectionBaseRealSwitch(right);
if (nextSection == null) { if (nextSection == null) {
throw new SimulationException(SimulationExceptionType.Invalid_Operation, throw new SimulationException(SimulationExceptionType.Invalid_Operation,
String.format("信号机[%s]前方未找到站台轨或折返轨", signal.getName())); String.format("信号机[%s]前方未找到站台轨或折返轨", signal.getName()));
@ -899,7 +899,7 @@ public class VirtualRealityTrain extends VirtualRealityDevice {
Signal signal = section.getSignalOf(right); Signal signal = section.getSignalOf(right);
if (signal != null && signal.isMainAspect()) { //如果车头区段的同向信号机正常开放 if (signal != null && signal.isMainAspect()) { //如果车头区段的同向信号机正常开放
SectionPosition signalPosition = new SectionPosition(section, signal.getOffset()); SectionPosition signalPosition = new SectionPosition(section, signal.getOffset());
return CalculateService.calculateDistance(headPosition, signalPosition, right); return CalculateService.calculateDistance(headPosition, signalPosition, right, false);
} }
return null; return null;
} }

View File

@ -203,7 +203,7 @@ public class SrTrainServiceImpl implements UDPRealDeviceService {
} else { } else {
recommendedSpeedMax = 0; 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) { //如果列车已经抵达或越过目标位置 if (distance == null || distance <= SimulationConstants.PARK_POINT_MAX_OFFSET) { //如果列车已经抵达或越过目标位置
newSpeed = 0; newSpeed = 0;
} else { } else {

View File

@ -134,7 +134,7 @@ public class VRTrainRunningService {
*/ */
private void axleCounterCount(Simulation simulation, VirtualRealityTrain train, SectionPosition headPosition, SectionPosition headPositionNew) { private void axleCounterCount(Simulation simulation, VirtualRealityTrain train, SectionPosition headPosition, SectionPosition headPositionNew) {
boolean trainRight = train.isRight(); boolean trainRight = train.isRight();
Float distance = CalculateService.calculateDistance(headPosition, headPositionNew, trainRight); //列车移动的距离 Float distance = CalculateService.calculateDistance(headPosition, headPositionNew, trainRight, false); //列车移动的距离
if (distance == null) if (distance == null)
return; return;

View File

@ -116,7 +116,7 @@ public class SpeedCurve {
float speedMax = Math.min(train.getAtoSpeedMax(), train.getSpeedLimit() * 0.9f); float speedMax = Math.min(train.getAtoSpeedMax(), train.getSpeedLimit() * 0.9f);
SpeedCurve atoStopCurve; SpeedCurve atoStopCurve;
if (stopPosition != null) { if (stopPosition != null) {
Float stopPointDistance = CalculateService.calculateDistance(headPosition, stopPosition, right); Float stopPointDistance = CalculateService.calculateDistance(headPosition, stopPosition, right, false);
float ebTriggerDistance = ma.calculateDistanceOfEbTriggerEnd(); float ebTriggerDistance = ma.calculateDistanceOfEbTriggerEnd();
if (stopPointDistance != null && stopPointDistance <= ebTriggerDistance) { if (stopPointDistance != null && stopPointDistance <= ebTriggerDistance) {
// 列车停车位置距离小于eb触发距离 // 列车停车位置距离小于eb触发距离
@ -316,7 +316,7 @@ public class SpeedCurve {
Float needLimitSpeed = logic.getNeedLimitSpeed(); Float needLimitSpeed = logic.getNeedLimitSpeed();
if (needLimitSpeed != null && needLimitSpeed * 0.9f < limitSpeed) { //新的限速更小 if (needLimitSpeed != null && needLimitSpeed * 0.9f < limitSpeed) { //新的限速更小
endPosition = new SectionPosition(base, logic.getEndOffsetByDirection(!right)); //限速起始点 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过早考虑限速没有意义 if (distance != null && (distance > 500 || distance > totalLen)) //限速点在车头前方限速点距车头不超过500m过早考虑限速没有意义
break; break;
if (distance != null && distance > 0) { if (distance != null && distance > 0) {

View File

@ -147,7 +147,7 @@ public class ATOService {
Objects.requireNonNull(ma); Objects.requireNonNull(ma);
// ATP安全防护最远可达到位置 // ATP安全防护最远可达到位置
SectionPosition endPosition = ma.getEnd().getEndPosition(); SectionPosition endPosition = ma.getEnd().getEndPosition();
return CalculateService.calculateDistance(headPosition, endPosition, right); return CalculateService.calculateDistance(headPosition, endPosition, right, false);
} }
// /** // /**

View File

@ -431,7 +431,7 @@ public class ATPLogicLoop {
if (target != null) { if (target != null) {
float stopPoint = target.getStopPointByDirection(right); float stopPoint = target.getStopPointByDirection(right);
SectionPosition targetStopPosition = new SectionPosition(target, stopPoint); SectionPosition targetStopPosition = new SectionPosition(target, stopPoint);
Float distance2NextStation = CalculateService.calculateDistance(headPosition, targetStopPosition, right); Float distance2NextStation = CalculateService.calculateDistance(headPosition, targetStopPosition, right, false);
//距下一站的距离小于200视为即将到站 //距下一站的距离小于200视为即将到站
boolean old = train.isBeAbout2Arrive(); boolean old = train.isBeAbout2Arrive();
train.setBeAbout2Arrive(distance2NextStation != null && distance2NextStation < 200); train.setBeAbout2Arrive(distance2NextStation != null && distance2NextStation < 200);

View File

@ -88,9 +88,9 @@ public class ATPService {
SectionPosition headPosition = train.getHeadPosition(); SectionPosition headPosition = train.getHeadPosition();
boolean right = train.isRight(); boolean right = train.isRight();
SectionPosition endPosition = end.getEndPosition(); SectionPosition endPosition = end.getEndPosition();
Float distance = CalculateService.calculateDistance(headPosition, endPosition, right); Float distance = CalculateService.calculateDistance(headPosition, endPosition, right, false);
if (Objects.isNull(distance)) { // 正向找未找到,则反向找 if (Objects.isNull(distance)) { // 正向找未找到,则反向找
distance = CalculateService.calculateDistance(headPosition, endPosition, !right); distance = CalculateService.calculateDistance(headPosition, endPosition, !right, false);
if (Objects.nonNull(distance)) { if (Objects.nonNull(distance)) {
distance = -distance; distance = -distance;
} }

View File

@ -49,7 +49,7 @@ public class TrainTargetUpdateService {
if (temp == null) if (temp == null)
break; break;
if (!temp.isFunctionTrack()) { if (!temp.isFunctionTrack()) {
temp = temp.getNextRunningSectionBaseRealSwitch(right); temp = temp.findNextRunningSectionBaseRealSwitch(right);
continue; continue;
} }
Signal signal = temp.getSignalOf(right); Signal signal = temp.getSignalOf(right);
@ -61,7 +61,7 @@ public class TrainTargetUpdateService {
if (temp.isNormalStandTrack() || temp.isTransferTrack()) { if (temp.isNormalStandTrack() || temp.isTransferTrack()) {
if (temp.isNormalStandTrack()) { if (temp.isNormalStandTrack()) {
if (temp.getStandList().stream().anyMatch(stand -> stand.isJumpStop(train.getGroupNumber()))) { //该列车应在站台跳停 if (temp.getStandList().stream().anyMatch(stand -> stand.isJumpStop(train.getGroupNumber()))) { //该列车应在站台跳停
temp = temp.getNextRunningSectionBaseRealSwitch(right); temp = temp.findNextRunningSectionBaseRealSwitch(right);
continue; continue;
} }
} }
@ -80,7 +80,7 @@ public class TrainTargetUpdateService {
} }
} }
} }
temp = temp.getNextRunningSectionBaseRealSwitch(right); temp = temp.findNextRunningSectionBaseRealSwitch(right);
} }
return newTarget; return newTarget;
} }
@ -115,7 +115,7 @@ public class TrainTargetUpdateService {
newTarget = section; newTarget = section;
} }
} }
section = section.getNextRunningSectionBaseRealSwitch(right); section = section.findNextRunningSectionBaseRealSwitch(right);
if (section == null) { if (section == null) {
break; break;
} else { } else {

View File

@ -157,7 +157,7 @@ public class RobotLogicLoop {
//准备发车 //准备发车
robotReadyForDeparture(simulation, train); robotReadyForDeparture(simulation, train);
//机器人驾驶 //机器人驾驶
if (train.getRobotTargetPosition() != null) { if (driver.getCommand() != null) { //如果有和驾驶行为不冲突的指令这里需要做修改
robotDriveByCommand(simulation, driver, train); robotDriveByCommand(simulation, driver, train);
} else if (railway) { } else if (railway) {
railRobotDrive(simulation, train); railRobotDrive(simulation, train);
@ -166,7 +166,7 @@ public class RobotLogicLoop {
} }
/** /**
* 大铁机器人自动驾驶 * 大铁机器人自动驾驶目前的驾驶逻辑是针对RM/NRM模式驾驶
* 在确认列车自身状态正确的情况下车门是关闭状态等如果是没有计划的车次则只看信号如果是有计划的车次还需要看计划 * 在确认列车自身状态正确的情况下车门是关闭状态等如果是没有计划的车次则只看信号如果是有计划的车次还需要看计划
*/ */
private void railRobotDrive(Simulation simulation, VirtualRealityTrain train) { 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) { if (next == null) {
targetPosition = new SectionPosition(nextSection, right ? nextSection.getLen() - 10 : 10); //轨道尽头10m处 targetPosition = new SectionPosition(nextSection, right ? nextSection.getLen() - 10 : 10); //轨道尽头10m处
break; break;
@ -264,7 +264,7 @@ public class RobotLogicLoop {
break; break;
} }
} }
nextSection = nextSection.getNextRunningSectionBaseRealSwitch(right); nextSection = nextSection.findNextRunningSectionBaseRealSwitch(right);
if (nextSection == null) if (nextSection == null)
break; break;
} }
@ -289,7 +289,7 @@ public class RobotLogicLoop {
boolean right = train.isRight(); boolean right = train.isRight();
float speed = train.getSpeed(); 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) { //如果列车已经抵达或越过目标位置 if (distance == null || distance <= SimulationConstants.PARK_POINT_MAX_OFFSET) { //如果列车已经抵达或越过目标位置
atoService.doBreakMax(train); atoService.doBreakMax(train);
return; return;