From 99d0adb574bacb2e5fcd7fac73f77393d22df11f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Etienne=20Bougu=C3=A9?= Date: Wed, 6 Nov 2024 10:24:46 +0100 Subject: [PATCH] core: warn when invalid detector is found MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre-Etienne Bougué --- .../src/main/kotlin/fr/sncf/osrd/RawInfraRJSParser.kt | 2 +- .../kotlin/fr/sncf/osrd/sim_infra/impl/RawInfraBuilder.kt | 8 ++++++++ .../kotlin/fr/sncf/osrd/sim_infra/impl/RawInfraImpl.kt | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/core/kt-osrd-rjs-parser/src/main/kotlin/fr/sncf/osrd/RawInfraRJSParser.kt b/core/kt-osrd-rjs-parser/src/main/kotlin/fr/sncf/osrd/RawInfraRJSParser.kt index 7aa8a5bebb6..dae8f06c1fb 100644 --- a/core/kt-osrd-rjs-parser/src/main/kotlin/fr/sncf/osrd/RawInfraRJSParser.kt +++ b/core/kt-osrd-rjs-parser/src/main/kotlin/fr/sncf/osrd/RawInfraRJSParser.kt @@ -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) diff --git a/core/kt-osrd-sim-infra/src/main/kotlin/fr/sncf/osrd/sim_infra/impl/RawInfraBuilder.kt b/core/kt-osrd-sim-infra/src/main/kotlin/fr/sncf/osrd/sim_infra/impl/RawInfraBuilder.kt index ccd2c00f133..2b691d20fcc 100644 --- a/core/kt-osrd-sim-infra/src/main/kotlin/fr/sncf/osrd/sim_infra/impl/RawInfraBuilder.kt +++ b/core/kt-osrd-sim-infra/src/main/kotlin/fr/sncf/osrd/sim_infra/impl/RawInfraBuilder.kt @@ -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 } diff --git a/core/kt-osrd-sim-infra/src/main/kotlin/fr/sncf/osrd/sim_infra/impl/RawInfraImpl.kt b/core/kt-osrd-sim-infra/src/main/kotlin/fr/sncf/osrd/sim_infra/impl/RawInfraImpl.kt index d5eec9e3034..3ed5ea44223 100644 --- a/core/kt-osrd-sim-infra/src/main/kotlin/fr/sncf/osrd/sim_infra/impl/RawInfraImpl.kt +++ b/core/kt-osrd-sim-infra/src/main/kotlin/fr/sncf/osrd/sim_infra/impl/RawInfraImpl.kt @@ -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