diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/AtpSectionService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/AtpSectionService.java index a52761d95..9967344d6 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/AtpSectionService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/AtpSectionService.java @@ -185,6 +185,13 @@ public class AtpSectionService { section.judgeAsInvalid(); } } + //ARB故障判定 + if (Section.AxleFault.ARB.equals(section.getFault())) { + section.setInvalid(true); + for (Section logic : section.getLogicList()) { + logic.setInvalid(true); + } + } } /** diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/ZCLogicLoop.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/ZCLogicLoop.java index 68f6baee7..f16a4fb72 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/ZCLogicLoop.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/ZCLogicLoop.java @@ -132,7 +132,7 @@ public class ZCLogicLoop { } //非通信车占用区段 if (section.isNonCbtcOccupy()) { - endList.add(new MovementAuthority.End(section, MovementAuthority.EndType.NCT_OCCUPIED_IN_FRONT_OF_SECTION)); + endList.add(new MovementAuthority.End(section, MovementAuthority.EndType.NCT_OCCUPIED_SECTION)); return endList; } int count = 0; @@ -182,7 +182,7 @@ public class ZCLogicLoop { if (temp.isNonCbtcOccupy()) { SectionPosition headPosition1 = train.getHeadPosition(); if (!temp.isSamePhysical(headPosition1.getSection().getCode())) { - endList.add(new MovementAuthority.End(temp, MovementAuthority.EndType.NCT_OCCUPIED_IN_FRONT_OF_SECTION)); + endList.add(new MovementAuthority.End(temp, MovementAuthority.EndType.NCT_OCCUPIED_SECTION)); } } //检查关闭的区段 @@ -283,11 +283,14 @@ public class ZCLogicLoop { Section section = headPosition.getSection(); int count = 0; while (Objects.nonNull(section) && count < 20) { + if (count > 1 && !CollectionUtils.isEmpty(endList)) + break; ++count; // 信号机 MovementAuthority.End signalEnd = checkGroundSignal(section, right); if (Objects.nonNull(signalEnd)) { - deviceEnd = signalEnd; + endList.add(signalEnd); +// deviceEnd = signalEnd; break; } // 轨道尽头/问题道岔 @@ -295,15 +298,24 @@ public class ZCLogicLoop { if (Objects.isNull(temp)) { // 到尽头 if (section.isSwitchTrack()) { // 问题道岔 if (Objects.nonNull(section.getSectionOf(!right))) { - deviceEnd = new MovementAuthority.End(section.getSectionOf(!right), - MovementAuthority.EndType.FAULT_SWITCH); + endList.add(new MovementAuthority.End(section.getSectionOf(!right), + MovementAuthority.EndType.FAULT_SWITCH)); +// deviceEnd = new MovementAuthority.End(section.getSectionOf(!right), +// MovementAuthority.EndType.FAULT_SWITCH); } } else { - deviceEnd = new MovementAuthority.End(section, - MovementAuthority.EndType.END_TRACK); + endList.add(new MovementAuthority.End(section, + MovementAuthority.EndType.END_TRACK)); +// deviceEnd = new MovementAuthority.End(section, +// MovementAuthority.EndType.END_TRACK); } break; } +// else { +// if (temp.isNonCbtcOccupy() && temp.isInvalid()) { +// endList.add(new MovementAuthority.End(temp, MovementAuthority.EndType.NCT_OCCUPIED_SECTION)); +// } +// } section = temp; } if (Objects.nonNull(deviceEnd)) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java index 82c509711..3835ac6f9 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java @@ -12,6 +12,7 @@ import lombok.Setter; import org.springframework.util.CollectionUtils; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Objects; @@ -1109,6 +1110,56 @@ public class Section extends MayOutOfOrderDevice { } } } + }, + + ARB { + @Override + public boolean apply(MayOutOfOrderDevice device) { + Section section = (Section) device; + List
sections; + if (!section.isAxleCounter()) { + if (section.getParent() != null && section.getParent().isAxleCounter()) { + sections = Collections.singletonList(section.getParent()); + } else if (!CollectionUtils.isEmpty(section.getLogicList())) { + sections = section.getLogicList(); + } else { + sections = new ArrayList<>(); + } + } else { + sections = Collections.singletonList(section); + } + boolean flag = false; + for (Section axleSection : sections) { + if (axleSection.isAxleCounter() && !this.equals(axleSection.getFault())) { + flag = true; + axleSection.setFault(this); + } + } + return flag; + } + + @Override + public void fix(MayOutOfOrderDevice device) { + Section section = (Section) device; + List
sections; + if (!section.isAxleCounter()) { + if (section.getParent() != null && section.getParent().isAxleCounter()) { + sections = Collections.singletonList(section.getParent()); + } else if (!CollectionUtils.isEmpty(section.getLogicList())) { + sections = section.getLogicList(); + } else { + sections = new ArrayList<>(); + } + } else { + sections = Collections.singletonList(section); + } + boolean flag = false; + for (Section axleSection : sections) { + if (this.equals(axleSection.getFault())) { + axleSection.setFault(null); + } + } + } } } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/support/MovementAuthority.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/support/MovementAuthority.java index 71e3a6cbb..ec9c7f652 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/support/MovementAuthority.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/support/MovementAuthority.java @@ -5,7 +5,6 @@ import club.joylink.rtss.simulation.cbtc.data.CalculateService; import club.joylink.rtss.simulation.cbtc.data.map.MapNamedElement; import club.joylink.rtss.simulation.cbtc.data.map.Section; import club.joylink.rtss.simulation.cbtc.data.map.Signal; -import club.joylink.rtss.simulation.cbtc.data.map.Stand; 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; @@ -153,7 +152,7 @@ public class MovementAuthority { // float offset = right ? 0 : baseSection.getLen(); // return new SectionPosition(baseSection, offset); // } - case NCT_OCCUPIED_IN_FRONT_OF_SECTION:{ + case NCT_OCCUPIED_SECTION:{ Section section = (Section) this.device; Section previous = section.getNextRunningSectionOf(!right); float offset = right ? 0 : previous.getLen(); @@ -213,9 +212,9 @@ public class MovementAuthority { UNLOCKED_OVERLAP, UNLOCK_SECTION, /** - * 区段前方有非通信车占用 + * 非通信车占用区段 */ - NCT_OCCUPIED_IN_FRONT_OF_SECTION, + NCT_OCCUPIED_SECTION, /** * 故障区段 */ 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 d6589d00e..36d985465 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 @@ -602,6 +602,8 @@ public class VirtualRealityTrain extends VirtualRealityDevice { } public void updateTBForce(float fk, float fb) { + if (isEB()) + return; if (Fault.DRIVE_FAULT.equals(fault) && fk > 0) { return; } @@ -983,7 +985,7 @@ public class VirtualRealityTrain extends VirtualRealityDevice { * 设置紧急制动的功率和制动力 */ public void emergencyBreak() { - updateTBForce(0, 350); + enforceUpdateTBForce(0, 350); } @Getter diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/robot/RobotLogicLoop.java b/src/main/java/club/joylink/rtss/simulation/cbtc/robot/RobotLogicLoop.java index daae146ba..5ee0f18c6 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/robot/RobotLogicLoop.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/robot/RobotLogicLoop.java @@ -21,12 +21,10 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.core.task.TaskExecutor; import org.springframework.stereotype.Component; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; import java.util.concurrent.atomic.AtomicLong; import java.util.stream.Collectors; +import java.util.stream.Stream; /** * 仿真机器人逻辑循环 @@ -110,8 +108,11 @@ public class RobotLogicLoop { switch (train.getDriveMode()) { case AM: case CM: + Float recommendedSpeedMax = Stream.of(train.getAtpSpeedMax(), train.getSpeedLimit() * 0.9f, train.getAtoSpeedMax()) + .min(Comparator.comparingDouble(Float::doubleValue)).get(); + distance = ATOService.calculateTargetRemainDistance(train, train.getMa()); speedCurve = SpeedCurve.buildTargetSpeedCurve(headPosition, tailPosition, right, - distance, speed, Math.min(train.getAtpSpeedMax(), train.getSpeedLimit()) * 0.9f); + distance, speed, recommendedSpeedMax); break; case RM: speedCurve = SpeedCurve.buildTargetSpeedCurve(headPosition, tailPosition, right,