Merge branch 'test-training2' of https://git.code.tencent.com/lian-cbtc/rtss-server into test-training2-xzb1
This commit is contained in:
commit
3ff942aaa4
@ -25,7 +25,7 @@ CREATE TABLE `rts_paper_composition` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '试卷蓝图id',
|
||||
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '试卷蓝图名称',
|
||||
`profile` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '试卷蓝图简介',
|
||||
`map_id` bigint DEFAULT NULL COMMENT '对应的mapId',
|
||||
`map_id` bigint NOT NULL COMMENT '对应的mapId',
|
||||
`org_id` bigint DEFAULT NULL COMMENT '组织id',
|
||||
`start_time` datetime DEFAULT NULL COMMENT '启用起始时间',
|
||||
`end_time` datetime DEFAULT NULL COMMENT '启用截止时间',
|
||||
|
@ -10,6 +10,8 @@ public class RtsTraining2Rule {
|
||||
|
||||
private String simType;
|
||||
|
||||
private String lineCode;
|
||||
|
||||
private String locationRule;
|
||||
|
||||
private String deviceRule;
|
||||
|
@ -225,6 +225,66 @@ public class RtsTraining2RuleExample {
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLineCodeIsNull() {
|
||||
addCriterion("line_code is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLineCodeIsNotNull() {
|
||||
addCriterion("line_code is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLineCodeEqualTo(String value) {
|
||||
addCriterion("line_code =", value, "lineCode");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLineCodeNotEqualTo(String value) {
|
||||
addCriterion("line_code <>", value, "lineCode");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLineCodeGreaterThan(String value) {
|
||||
addCriterion("line_code >", value, "lineCode");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLineCodeGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("line_code >=", value, "lineCode");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLineCodeLessThan(String value) {
|
||||
addCriterion("line_code <", value, "lineCode");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLineCodeLessThanOrEqualTo(String value) {
|
||||
addCriterion("line_code <=", value, "lineCode");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLineCodeIn(List<String> values) {
|
||||
addCriterion("line_code in", values, "lineCode");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLineCodeNotIn(List<String> values) {
|
||||
addCriterion("line_code not in", values, "lineCode");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLineCodeBetween(String value1, String value2) {
|
||||
addCriterion("line_code between", value1, value2, "lineCode");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLineCodeNotBetween(String value1, String value2) {
|
||||
addCriterion("line_code not between", value1, value2, "lineCode");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andFunctionIdIsNull() {
|
||||
addCriterion("function_id is null");
|
||||
return (Criteria) this;
|
||||
|
@ -366,6 +366,7 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService {
|
||||
itemMap.put(SimulationWorkParamVO.Item.DEFAULT_MEMBER, dispatcherOptional.get().getId());
|
||||
}
|
||||
SimulationWorkParamVO.DomConfigVO domConfig = SimulationWorkParamVO.DomConfigVO.builder()
|
||||
.hasVoice(true)
|
||||
.trainingDesign(true)
|
||||
.hasMemberManager(true)
|
||||
.build();
|
||||
@ -389,6 +390,7 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService {
|
||||
itemMap.put(SimulationWorkParamVO.Item.DEFAULT_MEMBER, dispatcherOptional.get().getId());
|
||||
}
|
||||
SimulationWorkParamVO.DomConfigVO domConfig = SimulationWorkParamVO.DomConfigVO.builder()
|
||||
.hasVoice(true)
|
||||
.isJoint(true)
|
||||
.hasMemberManager(true)
|
||||
.build();
|
||||
@ -404,6 +406,7 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService {
|
||||
return null;
|
||||
}
|
||||
SimulationWorkParamVO.DomConfigVO domConfig = SimulationWorkParamVO.DomConfigVO.builder()
|
||||
.hasVoice(true)
|
||||
.hasExam(true)
|
||||
.build();
|
||||
return buildCreateVO(mapId, name, name, simType, null, domConfig);
|
||||
@ -418,6 +421,7 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService {
|
||||
return null;
|
||||
}
|
||||
SimulationWorkParamVO.DomConfigVO domConfig = SimulationWorkParamVO.DomConfigVO.builder()
|
||||
.hasVoice(true)
|
||||
.hasTraining(true)
|
||||
.hasMemberManager(true)
|
||||
.build();
|
||||
@ -433,6 +437,7 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService {
|
||||
return null;
|
||||
}
|
||||
SimulationWorkParamVO.DomConfigVO domConfig = SimulationWorkParamVO.DomConfigVO.builder()
|
||||
.hasVoice(true)
|
||||
.hasTraining(true)
|
||||
.build();
|
||||
return buildCreateVO(mapId, name, name, simType, null, domConfig);
|
||||
@ -478,6 +483,7 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService {
|
||||
return null;
|
||||
}
|
||||
SimulationWorkParamVO.DomConfigVO domConfig = SimulationWorkParamVO.DomConfigVO.builder()
|
||||
.hasVoice(true)
|
||||
.singleMember(true)
|
||||
.hasMemberManager(true)
|
||||
.build();
|
||||
@ -501,6 +507,7 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService {
|
||||
return null;
|
||||
}
|
||||
SimulationWorkParamVO.DomConfigVO domConfig = SimulationWorkParamVO.DomConfigVO.builder()
|
||||
.hasVoice(true)
|
||||
.singleMember(true)
|
||||
.hasMemberManager(true)
|
||||
.build();
|
||||
@ -561,6 +568,7 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService {
|
||||
return null;
|
||||
}
|
||||
SimulationWorkParamVO.DomConfigVO domConfig = SimulationWorkParamVO.DomConfigVO.builder()
|
||||
.hasVoice(true)
|
||||
.singleMember(true)
|
||||
.hasMemberManager(true)
|
||||
.build();
|
||||
@ -584,6 +592,7 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService {
|
||||
return null;
|
||||
}
|
||||
SimulationWorkParamVO.DomConfigVO domConfig = SimulationWorkParamVO.DomConfigVO.builder()
|
||||
.hasVoice(true)
|
||||
.singleMember(true)
|
||||
.hasMemberManager(true)
|
||||
.build();
|
||||
|
@ -60,7 +60,7 @@ public class Training2RuleService {
|
||||
runningMapIdSet.add(mapId);
|
||||
// 规则列表
|
||||
RtsTraining2RuleExample example = new RtsTraining2RuleExample();
|
||||
example.createCriteria().andSimTypeEqualTo(simulation.getBuildParams().getWorkParamVO().getType().name());
|
||||
example.createCriteria().andLineCodeEqualTo(simulation.getBuildParams().getMap().getLineCode());
|
||||
List<RtsTraining2RuleWithBLOBs> ruleList = rtsTraining2RuleMapper.selectByExampleWithBLOBs(example);
|
||||
if (!CollectionUtils.isEmpty(ruleList)) {
|
||||
// 清除数据库原有数据
|
||||
|
@ -10,6 +10,7 @@ import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
|
||||
import club.joylink.rtss.simulation.cbtc.onboard.ATO.SpeedCurve;
|
||||
import club.joylink.rtss.simulation.cbtc.onboard.ATP.OnboardAtpApiService;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@ -27,6 +28,7 @@ public class MaService {
|
||||
private OnboardAtpApiService onboardAtpApiService;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class Ma {
|
||||
public static final int Safety_Margin = 1; // 安全余量,单位m,暂时没有计算紧急制动曲线,暂时不用
|
||||
public static final int EB_Trigger = 20; // 紧急制动触发点偏移量,单位m
|
||||
|
@ -35,7 +35,6 @@ public class ResponderService {
|
||||
for (Responder responder : responders) {
|
||||
if (responder.isBetween(headPosition, headPositionNew)) { // 列车经过应答器
|
||||
log.debug(String.format("列车[%s]经过应答器[%s]", train.getGroupNumber(), responder.debugStr()));
|
||||
train.viaResponder(responder);
|
||||
if (!train.isCommunicable() && train.isAtpOn() &&
|
||||
(responder.isIB() || responder.isVB())) {
|
||||
this.maService.calculateAndUpdateItcMa(simulation, train, responder);
|
||||
|
@ -7,7 +7,6 @@ import club.joylink.rtss.simulation.cbtc.ATS.service.stage.AtsRealRunRecordServi
|
||||
import club.joylink.rtss.simulation.cbtc.ATS.service.stage.AtsTrainStageHandler;
|
||||
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcStationRunPlanLog;
|
||||
import club.joylink.rtss.simulation.cbtc.ISCS.OnBoardPisService;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
@ -48,9 +47,6 @@ public class AtsTrainMonitorService {
|
||||
private AtsStandService atsStandService;
|
||||
@Autowired
|
||||
private OnboardAtpApiService onboardAtpApiService;
|
||||
@Autowired
|
||||
private OnBoardPisService onBoardPisService;
|
||||
|
||||
|
||||
public void monitorForTrainPosition(Simulation simulation){
|
||||
List<TrainInfo> trainList = simulation.getRepository().getSuperviseTrainList();
|
||||
|
@ -1,39 +1,39 @@
|
||||
package club.joylink.rtss.simulation.cbtc.ISCS;
|
||||
|
||||
import club.joylink.rtss.services.voice.VoiceService;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
|
||||
import club.joylink.rtss.vo.client.iscs.Ats2PisMsg;
|
||||
import club.joylink.rtss.vo.client.voice.BaseVoiceSynthesisVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* PIS系统逻辑服务
|
||||
*/
|
||||
@Component
|
||||
public class OnBoardPisService {
|
||||
/*@Autowired
|
||||
@Qualifier("baiDuVoiceService")
|
||||
private IVoiceService iVoiceService;*/
|
||||
|
||||
@Autowired
|
||||
// @Qualifier("baiDuVoiceService2")
|
||||
private VoiceService iVoiceService;
|
||||
public void play(Simulation simulation, Ats2PisMsg msg) {
|
||||
String content;
|
||||
if (msg.isArrivalMsg()) {
|
||||
String direction = msg.getStand().isInside() ? "左" : "右";
|
||||
content = msg.getStation().getName() + "站到了,下车的乘客请从列车运行方向的" + direction + "侧车门下车";
|
||||
} else {
|
||||
content = "本次列车开往" + msg.getTerminalStation().getName() + "方向,下一站" + msg.getStation().getName();
|
||||
}
|
||||
BaseVoiceSynthesisVO vo = new BaseVoiceSynthesisVO(content);
|
||||
String path = iVoiceService.synthesis(vo).getFilePath();
|
||||
// String path = iVoiceService.synthesis(content);
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
VirtualRealityTrain train = repository.getOnlineTrainBy(msg.getGroupNumber());
|
||||
train.getVrAudio().updateUrl(path);
|
||||
}
|
||||
}
|
||||
//package club.joylink.rtss.simulation.cbtc.ISCS;
|
||||
//
|
||||
//import club.joylink.rtss.services.voice.VoiceService;
|
||||
//import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
//import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
|
||||
//import club.joylink.rtss.vo.client.iscs.Ats2PisMsg;
|
||||
//import club.joylink.rtss.vo.client.voice.BaseVoiceSynthesisVO;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
///**
|
||||
// * PIS系统逻辑服务
|
||||
// */
|
||||
//@Component
|
||||
//public class OnBoardPisService {
|
||||
// /*@Autowired
|
||||
// @Qualifier("baiDuVoiceService")
|
||||
// private IVoiceService iVoiceService;*/
|
||||
//
|
||||
// @Autowired
|
||||
//// @Qualifier("baiDuVoiceService2")
|
||||
// private VoiceService iVoiceService;
|
||||
// public void play(Simulation simulation, Ats2PisMsg msg) {
|
||||
// String content;
|
||||
// if (msg.isArrivalMsg()) {
|
||||
// String direction = msg.getStand().isInside() ? "左" : "右";
|
||||
// content = msg.getStation().getName() + "站到了,下车的乘客请从列车运行方向的" + direction + "侧车门下车";
|
||||
// } else {
|
||||
// content = "本次列车开往" + msg.getTerminalStation().getName() + "方向,下一站" + msg.getStation().getName();
|
||||
// }
|
||||
// BaseVoiceSynthesisVO vo = new BaseVoiceSynthesisVO(content);
|
||||
// String path = iVoiceService.synthesis(vo).getFilePath();
|
||||
//// String path = iVoiceService.synthesis(content);
|
||||
// SimulationDataRepository repository = simulation.getRepository();
|
||||
// VirtualRealityTrain train = repository.getOnlineTrainBy(msg.getGroupNumber());
|
||||
// train.getVrAudio().updateUrl(path);
|
||||
// }
|
||||
//}
|
||||
|
@ -87,10 +87,6 @@ public class Responder extends MapNamedElement {
|
||||
return this.isVB() || this.isFB();
|
||||
}
|
||||
|
||||
public void exchangeData(VirtualRealityTrain train) {
|
||||
train.viaResponder(this);
|
||||
}
|
||||
|
||||
public boolean isBetween(SectionPosition a, SectionPosition b) {
|
||||
return this.position.isBetween(a, b);
|
||||
}
|
||||
|
@ -378,25 +378,25 @@ public class StorageSimulationDataRepository {
|
||||
if (Objects.nonNull(this.vrDoorList)) {
|
||||
for (StorageVirtualRealityScreenDoor vrDoor : this.vrDoorList) {
|
||||
VirtualRealityDevice vrDevice = repository.getVRByCode(vrDoor.getCode());
|
||||
vrDoor.recover2Simulation(vrDevice, repository);
|
||||
vrDoor.recover2Simulation(vrDevice, simulation, repository);
|
||||
}
|
||||
}
|
||||
if (Objects.nonNull(this.vrSignalList)) {
|
||||
for (StorageVirtualRealitySignal vrSignal : this.vrSignalList) {
|
||||
VirtualRealityDevice vrDevice = repository.getVRByCode(vrSignal.getCode());
|
||||
vrSignal.recover2Simulation(vrDevice, repository);
|
||||
vrSignal.recover2Simulation(vrDevice, simulation, repository);
|
||||
}
|
||||
}
|
||||
if (Objects.nonNull(this.vrSwitchList)) {
|
||||
for (StorageVirtualRealitySwitch vrSwitch : this.vrSwitchList) {
|
||||
VirtualRealityDevice vrDevice = repository.getVRByCode(vrSwitch.getCode());
|
||||
vrSwitch.recover2Simulation(vrDevice, repository);
|
||||
vrSwitch.recover2Simulation(vrDevice, simulation, repository);
|
||||
}
|
||||
}
|
||||
if (Objects.nonNull(this.vrSectionList)) {
|
||||
for (StorageVirtualRealitySection vrSection : this.vrSectionList) {
|
||||
VirtualRealityDevice vrDevice = repository.getVRByCode(vrSection.getCode());
|
||||
vrSection.recover2Simulation(vrDevice, repository);
|
||||
vrSection.recover2Simulation(vrDevice, simulation, repository);
|
||||
}
|
||||
}
|
||||
// 恢复服务-车次计划列表map
|
||||
@ -428,7 +428,7 @@ public class StorageSimulationDataRepository {
|
||||
if (Objects.nonNull(this.usedTrainList)) {
|
||||
for (StorageVirtualRealityTrain train : this.usedTrainList) {
|
||||
VirtualRealityDevice vrTrain = repository.getVRByCode(train.getGroupNumber());
|
||||
train.recover2Simulation(vrTrain, repository);
|
||||
train.recover2Simulation(vrTrain, simulation, repository);
|
||||
repository.addOnlineTrain((VirtualRealityTrain) vrTrain);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package club.joylink.rtss.simulation.cbtc.data.storage.ato;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.onboard.ATO.SpeedCurve;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.onboard.ATO.SpeedCurve;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
@ -23,7 +23,7 @@ public class StorageSpeedCurve {
|
||||
this.speedCalculators = StorageSpeedCalculator.convertFromSpeedCalculatorList(speedCurve.getSpeedCalculators());
|
||||
}
|
||||
|
||||
public SpeedCurve recover2Simulation(SimulationDataRepository repository) {
|
||||
public SpeedCurve convert2SimulationObj(SimulationDataRepository repository) {
|
||||
return new SpeedCurve(totalDistance,
|
||||
StorageSpeedCalculator.convert2SpeedCalculatorList(speedCalculators));
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package club.joylink.rtss.simulation.cbtc.data.storage.support;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SignalAspect;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Signal;
|
||||
import club.joylink.rtss.vo.client.operation.DriveParamVO;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
@ -9,7 +11,7 @@ import lombok.Setter;
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public class StorageDriveParam {
|
||||
public class StorageDriveParamVO {
|
||||
/**
|
||||
* 限速值
|
||||
*/
|
||||
@ -41,7 +43,7 @@ public class StorageDriveParam {
|
||||
|
||||
private boolean releaseEB;
|
||||
|
||||
public StorageDriveParam(DriveParamVO param) {
|
||||
public StorageDriveParamVO(DriveParamVO param) {
|
||||
this.speedLimit = param.getSpeedLimit();
|
||||
this.run = param.isRun();
|
||||
this.targetDeviceCode = param.getTargetDeviceCode();
|
||||
@ -53,4 +55,21 @@ public class StorageDriveParam {
|
||||
this.throughSignalAspect = param.getThroughSignalAspect();
|
||||
this.releaseEB = param.isReleaseEB();
|
||||
}
|
||||
|
||||
public DriveParamVO convert2SimulationObj(SimulationDataRepository repository) {
|
||||
DriveParamVO param = new DriveParamVO();
|
||||
param.setSpeedLimit(speedLimit);
|
||||
param.setRun(run);
|
||||
param.setTargetDeviceCode(targetDeviceCode);
|
||||
if (targetPosition != null) {
|
||||
param.setTargetPosition(targetPosition.convert2SimulationObj(repository));
|
||||
}
|
||||
param.setThrough(through);
|
||||
if (throughSignal != null) {
|
||||
param.setThroughSignal(repository.getByCode(throughSignal, Signal.class));
|
||||
}
|
||||
param.setThroughSignalAspect(throughSignalAspect);
|
||||
param.setReleaseEB(releaseEB);
|
||||
return param;
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package club.joylink.rtss.simulation.cbtc.data.storage.support;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.ATP.ground.MaService;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.MapNamedElement;
|
||||
import club.joylink.rtss.simulation.cbtc.data.storage.ato.StorageSpeedCurve;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public class StorageMa {
|
||||
private String trainCode;
|
||||
private String deviceCode;
|
||||
private MaService.MaType type;
|
||||
private StorageSectionPosition eoaPosition;
|
||||
private float distanceToEoa;
|
||||
private StorageSpeedCurve ebTriggerCurve;
|
||||
private StorageSpeedCurve atoStopCurve;
|
||||
|
||||
public StorageMa(@NonNull MaService.Ma ma) {
|
||||
if (ma.getTrain() != null) {
|
||||
this.trainCode = ma.getTrain().getCode();
|
||||
}
|
||||
if (ma.getDevice() != null) {
|
||||
this.deviceCode = ma.getDevice().getCode();
|
||||
}
|
||||
this.type = ma.getType();
|
||||
if (ma.getEoaPosition() != null) {
|
||||
this.eoaPosition = new StorageSectionPosition(ma.getEoaPosition());
|
||||
}
|
||||
this.distanceToEoa = ma.getDistanceToEoa();
|
||||
if (ma.getEbTriggerCurve() != null) {
|
||||
this.ebTriggerCurve = new StorageSpeedCurve(ma.getEbTriggerCurve());
|
||||
}
|
||||
if (ma.getAtoStopCurve() != null) {
|
||||
this.atoStopCurve = new StorageSpeedCurve(ma.getAtoStopCurve());
|
||||
}
|
||||
}
|
||||
|
||||
public MaService.Ma convert2SimulationObj(SimulationDataRepository repository) {
|
||||
VirtualRealityTrain train = repository.getVRByCode(trainCode, VirtualRealityTrain.class);
|
||||
MapNamedElement device = repository.getByCode(deviceCode, MapNamedElement.class);
|
||||
MaService.Ma ma = new MaService.Ma(train, device, type);
|
||||
if (eoaPosition != null) {
|
||||
ma.setEoaPosition(eoaPosition.convert2SimulationObj(repository));
|
||||
}
|
||||
ma.setDistanceToEoa(distanceToEoa);
|
||||
if (ebTriggerCurve != null) {
|
||||
ma.setEbTriggerCurve(ebTriggerCurve.convert2SimulationObj(repository));
|
||||
}
|
||||
if (atoStopCurve != null) {
|
||||
ma.setAtoStopCurve(atoStopCurve.convert2SimulationObj(repository));
|
||||
}
|
||||
return ma;
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package club.joylink.rtss.simulation.cbtc.data.storage.support;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.onboard.ATO.SpeedCurve;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.MapNamedElement;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Section;
|
||||
@ -8,6 +7,7 @@ import club.joylink.rtss.simulation.cbtc.data.storage.ato.StorageSpeedCurve;
|
||||
import club.joylink.rtss.simulation.cbtc.data.support.MovementAuthority;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
|
||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
|
||||
import club.joylink.rtss.simulation.cbtc.onboard.ATO.SpeedCurve;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
@ -17,7 +17,7 @@ import java.util.Objects;
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public class StorageMA {
|
||||
public class StorageMovementAuthority {
|
||||
|
||||
/** 移动授权终点设备存储 */
|
||||
private StorageEnd end;
|
||||
@ -25,7 +25,7 @@ public class StorageMA {
|
||||
/** 防护速度曲线 */
|
||||
private StorageSpeedCurve protectSpeedCurve;
|
||||
|
||||
public StorageMA(MovementAuthority ma) {
|
||||
public StorageMovementAuthority(MovementAuthority ma) {
|
||||
if (ma.getEnd() != null) {
|
||||
this.end = new StorageEnd(ma.getEnd());
|
||||
}
|
||||
@ -37,7 +37,7 @@ public class StorageMA {
|
||||
public MovementAuthority convert2SimulationObj(SimulationDataRepository repository) {
|
||||
SpeedCurve psc = null;
|
||||
if (Objects.nonNull(this.protectSpeedCurve)) {
|
||||
psc = this.protectSpeedCurve.recover2Simulation(repository);
|
||||
psc = this.protectSpeedCurve.convert2SimulationObj(repository);
|
||||
}
|
||||
return new MovementAuthority(end.convert2SimulationObj(repository), psc);
|
||||
}
|
@ -7,7 +7,7 @@ import lombok.NoArgsConstructor;
|
||||
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
public abstract class StorageControllableVrDevice<C> extends StorageVirtualRealityDeviceStatus {
|
||||
public abstract class StorageControllableVrDevice<C> extends StorageVirtualRealityDevice {
|
||||
/**
|
||||
* 控制指令
|
||||
*/
|
||||
|
@ -1,7 +1,8 @@
|
||||
package club.joylink.rtss.simulation.cbtc.data.storage.vr;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityDevice;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
|
||||
import club.joylink.rtss.util.jsonSerialize.Boolean2NumDeserializer;
|
||||
import club.joylink.rtss.util.jsonSerialize.Boolean2NumSerializer;
|
||||
@ -16,7 +17,7 @@ import java.util.Objects;
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public class StorageTrainDoor extends StorageControllableVrDevice<VirtualRealityTrain.Door.Operation> {
|
||||
public class StorageDoor extends StorageControllableVrDevice<VirtualRealityTrain.Door.Operation> {
|
||||
private String code;
|
||||
|
||||
@JsonSerialize(using = Boolean2NumSerializer.class)
|
||||
@ -27,7 +28,7 @@ public class StorageTrainDoor extends StorageControllableVrDevice<VirtualReality
|
||||
@JsonDeserialize(using = Boolean2NumDeserializer.class)
|
||||
private Boolean lock;
|
||||
|
||||
public StorageTrainDoor(VirtualRealityTrain.Door door) {
|
||||
public StorageDoor(VirtualRealityTrain.Door door) {
|
||||
this.code = door.getCode();
|
||||
this.close = door.isClose();
|
||||
this.lock = door.isLock();
|
||||
@ -49,7 +50,21 @@ public class StorageTrainDoor extends StorageControllableVrDevice<VirtualReality
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recover2Simulation(VirtualRealityDevice vrDevice, SimulationDataRepository repository) {
|
||||
public boolean convert(MapElement element) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recover2Simulation(MapElement element, Simulation simulation, SimulationDataRepository repository) {
|
||||
VirtualRealityTrain.Door door = (VirtualRealityTrain.Door) element;
|
||||
if (Objects.nonNull(this.close)) {
|
||||
door.setClose(close);
|
||||
}
|
||||
if (Objects.nonNull(this.lock)) {
|
||||
door.setLock(lock);
|
||||
}
|
||||
if (this.getRemain() > 0) {
|
||||
this.recoverTo(door);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package club.joylink.rtss.simulation.cbtc.data.storage.vr;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.data.storage.device.StorageDevice;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityDevice;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public abstract class StorageVirtualRealityDevice extends StorageDevice {
|
||||
public StorageVirtualRealityDevice(VirtualRealityDevice device) {
|
||||
super(device.getCode());
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package club.joylink.rtss.simulation.cbtc.data.storage.vr;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.MapNamedElement;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.*;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public abstract class StorageVirtualRealityDeviceStatus {
|
||||
|
||||
private String code;
|
||||
|
||||
public StorageVirtualRealityDeviceStatus(VirtualRealityDevice device) {
|
||||
this.code = device.getCode();
|
||||
}
|
||||
|
||||
public abstract void recover2Simulation(VirtualRealityDevice vrDevice, SimulationDataRepository repository);
|
||||
}
|
@ -1,7 +1,8 @@
|
||||
package club.joylink.rtss.simulation.cbtc.data.storage.vr;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityDevice;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor;
|
||||
import club.joylink.rtss.util.jsonSerialize.Boolean2NumDeserializer;
|
||||
import club.joylink.rtss.util.jsonSerialize.Boolean2NumSerializer;
|
||||
@ -92,7 +93,12 @@ public class StorageVirtualRealityScreenDoor extends StorageControllableVrDevice
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recover2Simulation(VirtualRealityDevice vrDevice, SimulationDataRepository repository) {
|
||||
public boolean convert(MapElement element) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recover2Simulation(MapElement vrDevice, Simulation simulation, SimulationDataRepository repository) {
|
||||
VirtualRealityScreenDoor door = (VirtualRealityScreenDoor) vrDevice;
|
||||
door.setClose(close != null ? close : true);
|
||||
door.setOpen2End(open2End != null ? open2End : false);
|
||||
|
@ -1,12 +1,13 @@
|
||||
package club.joylink.rtss.simulation.cbtc.data.storage.vr;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityDevice;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySectionAxleCounter;
|
||||
import club.joylink.rtss.util.jsonSerialize.Boolean2NumDeserializer;
|
||||
import club.joylink.rtss.util.jsonSerialize.Boolean2NumSerializer;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
@ -14,7 +15,7 @@ import lombok.Setter;
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public class StorageVirtualRealitySection extends StorageVirtualRealityDeviceStatus {
|
||||
public class StorageVirtualRealitySection extends StorageVirtualRealityDevice {
|
||||
|
||||
/**
|
||||
* 是否占用
|
||||
@ -67,7 +68,12 @@ public class StorageVirtualRealitySection extends StorageVirtualRealityDeviceSta
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recover2Simulation(VirtualRealityDevice vrDevice, SimulationDataRepository repository) {
|
||||
public boolean convert(MapElement element) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recover2Simulation(MapElement vrDevice, Simulation simulation, SimulationDataRepository repository) {
|
||||
VirtualRealitySectionAxleCounter s = (VirtualRealitySectionAxleCounter) vrDevice;
|
||||
s.setOccupy(occupy != null ? occupy : false);
|
||||
s.setPreReset(preReset != null ? preReset : false);
|
||||
|
@ -1,8 +1,9 @@
|
||||
package club.joylink.rtss.simulation.cbtc.data.storage.vr;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SignalAspect;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityDevice;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
@ -43,7 +44,7 @@ public class StorageVirtualRealitySignal extends StorageControllableVrDevice<Sig
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recover2Simulation(VirtualRealityDevice vrDevice, SimulationDataRepository repository) {
|
||||
public void recover2Simulation(MapElement vrDevice, Simulation simulation, SimulationDataRepository repository) {
|
||||
VirtualRealitySignal signal = (VirtualRealitySignal) vrDevice;
|
||||
if (this.aspect != null) {
|
||||
signal.setAspect(this.aspect);
|
||||
@ -53,4 +54,9 @@ public class StorageVirtualRealitySignal extends StorageControllableVrDevice<Sig
|
||||
}
|
||||
signal.setFault(fault);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean convert(MapElement element) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
package club.joylink.rtss.simulation.cbtc.data.storage.vr;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SwitchIndication;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityDevice;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
@ -46,7 +47,7 @@ public class StorageVirtualRealitySwitch extends StorageControllableVrDevice<Vir
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recover2Simulation(VirtualRealityDevice vrDevice, SimulationDataRepository repository) {
|
||||
public void recover2Simulation(MapElement vrDevice, Simulation simulation, SimulationDataRepository repository) {
|
||||
VirtualRealitySwitch s = (VirtualRealitySwitch) vrDevice;
|
||||
if (this.p != null) {
|
||||
s.setP(p);
|
||||
@ -55,4 +56,9 @@ public class StorageVirtualRealitySwitch extends StorageControllableVrDevice<Vir
|
||||
this.recoverTo(s);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean convert(MapElement element) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,463 +1,312 @@
|
||||
package club.joylink.rtss.simulation.cbtc.data.storage.vr;
|
||||
|
||||
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.TrainTBControl;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Responder;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
|
||||
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.Station;
|
||||
import club.joylink.rtss.simulation.cbtc.data.storage.support.StorageDriveParam;
|
||||
import club.joylink.rtss.simulation.cbtc.data.storage.support.StorageMA;
|
||||
import club.joylink.rtss.simulation.cbtc.data.storage.support.StorageDriveParamVO;
|
||||
import club.joylink.rtss.simulation.cbtc.data.storage.support.StorageMa;
|
||||
import club.joylink.rtss.simulation.cbtc.data.storage.support.StorageMovementAuthority;
|
||||
import club.joylink.rtss.simulation.cbtc.data.storage.support.StorageSectionPosition;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.StandParkedTrainActivity;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityDevice;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
|
||||
import club.joylink.rtss.vo.client.operation.DriveParamVO;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain.*;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.LinkedHashSet;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public class StorageVirtualRealityTrain extends StorageVirtualRealityDeviceStatus {
|
||||
|
||||
/**
|
||||
* 车组号
|
||||
*/
|
||||
public class StorageVirtualRealityTrain extends StorageVirtualRealityDevice {
|
||||
private String groupNumber;
|
||||
|
||||
/**
|
||||
* 列车运行级别
|
||||
*/
|
||||
private boolean noCommunicateDevice;
|
||||
private boolean communication;
|
||||
private RunLevel runLevel;
|
||||
|
||||
/**
|
||||
* 驾驶模式
|
||||
*/
|
||||
private DriveMode driveMode;
|
||||
|
||||
/**
|
||||
* 临时预选模式
|
||||
*/
|
||||
private VirtualRealityTrain.PreselectionMode tempPreselectionMode;
|
||||
|
||||
/**
|
||||
* 预选模式
|
||||
*/
|
||||
private VirtualRealityTrain.PreselectionMode preselectionMode;
|
||||
|
||||
/**
|
||||
* 服务号
|
||||
*/
|
||||
private PreselectionMode tempPreselectionMode;
|
||||
private PreselectionMode preselectionMode;
|
||||
private String serviceNumber;
|
||||
|
||||
/**
|
||||
* 车次号
|
||||
*/
|
||||
private String tripNumber;
|
||||
|
||||
/**
|
||||
* 目的地码
|
||||
*/
|
||||
private String destinationCode;
|
||||
|
||||
/**
|
||||
* 下一站
|
||||
*/
|
||||
private String nextStationCode;
|
||||
|
||||
/**
|
||||
* 即将到站
|
||||
*/
|
||||
private boolean beAbout2Arrive;
|
||||
|
||||
/**
|
||||
* 下一目标区段code
|
||||
*/
|
||||
private String targetSectionCode;
|
||||
|
||||
/**
|
||||
* 站台停靠时间
|
||||
*/
|
||||
private String targetCode;
|
||||
private int parkTime;
|
||||
|
||||
/**
|
||||
* 停站剩余时间,单位ms
|
||||
*/
|
||||
private int parkRemainTime;
|
||||
|
||||
/**
|
||||
* 发车提示
|
||||
*/
|
||||
private String parkSectionCode;
|
||||
private boolean departure;
|
||||
|
||||
/**
|
||||
* 列车站台停靠
|
||||
*/
|
||||
private boolean parking;
|
||||
|
||||
/**
|
||||
* 站台停靠列车动作
|
||||
*/
|
||||
private StandParkedTrainActivity standParkedTrainActivity;
|
||||
|
||||
private boolean nextParking;
|
||||
|
||||
/**
|
||||
* 跳站信息
|
||||
*/
|
||||
private boolean jump;
|
||||
|
||||
/**
|
||||
* 是否扣车
|
||||
*/
|
||||
private boolean hold;
|
||||
|
||||
/**
|
||||
* 制动
|
||||
*/
|
||||
private boolean breaking;
|
||||
|
||||
/**
|
||||
* 终点站
|
||||
*/
|
||||
private String terminalStationCode;
|
||||
|
||||
/**
|
||||
* 车头位置
|
||||
*/
|
||||
private StorageSectionPosition headPosition;
|
||||
|
||||
/**
|
||||
* 车尾位置
|
||||
*/
|
||||
private StorageSectionPosition tailPosition;
|
||||
|
||||
/**
|
||||
* 是否向右行驶
|
||||
*/
|
||||
private boolean right;
|
||||
|
||||
/**
|
||||
* 托管的目标位置
|
||||
*/
|
||||
private StorageSectionPosition robotTargetPosition;
|
||||
|
||||
/**
|
||||
* 移动授权
|
||||
*/
|
||||
private StorageMA ma;
|
||||
|
||||
private StorageMovementAuthority ma;
|
||||
private StorageMa ma2;
|
||||
private int cbtcMaMissDuration;
|
||||
|
||||
private int itcMaMissDuration;
|
||||
|
||||
private VirtualRealityTrain.Handwheel gear;
|
||||
/**
|
||||
* 实际运行速度
|
||||
*/
|
||||
private Handwheel gear;
|
||||
private float speed;
|
||||
|
||||
private float locationKM;
|
||||
private float targetDistance;
|
||||
|
||||
private float atoSpeedMax;
|
||||
|
||||
/**
|
||||
* ATO推荐速度
|
||||
*/
|
||||
private float atoSpeed;
|
||||
|
||||
/**
|
||||
* ATP防护速度
|
||||
*/
|
||||
private float atpSpeed;
|
||||
|
||||
/**
|
||||
* 限速
|
||||
*/
|
||||
private float speedLimit;
|
||||
|
||||
/**
|
||||
* 是否信号EB
|
||||
*/
|
||||
private boolean signalEB;
|
||||
|
||||
/**
|
||||
* 是否电路EB
|
||||
*/
|
||||
private boolean circuitEB;
|
||||
|
||||
/**
|
||||
* 是否折返中
|
||||
*/
|
||||
private StandParkedTrainActivity standParkedTrainActivity;
|
||||
private boolean nextParking;
|
||||
private boolean jump;
|
||||
private boolean hold;
|
||||
private boolean trainHold;
|
||||
private boolean dtro;
|
||||
|
||||
private boolean changeEnds;
|
||||
|
||||
private int changeEndsRemainTime;
|
||||
|
||||
/**
|
||||
* ATO是否开启
|
||||
*/
|
||||
private boolean atoOn;
|
||||
|
||||
/**
|
||||
* ATP是否可用
|
||||
*/
|
||||
private boolean atpOn;
|
||||
|
||||
private boolean priorityRouteSet;
|
||||
|
||||
/**
|
||||
* 门1
|
||||
*/
|
||||
private StorageTrainDoor door1;
|
||||
|
||||
/**
|
||||
* 门2
|
||||
*/
|
||||
private StorageTrainDoor door2;
|
||||
|
||||
/**
|
||||
* 当前功率
|
||||
*/
|
||||
private float currentPower;
|
||||
|
||||
/**
|
||||
* 牵引力,单位kN
|
||||
* 公式 fk = 350 (0 <= v <= 36km/h)
|
||||
* fk = 12900 / v (36 < v < 80km/h)
|
||||
*/
|
||||
private StorageDoor door1;
|
||||
private StorageDoor door2;
|
||||
private DoorMode doorMode;
|
||||
private DoorSelection doorSelection;
|
||||
private float fk;
|
||||
|
||||
/**
|
||||
* 制动力,单位kN
|
||||
*/
|
||||
private float fb;
|
||||
|
||||
private TrainTBControl tbControl;
|
||||
|
||||
private float leverPosition;
|
||||
|
||||
private VirtualRealityTrain.Fault fault;
|
||||
|
||||
private Fault fault;
|
||||
private boolean backUp;
|
||||
|
||||
/**
|
||||
* 发车延迟时间
|
||||
*/
|
||||
private int delayTime;
|
||||
private boolean powerOn;
|
||||
private boolean pantograph1Up;
|
||||
private boolean pantograph2Up;
|
||||
private String linkTrainCode;
|
||||
private RunType runType;
|
||||
private boolean orderStop;
|
||||
private boolean needDepartureCommand;
|
||||
private boolean positioned;
|
||||
private int runningTime;
|
||||
private boolean released;
|
||||
private LinkedHashSet<ConfirmationMessage> confirmationMessages;
|
||||
private boolean atoCanOpen;
|
||||
// private String vrAudioCode;
|
||||
private StorageDriveParamVO robotDriveParam;
|
||||
|
||||
/**
|
||||
* 列车是否通电
|
||||
*/
|
||||
private boolean powerOn = true;
|
||||
|
||||
private boolean pantograph1Up = true;
|
||||
|
||||
private boolean pantograph2Up = true;
|
||||
|
||||
private String linkTrainGroupNumber;
|
||||
// private Queue<Responder> lastTwoPassedResponders;
|
||||
|
||||
private List<String> lastTwoPassedResponders;
|
||||
|
||||
private StorageDriveParam driveParam;
|
||||
|
||||
private String parkSection;
|
||||
|
||||
public StorageVirtualRealityTrain(VirtualRealityTrain train) {
|
||||
super(train);
|
||||
this.groupNumber = train.getGroupNumber();
|
||||
this.runLevel = train.getRunLevel();
|
||||
this.driveMode = train.getDriveMode();
|
||||
this.tempPreselectionMode = train.getTempPreselectionMode();
|
||||
this.preselectionMode = train.getPreselectionMode();
|
||||
this.serviceNumber = train.getServiceNumber();
|
||||
this.tripNumber = train.getTripNumber();
|
||||
this.destinationCode = train.getDestinationCode();
|
||||
if (train.getNextStation() != null) {
|
||||
this.nextStationCode = train.getNextStation().getCode();
|
||||
}
|
||||
if (Objects.nonNull(train.getTarget())) {
|
||||
this.targetSectionCode = train.getTarget().getCode();
|
||||
}
|
||||
this.standParkedTrainActivity = train.getStandParkedTrainActivity();
|
||||
this.nextParking = train.isNextParking();
|
||||
this.beAbout2Arrive = train.isBeAbout2Arrive();
|
||||
this.jump = train.isJump();
|
||||
this.hold = train.isHold();
|
||||
this.parkTime = train.getParkTime();
|
||||
this.parkRemainTime = train.getParkRemainTime();
|
||||
this.departure = train.isDeparture();
|
||||
this.breaking = train.isBreaking();
|
||||
if (train.getTerminalStation() != null) {
|
||||
this.terminalStationCode = train.getTerminalStation().getCode();
|
||||
}
|
||||
if (train.getHeadPosition() != null) {
|
||||
this.headPosition = new StorageSectionPosition(train.getHeadPosition());
|
||||
}
|
||||
this.right = train.isRight();
|
||||
// if (train.getRobotTargetPosition() != null) {
|
||||
// this.robotTargetPosition = new StorageSectionPosition(train.getRobotTargetPosition());
|
||||
// }
|
||||
if (train.getMa() != null) {
|
||||
this.ma = new StorageMA(train.getMa());
|
||||
}
|
||||
this.cbtcMaMissDuration = train.getCbtcMaMissDuration();
|
||||
this.gear = train.getGear();
|
||||
this.speed = train.getSpeed();
|
||||
this.targetDistance = train.getTargetDistance();
|
||||
this.atoSpeedMax = train.getAtoSpeedMax();
|
||||
this.atoSpeed = train.getAtoSpeed();
|
||||
this.atpSpeed = train.getAtpSpeed();
|
||||
// this.speedLimit = train.getNonNullSpeedLimit();
|
||||
this.signalEB = train.isSignalEB();
|
||||
this.circuitEB = train.isCircuitEB();
|
||||
this.dtro = train.isDtro();
|
||||
this.changeEnds = train.isChangeEnds();
|
||||
this.changeEndsRemainTime = train.getChangeEndsRemainTime();
|
||||
this.atoOn = train.isAtoOn();
|
||||
this.atpOn = train.isAtpOn();
|
||||
this.priorityRouteSet = train.isPriorityRouteSet();
|
||||
this.door1 = new StorageTrainDoor(train.getDoor1());
|
||||
this.door2 = new StorageTrainDoor(train.getDoor2());
|
||||
this.fk = train.getFk();
|
||||
this.fb = train.getFb();
|
||||
this.tbControl = train.getTbControl();
|
||||
this.leverPosition = train.getLeverPosition();
|
||||
this.fault = train.getFault();
|
||||
this.backUp = train.isBackUp();
|
||||
this.delayTime = train.getDelayTime();
|
||||
this.powerOn = train.isPowerOn();
|
||||
this.pantograph1Up = train.isPantograph1Up();
|
||||
this.pantograph2Up = train.isPantograph2Up();
|
||||
if (train.getLinkTrain() != null) {
|
||||
this.linkTrainGroupNumber = train.getLinkTrain().getGroupNumber();
|
||||
}
|
||||
// 20220721修改为保存应答器Code
|
||||
this.lastTwoPassedResponders = train.getLastTwoPassedResponders().stream().map(Responder::getCode).collect(Collectors.toList());
|
||||
this.driveParam = new StorageDriveParam(train.getRobotDriveParam());
|
||||
if (train.getParkSection() != null) {
|
||||
this.parkSection = train.getParkSection().getCode();
|
||||
}
|
||||
public StorageVirtualRealityTrain(VirtualRealityTrain virtualRealityTrain) {
|
||||
super(virtualRealityTrain);
|
||||
groupNumber = virtualRealityTrain.getGroupNumber();
|
||||
}
|
||||
|
||||
public static StorageVirtualRealityTrain convert2Storage(VirtualRealityTrain vrTrain) {
|
||||
return new StorageVirtualRealityTrain(vrTrain);
|
||||
public static StorageVirtualRealityTrain convert2Storage(VirtualRealityTrain virtualRealityTrain) {
|
||||
StorageVirtualRealityTrain storageVirtualRealityTrain = new StorageVirtualRealityTrain(virtualRealityTrain);
|
||||
storageVirtualRealityTrain.setNoCommunicateDevice(virtualRealityTrain.isNoCommunicateDevice());
|
||||
storageVirtualRealityTrain.setCommunication(virtualRealityTrain.isCommunication());
|
||||
storageVirtualRealityTrain.setRunLevel(virtualRealityTrain.getRunLevel());
|
||||
storageVirtualRealityTrain.setDriveMode(virtualRealityTrain.getDriveMode());
|
||||
storageVirtualRealityTrain.setTempPreselectionMode(virtualRealityTrain.getTempPreselectionMode());
|
||||
storageVirtualRealityTrain.setPreselectionMode(virtualRealityTrain.getPreselectionMode());
|
||||
storageVirtualRealityTrain.setServiceNumber(virtualRealityTrain.getServiceNumber());
|
||||
storageVirtualRealityTrain.setTripNumber(virtualRealityTrain.getTripNumber());
|
||||
storageVirtualRealityTrain.setDestinationCode(virtualRealityTrain.getDestinationCode());
|
||||
if (virtualRealityTrain.getNextStation() != null) {
|
||||
storageVirtualRealityTrain.setNextStationCode(virtualRealityTrain.getNextStation().getCode());
|
||||
}
|
||||
storageVirtualRealityTrain.setBeAbout2Arrive(virtualRealityTrain.isBeAbout2Arrive());
|
||||
if (virtualRealityTrain.getTarget() != null) {
|
||||
storageVirtualRealityTrain.setTargetCode(virtualRealityTrain.getTarget().getCode());
|
||||
}
|
||||
storageVirtualRealityTrain.setParkTime(virtualRealityTrain.getParkTime());
|
||||
storageVirtualRealityTrain.setParkRemainTime(virtualRealityTrain.getParkRemainTime());
|
||||
if (virtualRealityTrain.getParkSection() != null) {
|
||||
storageVirtualRealityTrain.setParkSectionCode(virtualRealityTrain.getParkSection().getCode());
|
||||
}
|
||||
storageVirtualRealityTrain.setDeparture(virtualRealityTrain.isDeparture());
|
||||
storageVirtualRealityTrain.setBreaking(virtualRealityTrain.isBreaking());
|
||||
if (virtualRealityTrain.getTerminalStation() != null) {
|
||||
storageVirtualRealityTrain.setTerminalStationCode(virtualRealityTrain.getTerminalStation().getCode());
|
||||
}
|
||||
if (virtualRealityTrain.getHeadPosition() != null) {
|
||||
storageVirtualRealityTrain.setHeadPosition(new StorageSectionPosition(virtualRealityTrain.getHeadPosition()));
|
||||
}
|
||||
if (virtualRealityTrain.getTailPosition() != null) {
|
||||
storageVirtualRealityTrain.setTailPosition(new StorageSectionPosition(virtualRealityTrain.getTailPosition()));
|
||||
}
|
||||
storageVirtualRealityTrain.setRight(virtualRealityTrain.isRight());
|
||||
if (virtualRealityTrain.getMa() != null) {
|
||||
storageVirtualRealityTrain.setMa(new StorageMovementAuthority(virtualRealityTrain.getMa()));
|
||||
}
|
||||
if (virtualRealityTrain.getMa2() != null) {
|
||||
storageVirtualRealityTrain.setMa2(new StorageMa(virtualRealityTrain.getMa2()));
|
||||
}
|
||||
storageVirtualRealityTrain.setCbtcMaMissDuration(virtualRealityTrain.getCbtcMaMissDuration());
|
||||
storageVirtualRealityTrain.setGear(virtualRealityTrain.getGear());
|
||||
storageVirtualRealityTrain.setSpeed(virtualRealityTrain.getSpeed());
|
||||
storageVirtualRealityTrain.setLocationKM(virtualRealityTrain.getLocationKM());
|
||||
storageVirtualRealityTrain.setTargetDistance(virtualRealityTrain.getTargetDistance());
|
||||
storageVirtualRealityTrain.setAtoSpeedMax(virtualRealityTrain.getAtoSpeedMax());
|
||||
storageVirtualRealityTrain.setAtoSpeed(virtualRealityTrain.getAtoSpeed());
|
||||
storageVirtualRealityTrain.setAtpSpeed(virtualRealityTrain.getAtpSpeed());
|
||||
storageVirtualRealityTrain.setSignalEB(virtualRealityTrain.isSignalEB());
|
||||
storageVirtualRealityTrain.setCircuitEB(virtualRealityTrain.isCircuitEB());
|
||||
storageVirtualRealityTrain.setStandParkedTrainActivity(virtualRealityTrain.getStandParkedTrainActivity());
|
||||
storageVirtualRealityTrain.setNextParking(virtualRealityTrain.isNextParking());
|
||||
storageVirtualRealityTrain.setJump(virtualRealityTrain.isJump());
|
||||
storageVirtualRealityTrain.setHold(virtualRealityTrain.isHold());
|
||||
storageVirtualRealityTrain.setTrainHold(virtualRealityTrain.isTrainHold());
|
||||
storageVirtualRealityTrain.setDtro(virtualRealityTrain.isDtro());
|
||||
storageVirtualRealityTrain.setChangeEnds(virtualRealityTrain.isChangeEnds());
|
||||
storageVirtualRealityTrain.setChangeEndsRemainTime(virtualRealityTrain.getChangeEndsRemainTime());
|
||||
storageVirtualRealityTrain.setAtoOn(virtualRealityTrain.isAtoOn());
|
||||
storageVirtualRealityTrain.setAtpOn(virtualRealityTrain.isAtpOn());
|
||||
storageVirtualRealityTrain.setPriorityRouteSet(virtualRealityTrain.isPriorityRouteSet());
|
||||
if (virtualRealityTrain.getDoor1() != null) {
|
||||
storageVirtualRealityTrain.setDoor1(new StorageDoor(virtualRealityTrain.getDoor1()));
|
||||
}
|
||||
if (virtualRealityTrain.getDoor2() != null) {
|
||||
storageVirtualRealityTrain.setDoor2(new StorageDoor(virtualRealityTrain.getDoor2()));
|
||||
}
|
||||
storageVirtualRealityTrain.setDoorMode(virtualRealityTrain.getDoorMode());
|
||||
storageVirtualRealityTrain.setDoorSelection(virtualRealityTrain.getDoorSelection());
|
||||
storageVirtualRealityTrain.setFk(virtualRealityTrain.getFk());
|
||||
storageVirtualRealityTrain.setFb(virtualRealityTrain.getFb());
|
||||
storageVirtualRealityTrain.setTbControl(virtualRealityTrain.getTbControl());
|
||||
storageVirtualRealityTrain.setLeverPosition(virtualRealityTrain.getLeverPosition());
|
||||
storageVirtualRealityTrain.setFault(virtualRealityTrain.getFault());
|
||||
storageVirtualRealityTrain.setBackUp(virtualRealityTrain.isBackUp());
|
||||
storageVirtualRealityTrain.setDelayTime(virtualRealityTrain.getDelayTime());
|
||||
storageVirtualRealityTrain.setPowerOn(virtualRealityTrain.isPowerOn());
|
||||
storageVirtualRealityTrain.setPantograph1Up(virtualRealityTrain.isPantograph1Up());
|
||||
storageVirtualRealityTrain.setPantograph2Up(virtualRealityTrain.isPantograph2Up());
|
||||
if (virtualRealityTrain.getLinkTrain() != null) {
|
||||
storageVirtualRealityTrain.setLinkTrainCode(virtualRealityTrain.getLinkTrain().getCode());
|
||||
}
|
||||
storageVirtualRealityTrain.setRunType(virtualRealityTrain.getRunType());
|
||||
storageVirtualRealityTrain.setOrderStop(virtualRealityTrain.isOrderStop());
|
||||
storageVirtualRealityTrain.setNeedDepartureCommand(virtualRealityTrain.isNeedDepartureCommand());
|
||||
storageVirtualRealityTrain.setPositioned(virtualRealityTrain.isPositioned());
|
||||
storageVirtualRealityTrain.setRunningTime(virtualRealityTrain.getRunningTime());
|
||||
storageVirtualRealityTrain.setReleased(virtualRealityTrain.isReleased());
|
||||
storageVirtualRealityTrain.setConfirmationMessages(virtualRealityTrain.getConfirmationMessages());
|
||||
storageVirtualRealityTrain.setAtoCanOpen(virtualRealityTrain.isAtoCanOpen());
|
||||
// if (virtualRealityTrain.getVrAudio() != null) {
|
||||
// storageVirtualRealityTrain.setVrAudioCode(virtualRealityTrain.getVrAudio().getCode());
|
||||
// }
|
||||
if (virtualRealityTrain.getRobotDriveParam() != null) {
|
||||
storageVirtualRealityTrain.setRobotDriveParam(new StorageDriveParamVO(virtualRealityTrain.getRobotDriveParam()));
|
||||
}
|
||||
return storageVirtualRealityTrain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recover2Simulation(VirtualRealityDevice vrDevice, SimulationDataRepository repository) {
|
||||
VirtualRealityTrain train = (VirtualRealityTrain) vrDevice;
|
||||
train.setRunLevel(runLevel);
|
||||
train.setDriveMode(driveMode);
|
||||
train.setTempPreselectionMode(tempPreselectionMode);
|
||||
train.setPreselectionMode(preselectionMode);
|
||||
train.setServiceNumber(serviceNumber);
|
||||
train.setTripNumber(tripNumber);
|
||||
train.setDestinationCode(destinationCode);
|
||||
Section targetSection;
|
||||
if (Objects.nonNull(this.targetSectionCode)) {
|
||||
targetSection = repository.getByCode(this.targetSectionCode, Section.class);
|
||||
train.setTarget(targetSection);
|
||||
}
|
||||
Station nextStation;
|
||||
if (Objects.nonNull(this.nextStationCode)) {
|
||||
nextStation = repository.getByCode(nextStationCode, Station.class);
|
||||
train.setNextStation(nextStation);
|
||||
}
|
||||
train.setBeAbout2Arrive(beAbout2Arrive);
|
||||
train.setNextParking(nextParking);
|
||||
train.setStandParkedTrainActivity(this.standParkedTrainActivity);
|
||||
train.setJump(jump);
|
||||
train.setHold(hold);
|
||||
train.setParkTime(parkTime);
|
||||
train.setParkRemainTime(parkRemainTime);
|
||||
train.setDeparture(departure);
|
||||
train.setBreaking(breaking);
|
||||
if (terminalStationCode != null) {
|
||||
train.setTerminalStation(repository.getByCode(terminalStationCode, Station.class));
|
||||
}
|
||||
if (headPosition != null) {
|
||||
train.setHeadPosition(headPosition.convert2SimulationObj(repository));
|
||||
}
|
||||
train.setRight(right);
|
||||
if (robotTargetPosition != null) {
|
||||
train.setRobotTargetPosition(robotTargetPosition.convert2SimulationObj(repository));
|
||||
}
|
||||
if (ma != null) {
|
||||
train.setMa(ma.convert2SimulationObj(repository));
|
||||
}
|
||||
train.setCbtcMaMissDuration(cbtcMaMissDuration);
|
||||
train.setGear(this.gear == null ? VirtualRealityTrain.Handwheel.ATO : this.gear);
|
||||
train.setSpeed(speed);
|
||||
train.setTargetDistance(targetDistance);
|
||||
train.setAtoSpeedMax(atoSpeedMax);
|
||||
train.setAtoSpeed(atoSpeed);
|
||||
train.setAtpSpeed(atpSpeed);
|
||||
train.setSpeedLimit(speedLimit);
|
||||
train.setSignalEB(signalEB);
|
||||
train.setCircuitEB(circuitEB);
|
||||
train.setDtro(dtro);
|
||||
train.setChangeEnds(changeEnds);
|
||||
train.setChangeEndsRemainTime(changeEndsRemainTime);
|
||||
train.setAtoOn(atoOn);
|
||||
train.setAtpOn(atpOn);
|
||||
train.setPriorityRouteSet(priorityRouteSet);
|
||||
if (door1 != null) {
|
||||
door1.recover2Simulation(train.getDoor1());
|
||||
}
|
||||
if (door2 != null) {
|
||||
door2.recover2Simulation(train.getDoor2());
|
||||
}
|
||||
train.setFk(fk);
|
||||
train.setFb(fb);
|
||||
train.setTbControl(tbControl);
|
||||
train.setLeverPosition(leverPosition);
|
||||
train.setFault(this.fault);
|
||||
train.setBackUp(backUp);
|
||||
train.setDelayTime(delayTime);
|
||||
train.setPowerOn(powerOn);
|
||||
train.setPantograph1Up(pantograph1Up);
|
||||
train.setPantograph2Up(pantograph2Up);
|
||||
if (linkTrainGroupNumber != null) {
|
||||
train.setLinkTrain(repository.getVRByCode(linkTrainGroupNumber, VirtualRealityTrain.class));
|
||||
}
|
||||
// 这里原本反序列化注释,后续再做处理
|
||||
if (!CollectionUtils.isEmpty(lastTwoPassedResponders)) {
|
||||
// train.setLastTwoPassedResponders(lastTwoPassedResponders);
|
||||
}
|
||||
if (driveParam != null) {
|
||||
train.setRobotDriveParam(convert2DriveParam(driveParam, repository));
|
||||
}
|
||||
if (parkSection != null) {
|
||||
train.setParkSection(repository.getByCode(parkSection, Section.class));
|
||||
}
|
||||
public boolean convert(MapElement element) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private DriveParamVO convert2DriveParam(StorageDriveParam storageDriveParam, SimulationDataRepository repository) {
|
||||
DriveParamVO param = new DriveParamVO();
|
||||
param.setSpeedLimit(storageDriveParam.getSpeedLimit());
|
||||
param.setRun(storageDriveParam.isRun());
|
||||
param.setTargetDeviceCode(storageDriveParam.getTargetDeviceCode());
|
||||
if (storageDriveParam.getTargetPosition() != null) {
|
||||
param.setTargetPosition(storageDriveParam.getTargetPosition().convert2SimulationObj(repository));
|
||||
@Override
|
||||
public void recover2Simulation(MapElement element, Simulation simulation, SimulationDataRepository repository) {
|
||||
VirtualRealityTrain virtualRealityTrain = (VirtualRealityTrain) element;
|
||||
virtualRealityTrain.setNoCommunicateDevice(noCommunicateDevice);
|
||||
virtualRealityTrain.setCommunication(communication);
|
||||
virtualRealityTrain.setRunLevel(runLevel);
|
||||
virtualRealityTrain.setDriveMode(driveMode);
|
||||
virtualRealityTrain.setTempPreselectionMode(tempPreselectionMode);
|
||||
virtualRealityTrain.setPreselectionMode(preselectionMode);
|
||||
virtualRealityTrain.setServiceNumber(serviceNumber);
|
||||
virtualRealityTrain.setTripNumber(tripNumber);
|
||||
virtualRealityTrain.setDestinationCode(destinationCode);
|
||||
if (nextStationCode != null) {
|
||||
virtualRealityTrain.setNextStation(repository.getByCode(nextStationCode, Station.class));
|
||||
}
|
||||
param.setThrough(storageDriveParam.getThrough());
|
||||
if (storageDriveParam.getThroughSignal() != null) {
|
||||
param.setThroughSignal(repository.getByCode(storageDriveParam.getThroughSignal(), Signal.class));
|
||||
virtualRealityTrain.setBeAbout2Arrive(beAbout2Arrive);
|
||||
if (targetCode != null) {
|
||||
virtualRealityTrain.setTarget(repository.getByCode(targetCode, Section.class));
|
||||
}
|
||||
virtualRealityTrain.setParkTime(parkTime);
|
||||
virtualRealityTrain.setParkRemainTime(parkRemainTime);
|
||||
if (parkSectionCode != null) {
|
||||
virtualRealityTrain.setParkSection(repository.getByCode(parkSectionCode, Section.class));
|
||||
}
|
||||
virtualRealityTrain.setDeparture(departure);
|
||||
virtualRealityTrain.setBreaking(breaking);
|
||||
if (terminalStationCode != null) {
|
||||
virtualRealityTrain.setTerminalStation(repository.getByCode(terminalStationCode, Station.class));
|
||||
}
|
||||
if (headPosition != null) {
|
||||
virtualRealityTrain.setHeadPosition(headPosition.convert2SimulationObj(repository));
|
||||
}
|
||||
if (tailPosition != null) {
|
||||
virtualRealityTrain.setTailPosition(tailPosition.convert2SimulationObj(repository));
|
||||
}
|
||||
virtualRealityTrain.setRight(right);
|
||||
if (ma != null) {
|
||||
virtualRealityTrain.setMa(ma.convert2SimulationObj(repository));
|
||||
}
|
||||
if (ma2 != null) {
|
||||
virtualRealityTrain.setMa2(ma2.convert2SimulationObj(repository));
|
||||
}
|
||||
virtualRealityTrain.setCbtcMaMissDuration(cbtcMaMissDuration);
|
||||
virtualRealityTrain.setGear(gear);
|
||||
virtualRealityTrain.setSpeed(speed);
|
||||
virtualRealityTrain.setLocationKM(locationKM);
|
||||
virtualRealityTrain.setTargetDistance(targetDistance);
|
||||
virtualRealityTrain.setAtoSpeedMax(atoSpeedMax);
|
||||
virtualRealityTrain.setAtoSpeed(atoSpeed);
|
||||
virtualRealityTrain.setAtpSpeed(atpSpeed);
|
||||
virtualRealityTrain.setSignalEB(signalEB);
|
||||
virtualRealityTrain.setCircuitEB(circuitEB);
|
||||
virtualRealityTrain.setStandParkedTrainActivity(standParkedTrainActivity);
|
||||
virtualRealityTrain.setNextParking(nextParking);
|
||||
virtualRealityTrain.setJump(jump);
|
||||
virtualRealityTrain.setHold(hold);
|
||||
virtualRealityTrain.setTrainHold(trainHold);
|
||||
virtualRealityTrain.setDtro(dtro);
|
||||
virtualRealityTrain.setChangeEnds(changeEnds);
|
||||
virtualRealityTrain.setChangeEndsRemainTime(changeEndsRemainTime);
|
||||
virtualRealityTrain.setAtoOn(atoOn);
|
||||
virtualRealityTrain.setAtpOn(atpOn);
|
||||
virtualRealityTrain.setPriorityRouteSet(priorityRouteSet);
|
||||
if (door1 != null) {
|
||||
door1.recover2Simulation(virtualRealityTrain.getDoor1());
|
||||
}
|
||||
if (door2 != null) {
|
||||
door2.recover2Simulation(virtualRealityTrain.getDoor2());
|
||||
}
|
||||
virtualRealityTrain.setDoorMode(doorMode);
|
||||
virtualRealityTrain.setDoorSelection(doorSelection);
|
||||
virtualRealityTrain.setFk(fk);
|
||||
virtualRealityTrain.setFb(fb);
|
||||
virtualRealityTrain.setTbControl(tbControl);
|
||||
virtualRealityTrain.setLeverPosition(leverPosition);
|
||||
virtualRealityTrain.setFault(fault);
|
||||
virtualRealityTrain.setBackUp(backUp);
|
||||
virtualRealityTrain.setDelayTime(delayTime);
|
||||
virtualRealityTrain.setPowerOn(powerOn);
|
||||
virtualRealityTrain.setPantograph1Up(pantograph1Up);
|
||||
virtualRealityTrain.setPantograph2Up(pantograph2Up);
|
||||
if (linkTrainCode != null) {
|
||||
virtualRealityTrain.setLinkTrain(repository.getByCode(linkTrainCode, VirtualRealityTrain.class));
|
||||
}
|
||||
virtualRealityTrain.setRunType(runType);
|
||||
virtualRealityTrain.setOrderStop(orderStop);
|
||||
virtualRealityTrain.setNeedDepartureCommand(needDepartureCommand);
|
||||
virtualRealityTrain.setPositioned(positioned);
|
||||
virtualRealityTrain.setRunningTime(runningTime);
|
||||
virtualRealityTrain.setReleased(released);
|
||||
if (!CollectionUtils.isEmpty(confirmationMessages)) {
|
||||
confirmationMessages.forEach(virtualRealityTrain::addMessage);
|
||||
}
|
||||
virtualRealityTrain.setAtoCanOpen(atoCanOpen);
|
||||
// if (vrAudioCode != null) {
|
||||
// virtualRealityTrain.setVrAudio(repository.getByCode(vrAudioCode, VirtualRealityAudio.class));
|
||||
// }
|
||||
if (robotDriveParam != null) {
|
||||
virtualRealityTrain.setRobotDriveParam(robotDriveParam.convert2SimulationObj(repository));
|
||||
}
|
||||
param.setThroughSignalAspect(storageDriveParam.getThroughSignalAspect());
|
||||
param.setReleaseEB(storageDriveParam.isReleaseEB());
|
||||
return param;
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import club.joylink.rtss.simulation.cbtc.constant.TrainTBControl;
|
||||
import club.joylink.rtss.simulation.cbtc.data.CalculateService;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.*;
|
||||
import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan;
|
||||
import club.joylink.rtss.simulation.cbtc.data.support.FixedQueue;
|
||||
import club.joylink.rtss.simulation.cbtc.data.support.MovementAuthority;
|
||||
import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
|
||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
|
||||
@ -20,7 +19,10 @@ import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 虚拟真实列车
|
||||
@ -407,11 +409,6 @@ public class VirtualRealityTrain extends VirtualRealityDevice {
|
||||
*/
|
||||
private VirtualRealityTrain linkTrain;
|
||||
|
||||
/**
|
||||
* 最近经过的两个应答器
|
||||
*/
|
||||
private Queue<Responder> lastTwoPassedResponders = new FixedQueue<>(Responders_Record);
|
||||
|
||||
/**
|
||||
* 运行类型
|
||||
*/
|
||||
@ -453,7 +450,7 @@ public class VirtualRealityTrain extends VirtualRealityDevice {
|
||||
*/
|
||||
private boolean atoCanOpen;
|
||||
|
||||
private VirtualRealityAudio vrAudio;
|
||||
// private VirtualRealityAudio vrAudio;
|
||||
|
||||
private DriveParamVO robotDriveParam = new DriveParamVO();
|
||||
|
||||
@ -469,22 +466,24 @@ public class VirtualRealityTrain extends VirtualRealityDevice {
|
||||
|
||||
public void setRunType(RunType runType) {
|
||||
this.runType = runType;
|
||||
switch (runType) {
|
||||
case ENERGY_CONSERVATION:
|
||||
this.atoSpeedMax = this.atpSpeedMax * 0.2f * 0.9f;
|
||||
break;
|
||||
case MIDDLE_TWO:
|
||||
this.atoSpeedMax = this.atpSpeedMax * 0.4f * 0.9f;
|
||||
break;
|
||||
case MIDDLE_ONE:
|
||||
this.atoSpeedMax = this.atpSpeedMax * 0.6f * 0.9f;
|
||||
break;
|
||||
case NORMAL:
|
||||
this.atoSpeedMax = this.atpSpeedMax * 0.8f * 0.9f;
|
||||
break;
|
||||
case ACCELERATE:
|
||||
this.atoSpeedMax = this.atpSpeedMax * 0.9f;
|
||||
break;
|
||||
if (runType != null) {
|
||||
switch (runType) {
|
||||
case ENERGY_CONSERVATION:
|
||||
this.atoSpeedMax = this.atpSpeedMax * 0.2f * 0.9f;
|
||||
break;
|
||||
case MIDDLE_TWO:
|
||||
this.atoSpeedMax = this.atpSpeedMax * 0.4f * 0.9f;
|
||||
break;
|
||||
case MIDDLE_ONE:
|
||||
this.atoSpeedMax = this.atpSpeedMax * 0.6f * 0.9f;
|
||||
break;
|
||||
case NORMAL:
|
||||
this.atoSpeedMax = this.atpSpeedMax * 0.8f * 0.9f;
|
||||
break;
|
||||
case ACCELERATE:
|
||||
this.atoSpeedMax = this.atpSpeedMax * 0.9f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -522,8 +521,8 @@ public class VirtualRealityTrain extends VirtualRealityDevice {
|
||||
this.preselectionMode = PreselectionMode.AM_C;
|
||||
this.doorSelection = DoorSelection.Z;
|
||||
this.confirmationMessages.clear();
|
||||
String audioCode = groupNumber + "_audio";
|
||||
this.vrAudio = new VirtualRealityAudio(audioCode, audioCode);
|
||||
// String audioCode = groupNumber + "_audio";
|
||||
// this.vrAudio = new VirtualRealityAudio(audioCode, audioCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -572,13 +571,11 @@ public class VirtualRealityTrain extends VirtualRealityDevice {
|
||||
this.fb = 0;
|
||||
this.tbControl = null;
|
||||
this.leverPosition = 0;
|
||||
this.fault = null;
|
||||
this.delayTime = 0;
|
||||
this.powerOn = true;
|
||||
this.pantograph1Up = true;
|
||||
this.pantograph2Up = true;
|
||||
this.linkTrain = null;
|
||||
this.lastTwoPassedResponders = new FixedQueue<>(Responders_Record);
|
||||
this.runType = null;
|
||||
this.orderStop = false;
|
||||
this.needDepartureCommand = false;
|
||||
@ -1225,29 +1222,6 @@ public class VirtualRealityTrain extends VirtualRealityDevice {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean passedResponder() {
|
||||
return !lastTwoPassedResponders.isEmpty();
|
||||
}
|
||||
|
||||
public void viaResponder(Responder responder) {
|
||||
if (lastTwoPassedResponders.isEmpty()) {
|
||||
lastTwoPassedResponders.offer(responder);
|
||||
return;
|
||||
}
|
||||
lastTwoPassedResponders.remove(responder);
|
||||
lastTwoPassedResponders.offer(responder);
|
||||
if (!this.positioned && lastTwoPassedResponders.size() >= 2) {
|
||||
this.positioned = true;
|
||||
}
|
||||
// if (lastTwoPassedResponders.stream().allMatch(Responder::isLocalizable)) {
|
||||
// this.positioned = true;
|
||||
// }
|
||||
}
|
||||
|
||||
public void clearResponders() {
|
||||
lastTwoPassedResponders.clear();
|
||||
}
|
||||
|
||||
public boolean isCommunicable() {
|
||||
Section section = headPosition.getSection();
|
||||
return communication && section.anyZcWorking();
|
||||
|
@ -185,11 +185,11 @@ public class MetroSimulationWorkServiceImpl implements SimulationWorkService {
|
||||
atsLogicLoop.addJobs(simulation);
|
||||
simulationRobotService.addJobs(simulation);
|
||||
vrTrainRunningService.addJobs(simulation);
|
||||
ciLogic.addJobs(simulation);
|
||||
vrDeviceLogicLoop.addJobs(simulation);
|
||||
atsMessageCollectAndDispatcher.addJobs(simulation);
|
||||
ciLogic.addJobs(simulation);
|
||||
joylink3DMessageService.addJobs(simulation);
|
||||
faultGenerator.addJobs(simulation);
|
||||
atsMessageCollectAndDispatcher.addJobs(simulation);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
243
src/main/java/club/joylink/rtss/util/StorageGenerateUtil.java
Normal file
243
src/main/java/club/joylink/rtss/util/StorageGenerateUtil.java
Normal file
@ -0,0 +1,243 @@
|
||||
package club.joylink.rtss.util;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
|
||||
import club.joylink.rtss.simulation.cbtc.data.storage.device.StorageDevice;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class StorageGenerateUtil {
|
||||
public static void main(String[] args) throws ClassNotFoundException, NoSuchFieldException {
|
||||
generate(VirtualRealityTrain.class, "club.joylink.rtss.simulation.cbtc.data.storage.vr", "noCommunicateDevice");
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成Storage类文件
|
||||
*
|
||||
* @param aClass 要生成文件的类
|
||||
* @param packageName 生成的文件要放入的包
|
||||
* @param startFieldName 从这个字段开始是要存的字段
|
||||
*/
|
||||
public static void generate(Class<?> aClass, String packageName, String startFieldName) {
|
||||
String sourceClassName = aClass.getSimpleName();
|
||||
String targetClassName = String.format("Storage%s", sourceClassName);
|
||||
File file = new File(String.format("./src/main/java/%s/%s", packageName.replace(".", "/"), targetClassName + ".java"));
|
||||
FileWriter fileWriter;
|
||||
try {
|
||||
fileWriter = new FileWriter(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException();
|
||||
}
|
||||
try {
|
||||
Field[] declaredFields = aClass.getDeclaredFields();
|
||||
List<Field> fieldList = new ArrayList<>(Arrays.asList(declaredFields));
|
||||
for (Iterator<Field> iterator = fieldList.iterator(); iterator.hasNext(); ) { //删除所有不需要保存的字段
|
||||
Field field = iterator.next();
|
||||
if (field.getName().equals(startFieldName)) {
|
||||
break;
|
||||
}
|
||||
iterator.remove();
|
||||
}
|
||||
|
||||
List<String> importStrList = new ArrayList<>();
|
||||
List<String> fieldStrList = new ArrayList<>();
|
||||
List<String> convert2StorageMethodStrList = new ArrayList<>();
|
||||
List<String> recover2SimulationMethodStrList = new ArrayList<>();
|
||||
|
||||
String lowercaseSourceClassName = lowercaseInitial(sourceClassName);
|
||||
//convert2Storage方法开头
|
||||
convert2StorageMethodStrList.add(String.format("public static %s convert2Storage(%s %s) {", targetClassName, sourceClassName, lowercaseSourceClassName));
|
||||
String storageObjectName = lowercaseInitial(targetClassName);
|
||||
convert2StorageMethodStrList.add(String.format("%s %s = new %s(%s);", targetClassName, storageObjectName, targetClassName, lowercaseSourceClassName));
|
||||
//recover2Simulation方法开头
|
||||
String element = "element";
|
||||
String repository = "repository";
|
||||
recover2SimulationMethodStrList.add("@Override");
|
||||
recover2SimulationMethodStrList.add("public void recover2Simulation(MapElement element, Simulation simulation, SimulationDataRepository repository) {");
|
||||
recover2SimulationMethodStrList.add(String.format("%s %s = (%s) %s;", sourceClassName, lowercaseSourceClassName, sourceClassName, element));
|
||||
|
||||
|
||||
for (Field declaredField : fieldList) {
|
||||
Class<?> fieldType = declaredField.getType();
|
||||
String fieldClassSimpleName = fieldType.getSimpleName();
|
||||
String sourceFieldName = declaredField.getName(); //源文件字段名
|
||||
String uppercaseSourceFieldName = uppercaseInitial(sourceFieldName);
|
||||
|
||||
Type genericType = declaredField.getGenericType();
|
||||
List<Class<Object>> genericClassList;
|
||||
if (genericType instanceof ParameterizedType) {
|
||||
ParameterizedType parameterizedType = (ParameterizedType) genericType;
|
||||
genericClassList = Stream.of(parameterizedType.getActualTypeArguments())
|
||||
.map(ata -> {
|
||||
Class<Object> cls = (Class<Object>) ata;
|
||||
importStrList.add(String.format("import %s;", cls.getName()).replace("$", "."));
|
||||
return cls;
|
||||
}).collect(Collectors.toList());
|
||||
} else {
|
||||
genericClassList = null;
|
||||
}
|
||||
|
||||
if (fieldType.isPrimitive()) { //基础类型
|
||||
fieldStrList.add(String.format("private %s %s;", fieldClassSimpleName, sourceFieldName));
|
||||
|
||||
if (fieldType.equals(boolean.class)) {
|
||||
convert2StorageMethodStrList.add(String.format("%s.set%s(%s.is%s());", storageObjectName, uppercaseSourceFieldName, lowercaseSourceClassName, uppercaseSourceFieldName));
|
||||
} else {
|
||||
convert2StorageMethodStrList.add(String.format("%s.set%s(%s.get%s());", storageObjectName, uppercaseSourceFieldName, lowercaseSourceClassName, uppercaseSourceFieldName));
|
||||
}
|
||||
|
||||
recover2SimulationMethodStrList.add(String.format("%s.set%s(%s);", lowercaseSourceClassName, uppercaseSourceFieldName, sourceFieldName));
|
||||
|
||||
} else if (fieldType.isEnum()) { //枚举
|
||||
importStrList.add(String.format("import %s;", fieldType.getName()).replace("$", "."));
|
||||
fieldStrList.add(String.format("private %s %s;", fieldClassSimpleName, sourceFieldName));
|
||||
|
||||
convert2StorageMethodStrList.add(String.format("%s.set%s(%s.get%s());", storageObjectName, uppercaseSourceFieldName, lowercaseSourceClassName, uppercaseSourceFieldName));
|
||||
|
||||
recover2SimulationMethodStrList.add(String.format("%s.set%s(%s);", lowercaseSourceClassName, uppercaseSourceFieldName, sourceFieldName));
|
||||
} else if (fieldType.getPackageName().startsWith("java.lang")) { //包装类
|
||||
fieldStrList.add(String.format("private %s %s;", fieldClassSimpleName, sourceFieldName));
|
||||
|
||||
convert2StorageMethodStrList.add(String.format("%s.set%s(%s.get%s());", storageObjectName, uppercaseSourceFieldName, lowercaseSourceClassName, uppercaseSourceFieldName));
|
||||
|
||||
recover2SimulationMethodStrList.add(String.format("%s.set%s(%s);", lowercaseSourceClassName, uppercaseSourceFieldName, sourceFieldName));
|
||||
} else if (fieldType.getPackageName().startsWith("club.joylink")){ //自定义类
|
||||
importStrList.add(String.format("import %s;", fieldType.getName()).replace("$", "."));
|
||||
if (MapElement.class.isAssignableFrom(fieldType)) { //地图元素
|
||||
String targetFieldName = sourceFieldName + "Code"; //目标文件字段名
|
||||
fieldStrList.add(String.format("private String %s;", targetFieldName));
|
||||
|
||||
convert2StorageMethodStrList.add(String.format("if (%s.get%s() != null) {", lowercaseSourceClassName, uppercaseInitial(sourceFieldName)));
|
||||
convert2StorageMethodStrList.add(String.format("%s.set%s(%s.get%s().getCode());", storageObjectName,
|
||||
uppercaseInitial(targetFieldName), lowercaseSourceClassName, uppercaseInitial(sourceFieldName)));
|
||||
convert2StorageMethodStrList.add("}");
|
||||
|
||||
recover2SimulationMethodStrList.add(String.format("if (%s != null) {", targetFieldName));
|
||||
recover2SimulationMethodStrList.add(String.format("%s.set%s(%s.getByCode(%s, %s));", lowercaseSourceClassName, uppercaseSourceFieldName, repository,
|
||||
targetFieldName, fieldClassSimpleName + ".class"));
|
||||
recover2SimulationMethodStrList.add("}");
|
||||
} else {
|
||||
String storageFieldClassName = String.format("Storage%s", fieldClassSimpleName);
|
||||
try {
|
||||
Class<?> storageField = Class.forName("club.joylink.rtss.simulation.cbtc.data.storage.support." + storageFieldClassName);
|
||||
importStrList.add(String.format("import %s;", storageField.getName()));
|
||||
fieldStrList.add(String.format("private %s %s;", storageFieldClassName, sourceFieldName));
|
||||
|
||||
convert2StorageMethodStrList.add(String.format("if (%s.get%s() != null) {", lowercaseSourceClassName, uppercaseSourceFieldName));
|
||||
convert2StorageMethodStrList.add(String.format("%s.set%s(new %s(%s.get%s()));", storageObjectName, uppercaseSourceFieldName,
|
||||
storageFieldClassName, lowercaseSourceClassName, uppercaseSourceFieldName));
|
||||
convert2StorageMethodStrList.add("}");
|
||||
|
||||
recover2SimulationMethodStrList.add(String.format("if (%s != null) {", sourceFieldName));
|
||||
recover2SimulationMethodStrList.add(String.format("%s.set%s(%s.convert2SimulationObj(%s));", lowercaseSourceClassName, uppercaseSourceFieldName,
|
||||
sourceFieldName, repository));
|
||||
recover2SimulationMethodStrList.add("}");
|
||||
} catch (ClassNotFoundException e) {
|
||||
System.out.printf("缺少%s%n", storageFieldClassName);
|
||||
}
|
||||
}
|
||||
} else { //其它
|
||||
importStrList.add(String.format("import %s;", fieldType.getName()).replace("$", "."));
|
||||
if (CollectionUtils.isEmpty(genericClassList)) {
|
||||
fieldStrList.add(String.format("private %s %s;", fieldClassSimpleName, sourceFieldName));
|
||||
} else {
|
||||
String genericClassSimpleNames = genericClassList.stream().map(Class::getSimpleName).collect(Collectors.joining(","));
|
||||
fieldStrList.add(String.format("private %s<%s> %s;", fieldClassSimpleName, genericClassSimpleNames, sourceFieldName));
|
||||
}
|
||||
|
||||
String uppercaseFieldName = uppercaseInitial(sourceFieldName);
|
||||
convert2StorageMethodStrList.add(String.format("%s.set%s(%s.get%s());", storageObjectName, uppercaseFieldName, lowercaseSourceClassName, uppercaseFieldName));
|
||||
|
||||
recover2SimulationMethodStrList.add(String.format("%s.set%s(%s);", lowercaseSourceClassName, uppercaseSourceFieldName, sourceFieldName));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//package
|
||||
writeLine(fileWriter, String.format("package %s;", packageName));
|
||||
//import父类
|
||||
writeLine(fileWriter, String.format("import %s;", StorageDevice.class.getName()));
|
||||
//import注解
|
||||
writeLine(fileWriter, String.format("import %s;", Getter.class.getName()));
|
||||
writeLine(fileWriter, String.format("import %s;", Setter.class.getName()));
|
||||
writeLine(fileWriter, String.format("import %s;", NoArgsConstructor.class.getName()));
|
||||
//import recover2Simulation方法参数类型
|
||||
writeLine(fileWriter, String.format("import %s;", MapElement.class.getName()));
|
||||
writeLine(fileWriter, String.format("import %s;", Simulation.class.getName()));
|
||||
writeLine(fileWriter, String.format("import %s;", SimulationDataRepository.class.getName()));
|
||||
//import列表
|
||||
importStrList.forEach(str -> writeLine(fileWriter, str));
|
||||
//注解
|
||||
writeLine(fileWriter, "@Getter");
|
||||
writeLine(fileWriter, "@Setter");
|
||||
writeLine(fileWriter, "@NoArgsConstructor");
|
||||
//类声明
|
||||
writeLine(fileWriter, String.format("public class %s extends StorageDevice {", targetClassName));
|
||||
//字段
|
||||
fieldStrList.forEach(str -> writeLine(fileWriter, str));
|
||||
//构造器
|
||||
writeLine(fileWriter, String.format("public %s(%s %s) {", targetClassName, sourceClassName, lowercaseSourceClassName));
|
||||
writeLine(fileWriter, String.format("super(%s);", lowercaseSourceClassName));
|
||||
writeLine(fileWriter, "}");
|
||||
//convert2Storage方法
|
||||
convert2StorageMethodStrList.forEach(str -> writeLine(fileWriter, str));
|
||||
writeLine(fileWriter, String.format("return %s;", storageObjectName));
|
||||
writeLine(fileWriter, "}");
|
||||
//convert方法
|
||||
writeLine(fileWriter, "@Override");
|
||||
writeLine(fileWriter, "public boolean convert(MapElement element) {");
|
||||
writeLine(fileWriter, "return true;");
|
||||
writeLine(fileWriter, "}");
|
||||
//recover2Simulation方法
|
||||
recover2SimulationMethodStrList.forEach(str -> writeLine(fileWriter, str));
|
||||
writeLine(fileWriter, "}");
|
||||
//类结尾
|
||||
writeLine(fileWriter, "}");
|
||||
|
||||
fileWriter.flush();
|
||||
fileWriter.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static String lowercaseInitial(String s) {
|
||||
String s1 = String.valueOf(s.charAt(0)).toLowerCase();
|
||||
String s2 = s.substring(1);
|
||||
return s1 + s2;
|
||||
}
|
||||
|
||||
private static String uppercaseInitial(String s) {
|
||||
String s1 = String.valueOf(s.charAt(0)).toUpperCase();
|
||||
String s2 = s.substring(1);
|
||||
return s1 + s2;
|
||||
}
|
||||
|
||||
private static void writeLine(FileWriter writer, String text) {
|
||||
try {
|
||||
writer.write(String.format("%s\n", text));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,13 +1,22 @@
|
||||
package club.joylink.rtss.vo.training2.rule;
|
||||
|
||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.RunLevel;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SignalAspect;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SwitchIndication;
|
||||
import club.joylink.rtss.simulation.cbtc.data.CalculateService;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.*;
|
||||
import club.joylink.rtss.simulation.cbtc.data.storage.StorageSimulation;
|
||||
import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySectionAxleCounter;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
|
||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
|
||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
|
||||
import club.joylink.rtss.util.JsonUtils;
|
||||
import lombok.Getter;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@ -63,17 +72,6 @@ public enum BgSceneStatusRule {
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 道岔封锁背景:将道岔设置为未封锁
|
||||
*/
|
||||
SWITCH_BLOCK_BG_SCENE("道岔封锁背景") {
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Switch iSwitch = (Switch) mapElement;
|
||||
setBlockSwitch(iSwitch, false);
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 道岔解封背景:将道岔设置为封锁
|
||||
*/
|
||||
@ -81,18 +79,9 @@ public enum BgSceneStatusRule {
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Switch iSwitch = (Switch) mapElement;
|
||||
setBlockSwitch(iSwitch, true);
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 道岔单锁背景:将道岔设置为未封锁
|
||||
*/
|
||||
SWITCH_SINGLE_BLOCK_BG_SCENE("道岔单锁背景") {
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Switch iSwitch = (Switch) mapElement;
|
||||
setSingleLockSwitch(iSwitch, false);
|
||||
iSwitch.setBlockade(true);
|
||||
iSwitch.getAllSections().stream().forEach(section -> section.setBlockade(true));
|
||||
iSwitch.setInit(false);
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
@ -103,7 +92,39 @@ public enum BgSceneStatusRule {
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Switch iSwitch = (Switch) mapElement;
|
||||
setSingleLockSwitch(iSwitch, true);
|
||||
iSwitch.setSingleLock(true);
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
SWITCH_FAULT_UNLOCK_BG_SCENE("道岔故障解锁背景") {
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Switch iSwitch = (Switch) mapElement;
|
||||
iSwitch.setRouteLock(true);
|
||||
iSwitch.getAllSections().forEach(section -> section.setRouteLock(true));
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
SWITCH_AXLE_FAULT_PRE_RESET_BG_SCENE("道岔计轴预复位背景") {
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Switch iSwitch = (Switch) mapElement;
|
||||
Switch.SwitchFault.AXLE_FAULT.apply(iSwitch);
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
SWITCH_SECTION_ACTIVE_BG_SCENE("道岔区段激活背景") {
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Switch iSwitch = (Switch) mapElement;
|
||||
return SECTION_ACTIVE_BG_SCENE.doHandle(simulation, iSwitch.getA());
|
||||
}
|
||||
},
|
||||
SWITCH_SECTION_LIMIT_SPEED("道岔区段速度限制背景") {
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Switch iSwitch = (Switch) mapElement;
|
||||
iSwitch.getAllSections().forEach(section -> section.setSpeedUpLimit(5));
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
@ -133,6 +154,69 @@ public enum BgSceneStatusRule {
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 信号机重开背景
|
||||
*/
|
||||
SIGNAL_REOPEN_BG_SCENE("信号机重开背景") {
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Signal signal = (Signal) mapElement;
|
||||
Route route = signal.getRouteList().get(0);
|
||||
openRouteDirect(simulation, route);
|
||||
VirtualRealitySignal vrSignal = signal.getVirtualSignal();
|
||||
signal.setForbidden(true);
|
||||
signal.setAspect(signal.getDefaultAspect());
|
||||
vrSignal.setAspect(signal.getDefaultAspect());
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 信号机关灯背景
|
||||
*/
|
||||
SIGNAL_CLOSE_BG_SCENE("信号机关灯背景") {
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Signal signal = (Signal) mapElement;
|
||||
Route route = signal.getRouteList().get(0);
|
||||
openRouteDirect(simulation, route);
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 信号机引导背景
|
||||
*/
|
||||
SIGNAL_GUIDE_BG_SCENE("信号机引导背景") {
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Signal signal = (Signal) mapElement;
|
||||
// 开放进路
|
||||
Route route = signal.getRouteList().get(0);
|
||||
openRouteDirect(simulation, route);
|
||||
// 关闭信号机
|
||||
VirtualRealitySignal vrSignal = signal.getVirtualSignal();
|
||||
signal.setForbidden(true);
|
||||
signal.setAspect(signal.getDefaultAspect());
|
||||
vrSignal.setAspect(signal.getDefaultAspect());
|
||||
// 添加信号机
|
||||
VirtualRealityTrain train = (VirtualRealityTrain) simulation.getRepository().getVrDeviceMap().values().stream()
|
||||
.filter(o -> o instanceof VirtualRealityTrain).findFirst().get();
|
||||
Section section = route.getStart().getSection();
|
||||
trainOnline(simulation, train, section, route.isRight());
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 进路交自动控背景
|
||||
*/
|
||||
SIGNAL_ROUTE_AUTO_SET_BG_SCENE("进路交自动控背景") {
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Signal signal = (Signal) mapElement;
|
||||
Route route = signal.getRouteList().get(0);
|
||||
route.setAtsControl(false);
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 区段区故解背景
|
||||
*/
|
||||
@ -144,6 +228,106 @@ public enum BgSceneStatusRule {
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 区段故障解锁背景
|
||||
*/
|
||||
SECTION_FAULT_UNLOCK_BG_SCENE("区段故障解锁背景") {
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Section section = (Section) mapElement;
|
||||
section.setRouteLock(true);
|
||||
section.setLockRight(true);
|
||||
if(!CollectionUtils.isEmpty(section.getLogicList())) {
|
||||
section.getLogicList().forEach(s -> {
|
||||
s.setRouteLock(true);
|
||||
s.setLockRight(true);
|
||||
});
|
||||
}
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
SECTION_UNLOCK_BG_SCENE("区段解封背景"){
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Section section = (Section) mapElement;
|
||||
section.setBlockade(true);
|
||||
if (!CollectionUtils.isEmpty(section.getLogicList())) {
|
||||
for (Section logic : section.getLogicList()) {
|
||||
logic.setBlockade(true);
|
||||
}
|
||||
}
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 区段激活背景
|
||||
*/
|
||||
SECTION_ACTIVE_BG_SCENE("区段激活背景") {
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Section section = (Section) mapElement;
|
||||
Section axleSection = section;
|
||||
if (Objects.nonNull(section.getParent())) {
|
||||
axleSection = section.getParent();
|
||||
}
|
||||
axleSection.setCutOff(true);
|
||||
for (Section logic : axleSection.getLogicList()) {
|
||||
logic.setCutOff(true);
|
||||
}
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 区段取消限速背景
|
||||
*/
|
||||
SECTION_CANCEL_LIMIT_SPEED_BG_SCENE("区段取消限速背景") {
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Section section = (Section) mapElement;
|
||||
section.setSpeedUpLimit(5);
|
||||
return null;
|
||||
}
|
||||
},
|
||||
SECTION_CONFIRM_AXIS_VALID_BG_SCENE("设置计轴生效背景") {
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Section section = (Section) mapElement;
|
||||
if (Objects.nonNull(section.getParent())) {
|
||||
section.getParent().judgeAsNctOccupied(simulation);
|
||||
} else {
|
||||
section.judgeAsNctOccupied(simulation);
|
||||
}
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
SECTION_AXIS_PRE_RESET_BG_SCENE("计轴预复位背景") {
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Section section = (Section) mapElement;
|
||||
if(!section.isAxleCounter() && !section.isCross()){
|
||||
throw new SimulationException(SimulationExceptionType.Simulation_Map_Data_Error);
|
||||
}
|
||||
VirtualRealitySectionAxleCounter virtualAxleCounter = section.findAxleCounterSection().getVirtualAxleCounter();
|
||||
virtualAxleCounter.setOccupy(true);
|
||||
virtualAxleCounter.setPreReset(false);
|
||||
virtualAxleCounter.setLeftCount(2);
|
||||
virtualAxleCounter.setRightCount(2);
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
SECTION_TURN_BACK_REENTRY_STRATEGY("区段折返策略修改背景"){
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Section section = (Section) mapElement;
|
||||
Stand stand = section.getStandList().get(0);
|
||||
stand.setTypeStrategy(Stand.TurnBackType.AUTO);
|
||||
// 添加信号机
|
||||
VirtualRealityTrain train = (VirtualRealityTrain) simulation.getRepository().getVrDeviceMap().values().stream()
|
||||
.filter(o -> o instanceof VirtualRealityTrain).findFirst().get();
|
||||
BgSceneStatusRule.trainOnline(simulation, train, section, stand.isRight());
|
||||
return null;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 车站上电解锁
|
||||
*/
|
||||
@ -154,7 +338,51 @@ public enum BgSceneStatusRule {
|
||||
restartInterlock(simulation, station);
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
STAND_EARLY_DEPART_BG_SCENE("提前发车背景") {
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Stand stand = (Stand) mapElement;
|
||||
Section section = stand.getSection();
|
||||
Route route = stand.getSection().getSignalToRight().getRouteList().stream().filter(r ->
|
||||
(section.equals(r.getStart().getSection()) || r.containSection(section) && !r.routeLastSection(section))
|
||||
&& Objects.equals(stand.isRight(), r.getStart().isRight()))
|
||||
.findAny().orElse(null);
|
||||
if (Objects.nonNull(route)) {
|
||||
openRouteDirect(simulation, route);
|
||||
}
|
||||
// 添加信号机
|
||||
VirtualRealityTrain train = (VirtualRealityTrain) simulation.getRepository().getVrDeviceMap().values().stream()
|
||||
.filter(o -> o instanceof VirtualRealityTrain).findFirst().get();
|
||||
BgSceneStatusRule.trainOnline(simulation,train,section,route.isRight());
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
STAND_CANCEL_HOLD_TRAIN_BG_SCENE("站台取消扣车背景") {
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Stand stand = (Stand) mapElement;
|
||||
stand.setTrainLimit(3);
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
STAND_FORCE_CANCEL_HOLD_TRAIN_BG_SCENE("强制取消扣车背景") {
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Stand stand = (Stand) mapElement;
|
||||
stand.setCenterHoldTrain(true);
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
STAND_CANCEL_JUMP_STOP_BG_SCENE("站台取消设置跳停") {
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Stand stand = (Stand) mapElement;
|
||||
stand.setAllSkip(true);
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
/**
|
||||
@ -275,28 +503,6 @@ public enum BgSceneStatusRule {
|
||||
signal.setAspect(aspect);
|
||||
}
|
||||
|
||||
/**
|
||||
* 封锁、解封道岔
|
||||
* @param aSwitch 道岔
|
||||
*/
|
||||
private static void setBlockSwitch(Switch aSwitch, boolean block) {
|
||||
aSwitch.setBlockade(block);
|
||||
aSwitch.getA().setBlockade(block);
|
||||
aSwitch.getB().setBlockade(block);
|
||||
aSwitch.getC().setBlockade(block);
|
||||
if (block) {
|
||||
aSwitch.setInit(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置道岔单锁、单解
|
||||
*/
|
||||
private static void setSingleLockSwitch(Switch aSwitch, boolean block) {
|
||||
aSwitch.setSingleLock(block);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 重启联锁机
|
||||
*/
|
||||
@ -321,4 +527,29 @@ public enum BgSceneStatusRule {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 列车上线
|
||||
*/
|
||||
private static void trainOnline(Simulation simulation, VirtualRealityTrain train, Section section, boolean right) {
|
||||
//重叠检测
|
||||
SectionPosition headPosition = new SectionPosition(section, section.getStopPointByDirection(right));
|
||||
train.initManualTrain(headPosition, right);
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
//设置列车预选模式、驾驶模式、运行级别
|
||||
if (!headPosition.getSection().anyZcWorking()) {
|
||||
train.initAsRM();
|
||||
} else {
|
||||
MapConfig config = repository.getConfig();
|
||||
if (RunLevel.ITC.equals(config.getRunMode())) {
|
||||
train.initAsAM_I();
|
||||
} else if (RunLevel.IL.equals(config.getRunMode())) {
|
||||
train.initAsRM();
|
||||
}
|
||||
}
|
||||
TrainInfo trainInfo = TrainInfo.constructManualTrain(train);
|
||||
trainInfo.tracking(train);
|
||||
repository.addOnlineTrain(train);
|
||||
repository.addTrainInfo(trainInfo);
|
||||
}
|
||||
}
|
||||
|
@ -2,84 +2,105 @@ package club.joylink.rtss.vo.training2.rule;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.*;
|
||||
import club.joylink.rtss.vo.map.graph.MapStationNewVO;
|
||||
import lombok.Getter;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Random;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Getter
|
||||
public enum MapDeviceRule {
|
||||
METRO_ROUTE_LIST("地铁进路利列表") {
|
||||
@Override
|
||||
public List<Route> filterMapDeviceList(Simulation simulation) {
|
||||
boolean isMETRO = Simulation.Type.METRO.equals(simulation.getBuildParams().getWorkParamVO().getType());
|
||||
if (!isMETRO) {
|
||||
return List.of();
|
||||
}
|
||||
List<Route> routeList = simulation.getRepository().getRouteList().stream()
|
||||
.filter(r -> Signal.SignalType.PROTECTION.equals(r.getStart().getType())).collect(Collectors.toList());
|
||||
return generateRandomElement(routeList, 2);
|
||||
}
|
||||
},
|
||||
RAILWAY_PICK_ROUTE_LIST("大铁接车进路列表") {
|
||||
@Override
|
||||
public List<Route> filterMapDeviceList(Simulation simulation) {
|
||||
boolean isRailWay = Simulation.Type.RAILWAY.equals(simulation.getBuildParams().getWorkParamVO().getType());
|
||||
if (!isRailWay) {
|
||||
return List.of();
|
||||
}
|
||||
List<Route> routeList = simulation.getRepository().getRouteList().stream()
|
||||
.filter(r -> Objects.equals(r.getType(), Route.Type.RECEIVING)).collect(Collectors.toList());
|
||||
return generateRandomElement(routeList, 2);
|
||||
}
|
||||
},
|
||||
STATION_LIST("车站列表") {
|
||||
@Override
|
||||
public List<Station> filterMapDeviceList(Simulation simulation) {
|
||||
List<Station> stationList = simulation.getRepository().getStationList();
|
||||
List<Station> stationList = simulation.getBuildParams().getMap().getGraphDataNew().getStationList()
|
||||
.stream().filter(s -> s.isVisible() && s.isCentralized() && s.isCiStation()).map(MapStationNewVO::getCode)
|
||||
.map(code -> simulation.getRepository().getByCode(code, Station.class))
|
||||
.collect(Collectors.toList());
|
||||
return generateRandomElement(stationList, 1);
|
||||
}
|
||||
},
|
||||
STAND_LIST("站台列表"){
|
||||
@Override
|
||||
public List<Stand> filterMapDeviceList(Simulation simulation) {
|
||||
List<Station> stationList = STATION_LIST.filterMapDeviceList(simulation);
|
||||
Station station = stationList.get(0);
|
||||
return MapDeviceRule.generateRandomElement(station.getAllStandList(), 2);
|
||||
}
|
||||
},
|
||||
ROUTE_LIST("进路列表") {
|
||||
@Override
|
||||
public List<Route> filterMapDeviceList(Simulation simulation) {
|
||||
List<Station> stationList = STATION_LIST.filterMapDeviceList(simulation);
|
||||
Station station = stationList.get(0);
|
||||
List<Route> routeList = new ArrayList<>();
|
||||
station.getAllStandList().stream().filter(stand -> stand.getSection().getSignalToRight() != null)
|
||||
.forEach(stand -> routeList.addAll(stand.getSection().getSignalToRight().getRouteList()));
|
||||
return generateRandomElement(routeList, 2);
|
||||
}
|
||||
},
|
||||
SWITCH_LIST("道岔列表") {
|
||||
@Override
|
||||
public List<Switch> filterMapDeviceList(Simulation simulation) {
|
||||
List<Switch> switchList = simulation.getRepository().getSwitchList();
|
||||
List<Station> stationList = STATION_LIST.filterMapDeviceList(simulation);
|
||||
Station station = stationList.get(0);
|
||||
List<Switch> switchList = simulation.getRepository().getSwitchList().stream()
|
||||
.filter(aSwitch -> station.equals(aSwitch.getDeviceStation())).collect(Collectors.toList());
|
||||
return generateRandomElement(switchList, 2);
|
||||
}
|
||||
},
|
||||
SIGNAL_LIST("信号机列表") {
|
||||
@Override
|
||||
public List<Signal> filterMapDeviceList(Simulation simulation) {
|
||||
List<Signal> signalList = simulation.getRepository().getSignalList();
|
||||
List<Station> stationList = STATION_LIST.filterMapDeviceList(simulation);
|
||||
Station station = stationList.get(0);
|
||||
List<Signal> signalList = new ArrayList<>();
|
||||
station.getAllStandList().stream().filter(stand -> stand.getSection().getSignalToRight() != null)
|
||||
.forEach(stand -> signalList.add(stand.getSection().getSignalToRight()));
|
||||
return generateRandomElement(signalList, 2);
|
||||
}
|
||||
},
|
||||
RAILWAY_DEPARTURE_SIGNAL_LIST("大铁发车信号机列表") {
|
||||
SECTION_LIST("区段列表") {
|
||||
@Override
|
||||
public List<Signal> filterMapDeviceList(Simulation simulation) {
|
||||
List<Signal> signalList = simulation.getRepository().getSignalList().stream()
|
||||
.filter(s -> Signal.SignalType.DEPARTURE.equals(s.getType())).collect(Collectors.toList());
|
||||
return generateRandomElement(signalList, 2);
|
||||
public List<Section> filterMapDeviceList(Simulation simulation) {
|
||||
List<Route> routeList = ROUTE_LIST.filterMapDeviceList(simulation);
|
||||
List<Section> sectionList = new ArrayList<>(100);
|
||||
routeList.forEach(route -> sectionList.addAll(route.getSectionList()));
|
||||
return generateRandomElement(sectionList, 2);
|
||||
}
|
||||
},
|
||||
SECTION_LIST("普通区段列表") {
|
||||
SECTION_STAND_TURN_BACK_LIST("折返区段列表") {
|
||||
@Override
|
||||
public List<Section> filterMapDeviceList(Simulation simulation) {
|
||||
List<Section> sectionList = simulation.getRepository().getSectionList().stream()
|
||||
.filter(s -> s.getParent() == null).collect(Collectors.toList());
|
||||
.filter(section -> section.isStandTrack() && section.isTurnBackTrack())
|
||||
.collect(Collectors.toList());
|
||||
return MapDeviceRule.generateRandomElement(sectionList, 2);
|
||||
}
|
||||
},
|
||||
SECTION_NO_AXLE_COUNTER_LIST("非计轴区段列表") {
|
||||
@Override
|
||||
public List<Section> filterMapDeviceList(Simulation simulation) {
|
||||
List<String> stationCodeList = simulation.getBuildParams().getMap().getGraphDataNew().getStationList()
|
||||
.stream().filter(s -> s.isVisible() && s.isCentralized() && s.isCiStation()).map(MapStationNewVO::getCode)
|
||||
.collect(Collectors.toList());
|
||||
List<Section> sectionList = simulation.getRepository().getSectionList().stream()
|
||||
.filter(section -> stationCodeList.contains(section.getDeviceStation().getCode()) && !section.isAxleCounter())
|
||||
.collect(Collectors.toList());
|
||||
return generateRandomElement(sectionList, 2);
|
||||
}
|
||||
},
|
||||
SECTION_AXLE_COUNTER_LIST("道岔计轴区段列表") {
|
||||
@Override
|
||||
public List<Section> filterMapDeviceList(Simulation simulation) {
|
||||
List<String> stationCodeList = simulation.getBuildParams().getMap().getGraphDataNew().getStationList()
|
||||
.stream().filter(s -> s.isVisible() && s.isCentralized() && s.isCiStation()).map(MapStationNewVO::getCode)
|
||||
.collect(Collectors.toList());
|
||||
List<Section> sectionList = simulation.getRepository().getSectionList().stream()
|
||||
.filter(Section::isSwitchTrack).collect(Collectors.toList());
|
||||
.filter(section -> stationCodeList.contains(section.getDeviceStation().getCode()) && section.isAxleCounter())
|
||||
.collect(Collectors.toList());
|
||||
return generateRandomElement(sectionList, 2);
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,10 @@ public abstract class MapElementRule {
|
||||
return (Station) mapElement;
|
||||
} else if (mapElement instanceof Switch) {
|
||||
return ((Switch) mapElement).getDeviceStation();
|
||||
} else if (mapElement instanceof Section) {
|
||||
return ((Section) mapElement).getDeviceStation();
|
||||
} else if (mapElement instanceof Stand) {
|
||||
return ((Stand) mapElement).getDeviceStation();
|
||||
}
|
||||
throw new SimulationException(SimulationExceptionType.Simulation_Map_Data_Error);
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class MemberRule {
|
||||
/**
|
||||
* 所属设备编码
|
||||
*/
|
||||
String code = deviceCodeRule.resolve(simulation, mapElement);
|
||||
String code = String.valueOf(deviceCodeRule.resolve(simulation, mapElement));
|
||||
List<SimulationMember> resultMemberList = memberList.stream().filter(member -> member.getDevice() != null
|
||||
&& member.getDevice().getCode().equals(code)).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(resultMemberList)) {
|
||||
|
@ -97,7 +97,7 @@ public abstract class OperationRule {
|
||||
Operation2VO.ClientOperation2VO operation2 = new Operation2VO.ClientOperation2VO();
|
||||
operation2.setId(this.getId());
|
||||
if (PropertyValueRule.match(deviceCode)) { // 设备规则编码设置
|
||||
operation2.setDeviceCode(PropertyValueRule.valueOf(deviceCode).resolve(simulation, mapElement));
|
||||
operation2.setDeviceCode(String.valueOf(PropertyValueRule.valueOf(deviceCode).resolve(simulation, mapElement)));
|
||||
} else {
|
||||
operation2.setDeviceCode("");
|
||||
}
|
||||
|
@ -112,7 +112,16 @@ public enum PropertyValueRule {
|
||||
}
|
||||
return buttonVO.getCode();
|
||||
}
|
||||
};
|
||||
},
|
||||
SIGNAL_FIRST_ROUTE_CODE_LIST("信号机关联的第一条进路编码列表") {
|
||||
@Override
|
||||
public Object resolve(Simulation simulation, Object mapElement) {
|
||||
Signal signal = (Signal) mapElement;
|
||||
Route route = signal.getRouteList().get(0);
|
||||
return List.of(route.getCode());
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
private final String description;
|
||||
|
||||
@ -122,7 +131,7 @@ public enum PropertyValueRule {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public abstract String resolve(Simulation simulation, Object mapElement);
|
||||
public abstract Object resolve(Simulation simulation, Object mapElement);
|
||||
|
||||
public static boolean match(String ruleValue) {
|
||||
return Arrays.stream(PropertyValueRule.values()).anyMatch(r -> r.name().equals(ruleValue));
|
||||
@ -142,11 +151,11 @@ public enum PropertyValueRule {
|
||||
}
|
||||
String result = contentFormat;
|
||||
String propertyEnum;
|
||||
String propertyValue;
|
||||
Object propertyValue;
|
||||
for (String property : propertySet) {
|
||||
propertyEnum = property.replaceAll("[\\{\\}]", "");
|
||||
propertyValue = PropertyValueRule.valueOf(propertyEnum).resolve(simulation, mapElement);
|
||||
result = result.replace(property, propertyValue);
|
||||
result = result.replace(property, String.valueOf(propertyValue));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public abstract class ValuableRule {
|
||||
public StatusValueVO convert2BO(Simulation simulation, Object mapElement) {
|
||||
StatusValueVO valuable = JsonUtils.read(JsonUtils.writeValueAsString(this.getValuableVO()), StatusValueVO.class);
|
||||
if (elementCodeRule != null) {
|
||||
valuable.setElementCode(elementCodeRule.resolve(simulation, mapElement));
|
||||
valuable.setElementCode(String.valueOf(elementCodeRule.resolve(simulation, mapElement)));
|
||||
}
|
||||
return valuable;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
<resultMap id="BaseResultMap" type="club.joylink.rtss.entity.training2.RtsTraining2Rule" >
|
||||
<id column="id" property="id" jdbcType="BIGINT" />
|
||||
<result column="sim_type" property="simType" jdbcType="VARCHAR" />
|
||||
<result column="line_code" property="lineCode" jdbcType="VARCHAR"/>
|
||||
<result column="device_rule" property="deviceRule" jdbcType="VARCHAR" />
|
||||
<result column="client" property="client" jdbcType="VARCHAR" />
|
||||
<result column="name" property="name" jdbcType="VARCHAR" />
|
||||
@ -82,7 +83,7 @@
|
||||
</sql>
|
||||
|
||||
<sql id="Base_Column_List" >
|
||||
id, sim_type, device_rule, client, name, description, type, labels, scene_rule, creator_id, create_time, location_rule
|
||||
id, sim_type, line_code, device_rule, client, name, description, type, labels, scene_rule, creator_id, create_time, location_rule
|
||||
</sql>
|
||||
|
||||
<sql id="Blob_Column_List" >
|
||||
@ -138,11 +139,11 @@
|
||||
|
||||
<insert id="insert" parameterType="club.joylink.rtss.entity.training2.RtsTraining2RuleWithBLOBs" >
|
||||
insert into rts_training2_rule (
|
||||
id, sim_type, device_rule, client, name, description, type, labels,
|
||||
id, sim_type, line_code, device_rule, client, name, description, type, labels,
|
||||
scene_rule, creator_id, create_time, steps, failure_rule, location_rule
|
||||
)
|
||||
values (
|
||||
#{id,jdbcType=BIGINT}, #{simType,jdbcType=VARCHAR}, #{deviceRule,jdbcType=VARCHAR}, #{client,jdbcType=VARCHAR},
|
||||
#{id,jdbcType=BIGINT}, #{simType,jdbcType=VARCHAR}, #{lineCode,jdbcType=VARCHAR}, #{deviceRule,jdbcType=VARCHAR}, #{client,jdbcType=VARCHAR},
|
||||
#{name,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{labels,jdbcType=VARCHAR},
|
||||
#{sceneRule,jdbcType=VARCHAR}, #{creatorId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP},
|
||||
#{steps,jdbcType=LONGVARCHAR}, #{failureRule,jdbcType=LONGVARCHAR}, #{locationRule,jdbcType=VARCHAR}
|
||||
@ -158,6 +159,9 @@
|
||||
<if test="simType != null" >
|
||||
sim_type,
|
||||
</if>
|
||||
<if test="lineCode != null">
|
||||
line_code,
|
||||
</if>
|
||||
<if test="deviceRule != null" >
|
||||
device_rule,
|
||||
</if>
|
||||
@ -202,6 +206,9 @@
|
||||
<if test="simType != null" >
|
||||
#{simType,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="lineCode != null">
|
||||
#{lineCode,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="deviceRule != null" >
|
||||
#{deviceRule,jdbcType=VARCHAR},
|
||||
</if>
|
||||
@ -250,6 +257,9 @@
|
||||
<if test="record.simType != null" >
|
||||
sim_type = #{record.simType,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.lineCode != null">
|
||||
line_code = #{record.lineCode,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.deviceRule != null" >
|
||||
device_rule = #{record.deviceRule,jdbcType=VARCHAR},
|
||||
</if>
|
||||
@ -296,6 +306,7 @@
|
||||
update rts_training2_rule
|
||||
set id = #{record.id,jdbcType=BIGINT},
|
||||
sim_type = #{record.simType,jdbcType=VARCHAR},
|
||||
line_code = #{record.lineCode,jdbcType=VARCHAR},
|
||||
device_rule = #{record.deviceRule,jdbcType=VARCHAR},
|
||||
client = #{record.client,jdbcType=VARCHAR},
|
||||
name = #{record.name,jdbcType=VARCHAR},
|
||||
@ -317,6 +328,7 @@
|
||||
update rts_training2_rule
|
||||
set id = #{record.id,jdbcType=BIGINT},
|
||||
sim_type = #{record.simType,jdbcType=VARCHAR},
|
||||
line_code = #{record.lineCode,jdbcType=VARCHAR},
|
||||
device_rule = #{record.deviceRule,jdbcType=VARCHAR},
|
||||
client = #{record.client,jdbcType=VARCHAR},
|
||||
name = #{record.name,jdbcType=VARCHAR},
|
||||
@ -338,6 +350,9 @@
|
||||
<if test="simType != null" >
|
||||
sim_type = #{simType,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="lineCode != null">
|
||||
line_code = #{lineCode,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="deviceRule != null" >
|
||||
device_rule = #{deviceRule,jdbcType=VARCHAR},
|
||||
</if>
|
||||
@ -381,6 +396,7 @@
|
||||
<update id="updateByPrimaryKeyWithBLOBs" parameterType="club.joylink.rtss.entity.training2.RtsTraining2RuleWithBLOBs" >
|
||||
update rts_training2_rule
|
||||
set sim_type = #{simType,jdbcType=VARCHAR},
|
||||
line_code = #{lineCode,jdbcType=VARCHAR},
|
||||
device_rule = #{deviceRule,jdbcType=VARCHAR},
|
||||
client = #{client,jdbcType=VARCHAR},
|
||||
name = #{name,jdbcType=VARCHAR},
|
||||
@ -399,6 +415,7 @@
|
||||
<update id="updateByPrimaryKey" parameterType="club.joylink.rtss.entity.training2.RtsTraining2Rule" >
|
||||
update rts_training2_rule
|
||||
set sim_type = #{simType,jdbcType=VARCHAR},
|
||||
line_code = #{lineCode,jdbcType=VARCHAR},
|
||||
device_rule = #{deviceRule,jdbcType=VARCHAR},
|
||||
client = #{client,jdbcType=VARCHAR},
|
||||
name = #{name,jdbcType=VARCHAR},
|
||||
|
Loading…
Reference in New Issue
Block a user