From f7cb5fca157e2eb17e927a0d295a41c690e75ad2 Mon Sep 17 00:00:00 2001 From: thesai <1021828630@qq.com> Date: Thu, 25 Nov 2021 10:06:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=BF=E7=9C=9F=E5=AD=98=E5=82=A8=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=BB=93=E6=9E=84=E4=BF=AE=E6=94=B9=E3=80=81=E8=A1=A5?= =?UTF-8?q?=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/storage/device/StorageCatenary.java | 27 +++- .../data/storage/device/StorageCycle.java | 26 ++-- .../device/StorageDelayUnlockDevice.java | 37 +++-- .../data/storage/device/StorageDevice.java | 2 + .../cbtc/data/storage/device/StorageESP.java | 21 ++- .../device/StorageMayOutOfOrderDevice.java | 19 ++- .../cbtc/data/storage/device/StoragePSD.java | 45 +++--- .../data/storage/device/StorageRoute.java | 86 ++++++----- .../storage/device/StorageRouteOverlap.java | 52 ++++--- .../data/storage/device/StorageSection.java | 86 ++++------- .../data/storage/device/StorageSignal.java | 106 ++++++------- .../data/storage/device/StorageStand.java | 141 ++++++++---------- .../data/storage/device/StorageStation.java | 43 +++--- .../storage/device/StorageStatusDevice.java | 53 +++++++ .../data/storage/device/StorageSwitch.java | 61 +++----- .../cbtc/data/storage/device/StorageZC.java | 9 +- 16 files changed, 425 insertions(+), 389 deletions(-) create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageStatusDevice.java diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageCatenary.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageCatenary.java index 3d9b086f2..2bb5c362e 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageCatenary.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageCatenary.java @@ -1,13 +1,13 @@ package club.joylink.rtss.simulation.cbtc.data.storage.device; -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.map.Catenary; import club.joylink.rtss.simulation.cbtc.data.map.MapElement; 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; @@ -15,7 +15,7 @@ import lombok.Setter; @Getter @Setter @NoArgsConstructor -public class StorageCatenary extends StorageDevice { +public class StorageCatenary extends StorageMayOutOfOrderDevice { /** * 是否带电 @@ -24,21 +24,32 @@ public class StorageCatenary extends StorageDevice { @JsonDeserialize(using = Boolean2NumDeserializer.class) private Boolean on; - public StorageCatenary(String code) { - super(code); + public StorageCatenary(Catenary catenary) { + super(catenary); } public static StorageCatenary convert2Storage(Catenary catenary) { - StorageCatenary storageCatenary = new StorageCatenary(catenary.getCode()); - if (!catenary.isOn()) { - storageCatenary.setOn(catenary.isOn()); + StorageCatenary storageCatenary = new StorageCatenary(catenary); + if (storageCatenary.convert(catenary)) { return storageCatenary; } return null; } + @Override + public boolean convert(MapElement element) { + boolean change = super.convert(element); + Catenary catenary = (Catenary) element; + if (!catenary.isOn()) { + change = true; + this.setOn(catenary.isOn()); + } + return change; + } + @Override public void recover2Simulation(MapElement element, Simulation simulation, SimulationDataRepository repository) { + super.recover2Simulation(element, simulation, repository); Catenary catenary = (Catenary) element; catenary.setOn(on != null ? on : false); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageCycle.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageCycle.java index 569694fd1..c46543df7 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageCycle.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageCycle.java @@ -14,7 +14,7 @@ import lombok.Setter; @Getter @Setter @NoArgsConstructor -public class StorageCycle extends StorageMayOutOfOrderDevice { +public class StorageCycle extends StorageDevice { /** 是否已经设置 */ @@ -22,23 +22,29 @@ public class StorageCycle extends StorageMayOutOfOrderDevice { @JsonDeserialize(using = Boolean2NumDeserializer.class) private Boolean setUp; - public StorageCycle(String code, MayOutOfOrderDevice.DeviceFault fault) { - super(code, fault); + public StorageCycle(Cycle cycle) { + super(cycle.getCode()); } public static StorageCycle convert2Storage(Cycle cycle) { - boolean change = false; - StorageCycle storageCycle = new StorageCycle(cycle.getCode(), null); - if (cycle.isSetUp()) { - change = true; - storageCycle.setSetUp(cycle.isSetUp()); - } - if (change) { + StorageCycle storageCycle = new StorageCycle(cycle); + if (storageCycle.convert(cycle)) { return storageCycle; } return null; } + @Override + public boolean convert(MapElement element) { + boolean change = false; + Cycle cycle = (Cycle) element; + if (cycle.isSetUp()) { + change = true; + this.setSetUp(cycle.isSetUp()); + } + return change; + } + @Override public void recover2Simulation(MapElement element, Simulation simulation, SimulationDataRepository repository) { Cycle cycle = (Cycle) element; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageDelayUnlockDevice.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageDelayUnlockDevice.java index 9c47486b5..71d5080e6 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageDelayUnlockDevice.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageDelayUnlockDevice.java @@ -1,27 +1,46 @@ package club.joylink.rtss.simulation.cbtc.data.storage.device; +import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; import club.joylink.rtss.simulation.cbtc.data.map.DelayUnlockDevice; -import club.joylink.rtss.simulation.cbtc.data.map.MayOutOfOrderDevice; -import club.joylink.rtss.simulation.cbtc.data.map.Route; -import club.joylink.rtss.simulation.cbtc.data.map.Section; +import club.joylink.rtss.simulation.cbtc.data.map.MapElement; import lombok.Getter; import lombok.NoArgsConstructor; +import lombok.Setter; @Getter +@Setter @NoArgsConstructor public class StorageDelayUnlockDevice extends StorageMayOutOfOrderDevice { private int remain; - public StorageDelayUnlockDevice(String code, MayOutOfOrderDevice.DeviceFault fault) { - super(code, fault); + public StorageDelayUnlockDevice(DelayUnlockDevice device) { + super(device); } - public void saveFrom(DelayUnlockDevice device) { - this.remain = device.getRemain(); +// public void saveFrom(DelayUnlockDevice device) { +// this.remain = device.getRemain(); +// } + +// protected void recoverTo(DelayUnlockDevice device, SimulationDataRepository repository) { +// device.recover(this.remain); +// } + + @Override + public boolean convert(MapElement element) { + boolean change = super.convert(element); + DelayUnlockDevice device = (DelayUnlockDevice) element; + if (device.getRemain() > 0) { + change = true; + this.remain = device.getRemain(); + } + return change; } - protected void recoverTo(DelayUnlockDevice device, SimulationDataRepository repository) { - device.recover(this.remain); + @Override + public void recover2Simulation(MapElement element, Simulation simulation, SimulationDataRepository repository) { + super.recover2Simulation(element, simulation, repository); + DelayUnlockDevice device = (DelayUnlockDevice) element; + device.recover(remain); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageDevice.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageDevice.java index 4458ddcce..d51305c7b 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageDevice.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageDevice.java @@ -17,5 +17,7 @@ public abstract class StorageDevice { this.code = code; } + public abstract boolean convert(MapElement element); + public abstract void recover2Simulation(MapElement element, Simulation simulation, SimulationDataRepository repository); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageESP.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageESP.java index a60d18b8a..d2ac7227c 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageESP.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageESP.java @@ -29,18 +29,22 @@ public class StorageESP extends StorageDevice { } public static StorageESP convert2Storage(ESP esp) { - boolean change = false; StorageESP storageESP = new StorageESP(esp.getCode()); + if (storageESP.convert(esp)) { + return storageESP; + } + return null; + } + + @Override + public boolean convert(MapElement element) { + boolean change = false; + ESP esp = (ESP) element; if (esp.isEffective()) { change = true; - storageESP.setEffective(esp.isEffective()); - } - - if (change) { - return storageESP; - } else { - return null; + this.setEffective(esp.isEffective()); } + return change; } @Override @@ -48,4 +52,5 @@ public class StorageESP extends StorageDevice { ESP esp = (ESP) element; esp.setEffective(effective != null ? effective : false); } + } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageMayOutOfOrderDevice.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageMayOutOfOrderDevice.java index 897948c7b..b8bd6b4c3 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageMayOutOfOrderDevice.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageMayOutOfOrderDevice.java @@ -11,16 +11,27 @@ import lombok.Setter; @Getter @Setter @NoArgsConstructor -public class StorageMayOutOfOrderDevice extends StorageDevice { +public class StorageMayOutOfOrderDevice extends StorageStatusDevice { private MayOutOfOrderDevice.DeviceFault fault; - public StorageMayOutOfOrderDevice(String code, MayOutOfOrderDevice.DeviceFault fault) { - super(code); - this.fault = fault; + public StorageMayOutOfOrderDevice(MayOutOfOrderDevice device) { + super(device); + } + + @Override + public boolean convert(MapElement element) { + boolean change = super.convert(element); + MayOutOfOrderDevice device = (MayOutOfOrderDevice) element; + if (device.getFault() != null) { + change = true; + this.fault = device.getFault(); + } + return change; } @Override public void recover2Simulation(MapElement element, Simulation simulation, SimulationDataRepository repository) { + super.recover2Simulation(element, simulation, repository); MayOutOfOrderDevice mayOutOfOrderDevice = (MayOutOfOrderDevice) element; mayOutOfOrderDevice.setFault(fault); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StoragePSD.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StoragePSD.java index 8ecf291bc..90ea52148 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StoragePSD.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StoragePSD.java @@ -15,7 +15,7 @@ import lombok.Setter; @Getter @Setter @NoArgsConstructor -public class StoragePSD extends StorageDevice { +public class StoragePSD extends StorageStatusDevice { /** * 屏蔽门是否关闭 @@ -38,13 +38,6 @@ public class StoragePSD extends StorageDevice { @JsonDeserialize(using = Boolean2NumDeserializer.class) private Boolean interlockRelease; - /** - * 无状态 - */ - @JsonSerialize(using = Boolean2NumSerializer.class) - @JsonDeserialize(using = Boolean2NumDeserializer.class) - private Boolean noStatus; - // public StoragePSD(PSD psd) { // super(psd.getCode()); // if (!psd.isClose()) { @@ -58,43 +51,43 @@ public class StoragePSD extends StorageDevice { // } // } - public StoragePSD(String code) { - super(code); + public StoragePSD(PSD psd) { + super(psd); } public static StoragePSD convert2Storage(PSD psd) { - boolean change = false; - StoragePSD storagePSD = new StoragePSD(psd.getCode()); + StoragePSD storagePSD = new StoragePSD(psd); + if (storagePSD.convert(psd)) { + return storagePSD; + } + return null; + } + + @Override + public boolean convert(MapElement element) { + boolean change = super.convert(element); + PSD psd = (PSD) element; if (!psd.isClose()) { change = true; - storagePSD.setClose(psd.isClose()); + this.setClose(psd.isClose()); } if (!psd.isLock()) { change = true; - storagePSD.setLock(psd.isLock()); + this.setLock(psd.isLock()); } if (psd.isInterlockRelease()) { change = true; - storagePSD.setInterlockRelease(psd.isInterlockRelease()); - } - if (psd.isNoStatus()) { - change = true; - storagePSD.setNoStatus(psd.isNoStatus()); - } - - if (change) { - return storagePSD; - } else { - return null; + this.setInterlockRelease(psd.isInterlockRelease()); } + return change; } @Override public void recover2Simulation(MapElement element, Simulation simulation, SimulationDataRepository repository) { + super.recover2Simulation(element, simulation, repository); PSD psd = (PSD) element; psd.setClose(close != null ? close : true); psd.setLock(lock != null ? lock : true); psd.setInterlockRelease(interlockRelease != null ? interlockRelease : false); - psd.setNoStatus(noStatus != null ? noStatus : false); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageRoute.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageRoute.java index a9d41058a..755c350ac 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageRoute.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageRoute.java @@ -104,52 +104,57 @@ public class StorageRoute extends StorageDevice { } public static StorageRoute convert2Storage(Route route) { - boolean change = false; StorageRoute storageRoute = new StorageRoute(route.getCode()); - if (!route.isAtsControl()) { - change = true; - storageRoute.setAtsControl(route.isAtsControl()); - } - if (route.isFleetMode()) { - change = true; - storageRoute.setFleetMode(route.isFleetMode()); - } - if (route.isCiControl()) { - change = true; - storageRoute.setCiControl(route.isCiControl()); - } - if (route.isSetting()) { - change = true; - storageRoute.setSetting(route.isSetting()); - storageRoute.setSettingStartTime(route.getSettingStartTime()); - } - if (route.isGuideSetting()) { - change = true; - storageRoute.setSettingGuide(route.isGuideSetting()); - } - if (route.isLock()) { - change = true; - storageRoute.setLock(route.isLock()); - } - if (route.getDelayUnlockDevice() != null) { - change = true; - storageRoute.setDelayUnlockDevice(route.getDelayUnlockDevice().getCode()); - } - if (route.isNormalUnlock()) { - change = true; - storageRoute.setNormalUnlock(route.isNormalUnlock()); - } - if (Objects.nonNull(route.getUnlockedSection())) { - change = true; - storageRoute.setUnlockedSection(route.getUnlockedSection().getCode()); - } - - if (change) { + if (storageRoute.convert(route)) { return storageRoute; } return null; } + @Override + public boolean convert(MapElement element) { + boolean change = false; + Route route = (Route) element; + if (!route.isAtsControl()) { + change = true; + this.setAtsControl(route.isAtsControl()); + } + if (route.isFleetMode()) { + change = true; + this.setFleetMode(route.isFleetMode()); + } + if (route.isCiControl()) { + change = true; + this.setCiControl(route.isCiControl()); + } + if (route.isSetting()) { + change = true; + this.setSetting(route.isSetting()); + this.setSettingStartTime(route.getSettingStartTime()); + } + if (route.isGuideSetting()) { + change = true; + this.setSettingGuide(route.isGuideSetting()); + } + if (route.isLock()) { + change = true; + this.setLock(route.isLock()); + } + if (route.getDelayUnlockDevice() != null) { + change = true; + this.setDelayUnlockDevice(route.getDelayUnlockDevice().getCode()); + } + if (route.isNormalUnlock()) { + change = true; + this.setNormalUnlock(route.isNormalUnlock()); + } + if (Objects.nonNull(route.getUnlockedSection())) { + change = true; + this.setUnlockedSection(route.getUnlockedSection().getCode()); + } + return change; + } + @Override public void recover2Simulation(MapElement element, Simulation simulation, SimulationDataRepository repository) { Route route = (Route) element; @@ -168,4 +173,5 @@ public class StorageRoute extends StorageDevice { route.setUnlockedSection(repository.getByCode(this.unlockedSection, Section.class)); } } + } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageRouteOverlap.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageRouteOverlap.java index 1d7d12acd..9dcbf6f3b 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageRouteOverlap.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageRouteOverlap.java @@ -49,36 +49,40 @@ public class StorageRouteOverlap extends StorageDevice { } public static StorageRouteOverlap convert2Storage(RouteOverlap overlap) { - boolean change = false; StorageRouteOverlap storageOverlap = new StorageRouteOverlap(overlap.getCode()); - if (overlap.isReleasing()) { - change = true; - storageOverlap.setReleasing(overlap.isReleasing()); - } - if (overlap.isSetting()) { - change = true; - storageOverlap.setSetting(overlap.isSetting()); - } - if (overlap.isLock()) { - change = true; - storageOverlap.setLock(overlap.isLock()); - } - if (overlap.getRemainTime() > 0) { - change = true; - storageOverlap.setRemainTime(overlap.getRemainTime()); - } - - if (Objects.nonNull(overlap.getSettingStartTime())) { - change = true; - storageOverlap.setSettingStartTime(overlap.getSettingStartTime()); - } - - if (change) { + if (storageOverlap.convert(overlap)) { return storageOverlap; } return null; } + @Override + public boolean convert(MapElement element) { + boolean change = false; + RouteOverlap overlap = (RouteOverlap) element; + if (overlap.isReleasing()) { + change = true; + this.setReleasing(overlap.isReleasing()); + } + if (overlap.isSetting()) { + change = true; + this.setSetting(overlap.isSetting()); + } + if (overlap.isLock()) { + change = true; + this.setLock(overlap.isLock()); + } + if (overlap.getRemainTime() > 0) { + change = true; + this.setRemainTime(overlap.getRemainTime()); + } + if (Objects.nonNull(overlap.getSettingStartTime())) { + change = true; + this.setSettingStartTime(overlap.getSettingStartTime()); + } + return change; + } + @Override public void recover2Simulation(MapElement element, Simulation simulation, SimulationDataRepository repository) { RouteOverlap overlap = (RouteOverlap) element; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageSection.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageSection.java index e8a7a5767..68b9d9fc6 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageSection.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageSection.java @@ -15,6 +15,7 @@ import lombok.NoArgsConstructor; import lombok.Setter; import java.util.Objects; +import java.util.concurrent.atomic.AtomicInteger; @Getter @Setter @@ -88,103 +89,79 @@ public class StorageSection extends StorageDelayUnlockDevice { */ private Integer speedUpLimit; + private Integer speedLimitBeforeFault; + /** * 区故解第一根延时解锁剩余时间 */ private Integer delayTime; - /** - * 无状态 - */ - @JsonSerialize(using = Boolean2NumSerializer.class) - @JsonDeserialize(using = Boolean2NumDeserializer.class) - private Boolean noStatus; - - public StorageSection(String code, MayOutOfOrderDevice.DeviceFault fault) { - super(code, fault); + public StorageSection(Section section) { + super(section); } -// public StorageSection(Section section) { -// super(section.getCode()); -// blockade = section.isBlockade(); -// routeCode = section.getRouteCode(); -// routeLock = section.isRouteLock(); -// overlapLock = section.isOverlapLock(); -// ctOccupied = section.isCtOccupied(); -// nctOccupied = section.isNctOccupied(); -// cutOff = section.isCutOff(); -// invalid = section.isInvalid(); -// faultLock = section.isFaultLock(); -// speedUpLimit = section.getSpeedUpLimit(); -// } - public static StorageSection convert2Storage(Section section) { - boolean change = false; - StorageSection storageSection = new StorageSection(section.getCode(), section.getFault()); - if (storageSection.isFault()) { - change = true; + StorageSection storageSection = new StorageSection(section); + if (storageSection.convert(section)) { + return storageSection; } + return null; + } + + @Override + public boolean convert(MapElement element) { + boolean change = super.convert(element); + Section section = (Section) element; if (section.isBlockade()) { change = true; - storageSection.setBlockade(section.isBlockade()); + this.setBlockade(section.isBlockade()); } if (section.isRouteLock()) { change = true; - storageSection.setRouteLock(section.isRouteLock()); + this.setRouteLock(section.isRouteLock()); } Route route = section.getRoute(); if (route != null) { change = true; - storageSection.setRoute(route.getCode()); + this.setRoute(route.getCode()); } if (section.isLockRight()) { change = true; - storageSection.setLockRight(section.isLockRight()); + this.setLockRight(section.isLockRight()); } if (section.isOverlapLock()) { change = true; - storageSection.setOverlapLock(section.isOverlapLock()); + this.setOverlapLock(section.isOverlapLock()); } if (section.isCtOccupied()) { change = true; - storageSection.setCtOccupied(section.isCtOccupied()); + this.setCtOccupied(section.isCtOccupied()); } if (section.isNctOccupied()) { change = true; - storageSection.setNctOccupied(section.isNctOccupied()); + this.setNctOccupied(section.isNctOccupied()); } if (section.isCutOff()) { change = true; - storageSection.setCutOff(section.isCutOff()); + this.setCutOff(section.isCutOff()); } if (section.isInvalid()) { change = true; - storageSection.setInvalid(section.isInvalid()); + this.setInvalid(section.isInvalid()); } if (section.isFaultLock()) { change = true; - storageSection.setFaultLock(section.isFaultLock()); + this.setFaultLock(section.isFaultLock()); } if (!Objects.equals(section.getSpeedUpLimit(), -1)) { change = true; - storageSection.setSpeedUpLimit(section.getSpeedUpLimit()); + this.setSpeedUpLimit(section.getSpeedUpLimit()); } - if (section.getRemain() > 0) { + if (section.getSpeedLimitBeforeFault() != null) { change = true; - storageSection.saveFrom(section); + this.speedLimitBeforeFault = section.getSpeedLimitBeforeFault(); } - if (section.isNoStatus()) { - change = true; - storageSection.setNoStatus(section.isNoStatus()); - } - if (section.isFault()) { - change = true; - } - - if (change) { - return storageSection; - } - return null; + return change; } @Override @@ -202,9 +179,6 @@ public class StorageSection extends StorageDelayUnlockDevice { section.setInvalid(invalid != null? invalid : false); section.setFaultLock(faultLock != null ? faultLock : false); section.setSpeedUpLimit(speedUpLimit != null? speedUpLimit : -1); - if (this.getRemain() > 0) { - this.recoverTo(section, repository); - } - section.setNoStatus(noStatus != null ? noStatus : false); + section.setSpeedLimitBeforeFault(speedLimitBeforeFault); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageSignal.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageSignal.java index 624e2c5a0..175ffa2c6 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageSignal.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageSignal.java @@ -81,73 +81,57 @@ public class StorageSignal extends StorageDelayUnlockDevice { @JsonDeserialize(using = Boolean2NumDeserializer.class) private Boolean redOpen; - /** - * 无状态 - */ - @JsonSerialize(using = Boolean2NumSerializer.class) - @JsonDeserialize(using = Boolean2NumDeserializer.class) - private Boolean noStatus; - - public StorageSignal(String code, MayOutOfOrderDevice.DeviceFault fault) { - super(code, fault); + public StorageSignal(Signal signal) { + super(signal); } public static StorageSignal convert2Storage(Signal signal) { - boolean change = false; - StorageSignal storageSignal = new StorageSignal(signal.getCode(), signal.getFault()); - if (storageSignal.isFault()) { - change = true; - } - if (signal.getLockedRouteCode() != null) { - change = true; - storageSignal.setLockedRouteCode(signal.getLockedRouteCode()); - } - if (signal.isBlockade()) { - change = true; - storageSignal.setBlockade(signal.isBlockade()); - } - if (signal.getLevel() != 1) { - change = true; - storageSignal.setLevel(signal.getLevel()); - } - if (signal.isReblockade()) { - change = true; - storageSignal.setReblockade(signal.isReblockade()); - } - if (signal.isFpl()) { - change = true; - storageSignal.setFpl(signal.isFpl()); - } - if (!signal.isLogicLight()) { - change = true; - storageSignal.setLogicLight(signal.isLogicLight()); - } - if (!signal.getSignalModel().getDefaultAspect().equals(signal.getAspect())) { - change = true; - storageSignal.setAspect(signal.getAspect()); - } - if (signal.isForbidden()) { - change = true; - storageSignal.setForbidden(signal.isForbidden()); - } - if (signal.getRemain() > 0) { - change = true; - storageSignal.saveFrom(signal); - } - if (signal.isNoStatus()) { - change = true; - storageSignal.setNoStatus(signal.isNoStatus()); - } - if (signal.isFault()) { - change = true; - } - - if (change) { + StorageSignal storageSignal = new StorageSignal(signal); + if (storageSignal.convert(signal)) { return storageSignal; } return null; } + @Override + public boolean convert(MapElement element) { + boolean change = super.convert(element); + Signal signal = (Signal) element; + if (signal.getLockedRouteCode() != null) { + change = true; + this.setLockedRouteCode(signal.getLockedRouteCode()); + } + if (signal.isBlockade()) { + change = true; + this.setBlockade(signal.isBlockade()); + } + if (signal.getLevel() != 1) { + change = true; + this.setLevel(signal.getLevel()); + } + if (signal.isReblockade()) { + change = true; + this.setReblockade(signal.isReblockade()); + } + if (signal.isFpl()) { + change = true; + this.setFpl(signal.isFpl()); + } + if (!signal.isLogicLight()) { + change = true; + this.setLogicLight(signal.isLogicLight()); + } + if (!signal.getSignalModel().getDefaultAspect().equals(signal.getAspect())) { + change = true; + this.setAspect(signal.getAspect()); + } + if (signal.isForbidden()) { + change = true; + this.setForbidden(signal.isForbidden()); + } + return change; + } + @Override public void recover2Simulation(MapElement element, Simulation simulation, SimulationDataRepository repository) { super.recover2Simulation(element, simulation, repository); @@ -163,9 +147,5 @@ public class StorageSignal extends StorageDelayUnlockDevice { signal.setAspect(aspect); } signal.setForbidden(this.forbidden == null ? false : this.forbidden); - if (this.getRemain() > 0) { - this.recoverTo(signal, repository); - } - signal.setNoStatus(noStatus != null ? noStatus : false); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageStand.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageStand.java index 897586837..4e45e6c3e 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageStand.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageStand.java @@ -105,15 +105,8 @@ public class StorageStand extends StorageMayOutOfOrderDevice { @JsonDeserialize(using = Boolean2NumDeserializer.class) private Boolean parkingAlwaysValid; - /** - * 无状态 - */ - @JsonSerialize(using = Boolean2NumSerializer.class) - @JsonDeserialize(using = Boolean2NumDeserializer.class) - private Boolean noStatus; - - public StorageStand(String code, MayOutOfOrderDevice.DeviceFault fault) { - super(code, fault); + public StorageStand(Stand stand) { + super(stand); } // public StorageStand(Stand stand) { @@ -133,78 +126,73 @@ public class StorageStand extends StorageMayOutOfOrderDevice { // } public static StorageStand convert2Storage(Stand stand) { - boolean change = false; - StorageStand storageStand = new StorageStand(stand.getCode(), stand.getFault()); - if (storageStand.isFault()) { - change = true; - } - StorageESP storageESP = StorageESP.convert(stand.getEsp()); - if (storageESP != null) { - change = true; - storageStand.setEsp(storageESP); - } - if (stand.isTrainParking()) { - change = true; - storageStand.setTrainParking(stand.isTrainParking()); - } - if (stand.isEmergencyClosed()) { - change = true; - storageStand.setEmergencyClosed(stand.isEmergencyClosed()); - } - if (stand.getRemainTime() > 0) { - change = true; - storageStand.setRemainTime(stand.getRemainTime()); - } - if (stand.isStationHoldTrain()) { - change = true; - storageStand.setStationHoldTrain(stand.isStationHoldTrain()); - } - if (stand.isCenterHoldTrain()) { - change = true; - storageStand.setCenterHoldTrain(stand.isCenterHoldTrain()); - } - if (stand.isAutoHoldTrain()) { - change = true; - storageStand.setAutoHoldTrain(stand.isAutoHoldTrain()); - } - if (stand.isAllSkip()) { - change = true; - storageStand.setAllSkip(stand.isAssignSkip()); - } - if (!CollectionUtils.isEmpty(stand.getSkipSet())) { - change = true; - storageStand.setSkipSet(stand.getSkipSet()); - } - if (!Objects.equals(stand.getRunLevelTime(), 0)) { - change = true; - storageStand.setRunLevelTime(stand.getRunLevelTime()); - } - if (stand.isRunLevelTimeForever()) { - change = true; - storageStand.setRunLevelTimeForever(stand.isRunLevelTimeForever()); - } - if (!Objects.equals(stand.getParkingTime(), -1)) { - change = true; - storageStand.setParkingTime(stand.getParkingTime()); - } - if (stand.isParkingAlwaysValid()) { - change = true; - storageStand.setParkingAlwaysValid(stand.isParkingAlwaysValid()); - } - if (stand.isNoStatus()) { - change = true; - storageStand.setNoStatus(stand.isNoStatus()); - } - if (stand.isFault()) { - change = true; - } - - if (change) { + StorageStand storageStand = new StorageStand(stand); + if (storageStand.convert(stand)) { return storageStand; } return null; } + @Override + public boolean convert(MapElement element) { + boolean change = super.convert(element); + Stand stand = (Stand) element; + StorageESP storageESP = StorageESP.convert(stand.getEsp()); + if (storageESP != null) { + change = true; + this.setEsp(storageESP); + } + if (stand.isTrainParking()) { + change = true; + this.setTrainParking(stand.isTrainParking()); + } + if (stand.isEmergencyClosed()) { + change = true; + this.setEmergencyClosed(stand.isEmergencyClosed()); + } + if (stand.getRemainTime() > 0) { + change = true; + this.setRemainTime(stand.getRemainTime()); + } + if (stand.isStationHoldTrain()) { + change = true; + this.setStationHoldTrain(stand.isStationHoldTrain()); + } + if (stand.isCenterHoldTrain()) { + change = true; + this.setCenterHoldTrain(stand.isCenterHoldTrain()); + } + if (stand.isAutoHoldTrain()) { + change = true; + this.setAutoHoldTrain(stand.isAutoHoldTrain()); + } + if (stand.isAllSkip()) { + change = true; + this.setAllSkip(stand.isAssignSkip()); + } + if (!CollectionUtils.isEmpty(stand.getSkipSet())) { + change = true; + this.setSkipSet(stand.getSkipSet()); + } + if (!Objects.equals(stand.getRunLevelTime(), 0)) { + change = true; + this.setRunLevelTime(stand.getRunLevelTime()); + } + if (stand.isRunLevelTimeForever()) { + change = true; + this.setRunLevelTimeForever(stand.isRunLevelTimeForever()); + } + if (!Objects.equals(stand.getParkingTime(), -1)) { + change = true; + this.setParkingTime(stand.getParkingTime()); + } + if (stand.isParkingAlwaysValid()) { + change = true; + this.setParkingAlwaysValid(stand.isParkingAlwaysValid()); + } + return change; + } + @Override public void recover2Simulation(MapElement element, Simulation simulation, SimulationDataRepository repository) { super.recover2Simulation(element, simulation, repository); @@ -221,7 +209,6 @@ public class StorageStand extends StorageMayOutOfOrderDevice { stand.setRunLevelTimeForever(runLevelTimeForever != null ? runLevelTimeForever : false); stand.setParkingTime(parkingTime != null ? parkingTime : -1); stand.setParkingAlwaysValid(parkingAlwaysValid != null ? parkingAlwaysValid : false); - stand.setNoStatus(noStatus != null ? noStatus : false); } @Getter diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageStation.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageStation.java index 14438142b..d68ba8291 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageStation.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageStation.java @@ -19,7 +19,7 @@ import java.util.concurrent.atomic.AtomicInteger; @Getter @Setter @NoArgsConstructor -public class StorageStation extends StorageDevice { +public class StorageStation extends StorageStatusDevice { /** * 是否有控制模式 @@ -65,8 +65,8 @@ public class StorageStation extends StorageDevice { private Integer preResetValidDuration; - public StorageStation(String code) { - super(code); + public StorageStation(Station station) { + super(station); } // public StorageStation(Station station) { @@ -76,35 +76,42 @@ public class StorageStation extends StorageDevice { // } public static StorageStation convert2Storage(Station station) { - StorageStation storageStation = new StorageStation(station.getCode()); - storageStation.setControlMode(station.getControlMode()); - storageStation.setTbStrategyId(station.getTbStrategyId()); + StorageStation storageStation = new StorageStation(station); + storageStation.convert(station); + return storageStation; + } + + @Override + public boolean convert(MapElement element) { + super.convert(element); + Station station = (Station) element; + this.setControlMode(station.getControlMode()); + this.setTbStrategyId(station.getTbStrategyId()); if (station.isTotalGuideLock()) { - storageStation.setTotalGuideLock(station.isTotalGuideLock()); + this.setTotalGuideLock(station.isTotalGuideLock()); } if (station.getApplicant() != null) { - storageStation.setApplicant(station.getApplicant().getId()); + this.setApplicant(station.getApplicant().getId()); } if (station.getApply2TheControlMode() != null) { - storageStation.setApply2TheControlMode(station.getApply2TheControlMode()); + this.setApply2TheControlMode(station.getApply2TheControlMode()); } if (station.getValidDuration() != null) { - storageStation.setValidDuration(station.getValidDuration()); + this.setValidDuration(station.getValidDuration()); } if (station.isInterlockMachineStarting()) { - storageStation.setInterlockMachineStarting(station.isInterlockMachineStarting()); + this.setInterlockMachineStarting(station.isInterlockMachineStarting()); } - storageStation.setRestartTime(station.getRestartTime()); - storageStation.setController(station.getControllerId()); + this.setRestartTime(station.getRestartTime()); + this.setController(station.getControllerId()); if (station.isEmergencyController()) { - storageStation.setEmergencyController(station.isEmergencyController()); + this.setEmergencyController(station.isEmergencyController()); } - storageStation.setControlApplicant(station.getControlApplicantId()); + this.setControlApplicant(station.getControlApplicantId()); if (station.getPreResetValidDuration() != null && station.getPreResetValidDuration().get() != 0) { - storageStation.setPreResetValidDuration(station.getPreResetValidDuration().get()); + this.setPreResetValidDuration(station.getPreResetValidDuration().get()); } - - return storageStation; + return true; } @Override diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageStatusDevice.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageStatusDevice.java new file mode 100644 index 000000000..0267883b9 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageStatusDevice.java @@ -0,0 +1,53 @@ +package club.joylink.rtss.simulation.cbtc.data.storage.device; + +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.map.StatusDevice; +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; + +@Getter +@Setter +@NoArgsConstructor +public class StorageStatusDevice extends StorageDevice{ + @JsonSerialize(using = Boolean2NumSerializer.class) + @JsonDeserialize(using = Boolean2NumDeserializer.class) + private Boolean noStatus; + + @JsonSerialize(using = Boolean2NumSerializer.class) + @JsonDeserialize(using = Boolean2NumDeserializer.class) + private Boolean atsNoStatus; + + public StorageStatusDevice(StatusDevice device) { + super(device.getCode()); + } + + @Override + public boolean convert(MapElement element) { + StatusDevice device = (StatusDevice) element; + boolean change = false; + if (device.isNoStatus()) { + change = true; + this.noStatus = true; + } + if (device.isAtsNoStatus()) { + change = true; + this.setAtsNoStatus(true); + } + return change; + } + + @Override + public void recover2Simulation(MapElement element, Simulation simulation, SimulationDataRepository repository) { + StatusDevice device = (StatusDevice) element; + device.setNoStatus(this.noStatus == null ? false : this.noStatus); + device.setAtsNoStatus(this.atsNoStatus == null ? false : this.atsNoStatus); + } + +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageSwitch.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageSwitch.java index 4626ef834..a2335f405 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageSwitch.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageSwitch.java @@ -76,75 +76,62 @@ public class StorageSwitch extends StorageDelayUnlockDevice { */ private SwitchIndication pos; - @JsonSerialize(using = Boolean2NumSerializer.class) - @JsonDeserialize(using = Boolean2NumDeserializer.class) - private Boolean noStatus; - - public StorageSwitch(String code, MayOutOfOrderDevice.DeviceFault fault) { - super(code, fault); + public StorageSwitch(Switch aSwitch) { + super(aSwitch); } public static StorageSwitch convert2Storage(Switch s) { - boolean change = false; - StorageSwitch storageSwitch = new StorageSwitch(s.getCode(), s.getFault()); - if (storageSwitch.isFault()) { - change = true; + StorageSwitch storageSwitch = new StorageSwitch(s); + if (storageSwitch.convert(s)) { + return storageSwitch; } + return null; + } + + @Override + public boolean convert(MapElement element) { + boolean change = super.convert(element); + Switch s = (Switch) element; if (s.isSingleLock()) { change = true; - storageSwitch.setSingleLock(s.isSingleLock()); + this.setSingleLock(s.isSingleLock()); } if (s.isBlockade()) { change = true; - storageSwitch.setBlockade(s.isBlockade()); + this.setBlockade(s.isBlockade()); } if (s.isRouteLock()) { change = true; - storageSwitch.setRouteLock(s.isRouteLock()); + this.setRouteLock(s.isRouteLock()); } // Route route = s.getRoutes(); // if (route != null) { // change = true; -// storageSwitch.setRoute(route.getCode()); +// this.setRoute(route.getCode()); // } Set routes = s.getRoutes(); if (!CollectionUtils.isEmpty(routes)) { change = true; Set routeCodes = routes.stream().map(MapElement::getCode).collect(Collectors.toSet()); - storageSwitch.setRoutes(routeCodes); + this.setRoutes(routeCodes); } if (s.isFpLock()) { change = true; - storageSwitch.setFpLock(s.isFpLock()); + this.setFpLock(s.isFpLock()); } if (s.isOverlapLock()) { change = true; - storageSwitch.setOverlapLock(s.isOverlapLock()); + this.setOverlapLock(s.isOverlapLock()); } if (s.isMasterGuideLock()) { change = true; - storageSwitch.setMasterGuideLock(s.isMasterGuideLock()); + this.setMasterGuideLock(s.isMasterGuideLock()); } if (!SwitchIndication.N.equals(s.getPos())) { change = true; - storageSwitch.setPos(s.getPos()); + this.setPos(s.getPos()); } - if (s.getRemain() > 0) { - change = true; - storageSwitch.saveFrom(s); - } - if (s.isNoStatus()) { - change = true; - storageSwitch.setNoStatus(s.isNoStatus()); - } - if (s.isFault()) { - change = true; - } - - if (change) { - return storageSwitch; - } - return null; + return change; } @Override @@ -171,9 +158,5 @@ public class StorageSwitch extends StorageDelayUnlockDevice { if (pos != null) { s.setPos(pos); } - if (this.getRemain() > 0) { - this.recoverTo(s, repository); - } - s.setNoStatus(noStatus != null ? noStatus : false); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageZC.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageZC.java index 783e4d55f..d7c8c9a00 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageZC.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageZC.java @@ -14,17 +14,12 @@ import lombok.Setter; public class StorageZC extends StorageMayOutOfOrderDevice { private StorageZC (ZC zc) { - super(zc.getCode(), zc.getFault()); + super(zc); } public static StorageZC convert2Storage(ZC zc) { - boolean change = false; StorageZC storageZC = new StorageZC(zc); - if (zc.isFault()) { - change = true; - } - - if (change) { + if (storageZC.convert(zc)) { return storageZC; } return null;