This commit is contained in:
xiazengbin 2022-08-11 11:09:35 +08:00
commit f0fc1fed80
6 changed files with 93 additions and 128 deletions

View File

@ -868,16 +868,6 @@ public class Operation {
*/ */
Driver_Stop(Operation.OTHER), Driver_Stop(Operation.OTHER),
/**
* 确认运行至前方站
*/
Drive_Ahead(Operation.OTHER),
/**
* 进路闭塞法行车
*/
Route_Block_Drive(Operation.OTHER),
/** /**
* 开关门 * 开关门
*/ */

View File

@ -185,27 +185,11 @@ public class DriverOperateHandler {
simulationRobotService.stopTrain(simulation, simulationMember, groupNumber, eb); simulationRobotService.stopTrain(simulation, simulationMember, groupNumber, eb);
} }
/**
* 确认运行至前方站
*/
@OperateHandlerMapping(type = Operation.Type.Drive_Ahead)
public void driveAhead(Simulation simulation, SimulationMember simulationMember, String groupNumber) {
ATPService.driveAhead(simulation, groupNumber);
}
/**
* 进路闭塞法行车
*/
@OperateHandlerMapping(type = Operation.Type.Route_Block_Drive)
public void routeBlockDrive(Simulation simulation, SimulationMember simulationMember, String groupNumber) {
ATPService.routeBlockDrive(simulation, groupNumber);
}
/** /**
* 开关门 * 开关门
*/ */
@OperateHandlerMapping(type = Operation.Type.Open_Or_Close_Door) @OperateHandlerMapping(type = Operation.Type.Open_Or_Close_Door)
public void openOrCloseDoor(Simulation simulation, SimulationMember simulationMember, String groupNumber) { public void openOrCloseDoor(Simulation simulation, String groupNumber) {
ATPService.openOrCloseDoor(simulation, groupNumber); ATPService.openOrCloseDoor(simulation, groupNumber);
} }
@ -213,7 +197,7 @@ public class DriverOperateHandler {
* 回库 * 回库
*/ */
@OperateHandlerMapping(type = Operation.Type.Inbound) @OperateHandlerMapping(type = Operation.Type.Inbound)
public void inbound(Simulation simulation, SimulationMember simulationMember, String groupNumber) { public void inbound(Simulation simulation,String groupNumber) {
ATPService.inbound(simulation, groupNumber); ATPService.inbound(simulation, groupNumber);
} }
@ -221,7 +205,7 @@ public class DriverOperateHandler {
* 修改预选模式 * 修改预选模式
*/ */
@OperateHandlerMapping(type = Operation.Type.Change_Preselection_Mode) @OperateHandlerMapping(type = Operation.Type.Change_Preselection_Mode)
public void changePreselectionMode(Simulation simulation, SimulationMember simulationMember, String groupNumber public void changePreselectionMode(Simulation simulation, String groupNumber
, VirtualRealityTrain.PreselectionMode preselectionMode) { , VirtualRealityTrain.PreselectionMode preselectionMode) {
ATPService.changePreselectionMode(simulation, groupNumber, preselectionMode); ATPService.changePreselectionMode(simulation, groupNumber, preselectionMode);
} }
@ -230,7 +214,7 @@ public class DriverOperateHandler {
* 转NRM模式 * 转NRM模式
*/ */
@OperateHandlerMapping(type = Operation.Type.Apply_NRM) @OperateHandlerMapping(type = Operation.Type.Apply_NRM)
public void applyNRM(Simulation simulation, SimulationMember simulationMember, String groupNumber) { public void applyNRM(Simulation simulation, String groupNumber) {
ATPService.applyNRM(simulation, groupNumber); ATPService.applyNRM(simulation, groupNumber);
} }
} }

View File

@ -460,7 +460,7 @@ public class AtsTrainService {
} }
//找要越过的信号机 //找要越过的信号机
Section section = headPosition.getSection(); Section section = headPosition.getSection();
if (param.isThroughRedSignal()) { if (param.isThroughRedSignal()) { // 越红灯行驶
Signal signal = section.getSignalOf(right); Signal signal = section.getSignalOf(right);
boolean b = false; boolean b = false;
if (signal != null && signal.getPosition().isAheadOf(headPosition, right)) { if (signal != null && signal.getPosition().isAheadOf(headPosition, right)) {
@ -470,7 +470,7 @@ public class AtsTrainService {
BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(b, "需要车头所在区段前方有同向信号机,且同向信号机为禁止信号"); BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(b, "需要车头所在区段前方有同向信号机,且同向信号机为禁止信号");
param.setThroughSignal(signal); param.setThroughSignal(signal);
param.setThroughSignalAspect(signal.getVirtualSignal().getModel().getDefaultAspect()); param.setThroughSignalAspect(signal.getVirtualSignal().getModel().getDefaultAspect());
} else if (param.isThroughGuideSignal()) { } else if (param.isThroughGuideSignal()) { // 越引导行驶
Signal signal = section.getSignalOf(right); Signal signal = section.getSignalOf(right);
boolean b = false; boolean b = false;
if (signal != null && signal.getPosition().isAheadOf(headPosition, right)) { if (signal != null && signal.getPosition().isAheadOf(headPosition, right)) {
@ -480,11 +480,28 @@ public class AtsTrainService {
BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(b, "需要车头所在区段前方有同向信号机,且同向信号机为引导信号"); BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(b, "需要车头所在区段前方有同向信号机,且同向信号机为引导信号");
param.setThroughSignal(signal); param.setThroughSignal(signal);
param.setThroughSignalAspect(signal.getVirtualSignal().getModel().getDefaultAspect()); param.setThroughSignalAspect(signal.getVirtualSignal().getModel().getDefaultAspect());
} else { } else if (param.isDriverNextStand()){ // 行驶至前方车站
// 列车车头所在区段
Section headSection = train.getHeadPosition().getSection();
// 停车目的区段
if (section.isStandTrack()) {
targetPosition = new SectionPosition(headSection, headSection.getStopPointByDirection(train.isRight()));
} else {
targetPosition = train.calculateNextStandStopPosition();
if (targetPosition == null && train.getTarget() != null) {
targetPosition = new SectionPosition(train.getTarget(), train.getTarget().getStopPointByDirection(train.isRight()));
}
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotNull(targetPosition, train.debugStr() + "找不到下一个停车点");
}
atpService.changePreselectionMode(train, VirtualRealityTrain.PreselectionMode.RM);
} else if (param.isRouteBlockDriver()) { // 进路闭塞行车
if (!train.isAMMode()) {
atpService.changePreselectionMode(train, VirtualRealityTrain.PreselectionMode.AM_C);
}
}else {
param.setThroughSignal(null); param.setThroughSignal(null);
param.setThroughSignalAspect(null); param.setThroughSignalAspect(null);
} }
param.setTargetPosition(targetPosition); param.setTargetPosition(targetPosition);
train.setRobotDriveParam(param); train.setRobotDriveParam(param);
} }

View File

@ -280,6 +280,7 @@ public class Section extends DelayUnlockDevice {
this.closeInit = false; this.closeInit = false;
this.openInit = false; this.openInit = false;
this.closed = false; this.closed = false;
this.badShunt = false;
this.shuntingTypeList = new ArrayList<>(); this.shuntingTypeList = new ArrayList<>();
} }

View File

@ -19,6 +19,7 @@ import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain.PreselectionMode; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain.PreselectionMode;
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 club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import club.joylink.rtss.simulation.cbtc.onboard.ATO.SpeedCurve; import club.joylink.rtss.simulation.cbtc.onboard.ATO.SpeedCurve;
import club.joylink.rtss.simulation.cbtc.onboard.ATO.service.ATOService; import club.joylink.rtss.simulation.cbtc.onboard.ATO.service.ATOService;
import lombok.NonNull; import lombok.NonNull;
@ -298,18 +299,9 @@ public class ATPService {
} }
public void openOrCloseDoor(Simulation simulation, VirtualRealityTrain train, boolean right, boolean open) { public void openOrCloseDoor(Simulation simulation, VirtualRealityTrain train, boolean right, boolean open) {
if (train.getSpeed() != 0) { BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(train.getSpeed() == 0, String.format("列车[%s]未停止,不能操作车门", train.getGroupNumber()));
log.warn(String.format("列车[%s]未停止,不能操作车门", train.getGroupNumber())); BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(train.getDoorMode().isAuto(open), String.format("列车[%s]门模式自动,不能操作车门", train.getGroupNumber()));
return; BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(train.getDoorSelection().match(right),String.format("列车[%s]门选择与操作不匹配", train.getGroupNumber()));
}
if (!train.getDoorMode().isAuto(open)) {
log.warn(String.format("列车[%s]门模式自动,不能操作车门", train.getGroupNumber()));
return;
}
if (!train.getDoorSelection().match(right)) {
log.warn(String.format("列车[%s]门选择与操作不匹配", train.getGroupNumber()));
return;
}
List<Stand> standList = train.getHeadPosition().getSection().getStandList(); List<Stand> standList = train.getHeadPosition().getSection().getStandList();
VirtualRealityTrain.Door door = train.getDoorByDirection(right); VirtualRealityTrain.Door door = train.getDoorByDirection(right);
if (open) { if (open) {
@ -496,52 +488,6 @@ public class ATPService {
} }
} }
/**
* 确认运行至前方站
*/
public void driveAhead(Simulation simulation, String groupNumber) {
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
// 列车车头所在区段
Section section = train.getHeadPosition().getSection();
// 停车目的区段
SectionPosition standStopPosition;
if (section.isStandTrack()) {
standStopPosition = new SectionPosition(section, section.getStopPointByDirection(train.isRight()));
} else {
standStopPosition = train.calculateNextStandStopPosition();
if (standStopPosition == null && train.getTarget() != null) {
standStopPosition = new SectionPosition(train.getTarget(), train.getTarget().getStopPointByDirection(train.isRight()));
}
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotNull(standStopPosition, train.debugStr() + "找不到下一个停车点");
}
if (!train.isStopAtThePosition(standStopPosition)) { //如果列车没停到目标位置
if (!train.isInTheGear(VirtualRealityTrain.Handwheel.MANUAL)) { // 改变工况手轮档位
changeGear(train, VirtualRealityTrain.Handwheel.MANUAL);
}
float percent = train.isEB() && (!train.isStop() || !train.isLeverNotInTractionGear())
? -2F : (!train.isStop() ? -1F : 0);
if (percent != 0) {
changeTrainForce(train, percent); // 改变列车的牵引/
}
if ((!DriveMode.RM.equals(train.getDriveMode()) || train.isEB()) && !train.isNRMMode()) {
changePreselectionMode(train, PreselectionMode.RM); // 修改预选模式
}
train.setRobotTargetPosition(standStopPosition);
train.getRobotDriveParam().setRun(true);
train.getRobotDriveParam().setStop(false);
}
}
/**
* 进路闭塞法行车
*/
public void routeBlockDrive(Simulation simulation, String groupNumber) {
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
if (!train.isAMMode()) {
changePreselectionMode(train, PreselectionMode.AM_C);
}
}
/** /**
* 开关门 * 开关门
*/ */
@ -561,18 +507,14 @@ public class ATPService {
open = false; open = false;
} else { } else {
Stand stand = standList.get(0); Stand stand = standList.get(0);
if (stand.isInside() && stand.isRight()) { // 内测 if (stand.isInside() && stand.isRight()) { // 内测右站台开1门
if (stand.isRight()) { // 右站台开1门 doorIsRight = train.judgeDirection4DoorIsRight(train.getDoor1());
doorIsRight = train.judgeDirection4DoorIsRight(train.getDoor1()); } else if (stand.isInside() && !stand.isRight()) { // 内测左站台开2门
} else { // 左站台开2门 doorIsRight = train.judgeDirection4DoorIsRight(train.getDoor2());
doorIsRight = train.judgeDirection4DoorIsRight(train.getDoor2()); } else if (!stand.isInside() && stand.isRight()) { //外侧右站台开2门
} doorIsRight = train.judgeDirection4DoorIsRight(train.getDoor2());
} else { //外侧 } else {
if (stand.isRight()) { // 右站台开2门 doorIsRight = train.judgeDirection4DoorIsRight(train.getDoor1());
doorIsRight = train.judgeDirection4DoorIsRight(train.getDoor2());
} else { // 左站台开1门
doorIsRight = train.judgeDirection4DoorIsRight(train.getDoor1());
}
} }
open = true; open = true;
} }
@ -601,28 +543,17 @@ public class ATPService {
/** /**
* 修改预选模式 * 修改预选模式
*/ */
public void changePreselectionMode(Simulation simulation, String groupNumber, VirtualRealityTrain.PreselectionMode preselectionMode) { public void changePreselectionMode(Simulation simulation, String groupNumber, VirtualRealityTrain.PreselectionMode preselectionMode) {
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber); VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
// 检验条件
operationVail(simulation,train);
if (!train.isAtpOn()) { if (!train.isAtpOn()) {
this.openAtp(train); this.openAtp(train);
} }
if (train.isSignalEB()) { if (train.isSignalEB()) {
this.releaseEB(train); this.releaseEB(train);
} }
PreselectionMode trainMode = train.getPreselectionMode(); changePreselectionMode(train, preselectionMode);
if (trainMode != preselectionMode) { //预选级别不对
changePreselectionMode(train, preselectionMode);
} else if (trainMode.isMatchTheDriveMode(DriveMode.AM) && !train.isAMMode()) {
if (!train.isInTheGear(VirtualRealityTrain.Handwheel.ATO)) {
this.changeGear(train, VirtualRealityTrain.Handwheel.ATO);
}
if (!train.isLeverInCoastingGear()) {
this.changeTrainForce(train, 0F); // 改变列车的牵引
}
if (!train.isAtoOn()) {
this.openATO(train);
}
}
} }
/** /**
@ -630,7 +561,9 @@ public class ATPService {
*/ */
public void applyNRM(Simulation simulation, String groupNumber) { public void applyNRM(Simulation simulation, String groupNumber) {
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber); VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
if (!train.isNRMMode()) { // 检验条件
operationVail(simulation,train);
while (!train.isNRMMode()) {
this.cutOffAtp(train); this.cutOffAtp(train);
} }
} }
@ -673,16 +606,35 @@ public class ATPService {
* @param train 列车 * @param train 列车
* @param preselectionMode 预选模式 * @param preselectionMode 预选模式
*/ */
private void changePreselectionMode(VirtualRealityTrain train, PreselectionMode preselectionMode) { public void changePreselectionMode(VirtualRealityTrain train, PreselectionMode preselectionMode) {
if (train.getPreselectionMode() != preselectionMode) { boolean loop = true;
if (train.getTempPreselectionMode() != preselectionMode) { PreselectionMode trainMode = null;
if (preselectionMode.isHigherThan(train.getTempPreselectionMode())) { while (loop) {
this.preselectionModeUp(train); trainMode = train.getPreselectionMode();
} else { if (trainMode != preselectionMode) { //预选级别不对
this.preselectionModeDown(train); if (train.getPreselectionMode() != preselectionMode) {
if (train.getTempPreselectionMode() != preselectionMode) {
if (preselectionMode.isHigherThan(train.getTempPreselectionMode())) {
this.preselectionModeUp(train);
} else {
this.preselectionModeDown(train);
}
} else {
this.confirmMessage(train);
}
}
} else if (trainMode.isMatchTheDriveMode(DriveMode.AM) && !train.isAMMode()) {
if (!train.isInTheGear(VirtualRealityTrain.Handwheel.ATO)) {
this.changeGear(train, VirtualRealityTrain.Handwheel.ATO);
}
if (!train.isLeverInCoastingGear()) {
this.changeTrainForce(train, 0F); // 改变列车的牵引
}
if (!train.isAtoOn()) {
this.openATO(train);
} }
} else { } else {
this.confirmMessage(train); loop = false;
} }
} }
} }
@ -698,4 +650,12 @@ public class ATPService {
changePreselectionMode(train, PreselectionMode.RM); changePreselectionMode(train, PreselectionMode.RM);
} }
} }
private void operationVail(Simulation simulation,VirtualRealityTrain train){
boolean driverRobot = simulation.getSimulationMembers().stream()
.filter(simulationMember -> simulationMember.isDriver()
&& train.getCode().equals(simulationMember.getDevice().getCode()))
.anyMatch(SimulationMember::isRobot);
BusinessExceptionAssertEnum.OPERATION_FAIL.assertNotTrue(!driverRobot,"成员由用户扮演,操作不执行");
}
} }

View File

@ -59,6 +59,9 @@ public class DriveParamVO {
public static final int NO = 0; public static final int NO = 0;
public static final int RED_SIGNAL = 1; public static final int RED_SIGNAL = 1;
public static final int GUIDE_SIGNAL = 2; public static final int GUIDE_SIGNAL = 2;
public static final int DRIVER_NEXT_STAND = 3;
public static final int DRIVER_ROUTE_BLOCK = 4;
/** /**
* 要越过的信号机 * 要越过的信号机
*/ */
@ -106,4 +109,14 @@ public class DriveParamVO {
public boolean isThroughGuideSignal() { public boolean isThroughGuideSignal() {
return GUIDE_SIGNAL == through; return GUIDE_SIGNAL == through;
} }
@JsonIgnore
public boolean isDriverNextStand() {
return DRIVER_NEXT_STAND == through;
}
@JsonIgnore
public boolean isRouteBlockDriver() {
return DRIVER_ROUTE_BLOCK == through;
}
} }