Skip to content

Commit

Permalink
core: warn when invalid detector is found
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre-Etienne Bougué <bougue.pe@proton.me>
  • Loading branch information
bougue-pe committed Nov 18, 2024
1 parent 08a1080 commit 99d0adb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ private fun buildZones(builder: RawInfraBuilder) {
val nodeHasZone = BooleanArray(builder.getTrackNodes().size.toInt()) { false }

// TODO: change this algorithm to add all nodes to zones separately from iterating on track
// sections
// sections
for (trackSectionIdx in builder.getTrackSections()) {
val detectors = builder.getTrackSectionDetectors(trackSectionIdx)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,14 @@ class RawInfraBuilder {
}

fun setNextZone(detector: DirDetectorId, zone: ZoneId) {
if (nextZones[detector.opposite] == zone) {
// Invalid detector if the zone is identical on both sides: data issue
// (wrong place for detector or missing detectors around to avoid "zone-loop").
// This often leads to self-conflicts on trains.
logger.warn {
"detector ${detectorPool[detector.value].names} is not bounding a zone (both sides are inside a unique zone)"
}
}
nextZones[detector] = zone
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import kotlin.collections.set
import kotlin.time.Duration
import mu.KotlinLogging

private val logger = KotlinLogging.logger {}
val logger = KotlinLogging.logger {}

// TODO: refactor this structure (and its usage) to be able to model a speed limit affecting only
// trains using one specific route AND one specific speedLimitTag
Expand Down

0 comments on commit 99d0adb

Please sign in to comment.