增加特殊情况下使用的换端操作;修改机器人驾驶列车bug

This commit is contained in:
joylink_zhangsai 2023-10-25 14:15:10 +08:00
parent cf24e2e7f9
commit e7c6d428ad
3 changed files with 55 additions and 14 deletions

View File

@ -858,6 +858,11 @@ public class Operation {
* 切换ATO操作
*/
Try_Open_Ato(new Label[]{Label.OTHER}, true),
//--------------------------- 特殊操作多是ATS界面上对列车的操作 ---------------------------
/**
* 换端
*/
Special_Change_Head(new Label[]{Label.OTHER}, true),
//--------------------------- 方向杆 ---------------------------
/**
* 方向转换

View File

@ -0,0 +1,25 @@
package club.joylink.rtss.simulation.cbtc.ATS.operation.handler;
import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation;
import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandler;
import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandlerMapping;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@OperateHandler
@Slf4j
public class SpecialOperateHandler {
@Autowired
private ATPService atpService;
@OperateHandlerMapping(type = Operation.Type.Special_Change_Head)
public void changeHead(Simulation simulation, String groupNumber) {
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
if (train.isStop()) {
this.atpService.turnDirectionImmediately(train);
}
}
}

View File

@ -180,15 +180,19 @@ public class SimulationRobotService {
}
doBreakMax(simulation, train);
}
} else if (train.isRobotNeedRun() && (train.isRMMode()
|| train.isNRMMode())) { //CM应当根据推荐速度驾驶待实现
VirtualRealityTrain linkTrain = train.getLinkTrain();
if (linkTrain == null) {
Optional<SectionPosition> targetPositionOptional = calculateTargetPosition(simulation,
train);
targetPositionOptional.ifPresent(tp -> robotDrive(simulation, driver, train, tp));
} else {
robotDrive(simulation, driver, train, train.getRobotTargetPosition());
} else if (train.isRobotNeedRun()) {
if ((train.isRMMode() || train.isNRMMode())) { //RM或NRM
VirtualRealityTrain linkTrain = train.getLinkTrain();
if (linkTrain == null) {
Optional<SectionPosition> targetPositionOptional = calculateTargetPosition(simulation,
train);
targetPositionOptional.ifPresent(tp -> robotDrive(simulation, driver, train, tp));
} else {
robotDrive(simulation, driver, train, train.getRobotTargetPosition());
}
} else if (train.isCMMode()) { //CM
SpeedCurve speedCurve = train.getMa2().getAtoStopCurve();
atoService.doControlBySpeedCurve(train, speedCurve, speedCurve.getTotalDistance(), train.getAtoSpeed());
}
}
}
@ -255,12 +259,19 @@ public class SimulationRobotService {
// 如果计划停车区段为空或者计划停车区段中有包含当前区段
if (CollectionUtils.isEmpty(plannedParkingSections) || plannedParkingSections.contains(section)) {
SectionPosition stopPosition = section.buildStopPointPosition(right);
if (targetPosition == null || stopPosition.isAheadOf(targetPosition, right)) {
// 如果头部位置偏移小于停车点位置偏移目标点为当前停车点
if (headPosition.getOffset() < (section.getStopPointByDirection(right) + SimulationConstants.PARK_POINT_MAX_OFFSET)) { //防止意外开过站后无法发车
targetPosition = stopPosition;
}
SectionPosition maxStopPosition = CalculateService.calculateNextPositionByStartAndLen(stopPosition,
right, SimulationConstants.PARK_POINT_MAX_OFFSET, true);
if (maxStopPosition.isAheadOf(headPosition, right)) { //未越过最大停车点
targetPosition = stopPosition;
break;
}
// if (targetPosition == null || stopPosition.isAheadOf(targetPosition, right)) {
// CalculateService.calculateNextPositionByStartAndLen(stopPosition, right, SimulationConstants.PARK_POINT_MAX_OFFSET, true)
// // 如果头部位置偏移小于停车点位置偏移目标点为当前停车点
// if (headPosition.getOffset() < (section.getStopPointByDirection(right) + SimulationConstants.PARK_POINT_MAX_OFFSET)) { //防止意外开过站后无法发车
// targetPosition = stopPosition;
// }
// }
}
}