From 1428cf38f517153b8923d1d0bda79cc7b6d12020 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Fri, 2 Dec 2022 18:14:50 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E3=80=90=E5=A2=9E=E5=8A=A0=E5=AE=9E?= =?UTF-8?q?=E8=AE=AD=E8=83=8C=E6=99=AF=E7=A7=8D=E7=B1=BB=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../vo/training2/rule/BgSceneStatusRule.java | 142 ++++++++++++++++++ .../rtss/vo/training2/rule/MapDeviceRule.java | 34 ++++- .../vo/training2/rule/MapElementRule.java | 2 + .../rtss/vo/training2/rule/MemberRule.java | 2 +- .../rtss/vo/training2/rule/OperationRule.java | 2 +- .../vo/training2/rule/PropertyValueRule.java | 17 ++- .../rtss/vo/training2/rule/ValuableRule.java | 2 +- 7 files changed, 189 insertions(+), 12 deletions(-) diff --git a/src/main/java/club/joylink/rtss/vo/training2/rule/BgSceneStatusRule.java b/src/main/java/club/joylink/rtss/vo/training2/rule/BgSceneStatusRule.java index da1d2d6ab..41126b663 100644 --- a/src/main/java/club/joylink/rtss/vo/training2/rule/BgSceneStatusRule.java +++ b/src/main/java/club/joylink/rtss/vo/training2/rule/BgSceneStatusRule.java @@ -1,13 +1,19 @@ 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.VirtualRealitySignal; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch; +import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; import club.joylink.rtss.util.JsonUtils; import lombok.Getter; import org.springframework.util.CollectionUtils; @@ -133,6 +139,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 +213,65 @@ 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_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 null; + } + }, + /** + * 区段取消限速背景 + */ + 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 null; + } + }, /** * 车站上电解锁 */ @@ -321,4 +449,18 @@ 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(); + TrainInfo trainInfo = TrainInfo.constructManualTrain(train); + trainInfo.tracking(train); + repository.addOnlineTrain(train); + repository.addTrainInfo(trainInfo); + } } diff --git a/src/main/java/club/joylink/rtss/vo/training2/rule/MapDeviceRule.java b/src/main/java/club/joylink/rtss/vo/training2/rule/MapDeviceRule.java index e832b27de..bf57eaeaf 100644 --- a/src/main/java/club/joylink/rtss/vo/training2/rule/MapDeviceRule.java +++ b/src/main/java/club/joylink/rtss/vo/training2/rule/MapDeviceRule.java @@ -2,6 +2,7 @@ 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; @@ -21,8 +22,9 @@ public enum MapDeviceRule { if (!isMETRO) { return List.of(); } - List routeList = simulation.getRepository().getRouteList().stream() - .filter(r -> Signal.SignalType.PROTECTION.equals(r.getStart().getType())).collect(Collectors.toList()); + List signalList = METRO_DEPARTURE_SIGNAL_LIST.filterMapDeviceList(simulation); + List routeList = new ArrayList<>(); + signalList.forEach(s -> routeList.addAll(s.getRouteList())); return generateRandomElement(routeList, 2); } }, @@ -41,7 +43,10 @@ public enum MapDeviceRule { STATION_LIST("车站列表") { @Override public List filterMapDeviceList(Simulation simulation) { - List stationList = simulation.getRepository().getStationList(); + List 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); } }, @@ -59,6 +64,14 @@ public enum MapDeviceRule { return generateRandomElement(signalList, 2); } }, + METRO_DEPARTURE_SIGNAL_LIST("地铁信号机列表") { + @Override + public List filterMapDeviceList(Simulation simulation) { + List signalList = simulation.getRepository().getStandList().stream().map(s -> s.getSection().getSignalToRight()) + .filter(s -> s != null && !CollectionUtils.isEmpty(s.getRouteList())).collect(Collectors.toList()); + return generateRandomElement(signalList, 2); + } + }, RAILWAY_DEPARTURE_SIGNAL_LIST("大铁发车信号机列表") { @Override public List filterMapDeviceList(Simulation simulation) { @@ -70,8 +83,11 @@ public enum MapDeviceRule { SECTION_LIST("普通区段列表") { @Override public List
filterMapDeviceList(Simulation simulation) { - List
sectionList = simulation.getRepository().getSectionList().stream() - .filter(s -> s.getParent() == null).collect(Collectors.toList()); + List signalList = simulation.getRepository().getStandList().stream().map(s -> s.getSection().getSignalToRight()) + .filter(s -> s != null && !CollectionUtils.isEmpty(s.getRouteList())).collect(Collectors.toList()); + signalList = generateRandomElement(signalList, 2); + List
sectionList = new ArrayList<>(100); + signalList.forEach(s -> s.getRouteList().forEach(r -> sectionList.addAll(r.getSectionList()))); return generateRandomElement(sectionList, 2); } }, @@ -82,6 +98,14 @@ public enum MapDeviceRule { .filter(Section::isSwitchTrack).collect(Collectors.toList()); return generateRandomElement(sectionList, 2); } + }, + SECTION_ROUTE_LIST("") { + @Override + public List
filterMapDeviceList(Simulation simulation) { + List signalList = simulation.getRepository().getStandList().stream() + .map(s -> s.getSection().getSignalToRight()).filter(s -> s != null && !CollectionUtils.isEmpty(s.getRouteList())).collect(Collectors.toList()); + return null; + } } ; diff --git a/src/main/java/club/joylink/rtss/vo/training2/rule/MapElementRule.java b/src/main/java/club/joylink/rtss/vo/training2/rule/MapElementRule.java index f72ec64ba..95e6811c6 100644 --- a/src/main/java/club/joylink/rtss/vo/training2/rule/MapElementRule.java +++ b/src/main/java/club/joylink/rtss/vo/training2/rule/MapElementRule.java @@ -34,6 +34,8 @@ 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(); } throw new SimulationException(SimulationExceptionType.Simulation_Map_Data_Error); } diff --git a/src/main/java/club/joylink/rtss/vo/training2/rule/MemberRule.java b/src/main/java/club/joylink/rtss/vo/training2/rule/MemberRule.java index ef6996a6e..c521d8633 100644 --- a/src/main/java/club/joylink/rtss/vo/training2/rule/MemberRule.java +++ b/src/main/java/club/joylink/rtss/vo/training2/rule/MemberRule.java @@ -40,7 +40,7 @@ public class MemberRule { /** * 所属设备编码 */ - String code = deviceCodeRule.resolve(simulation, mapElement); + String code = String.valueOf(deviceCodeRule.resolve(simulation, mapElement)); List resultMemberList = memberList.stream().filter(member -> member.getDevice() != null && member.getDevice().getCode().equals(code)).collect(Collectors.toList()); if (CollectionUtils.isEmpty(resultMemberList)) { diff --git a/src/main/java/club/joylink/rtss/vo/training2/rule/OperationRule.java b/src/main/java/club/joylink/rtss/vo/training2/rule/OperationRule.java index 93728e914..d8db2166f 100644 --- a/src/main/java/club/joylink/rtss/vo/training2/rule/OperationRule.java +++ b/src/main/java/club/joylink/rtss/vo/training2/rule/OperationRule.java @@ -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(""); } diff --git a/src/main/java/club/joylink/rtss/vo/training2/rule/PropertyValueRule.java b/src/main/java/club/joylink/rtss/vo/training2/rule/PropertyValueRule.java index 53a6728c8..d123ca852 100644 --- a/src/main/java/club/joylink/rtss/vo/training2/rule/PropertyValueRule.java +++ b/src/main/java/club/joylink/rtss/vo/training2/rule/PropertyValueRule.java @@ -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; } diff --git a/src/main/java/club/joylink/rtss/vo/training2/rule/ValuableRule.java b/src/main/java/club/joylink/rtss/vo/training2/rule/ValuableRule.java index fb2c17d4f..b9a49fb38 100644 --- a/src/main/java/club/joylink/rtss/vo/training2/rule/ValuableRule.java +++ b/src/main/java/club/joylink/rtss/vo/training2/rule/ValuableRule.java @@ -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; } From e5aa725dca3b4283313bac80952dba42a476b449 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Mon, 5 Dec 2022 15:07:56 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9StorageVirtualRealityTrai?= =?UTF-8?q?n=EF=BC=9B=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8=AA=E7=B2=97?= =?UTF-8?q?=E7=B3=99=E7=9A=84Storage=E7=B1=BB=E7=94=9F=E6=88=90=E5=B7=A5?= =?UTF-8?q?=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RtsMapFunctionServiceImpl.java | 9 + .../simulation/cbtc/ATP/ground/MaService.java | 2 + .../cbtc/ATP/ground/ResponderService.java | 1 - .../simulation/cbtc/data/map/Responder.java | 4 - .../StorageSimulationDataRepository.java | 10 +- .../data/storage/ato/StorageSpeedCurve.java | 4 +- ...iveParam.java => StorageDriveParamVO.java} | 23 +- .../cbtc/data/storage/support/StorageMa.java | 55 ++ ...eMA.java => StorageMovementAuthority.java} | 8 +- .../vr/StorageControllableVrDevice.java | 2 +- ...StorageTrainDoor.java => StorageDoor.java} | 23 +- .../vr/StorageVirtualRealityDevice.java | 19 + .../vr/StorageVirtualRealityDeviceStatus.java | 23 - .../vr/StorageVirtualRealityScreenDoor.java | 10 +- .../vr/StorageVirtualRealitySection.java | 16 +- .../vr/StorageVirtualRealitySignal.java | 10 +- .../vr/StorageVirtualRealitySwitch.java | 10 +- .../vr/StorageVirtualRealityTrain.java | 637 +++++++----------- .../cbtc/data/vr/VirtualRealityTrain.java | 71 +- .../work/MetroSimulationWorkServiceImpl.java | 4 +- .../rtss/util/StorageGenerateUtil.java | 243 +++++++ 21 files changed, 682 insertions(+), 502 deletions(-) rename src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/support/{StorageDriveParam.java => StorageDriveParamVO.java} (61%) create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/support/StorageMa.java rename src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/support/{StorageMA.java => StorageMovementAuthority.java} (94%) rename src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/{StorageTrainDoor.java => StorageDoor.java} (64%) create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealityDevice.java delete mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealityDeviceStatus.java create mode 100644 src/main/java/club/joylink/rtss/util/StorageGenerateUtil.java diff --git a/src/main/java/club/joylink/rtss/services/mapFunction/RtsMapFunctionServiceImpl.java b/src/main/java/club/joylink/rtss/services/mapFunction/RtsMapFunctionServiceImpl.java index 9d696c7e8..bac266a96 100644 --- a/src/main/java/club/joylink/rtss/services/mapFunction/RtsMapFunctionServiceImpl.java +++ b/src/main/java/club/joylink/rtss/services/mapFunction/RtsMapFunctionServiceImpl.java @@ -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(); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/MaService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/MaService.java index 8cb0f5700..6203fc906 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/MaService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/MaService.java @@ -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 diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/ResponderService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/ResponderService.java index 648671895..778973c21 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/ResponderService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/ResponderService.java @@ -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); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Responder.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Responder.java index e2dffcc8d..23f108f75 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Responder.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Responder.java @@ -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); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/StorageSimulationDataRepository.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/StorageSimulationDataRepository.java index da884733e..c46e46a7f 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/StorageSimulationDataRepository.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/StorageSimulationDataRepository.java @@ -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); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/ato/StorageSpeedCurve.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/ato/StorageSpeedCurve.java index d04144375..508c2e578 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/ato/StorageSpeedCurve.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/ato/StorageSpeedCurve.java @@ -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)); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/support/StorageDriveParam.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/support/StorageDriveParamVO.java similarity index 61% rename from src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/support/StorageDriveParam.java rename to src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/support/StorageDriveParamVO.java index 4161ea703..8a3a5ebcf 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/support/StorageDriveParam.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/support/StorageDriveParamVO.java @@ -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; + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/support/StorageMa.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/support/StorageMa.java new file mode 100644 index 000000000..aab01816c --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/support/StorageMa.java @@ -0,0 +1,55 @@ +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.NonNull; + +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.getByCode(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; + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/support/StorageMA.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/support/StorageMovementAuthority.java similarity index 94% rename from src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/support/StorageMA.java rename to src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/support/StorageMovementAuthority.java index ce5a14165..31f6b86ea 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/support/StorageMA.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/support/StorageMovementAuthority.java @@ -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); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageControllableVrDevice.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageControllableVrDevice.java index cabddccfe..8d2198600 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageControllableVrDevice.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageControllableVrDevice.java @@ -7,7 +7,7 @@ import lombok.NoArgsConstructor; @Getter @NoArgsConstructor -public abstract class StorageControllableVrDevice extends StorageVirtualRealityDeviceStatus { +public abstract class StorageControllableVrDevice extends StorageVirtualRealityDevice { /** * 控制指令 */ diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageTrainDoor.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageDoor.java similarity index 64% rename from src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageTrainDoor.java rename to src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageDoor.java index efb0f57dc..ba3493f09 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageTrainDoor.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageDoor.java @@ -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 { +public class StorageDoor extends StorageControllableVrDevice { private String code; @JsonSerialize(using = Boolean2NumSerializer.class) @@ -27,7 +28,7 @@ public class StorageTrainDoor extends StorageControllableVrDevice 0) { + this.recoverTo(door); + } } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealityDevice.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealityDevice.java new file mode 100644 index 000000000..9b1aa4050 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealityDevice.java @@ -0,0 +1,19 @@ +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 { + + private String code; + + public StorageVirtualRealityDevice(VirtualRealityDevice device) { + super(device.getCode()); + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealityDeviceStatus.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealityDeviceStatus.java deleted file mode 100644 index 864d22b0f..000000000 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealityDeviceStatus.java +++ /dev/null @@ -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); -} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealityScreenDoor.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealityScreenDoor.java index d82ee44d2..80f206170 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealityScreenDoor.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealityScreenDoor.java @@ -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); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealitySection.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealitySection.java index 919a9f804..34562229e 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealitySection.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealitySection.java @@ -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); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealitySignal.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealitySignal.java index 7aeeaa223..f7bcbc4ca 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealitySignal.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealitySignal.java @@ -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 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 lastTwoPassedResponders; - - private List 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); + virtualRealityTrain.setConfirmationMessages(confirmationMessages); + 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; } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java index e3b6cb454..93f47bfc5 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java @@ -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 lastTwoPassedResponders = new FixedQueue<>(Responders_Record); - /** * 运行类型 */ @@ -446,7 +443,7 @@ public class VirtualRealityTrain extends VirtualRealityDevice { /** * 确认信息 */ - private final LinkedHashSet confirmationMessages = new LinkedHashSet<>(); + private LinkedHashSet confirmationMessages = new LinkedHashSet<>(); /** * ato可以开启 @@ -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; + } } } @@ -578,7 +577,6 @@ public class VirtualRealityTrain extends VirtualRealityDevice { 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 +1223,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(); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/work/MetroSimulationWorkServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/work/MetroSimulationWorkServiceImpl.java index d0e852173..e53353e74 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/work/MetroSimulationWorkServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/work/MetroSimulationWorkServiceImpl.java @@ -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 diff --git a/src/main/java/club/joylink/rtss/util/StorageGenerateUtil.java b/src/main/java/club/joylink/rtss/util/StorageGenerateUtil.java new file mode 100644 index 000000000..a3c7a751f --- /dev/null +++ b/src/main/java/club/joylink/rtss/util/StorageGenerateUtil.java @@ -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 fieldList = new ArrayList<>(Arrays.asList(declaredFields)); + for (Iterator iterator = fieldList.iterator(); iterator.hasNext(); ) { //删除所有不需要保存的字段 + Field field = iterator.next(); + if (field.getName().equals(startFieldName)) { + break; + } + iterator.remove(); + } + + List importStrList = new ArrayList<>(); + List fieldStrList = new ArrayList<>(); + List convert2StorageMethodStrList = new ArrayList<>(); + List 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> genericClassList; + if (genericType instanceof ParameterizedType) { + ParameterizedType parameterizedType = (ParameterizedType) genericType; + genericClassList = Stream.of(parameterizedType.getActualTypeArguments()) + .map(ata -> { + Class cls = (Class) 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(); + } + } +} From 219267c4557e311c717c0e390fc829ef99ffb1cd Mon Sep 17 00:00:00 2001 From: weizhihong Date: Mon, 5 Dec 2022 15:48:26 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E3=80=90=E7=94=9F=E6=88=90=E5=AE=9E?= =?UTF-8?q?=E8=AE=AD=E8=A7=84=E5=88=99=E4=BF=AE=E6=94=B9=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/training2/RtsTraining2Rule.java | 2 + .../training2/RtsTraining2RuleExample.java | 60 ++++++ .../training2/Training2RuleService.java | 2 +- .../vo/training2/rule/BgSceneStatusRule.java | 185 +++++++++++++----- .../rtss/vo/training2/rule/MapDeviceRule.java | 117 ++++++----- .../vo/training2/rule/MapElementRule.java | 2 + .../training2/RtsTraining2RuleMapper.xml | 23 ++- 7 files changed, 279 insertions(+), 112 deletions(-) diff --git a/src/main/java/club/joylink/rtss/entity/training2/RtsTraining2Rule.java b/src/main/java/club/joylink/rtss/entity/training2/RtsTraining2Rule.java index 754e457ff..2e06d145f 100644 --- a/src/main/java/club/joylink/rtss/entity/training2/RtsTraining2Rule.java +++ b/src/main/java/club/joylink/rtss/entity/training2/RtsTraining2Rule.java @@ -10,6 +10,8 @@ public class RtsTraining2Rule { private String simType; + private String lineCode; + private String locationRule; private String deviceRule; diff --git a/src/main/java/club/joylink/rtss/entity/training2/RtsTraining2RuleExample.java b/src/main/java/club/joylink/rtss/entity/training2/RtsTraining2RuleExample.java index 1823181f3..b09a45312 100644 --- a/src/main/java/club/joylink/rtss/entity/training2/RtsTraining2RuleExample.java +++ b/src/main/java/club/joylink/rtss/entity/training2/RtsTraining2RuleExample.java @@ -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 values) { + addCriterion("line_code in", values, "lineCode"); + return (Criteria) this; + } + + public Criteria andLineCodeNotIn(List 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; diff --git a/src/main/java/club/joylink/rtss/services/training2/Training2RuleService.java b/src/main/java/club/joylink/rtss/services/training2/Training2RuleService.java index ee1bfffcf..349cde26d 100644 --- a/src/main/java/club/joylink/rtss/services/training2/Training2RuleService.java +++ b/src/main/java/club/joylink/rtss/services/training2/Training2RuleService.java @@ -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 ruleList = rtsTraining2RuleMapper.selectByExampleWithBLOBs(example); if (!CollectionUtils.isEmpty(ruleList)) { // 清除数据库原有数据 diff --git a/src/main/java/club/joylink/rtss/vo/training2/rule/BgSceneStatusRule.java b/src/main/java/club/joylink/rtss/vo/training2/rule/BgSceneStatusRule.java index 41126b663..e64049f30 100644 --- a/src/main/java/club/joylink/rtss/vo/training2/rule/BgSceneStatusRule.java +++ b/src/main/java/club/joylink/rtss/vo/training2/rule/BgSceneStatusRule.java @@ -11,9 +11,12 @@ 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; @@ -69,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); - } - }, /** * 道岔解封背景:将道岔设置为封锁 */ @@ -87,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); } }, @@ -109,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); } }, @@ -231,6 +246,19 @@ public enum BgSceneStatusRule { 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); + } + }, /** * 区段激活背景 */ @@ -246,7 +274,7 @@ public enum BgSceneStatusRule { for (Section logic : axleSection.getLogicList()) { logic.setCutOff(true); } - return null; + return getBgScene(simulation); } }, /** @@ -260,7 +288,7 @@ public enum BgSceneStatusRule { return null; } }, - SECTION_CONFIRM_AXIS_VALID_BG_SCENE("") { + SECTION_CONFIRM_AXIS_VALID_BG_SCENE("设置计轴生效背景") { @Override public String doHandle(Simulation simulation, MapElement mapElement) { Section section = (Section) mapElement; @@ -269,6 +297,34 @@ public enum BgSceneStatusRule { } 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; } }, @@ -282,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); + } } + ; /** @@ -403,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); - } - - /** * 重启联锁机 */ @@ -458,6 +536,17 @@ public enum BgSceneStatusRule { 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); diff --git a/src/main/java/club/joylink/rtss/vo/training2/rule/MapDeviceRule.java b/src/main/java/club/joylink/rtss/vo/training2/rule/MapDeviceRule.java index bf57eaeaf..4d87f5f46 100644 --- a/src/main/java/club/joylink/rtss/vo/training2/rule/MapDeviceRule.java +++ b/src/main/java/club/joylink/rtss/vo/training2/rule/MapDeviceRule.java @@ -4,42 +4,14 @@ 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 filterMapDeviceList(Simulation simulation) { - boolean isMETRO = Simulation.Type.METRO.equals(simulation.getBuildParams().getWorkParamVO().getType()); - if (!isMETRO) { - return List.of(); - } - List signalList = METRO_DEPARTURE_SIGNAL_LIST.filterMapDeviceList(simulation); - List routeList = new ArrayList<>(); - signalList.forEach(s -> routeList.addAll(s.getRouteList())); - return generateRandomElement(routeList, 2); - } - }, - RAILWAY_PICK_ROUTE_LIST("大铁接车进路列表") { - @Override - public List filterMapDeviceList(Simulation simulation) { - boolean isRailWay = Simulation.Type.RAILWAY.equals(simulation.getBuildParams().getWorkParamVO().getType()); - if (!isRailWay) { - return List.of(); - } - List 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 filterMapDeviceList(Simulation simulation) { @@ -50,62 +22,87 @@ public enum MapDeviceRule { return generateRandomElement(stationList, 1); } }, + STAND_LIST("站台列表"){ + @Override + public List filterMapDeviceList(Simulation simulation) { + List stationList = STATION_LIST.filterMapDeviceList(simulation); + Station station = stationList.get(0); + return MapDeviceRule.generateRandomElement(station.getAllStandList(), 2); + } + }, + ROUTE_LIST("进路列表") { + @Override + public List filterMapDeviceList(Simulation simulation) { + List stationList = STATION_LIST.filterMapDeviceList(simulation); + Station station = stationList.get(0); + List 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 filterMapDeviceList(Simulation simulation) { - List switchList = simulation.getRepository().getSwitchList(); + List stationList = STATION_LIST.filterMapDeviceList(simulation); + Station station = stationList.get(0); + List switchList = simulation.getRepository().getSwitchList().stream() + .filter(aSwitch -> station.equals(aSwitch.getDeviceStation())).collect(Collectors.toList()); return generateRandomElement(switchList, 2); } }, SIGNAL_LIST("信号机列表") { @Override public List filterMapDeviceList(Simulation simulation) { - List signalList = simulation.getRepository().getSignalList(); + List stationList = STATION_LIST.filterMapDeviceList(simulation); + Station station = stationList.get(0); + List signalList = new ArrayList<>(); + station.getAllStandList().stream().filter(stand -> stand.getSection().getSignalToRight() != null) + .forEach(stand -> signalList.add(stand.getSection().getSignalToRight())); return generateRandomElement(signalList, 2); } }, - METRO_DEPARTURE_SIGNAL_LIST("地铁信号机列表") { - @Override - public List filterMapDeviceList(Simulation simulation) { - List signalList = simulation.getRepository().getStandList().stream().map(s -> s.getSection().getSignalToRight()) - .filter(s -> s != null && !CollectionUtils.isEmpty(s.getRouteList())).collect(Collectors.toList()); - return generateRandomElement(signalList, 2); - } - }, - RAILWAY_DEPARTURE_SIGNAL_LIST("大铁发车信号机列表") { - @Override - public List filterMapDeviceList(Simulation simulation) { - List signalList = simulation.getRepository().getSignalList().stream() - .filter(s -> Signal.SignalType.DEPARTURE.equals(s.getType())).collect(Collectors.toList()); - return generateRandomElement(signalList, 2); - } - }, - SECTION_LIST("普通区段列表") { + SECTION_LIST("区段列表") { @Override public List
filterMapDeviceList(Simulation simulation) { - List signalList = simulation.getRepository().getStandList().stream().map(s -> s.getSection().getSignalToRight()) - .filter(s -> s != null && !CollectionUtils.isEmpty(s.getRouteList())).collect(Collectors.toList()); - signalList = generateRandomElement(signalList, 2); + List routeList = ROUTE_LIST.filterMapDeviceList(simulation); List
sectionList = new ArrayList<>(100); - signalList.forEach(s -> s.getRouteList().forEach(r -> sectionList.addAll(r.getSectionList()))); + routeList.forEach(route -> sectionList.addAll(route.getSectionList())); + return generateRandomElement(sectionList, 2); + } + }, + SECTION_STAND_TURN_BACK_LIST("折返区段列表") { + @Override + public List
filterMapDeviceList(Simulation simulation) { + List
sectionList = simulation.getRepository().getSectionList().stream() + .filter(section -> section.isStandTrack() && section.isTurnBackTrack()) + .collect(Collectors.toList()); + return MapDeviceRule.generateRandomElement(sectionList, 2); + } + }, + SECTION_NO_AXLE_COUNTER_LIST("非计轴区段列表") { + @Override + public List
filterMapDeviceList(Simulation simulation) { + List stationCodeList = simulation.getBuildParams().getMap().getGraphDataNew().getStationList() + .stream().filter(s -> s.isVisible() && s.isCentralized() && s.isCiStation()).map(MapStationNewVO::getCode) + .collect(Collectors.toList()); + List
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
filterMapDeviceList(Simulation simulation) { + List stationCodeList = simulation.getBuildParams().getMap().getGraphDataNew().getStationList() + .stream().filter(s -> s.isVisible() && s.isCentralized() && s.isCiStation()).map(MapStationNewVO::getCode) + .collect(Collectors.toList()); List
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); } - }, - SECTION_ROUTE_LIST("") { - @Override - public List
filterMapDeviceList(Simulation simulation) { - List signalList = simulation.getRepository().getStandList().stream() - .map(s -> s.getSection().getSignalToRight()).filter(s -> s != null && !CollectionUtils.isEmpty(s.getRouteList())).collect(Collectors.toList()); - return null; - } } ; diff --git a/src/main/java/club/joylink/rtss/vo/training2/rule/MapElementRule.java b/src/main/java/club/joylink/rtss/vo/training2/rule/MapElementRule.java index 95e6811c6..bba1119b6 100644 --- a/src/main/java/club/joylink/rtss/vo/training2/rule/MapElementRule.java +++ b/src/main/java/club/joylink/rtss/vo/training2/rule/MapElementRule.java @@ -36,6 +36,8 @@ public abstract class MapElementRule { 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); } diff --git a/src/main/resources/mybatis/mapper/training2/RtsTraining2RuleMapper.xml b/src/main/resources/mybatis/mapper/training2/RtsTraining2RuleMapper.xml index 04b701a66..7b39cf8ab 100644 --- a/src/main/resources/mybatis/mapper/training2/RtsTraining2RuleMapper.xml +++ b/src/main/resources/mybatis/mapper/training2/RtsTraining2RuleMapper.xml @@ -4,6 +4,7 @@ + @@ -82,7 +83,7 @@ - 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 @@ -138,11 +139,11 @@ 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 @@ sim_type, + + line_code, + device_rule, @@ -202,6 +206,9 @@ #{simType,jdbcType=VARCHAR}, + + #{lineCode,jdbcType=VARCHAR}, + #{deviceRule,jdbcType=VARCHAR}, @@ -250,6 +257,9 @@ sim_type = #{record.simType,jdbcType=VARCHAR}, + + line_code = #{record.lineCode,jdbcType=VARCHAR}, + device_rule = #{record.deviceRule,jdbcType=VARCHAR}, @@ -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 @@ sim_type = #{simType,jdbcType=VARCHAR}, + + line_code = #{lineCode,jdbcType=VARCHAR}, + device_rule = #{deviceRule,jdbcType=VARCHAR}, @@ -381,6 +396,7 @@ 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 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}, From c059b435007fb8642385487b7bb88633acf9b755 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Mon, 5 Dec 2022 15:50:25 +0800 Subject: [PATCH 4/5] =?UTF-8?q?vrTrain=E8=83=8C=E6=99=AF=E4=BF=9D=E5=AD=98?= =?UTF-8?q?bug=E4=BF=AE=E6=94=B9=EF=BC=9B=E7=A7=BB=E9=99=A4vrTrain?= =?UTF-8?q?=E9=87=8C=E7=9A=84Audio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ATS/service/AtsTrainMonitorService.java | 4 - .../cbtc/ISCS/OnBoardPisService.java | 78 +++++++++---------- .../cbtc/data/storage/support/StorageMa.java | 8 +- .../vr/StorageVirtualRealityDevice.java | 3 - .../vr/StorageVirtualRealityTrain.java | 20 ++--- .../cbtc/data/vr/VirtualRealityTrain.java | 9 +-- 6 files changed, 61 insertions(+), 61 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainMonitorService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainMonitorService.java index 42aa490d9..494034c94 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainMonitorService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainMonitorService.java @@ -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 trainList = simulation.getRepository().getSuperviseTrainList(); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ISCS/OnBoardPisService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ISCS/OnBoardPisService.java index 7550c5937..a84ea74ec 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ISCS/OnBoardPisService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ISCS/OnBoardPisService.java @@ -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); +// } +//} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/support/StorageMa.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/support/StorageMa.java index aab01816c..5ac473614 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/support/StorageMa.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/support/StorageMa.java @@ -5,8 +5,14 @@ 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; @@ -37,7 +43,7 @@ public class StorageMa { } public MaService.Ma convert2SimulationObj(SimulationDataRepository repository) { - VirtualRealityTrain train = repository.getByCode(trainCode, VirtualRealityTrain.class); + 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) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealityDevice.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealityDevice.java index 9b1aa4050..5291c52ff 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealityDevice.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealityDevice.java @@ -10,9 +10,6 @@ import lombok.Setter; @Setter @NoArgsConstructor public abstract class StorageVirtualRealityDevice extends StorageDevice { - - private String code; - public StorageVirtualRealityDevice(VirtualRealityDevice device) { super(device.getCode()); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealityTrain.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealityTrain.java index c62fe52c5..4e76597c4 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealityTrain.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealityTrain.java @@ -13,12 +13,12 @@ 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.VirtualRealityAudio; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; 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.LinkedHashSet; @@ -95,7 +95,7 @@ public class StorageVirtualRealityTrain extends StorageVirtualRealityDevice { private boolean released; private LinkedHashSet confirmationMessages; private boolean atoCanOpen; - private String vrAudioCode; +// private String vrAudioCode; private StorageDriveParamVO robotDriveParam; public StorageVirtualRealityTrain(VirtualRealityTrain virtualRealityTrain) { @@ -194,9 +194,9 @@ public class StorageVirtualRealityTrain extends StorageVirtualRealityDevice { storageVirtualRealityTrain.setReleased(virtualRealityTrain.isReleased()); storageVirtualRealityTrain.setConfirmationMessages(virtualRealityTrain.getConfirmationMessages()); storageVirtualRealityTrain.setAtoCanOpen(virtualRealityTrain.isAtoCanOpen()); - if (virtualRealityTrain.getVrAudio() != null) { - storageVirtualRealityTrain.setVrAudioCode(virtualRealityTrain.getVrAudio().getCode()); - } +// if (virtualRealityTrain.getVrAudio() != null) { +// storageVirtualRealityTrain.setVrAudioCode(virtualRealityTrain.getVrAudio().getCode()); +// } if (virtualRealityTrain.getRobotDriveParam() != null) { storageVirtualRealityTrain.setRobotDriveParam(new StorageDriveParamVO(virtualRealityTrain.getRobotDriveParam())); } @@ -298,11 +298,13 @@ public class StorageVirtualRealityTrain extends StorageVirtualRealityDevice { virtualRealityTrain.setPositioned(positioned); virtualRealityTrain.setRunningTime(runningTime); virtualRealityTrain.setReleased(released); - virtualRealityTrain.setConfirmationMessages(confirmationMessages); - virtualRealityTrain.setAtoCanOpen(atoCanOpen); - if (vrAudioCode != null) { - virtualRealityTrain.setVrAudio(repository.getByCode(vrAudioCode, VirtualRealityAudio.class)); + 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)); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java index 93f47bfc5..33ff4cdda 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java @@ -443,14 +443,14 @@ public class VirtualRealityTrain extends VirtualRealityDevice { /** * 确认信息 */ - private LinkedHashSet confirmationMessages = new LinkedHashSet<>(); + private final LinkedHashSet confirmationMessages = new LinkedHashSet<>(); /** * ato可以开启 */ private boolean atoCanOpen; - private VirtualRealityAudio vrAudio; +// private VirtualRealityAudio vrAudio; private DriveParamVO robotDriveParam = new DriveParamVO(); @@ -521,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 @@ -571,7 +571,6 @@ 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; From d1793138779921760a5189de2556e8e9ca6d603d Mon Sep 17 00:00:00 2001 From: tiger_zhou <123456> Date: Mon, 5 Dec 2022 17:04:21 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=80=83=E8=AF=95?= =?UTF-8?q?=E8=93=9D=E5=9B=BE=20map=5Fid=20=E4=B8=8D=E8=83=BD=E4=B8=BA?= =?UTF-8?q?=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/20221012-xia-paper.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/20221012-xia-paper.sql b/sql/20221012-xia-paper.sql index 5fe745c7e..7f2cb09d9 100644 --- a/sql/20221012-xia-paper.sql +++ b/sql/20221012-xia-paper.sql @@ -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 '启用截止时间',