Skip to content

Commit

Permalink
core: add a virtual final clear zone
Browse files Browse the repository at this point in the history
  • Loading branch information
multun committed Apr 13, 2023
1 parent a1130e8 commit edd6608
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ interface SignalingSimulator {
fullPath: StaticIdxList<Block>,
evaluatedPathBegin: Int,
evaluatedPathEnd: Int,
zoneStates: List<ZoneStatus>
zoneStates: List<ZoneStatus>,
followingZoneState: ZoneStatus,
): IdxMap<LogicalSignalId, SigState>
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ class SignalingSimulatorImpl(override val sigModuleManager: SigSystemManager) :
fullPath: StaticIdxList<Block>,
evaluatedPathBegin: Int,
evaluatedPathEnd: Int,
zoneStates: List<ZoneStatus>
zoneStates: List<ZoneStatus>,
followingZoneState: ZoneStatus,
): IdxMap<LogicalSignalId, SigState> {
assert(evaluatedPathBegin >= 0)
assert(evaluatedPathEnd > evaluatedPathBegin)
Expand Down Expand Up @@ -131,7 +132,7 @@ class SignalingSimulatorImpl(override val sigModuleManager: SigSystemManager) :
if (!lastBlockEndsAtBufferStop) {
val blockSignals = blocks.getBlockSignals(lastBlock)
val lastSignal = blockSignals[blockSignals.size - 1]
signalEvalSequence.add(SignalEvalTask(lastSignal, ProtectionStatus.INCOMPATIBLE))
signalEvalSequence.add(SignalEvalTask(lastSignal, followingZoneState.toProtectionStatus()))
}

for (blockIndex in (0 until evaluatedPath.size).reversed()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class TestBALtoBAL {
fullPath.add(blockInfra.getBlocksAtDetector(detectorU.normal).first())
fullPath.add(blockInfra.getBlocksAtDetector(detectorV.normal).first())
val zoneStates = mutableListOf(ZoneStatus.CLEAR, ZoneStatus.CLEAR, ZoneStatus.CLEAR)
val res = simulator.evaluate(infra, loadedSignalInfra, blockInfra, fullPath, 0, fullPath.size, zoneStates)
val res = simulator.evaluate(infra, loadedSignalInfra, blockInfra, fullPath, 0, fullPath.size, zoneStates, ZoneStatus.INCOMPATIBLE)
assertEquals("A", res[loadedSignalInfra.getLogicalSignals(signalV).first()]!!.getEnum("aspect"))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class TestBAPRtoBAL {
fullPath.add(blockInfra.getBlocksAtDetector(detectorX.normal).first())
fullPath.add(blockInfra.getBlocksAtDetector(detectorY.normal).first())
val zoneStates = mutableListOf(ZoneStatus.CLEAR, ZoneStatus.CLEAR, ZoneStatus.INCOMPATIBLE)
val res = simulator.evaluate(infra, loadedSignalInfra, blockInfra, fullPath, 0, fullPath.size, zoneStates)
val res = simulator.evaluate(infra, loadedSignalInfra, blockInfra, fullPath, 0, fullPath.size, zoneStates, ZoneStatus.INCOMPATIBLE)
val logicalSignals = listOf(signalm, signalM, signaln, signalN).map{loadedSignalInfra.getLogicalSignals(it).first()}
val expectedAspects = listOf("VL", "VL", "A", "C")
asserSignalListAspectEquals(expectedAspects, res, logicalSignals)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ private fun computeSignalAspectChangeEvents(
zoneStates[zoneToPathIndexMap[event.zone]!!] = ZoneStatus.CLEAR

val simulatedSignalStates = simulator.evaluate(
rawInfra, loadedSignalInfra, blockInfra, blockPath, 0, blockPath.size, zoneStates
rawInfra, loadedSignalInfra, blockInfra,
blockPath, 0, blockPath.size,
zoneStates, ZoneStatus.CLEAR
)
val simulatedAspects = simulatedSignalStates.map { it.getEnum("aspect") }
for (pathSignal in pathSignals) {
Expand Down

0 comments on commit edd6608

Please sign in to comment.