添加列车<倒车限速><碰撞检测逻辑>

This commit is contained in:
joylink_zhangsai 2021-01-25 18:45:36 +08:00
parent ebb8cfd55e
commit 8459f38fc3
2 changed files with 54 additions and 28 deletions

View File

@ -72,8 +72,31 @@ public class VRTrainRunningService {
SectionPosition headPosition = train.getHeadPosition(); SectionPosition headPosition = train.getHeadPosition();
SectionPosition headPositionNew = CalculateService.calculateNextPositionByStartAndLen(headPosition, right, s); SectionPosition headPositionNew = CalculateService.calculateNextPositionByStartAndLen(headPosition, right, s);
// todo 碰撞检测如果撞车不修改位置 // todo 碰撞检测如果撞车不修改位置
//更新车头区段不会碰撞才更新
for (VirtualRealityTrain aTrain : simulation.getRepository().getOnlineTrainList()) {
if (aTrain.equals(train))
continue;
SectionPosition checkPosition;
if (s > 0) { //向前行驶
checkPosition = headPositionNew;
} else { //向后行驶
checkPosition = CalculateService.calculateNextPositionByStartAndLen(headPositionNew, !right, train.getLen());
}
Section checkSection = checkPosition.getSection();
SectionPosition aTrainHeadPosition = aTrain.getHeadPosition();
SectionPosition aTrainTailPosition = aTrain.calculateTailPosition();
if (aTrainHeadPosition.getSection().equals(checkSection) || aTrainTailPosition.getSection().equals(checkSection)) {
if (right == aTrain.isRight()) { //车头同向
if (aTrainTailPosition.isAheadOf(checkPosition, right) || checkPosition.isAheadOf(aTrainHeadPosition, right)) {
train.setHeadPosition(headPositionNew); train.setHeadPosition(headPositionNew);
}
} else {
if (aTrainHeadPosition.isAheadOf(checkPosition, right) || aTrainTailPosition.isAheadOf(checkPosition, right)) {
train.setHeadPosition(headPositionNew);
}
}
}
}
//列车级别 //列车级别
trainRunLevelUpgrade(simulation, train); trainRunLevelUpgrade(simulation, train);
//计轴器计数 //计轴器计数

View File

@ -3,10 +3,7 @@ package club.joylink.rtss.simulation.cbtc.onboard.ATP;
import club.joylink.rtss.simulation.cbtc.ATP.ground.GroundAtpApiService; import club.joylink.rtss.simulation.cbtc.ATP.ground.GroundAtpApiService;
import club.joylink.rtss.simulation.cbtc.ATS.AtsApiService; import club.joylink.rtss.simulation.cbtc.ATS.AtsApiService;
import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.constant.DriveMode; import club.joylink.rtss.simulation.cbtc.constant.*;
import club.joylink.rtss.simulation.cbtc.constant.RunLevel;
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
import club.joylink.rtss.simulation.cbtc.constant.SimulationModule;
import club.joylink.rtss.simulation.cbtc.data.CalculateService; import club.joylink.rtss.simulation.cbtc.data.CalculateService;
import club.joylink.rtss.simulation.cbtc.data.map.Section; import club.joylink.rtss.simulation.cbtc.data.map.Section;
import club.joylink.rtss.simulation.cbtc.data.map.Signal; import club.joylink.rtss.simulation.cbtc.data.map.Signal;
@ -34,7 +31,7 @@ import java.util.Objects;
public class ATPLogicLoop { public class ATPLogicLoop {
@Autowired @Autowired
private ATPService ATPService; private ATPService atpService;
@Autowired @Autowired
private AtsApiService atsApiService; private AtsApiService atsApiService;
@ -43,7 +40,7 @@ public class ATPLogicLoop {
private GroundAtpApiService groundAtpApiService; private GroundAtpApiService groundAtpApiService;
@Autowired @Autowired
private ATOService ATOService; private ATOService atoService;
@Autowired @Autowired
private ApplicationContext applicationContext; private ApplicationContext applicationContext;
@ -55,9 +52,9 @@ public class ATPLogicLoop {
for (VirtualRealityTrain train : onlineTrain) { for (VirtualRealityTrain train : onlineTrain) {
if (!train.isPowerOn()) { //如果列车断电 if (!train.isPowerOn()) { //如果列车断电
if (!train.isStop() && !train.isEB()) { if (!train.isStop() && !train.isEB()) {
ATPService.triggerSignalEB(train); atpService.triggerSignalEB(train);
} }
this.ATOService.closeATO(train); this.atoService.closeATO(train);
continue; continue;
} }
this.onboardLogicRun2(simulation, train); this.onboardLogicRun2(simulation, train);
@ -79,7 +76,7 @@ public class ATPLogicLoop {
if (train.isCbtcMaMiss()) { //cbtc级别ma丢失 if (train.isCbtcMaMiss()) { //cbtc级别ma丢失
if (train.isCBTC()) { //并且列车处于CBTC级别 if (train.isCBTC()) { //并且列车处于CBTC级别
train.setRunLevel(RunLevel.IL); train.setRunLevel(RunLevel.IL);
ATPService.triggerSignalEB(train); atpService.triggerSignalEB(train);
train.setMa(null); train.setMa(null);
} }
} }
@ -101,7 +98,7 @@ public class ATPLogicLoop {
private void driveLogicRun(Simulation simulation, VirtualRealityTrain train) { private void driveLogicRun(Simulation simulation, VirtualRealityTrain train) {
if (train.isChangeEnds() && train.isStop()) { if (train.isChangeEnds() && train.isStop()) {
// 列车换端中 // 列车换端中
this.ATPService.changeEndsProgress(train); this.atpService.changeEndsProgress(train);
return; return;
} }
if (!train.isAtoOn()) { if (!train.isAtoOn()) {
@ -127,7 +124,7 @@ public class ATPLogicLoop {
this.checkOnTransferAndSend2Ats(simulation, train, headPosition, tailPosition); this.checkOnTransferAndSend2Ats(simulation, train, headPosition, tailPosition);
if (!train.isBreaking()) { // 制动状态 if (!train.isBreaking()) { // 制动状态
// 施加常规制动防止倒溜 // 施加常规制动防止倒溜
this.ATOService.openBreaking(train); this.atoService.openBreaking(train);
} }
if (!train.isParkingAt()) { if (!train.isParkingAt()) {
this.checkParkingAndSend2Ats(simulation, train); this.checkParkingAndSend2Ats(simulation, train);
@ -140,7 +137,7 @@ public class ATPLogicLoop {
if (train.getLeverPosition() == 0 && train.getMa() != null) { if (train.getLeverPosition() == 0 && train.getMa() != null) {
Float distance = CalculateService.calculateDistance(headPosition, train.getMa().getEnd().getEndPosition(), right); Float distance = CalculateService.calculateDistance(headPosition, train.getMa().getEnd().getEndPosition(), right);
if (distance != null && distance > 100) { if (distance != null && distance > 100) {
ATPService.cancelSignalEB(train); atpService.cancelSignalEB(train);
applicationContext.publishEvent(new SimulationATPAutoCancelEBEvent(this, simulation, train)); applicationContext.publishEvent(new SimulationATPAutoCancelEBEvent(this, simulation, train));
log.info(String.format("列车[%s]移动授权距离超过100mEB自动缓解", train.getGroupNumber())); log.info(String.format("列车[%s]移动授权距离超过100mEB自动缓解", train.getGroupNumber()));
} }
@ -150,7 +147,7 @@ public class ATPLogicLoop {
} }
if (this.checkConditionToMove2(simulation, train)) { // 可以启动 if (this.checkConditionToMove2(simulation, train)) { // 可以启动
this.ATOService.closeBreaking(train); this.atoService.closeBreaking(train);
} else { } else {
return; return;
} }
@ -159,10 +156,16 @@ public class ATPLogicLoop {
if (train.isParkingAt()) { if (train.isParkingAt()) {
train.depart(); train.depart();
} }
// 列车倒车限速
if (ControlGear.Reverse.equals(train.getGear())) {
if (train.getSpeed() > 25 / 3.6) {
atpService.triggerSignalEB(train);
}
}
// 判断列车是否跳站 // 判断列车是否跳站
this.checkTrainJumpAndSend2Ats(simulation, train, headPosition, tailPosition, right); this.checkTrainJumpAndSend2Ats(simulation, train, headPosition, tailPosition, right);
if (train.isAtpOn()) { if (train.isAtpOn()) {
this.ATPService.speedProtect(simulation, train); this.atpService.speedProtect(simulation, train);
} }
if (train.isEB()) { if (train.isEB()) {
return; return;
@ -170,11 +173,11 @@ public class ATPLogicLoop {
} }
// 列车ATO自动驾驶逻辑运行 // 列车ATO自动驾驶逻辑运行
this.ATOService.ATO(train); this.atoService.ATO(train);
} }
private void checkParkingAndSend2Ats(Simulation simulation, VirtualRealityTrain train) { private void checkParkingAndSend2Ats(Simulation simulation, VirtualRealityTrain train) {
if (!train.isParkingAt() && this.ATPService.isStopOnTargetPosition(train)) { if (!train.isParkingAt() && this.atpService.isStopOnTargetPosition(train)) {
String stationName = null; String stationName = null;
if (train.getNextStation() != null) { if (train.getNextStation() != null) {
stationName = train.getNextStation().getName(); stationName = train.getNextStation().getName();
@ -206,7 +209,7 @@ public class ATPLogicLoop {
if (train.isJump()) { // 列车跳停,跳过开门 if (train.isJump()) { // 列车跳停,跳过开门
train.earlyDeparture(); train.earlyDeparture();
} else { } else {
this.ATOService.syncOpenDoor(simulation, train); this.atoService.syncOpenDoor(simulation, train);
if (this.isAllDoorOpen(simulation, train)) { if (this.isAllDoorOpen(simulation, train)) {
train.nextParkedTrainActivity(); train.nextParkedTrainActivity();
} }
@ -227,7 +230,7 @@ public class ATPLogicLoop {
// } // }
// } // }
// 可以关门 // 可以关门
this.ATOService.syncCloseDoor(simulation, train); this.atoService.syncCloseDoor(simulation, train);
if (this.isAllDoorClose(simulation, train)) { if (this.isAllDoorClose(simulation, train)) {
train.nextParkedTrainActivity(); train.nextParkedTrainActivity();
} }
@ -354,7 +357,7 @@ public class ATPLogicLoop {
if (train.isParking()) { if (train.isParking()) {
train.setParking(false); train.setParking(false);
} }
this.ATPService.speedProtect(simulation, train); this.atpService.speedProtect(simulation, train);
if (train.isEB()) { if (train.isEB()) {
return; return;
} }
@ -372,7 +375,7 @@ public class ATPLogicLoop {
Float distance = CalculateService.calculateDistance(headPosition, train.getMa().getEnd().getEndPosition(), right); Float distance = CalculateService.calculateDistance(headPosition, train.getMa().getEnd().getEndPosition(), right);
if (distance != null) { if (distance != null) {
if (distance > 100) { if (distance > 100) {
ATPService.cancelSignalEB(train); atpService.cancelSignalEB(train);
applicationContext.publishEvent(new SimulationATPAutoCancelEBEvent(this, simulation, train)); applicationContext.publishEvent(new SimulationATPAutoCancelEBEvent(this, simulation, train));
log.info(String.format("列车[%s]移动授权距离超过200mEB自动缓解", train.getGroupNumber())); log.info(String.format("列车[%s]移动授权距离超过200mEB自动缓解", train.getGroupNumber()));
} }
@ -383,7 +386,7 @@ public class ATPLogicLoop {
// 列车已经停车 // 列车已经停车
if (!train.isBreaking()) { if (!train.isBreaking()) {
// 施加常规制动防止倒溜 // 施加常规制动防止倒溜
this.ATOService.openBreaking(train); this.atoService.openBreaking(train);
} }
if (!train.isParking()) { if (!train.isParking()) {
// 检查列车是否站台停靠 // 检查列车是否站台停靠
@ -403,7 +406,7 @@ public class ATPLogicLoop {
// log.debug(String.format("列车[%s]发车条件不满足", train.getGroupNumber())); // log.debug(String.format("列车[%s]发车条件不满足", train.getGroupNumber()));
return; return;
} else { } else {
this.ATOService.closeBreaking(train); this.atoService.closeBreaking(train);
} }
} }
break; break;
@ -419,7 +422,7 @@ public class ATPLogicLoop {
if (train.isParking()) { if (train.isParking()) {
train.setParking(false); train.setParking(false);
} }
this.ATPService.speedProtect(simulation, train); this.atpService.speedProtect(simulation, train);
if (train.isEB()) { if (train.isEB()) {
return; return;
} }
@ -493,7 +496,7 @@ public class ATPLogicLoop {
// 检查列车是否在转换轨 // 检查列车是否在转换轨
this.checkOnTransferAndSend2Ats(simulation, train, headPosition, tailPosition); this.checkOnTransferAndSend2Ats(simulation, train, headPosition, tailPosition);
// 列车ATO自动驾驶逻辑运行 // 列车ATO自动驾驶逻辑运行
this.ATOService.ATO(train); this.atoService.ATO(train);
} }
/** /**
@ -592,11 +595,11 @@ public class ATPLogicLoop {
if (train.isDoorClosing()) { if (train.isDoorClosing()) {
return; return;
} }
this.ATOService.syncCloseDoor(simulation, train); this.atoService.syncCloseDoor(simulation, train);
} }
private void checkTrainStationParkingAndSend2Ats(Simulation simulation, VirtualRealityTrain train) { private void checkTrainStationParkingAndSend2Ats(Simulation simulation, VirtualRealityTrain train) {
if (!train.isParking() && this.ATPService.isStopOnTargetPosition(train)) { if (!train.isParking() && this.atpService.isStopOnTargetPosition(train)) {
String stationName = null; String stationName = null;
if (train.getNextStation() != null) { if (train.getNextStation() != null) {
stationName = train.getNextStation().getName(); stationName = train.getNextStation().getName();