添加列车<倒车限速><碰撞检测逻辑>
This commit is contained in:
parent
ebb8cfd55e
commit
8459f38fc3
@ -72,8 +72,31 @@ public class VRTrainRunningService {
|
||||
SectionPosition headPosition = train.getHeadPosition();
|
||||
SectionPosition headPositionNew = CalculateService.calculateNextPositionByStartAndLen(headPosition, right, s);
|
||||
// todo 碰撞检测?如果撞车,不修改位置
|
||||
train.setHeadPosition(headPositionNew);
|
||||
|
||||
//更新车头区段(不会碰撞才更新)
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
if (aTrainHeadPosition.isAheadOf(checkPosition, right) || aTrainTailPosition.isAheadOf(checkPosition, right)) {
|
||||
train.setHeadPosition(headPositionNew);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//列车级别
|
||||
trainRunLevelUpgrade(simulation, train);
|
||||
//计轴器计数
|
||||
|
@ -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.ATS.AtsApiService;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.DriveMode;
|
||||
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.constant.*;
|
||||
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.Signal;
|
||||
@ -34,7 +31,7 @@ import java.util.Objects;
|
||||
public class ATPLogicLoop {
|
||||
|
||||
@Autowired
|
||||
private ATPService ATPService;
|
||||
private ATPService atpService;
|
||||
|
||||
@Autowired
|
||||
private AtsApiService atsApiService;
|
||||
@ -43,7 +40,7 @@ public class ATPLogicLoop {
|
||||
private GroundAtpApiService groundAtpApiService;
|
||||
|
||||
@Autowired
|
||||
private ATOService ATOService;
|
||||
private ATOService atoService;
|
||||
|
||||
@Autowired
|
||||
private ApplicationContext applicationContext;
|
||||
@ -55,9 +52,9 @@ public class ATPLogicLoop {
|
||||
for (VirtualRealityTrain train : onlineTrain) {
|
||||
if (!train.isPowerOn()) { //如果列车断电
|
||||
if (!train.isStop() && !train.isEB()) {
|
||||
ATPService.triggerSignalEB(train);
|
||||
atpService.triggerSignalEB(train);
|
||||
}
|
||||
this.ATOService.closeATO(train);
|
||||
this.atoService.closeATO(train);
|
||||
continue;
|
||||
}
|
||||
this.onboardLogicRun2(simulation, train);
|
||||
@ -79,7 +76,7 @@ public class ATPLogicLoop {
|
||||
if (train.isCbtcMaMiss()) { //cbtc级别ma丢失
|
||||
if (train.isCBTC()) { //并且列车处于CBTC级别
|
||||
train.setRunLevel(RunLevel.IL);
|
||||
ATPService.triggerSignalEB(train);
|
||||
atpService.triggerSignalEB(train);
|
||||
train.setMa(null);
|
||||
}
|
||||
}
|
||||
@ -101,7 +98,7 @@ public class ATPLogicLoop {
|
||||
private void driveLogicRun(Simulation simulation, VirtualRealityTrain train) {
|
||||
if (train.isChangeEnds() && train.isStop()) {
|
||||
// 列车换端中
|
||||
this.ATPService.changeEndsProgress(train);
|
||||
this.atpService.changeEndsProgress(train);
|
||||
return;
|
||||
}
|
||||
if (!train.isAtoOn()) {
|
||||
@ -127,7 +124,7 @@ public class ATPLogicLoop {
|
||||
this.checkOnTransferAndSend2Ats(simulation, train, headPosition, tailPosition);
|
||||
if (!train.isBreaking()) { // 制动状态
|
||||
// 施加常规制动,防止倒溜
|
||||
this.ATOService.openBreaking(train);
|
||||
this.atoService.openBreaking(train);
|
||||
}
|
||||
if (!train.isParkingAt()) {
|
||||
this.checkParkingAndSend2Ats(simulation, train);
|
||||
@ -140,7 +137,7 @@ public class ATPLogicLoop {
|
||||
if (train.getLeverPosition() == 0 && train.getMa() != null) {
|
||||
Float distance = CalculateService.calculateDistance(headPosition, train.getMa().getEnd().getEndPosition(), right);
|
||||
if (distance != null && distance > 100) {
|
||||
ATPService.cancelSignalEB(train);
|
||||
atpService.cancelSignalEB(train);
|
||||
applicationContext.publishEvent(new SimulationATPAutoCancelEBEvent(this, simulation, train));
|
||||
log.info(String.format("列车[%s]移动授权距离超过100m,EB自动缓解", train.getGroupNumber()));
|
||||
}
|
||||
@ -150,7 +147,7 @@ public class ATPLogicLoop {
|
||||
}
|
||||
|
||||
if (this.checkConditionToMove2(simulation, train)) { // 可以启动
|
||||
this.ATOService.closeBreaking(train);
|
||||
this.atoService.closeBreaking(train);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
@ -159,10 +156,16 @@ public class ATPLogicLoop {
|
||||
if (train.isParkingAt()) {
|
||||
train.depart();
|
||||
}
|
||||
// 列车倒车限速
|
||||
if (ControlGear.Reverse.equals(train.getGear())) {
|
||||
if (train.getSpeed() > 25 / 3.6) {
|
||||
atpService.triggerSignalEB(train);
|
||||
}
|
||||
}
|
||||
// 判断列车是否跳站
|
||||
this.checkTrainJumpAndSend2Ats(simulation, train, headPosition, tailPosition, right);
|
||||
if (train.isAtpOn()) {
|
||||
this.ATPService.speedProtect(simulation, train);
|
||||
this.atpService.speedProtect(simulation, train);
|
||||
}
|
||||
if (train.isEB()) {
|
||||
return;
|
||||
@ -170,11 +173,11 @@ public class ATPLogicLoop {
|
||||
}
|
||||
|
||||
// 列车ATO自动驾驶逻辑运行
|
||||
this.ATOService.ATO(train);
|
||||
this.atoService.ATO(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;
|
||||
if (train.getNextStation() != null) {
|
||||
stationName = train.getNextStation().getName();
|
||||
@ -206,7 +209,7 @@ public class ATPLogicLoop {
|
||||
if (train.isJump()) { // 列车跳停,跳过开门
|
||||
train.earlyDeparture();
|
||||
} else {
|
||||
this.ATOService.syncOpenDoor(simulation, train);
|
||||
this.atoService.syncOpenDoor(simulation, train);
|
||||
if (this.isAllDoorOpen(simulation, train)) {
|
||||
train.nextParkedTrainActivity();
|
||||
}
|
||||
@ -227,7 +230,7 @@ public class ATPLogicLoop {
|
||||
// }
|
||||
// }
|
||||
// 可以关门
|
||||
this.ATOService.syncCloseDoor(simulation, train);
|
||||
this.atoService.syncCloseDoor(simulation, train);
|
||||
if (this.isAllDoorClose(simulation, train)) {
|
||||
train.nextParkedTrainActivity();
|
||||
}
|
||||
@ -354,7 +357,7 @@ public class ATPLogicLoop {
|
||||
if (train.isParking()) {
|
||||
train.setParking(false);
|
||||
}
|
||||
this.ATPService.speedProtect(simulation, train);
|
||||
this.atpService.speedProtect(simulation, train);
|
||||
if (train.isEB()) {
|
||||
return;
|
||||
}
|
||||
@ -372,7 +375,7 @@ public class ATPLogicLoop {
|
||||
Float distance = CalculateService.calculateDistance(headPosition, train.getMa().getEnd().getEndPosition(), right);
|
||||
if (distance != null) {
|
||||
if (distance > 100) {
|
||||
ATPService.cancelSignalEB(train);
|
||||
atpService.cancelSignalEB(train);
|
||||
applicationContext.publishEvent(new SimulationATPAutoCancelEBEvent(this, simulation, train));
|
||||
log.info(String.format("列车[%s]移动授权距离超过200m,EB自动缓解", train.getGroupNumber()));
|
||||
}
|
||||
@ -383,7 +386,7 @@ public class ATPLogicLoop {
|
||||
// 列车已经停车
|
||||
if (!train.isBreaking()) {
|
||||
// 施加常规制动,防止倒溜
|
||||
this.ATOService.openBreaking(train);
|
||||
this.atoService.openBreaking(train);
|
||||
}
|
||||
if (!train.isParking()) {
|
||||
// 检查列车是否站台停靠
|
||||
@ -403,7 +406,7 @@ public class ATPLogicLoop {
|
||||
// log.debug(String.format("列车[%s]发车条件不满足", train.getGroupNumber()));
|
||||
return;
|
||||
} else {
|
||||
this.ATOService.closeBreaking(train);
|
||||
this.atoService.closeBreaking(train);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -419,7 +422,7 @@ public class ATPLogicLoop {
|
||||
if (train.isParking()) {
|
||||
train.setParking(false);
|
||||
}
|
||||
this.ATPService.speedProtect(simulation, train);
|
||||
this.atpService.speedProtect(simulation, train);
|
||||
if (train.isEB()) {
|
||||
return;
|
||||
}
|
||||
@ -493,7 +496,7 @@ public class ATPLogicLoop {
|
||||
// 检查列车是否在转换轨
|
||||
this.checkOnTransferAndSend2Ats(simulation, train, headPosition, tailPosition);
|
||||
// 列车ATO自动驾驶逻辑运行
|
||||
this.ATOService.ATO(train);
|
||||
this.atoService.ATO(train);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -592,11 +595,11 @@ public class ATPLogicLoop {
|
||||
if (train.isDoorClosing()) {
|
||||
return;
|
||||
}
|
||||
this.ATOService.syncCloseDoor(simulation, train);
|
||||
this.atoService.syncCloseDoor(simulation, 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;
|
||||
if (train.getNextStation() != null) {
|
||||
stationName = train.getNextStation().getName();
|
||||
|
Loading…
Reference in New Issue
Block a user