大铁增加点灯灭灯操作;大铁不执行根据信号机模式自动切换点灯灭灯状态逻辑;修改部分列车运行指令的寻路逻辑;修改停车指令结束条件;修改大铁自动驾驶寻路逻辑
This commit is contained in:
parent
ba0c05eb64
commit
66d21c1778
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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,16 +68,18 @@ public class CiSignalControlService {
|
||||
* @param signal
|
||||
*/
|
||||
public void controlLightOfSignal(Simulation simulation, Signal signal) {
|
||||
VirtualRealitySignal vrSignal = signal.getVirtualSignal();
|
||||
if (signal.isCbtcMode() && !signal.isForcePhysical() && !signal.isLogicLight()) {
|
||||
if (vrSignal != null) {
|
||||
this.virtualRealityDeviceService.control(simulation, vrSignal, SignalAspect.No);
|
||||
} else {
|
||||
signal.setLogicLight(true);
|
||||
}
|
||||
} else if ((!signal.isCbtcMode() || signal.isForcePhysical()) && signal.isLogicLight()) {
|
||||
if (vrSignal != null) {
|
||||
this.virtualRealityDeviceService.control(simulation, vrSignal, vrSignal.getModel().getDefaultAspect());
|
||||
if (!simulation.getRepository().getConfig().isRailway()) {
|
||||
VirtualRealitySignal vrSignal = signal.getVirtualSignal();
|
||||
if (signal.isCbtcMode() && !signal.isForcePhysical() && !signal.isLogicLight()) {
|
||||
if (vrSignal != null) {
|
||||
this.virtualRealityDeviceService.control(simulation, vrSignal, SignalAspect.No);
|
||||
} else {
|
||||
signal.setLogicLight(true);
|
||||
}
|
||||
} else if ((!signal.isCbtcMode() || signal.isForcePhysical()) && signal.isLogicLight()) {
|
||||
if (vrSignal != null) {
|
||||
this.virtualRealityDeviceService.control(simulation, vrSignal, vrSignal.getModel().getDefaultAspect());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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,10 +54,18 @@ public class DeviceStatusServiceImpl implements DeviceStatusService {
|
||||
|
||||
private void initSignal(Simulation simulation) {
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
// 初始化非ctc虚拟真实信号机点红灯
|
||||
List<Signal> signalList = repository.getSignalList();
|
||||
for (Signal signal : signalList) {
|
||||
if (!signal.isCtc()) {
|
||||
if (!repository.getConfig().isRailway()) {
|
||||
// 初始化非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);
|
||||
vrSignal.control(vrSignal.getModel().getDefaultAspect());
|
||||
vrSignal.finish();
|
||||
|
@ -621,7 +621,9 @@ public class CommandBO {
|
||||
command.getTargetMember().setCommand(null);
|
||||
return null;
|
||||
}
|
||||
targetMember.setCommand(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));
|
||||
|
@ -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);
|
||||
}
|
||||
@ -519,7 +519,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 +628,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()));
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user