Merge remote-tracking branch 'origin/test' into ats-restruct
This commit is contained in:
commit
4d3e7b8735
@ -12,6 +12,7 @@ import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.*;
|
||||
import club.joylink.rtss.simulation.cbtc.data.support.MovementAuthority;
|
||||
import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySectionAxleCounter;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
|
||||
import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPService;
|
||||
import club.joylink.rtss.simulation.cbtc.onboard.ATP.OnboardAtpApiService;
|
||||
@ -84,6 +85,24 @@ public class ZCLogicLoop {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 为升级CM而强制更新ma(简单处理)
|
||||
* @return 是否更新成功
|
||||
*/
|
||||
public boolean updateCbtcMa4CM(Simulation simulation, VirtualRealityTrain train) {
|
||||
RunLevel defaultRunLevel = simulation.getRepository().getConfig().getRunMode();
|
||||
if (RunLevel.CBTC.equals(defaultRunLevel)) {
|
||||
List<VirtualRealityTrain> trainList = simulation.getRepository().getOnlineTrainList();
|
||||
SectionPosition headPosition = train.getHeadPosition();
|
||||
if (headPosition.getSection().anyZcWorking()) {
|
||||
List<MovementAuthority.End> endList = this.findMaEnd(simulation, train, trainList);
|
||||
MovementAuthority ma = this.compareAndBuildMa(train, endList);
|
||||
return onboardAtpApiService.ignoreDriveModeUpdateMA4CBTC(train, ma);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void calculateMAOfCBTC(Simulation simulation, VirtualRealityTrain train,
|
||||
List<VirtualRealityTrain> trainList) {
|
||||
// 查找移动授权终端列表
|
||||
@ -135,9 +154,14 @@ public class ZCLogicLoop {
|
||||
// }
|
||||
//非通信车占用区段
|
||||
if (section.isNonCbtcOccupy() && !section.isInvalid()) {
|
||||
VirtualRealitySectionAxleCounter axle = section.getVirtualAxleCounter();
|
||||
if (axle == null && section.getParent() != null)
|
||||
axle = section.getParent().getVirtualAxleCounter();
|
||||
if (axle == null || axle.getLeftCount() > 1 || axle.getRightCount() > 1) { //以计轴器计数为1作为是当前列车导致区段非通信车占用的判断依据
|
||||
endList.add(new MovementAuthority.End(section, MovementAuthority.EndType.NCT_OCCUPIED_SECTION));
|
||||
return endList;
|
||||
}
|
||||
}
|
||||
//通信车占用区段
|
||||
List<Section> occupiedLogicSectionList = simulation.getRepository().queryTrainOccupyAtpSectionList(train.getGroupNumber());
|
||||
Set<Section> occupiedLogicSectionSet;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package club.joylink.rtss.simulation.cbtc.ATS.operation.handler;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.ATP.ground.ZCLogicLoop;
|
||||
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;
|
||||
@ -7,7 +8,6 @@ import club.joylink.rtss.simulation.cbtc.CI.CiApiService;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.ControlGear;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.DriveMode;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.RunLevel;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Stand;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
|
||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
|
||||
@ -36,6 +36,9 @@ public class DriverOperateHandler {
|
||||
@Autowired
|
||||
private CiApiService ciApiService;
|
||||
|
||||
@Autowired
|
||||
private ZCLogicLoop zcLogicLoop;
|
||||
|
||||
@OperateHandlerMapping(type = Operation.Type.Driver_Force_Change)
|
||||
public void changeTrainForce(Simulation simulation, String groupNumber, Float percent) {
|
||||
Objects.requireNonNull(percent);
|
||||
@ -114,15 +117,11 @@ public class DriverOperateHandler {
|
||||
case CM: {
|
||||
if (!train.isAtpOn()) {
|
||||
throw new SimulationException(SimulationExceptionType.Invalid_Operation,
|
||||
String.format("列车[%s]ATP未开启,无法升级BM驾驶模式", train.getGroupNumber()));
|
||||
String.format("列车[%s]ATP未开启,无法升级CM驾驶模式", train.getGroupNumber()));
|
||||
}
|
||||
// if (RunLevel.ITC.equals(train.getRunLevel()) || RunLevel.CBTC.equals(train.getRunLevel())) {
|
||||
// train.useCMMode();
|
||||
// } else {
|
||||
// throw new SimulationException(SimulationExceptionType.Invalid_Operation,
|
||||
// String.format("列车[%s]非ITC/CBTC运行级别,无法升级BM驾驶模式", train.getGroupNumber()));
|
||||
// }
|
||||
if (zcLogicLoop.updateCbtcMa4CM(simulation, train)) {
|
||||
train.useCMMode();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case RM: {
|
||||
|
@ -7,6 +7,7 @@ import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
|
||||
import club.joylink.rtss.simulation.cbtc.event.SimulationDeviceFaultOverEvent;
|
||||
import club.joylink.rtss.simulation.cbtc.event.SimulationDeviceFaultSetEvent;
|
||||
import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -17,8 +18,15 @@ public class TrainFaultService{
|
||||
@Autowired
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Autowired
|
||||
private ATPService atpService;
|
||||
|
||||
public void setFault(Simulation simulation, MapElement device, FaultParam param) {
|
||||
VirtualRealityTrain.Fault fault = checkAndGetFault(param);
|
||||
if (VirtualRealityTrain.Fault.SUDDEN_EB.equals(fault)) {
|
||||
atpService.triggerSignalEB((VirtualRealityTrain) device);
|
||||
return;
|
||||
}
|
||||
boolean apply = fault.apply(device);
|
||||
if (apply) {
|
||||
this.applicationContext.publishEvent(new SimulationDeviceFaultSetEvent(this,
|
||||
|
@ -713,8 +713,7 @@ public class VirtualRealityTrain extends VirtualRealityDevice {
|
||||
// this.setSignalEB(false);
|
||||
this.setAtoOn(false);
|
||||
this.setDriveMode(DriveMode.RM);
|
||||
this.lossPosition();
|
||||
// this.positioned = false; //定位丢失
|
||||
// this.lossPosition();
|
||||
this.setCbtcMaMiss(); //通信断开
|
||||
// this.lastTwoPassedResponders.clear();
|
||||
// if (RunLevel.CBTC.equals(this.runLevel)) {
|
||||
@ -1157,7 +1156,10 @@ public class VirtualRealityTrain extends VirtualRealityDevice {
|
||||
train.emergencyBreak(); //暂时就在这里直接处理,可能正常应该是ATP的责任
|
||||
return true;
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
/** 突然EB */
|
||||
SUDDEN_EB{},;
|
||||
|
||||
public boolean apply(MapElement device) {
|
||||
VirtualRealityTrain train = (VirtualRealityTrain) device;
|
||||
|
@ -8,6 +8,7 @@ import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SimulationModule;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.*;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
|
||||
import club.joylink.rtss.vo.client.fault.FaultRuleVO;
|
||||
import club.joylink.rtss.vo.client.fault.FaultTriggerConditionVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -41,6 +42,9 @@ public class FaultGenerator {
|
||||
@Autowired
|
||||
private ZCFaultService zcFaultService;
|
||||
|
||||
@Autowired
|
||||
private TrainFaultService trainFaultService;
|
||||
|
||||
/**
|
||||
* 根据条件生成设备故障
|
||||
*
|
||||
@ -89,6 +93,11 @@ public class FaultGenerator {
|
||||
this.zcFaultService.setFault(simulation, zc, new FaultParam(zc.getCode(), faultRule.getFaultType()));
|
||||
break;
|
||||
}
|
||||
case TRAIN:{
|
||||
VirtualRealityTrain train = simulation.getRepository().getVRByCode(faultRule.getTargetDeviceCode(), VirtualRealityTrain.class);
|
||||
this.trainFaultService.setFault(simulation, train, new FaultParam(train.getCode(), faultRule.getFaultType()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
log.debug("仿真[{}]自动故障[{}]触发",simulation.getId(),faultRule.getFaultType());
|
||||
}
|
||||
|
@ -81,14 +81,11 @@ public class ATPLogicLoop {
|
||||
if (train.isITC() || train.isCBTC()) { //并且是ITC/CBTC级别
|
||||
train.setRunLevel(RunLevel.IL);
|
||||
atpService.triggerSignalEB(train);
|
||||
train.setMa(null);
|
||||
}
|
||||
} else { //列车有定位
|
||||
if (train.isCBTC() && train.isCbtcMaMiss()) { //CBTC列车的移动授权丢失
|
||||
train.setRunLevel(RunLevel.IL);
|
||||
train.lossPosition();
|
||||
atpService.triggerSignalEB(train);
|
||||
train.setMa(null);
|
||||
} else if (!train.isCbtcMaMiss() && defaultRunLevel.equals(RunLevel.CBTC)) {
|
||||
train.setCBTCMode();
|
||||
} else if (!train.isItcMaMiss()) {
|
||||
|
@ -37,9 +37,9 @@ public class ATPService {
|
||||
if (Objects.nonNull(train.getMa()) && train.getMa().getEnd().equals(ma.getEnd())) {
|
||||
return;
|
||||
}
|
||||
if (train.isEB() && !train.isStop()) {
|
||||
return;
|
||||
}
|
||||
// if (train.isEB() && !train.isStop()) {
|
||||
// return;
|
||||
// }
|
||||
Float protectDistance = this.calculateProtectDistance(train, ma.getEnd());
|
||||
if (Objects.isNull(protectDistance)) { // 安全运行距离未计算出,抛弃此次ma数据
|
||||
log.warn(String.format("列车[%s-%s|%s|%s]移动授权终点为[%s],未计算出安全防护距离",
|
||||
|
@ -16,6 +16,11 @@ public interface OnboardAtpApiService {
|
||||
*/
|
||||
void updateMA4CBTC(VirtualRealityTrain train, MovementAuthority ma);
|
||||
|
||||
/**
|
||||
* 忽略驾驶模式更新CBTC移动授权
|
||||
*/
|
||||
boolean ignoreDriveModeUpdateMA4CBTC(VirtualRealityTrain train, MovementAuthority ma);
|
||||
|
||||
void updateMA4ITC(VirtualRealityTrain train, MovementAuthority ma);
|
||||
|
||||
/**
|
||||
|
@ -48,6 +48,21 @@ public class OnboardAtpApiServiceImpl implements OnboardAtpApiService {
|
||||
train.setCbtcMaMissDuration(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ignoreDriveModeUpdateMA4CBTC(VirtualRealityTrain train, MovementAuthority ma) {
|
||||
if (ma == null)
|
||||
return false;
|
||||
if (!train.isAtpOn()) {
|
||||
return false;
|
||||
}
|
||||
if (train.getFault() == VirtualRealityTrain.Fault.COMMUNICATION_ABNORMAL) { //列车通信故障
|
||||
return false;
|
||||
}
|
||||
this.ATPService.updateMA(train, ma);
|
||||
train.setCbtcMaMissDuration(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMA4ITC(VirtualRealityTrain train, MovementAuthority ma) {
|
||||
if (ma == null)
|
||||
@ -207,9 +222,9 @@ public class OnboardAtpApiServiceImpl implements OnboardAtpApiService {
|
||||
|
||||
@Override
|
||||
public boolean canOpenATO(VirtualRealityTrain train) {
|
||||
if (train.isEB()) {
|
||||
return false;
|
||||
}
|
||||
// if (train.isEB()) {
|
||||
// return false;
|
||||
// }
|
||||
if (RunLevel.IL.equals(train.getRunLevel())) { //IL级别不能开
|
||||
return false;
|
||||
}
|
||||
|
@ -58,13 +58,16 @@ public class RobotLogicLoop {
|
||||
* 根据目标位置运行
|
||||
*/
|
||||
public void run(Simulation simulation) {
|
||||
executor.execute(() -> robotDriverLogicLoop(simulation));
|
||||
executor.execute(() -> robotReplyControlTransferApplicationLogicLoop(simulation));
|
||||
executor.execute(() -> robotStationControlAutoTransfer(simulation));
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
robotDriverLogicLoop(simulation);
|
||||
} catch (RuntimeException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
robotReplyControlTransferApplicationLogicLoop(simulation);
|
||||
robotStationControlAutoTransfer(simulation);
|
||||
// executor.execute(() -> robotDriverLogicLoop(simulation));
|
||||
// executor.execute(() -> robotReplyControlTransferApplicationLogicLoop(simulation));
|
||||
// executor.execute(() -> robotStationControlAutoTransfer(simulation));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -122,7 +125,9 @@ public class RobotLogicLoop {
|
||||
case CM:
|
||||
Float recommendedSpeedMax = Stream.of(train.getAtpSpeedMax(), train.getSpeedLimit() * 0.9f, train.getAtoSpeedMax())
|
||||
.min(Comparator.comparingDouble(Float::doubleValue)).get();
|
||||
float remainDistance = ATOService.calculateDistanceOfMa(headPosition, right, train.getMa());
|
||||
Float remainDistance = ATOService.calculateDistanceOfMa(headPosition, right, train.getMa());
|
||||
if (remainDistance == null)
|
||||
remainDistance = 0f;
|
||||
distance = Math.min(distance, remainDistance);
|
||||
speedCurve = SpeedCurve.buildTargetSpeedCurve(headPosition, tailPosition, right,
|
||||
distance, speed, recommendedSpeedMax);
|
||||
|
Loading…
Reference in New Issue
Block a user