@@ -3,6 +3,7 @@ package fr.sncf.osrd.signaling.impl
3
3
import fr.sncf.osrd.sim_infra.api.*
4
4
import fr.sncf.osrd.sim_infra.impl.BlockInfraBuilder
5
5
import fr.sncf.osrd.sim_infra.impl.blockInfraBuilder
6
+ import fr.sncf.osrd.utils.LogAggregator
6
7
import fr.sncf.osrd.utils.indexing.IdxMap
7
8
import fr.sncf.osrd.utils.indexing.MutableStaticIdxArrayList
8
9
import fr.sncf.osrd.utils.units.*
@@ -18,86 +19,87 @@ internal fun internalBuildBlocks(
18
19
// Step 1) associate DirDetectorIds to a list of delimiting logical signals
19
20
val signalDelimiters = findSignalDelimiters(rawSignalingInfra, loadedSignalInfra)
20
21
val detectorEntrySignals = makeDetectorEntrySignals(loadedSignalInfra, signalDelimiters)
21
- return blockInfraBuilder(loadedSignalInfra, rawSignalingInfra) {
22
- // Step 2) iterate on zone paths along the route path.
23
- // - maintain a list of currently active blocks
24
- // - At each signal, add it to compatible current blocks.
25
- // - if the signal is delimiting, stop and create the block (deduplicate it too)
26
- for (route in rawSignalingInfra.routes) {
27
- val routeEntryDet = rawSignalingInfra.getRouteEntry(route)
28
- val routeExitDet = rawSignalingInfra.getRouteExit(route)
29
- val entrySignals = detectorEntrySignals[routeEntryDet]
30
- var currentBlocks =
31
- getInitPartialBlocks(
32
- sigModuleManager,
33
- rawSignalingInfra,
34
- loadedSignalInfra,
35
- entrySignals,
36
- routeEntryDet
37
- )
38
- // while inside the route, we maintain a list of currently active blocks.
39
- // each block either expect any signaling system (when starting from a buffer stop or
40
- // wildcard
41
- // signal),
42
- // or expects a given signaling system. blocks can therefore tell whether a signal
43
- // belongs
44
- // there.
45
- // if a signal is not part of a block, it is ignored
46
- // if a signal delimits a block, it ends the block and starts a new ones, one per driver
47
- // if a signal does not delimit a block and has a single driver, it continues the block
48
- // if a signal does not delimit a block and has multiple drivers, it duplicates the
49
- // block
22
+ val missingSignalLogAggregator = LogAggregator ({ logger.debug(it) })
23
+ val result =
24
+ blockInfraBuilder(loadedSignalInfra, rawSignalingInfra) {
25
+ // Step 2) iterate on zone paths along the route path.
26
+ // - maintain a list of currently active blocks
27
+ // - At each signal, add it to compatible current blocks.
28
+ // - if the signal is delimiting, stop and create the block (deduplicate it too)
29
+ for (route in rawSignalingInfra.routes) {
30
+ val routeEntryDet = rawSignalingInfra.getRouteEntry(route)
31
+ val routeExitDet = rawSignalingInfra.getRouteExit(route)
32
+ val entrySignals = detectorEntrySignals[routeEntryDet]
33
+ var currentBlocks =
34
+ getInitPartialBlocks(
35
+ sigModuleManager,
36
+ rawSignalingInfra,
37
+ loadedSignalInfra,
38
+ entrySignals,
39
+ routeEntryDet,
40
+ missingSignalLogAggregator,
41
+ )
42
+ // While inside the route, we maintain a list of currently active blocks. Each block
43
+ // either expect any signaling system (when starting from a buffer stop or wildcard
44
+ // signal), or expects a given signaling system. Blocks can therefore tell whether a
45
+ // signal belongs there.
46
+ // If a signal is not part of a block, it is ignored. If a signal delimits a block,
47
+ // it ends the block and starts a new ones, one per driver. If a signal does not
48
+ // delimit a block and has a single driver, it continues the block. If a signal does
49
+ // not delimit a block and has multiple drivers, it duplicates the block.
50
50
51
- for (zonePath in rawSignalingInfra.getRoutePath(route)) {
52
- val zonePathLength = rawSignalingInfra.getZonePathLength(zonePath)
53
- for (block in currentBlocks) block.addZonePath(zonePath, zonePathLength)
51
+ for (zonePath in rawSignalingInfra.getRoutePath(route)) {
52
+ val zonePathLength = rawSignalingInfra.getZonePathLength(zonePath)
53
+ for (block in currentBlocks) block.addZonePath(zonePath, zonePathLength)
54
54
55
- // iterate over signals which are between the block entry and the block exit
56
- val signals = rawSignalingInfra.getSignals(zonePath)
57
- val signalsPositions = rawSignalingInfra.getSignalPositions(zonePath)
58
- for ((physicalSignal, position) in signals.zip(signalsPositions)) {
59
- val distanceToZonePathEnd = zonePathLength - position
60
- assert (distanceToZonePathEnd >= Distance .ZERO )
61
- assert (distanceToZonePathEnd <= zonePathLength.distance)
62
- for (signal in loadedSignalInfra.getLogicalSignals(physicalSignal)) {
63
- currentBlocks =
64
- updatePartialBlocks(
65
- sigModuleManager,
66
- currentBlocks,
67
- loadedSignalInfra,
68
- signal,
69
- distanceToZonePathEnd,
70
- )
55
+ // iterate over signals which are between the block entry and the block exit
56
+ val signals = rawSignalingInfra.getSignals(zonePath)
57
+ val signalsPositions = rawSignalingInfra.getSignalPositions(zonePath)
58
+ for ((physicalSignal, position) in signals.zip(signalsPositions)) {
59
+ val distanceToZonePathEnd = zonePathLength - position
60
+ assert (distanceToZonePathEnd >= Distance .ZERO )
61
+ assert (distanceToZonePathEnd <= zonePathLength.distance)
62
+ for (signal in loadedSignalInfra.getLogicalSignals(physicalSignal)) {
63
+ currentBlocks =
64
+ updatePartialBlocks(
65
+ sigModuleManager,
66
+ currentBlocks,
67
+ loadedSignalInfra,
68
+ signal,
69
+ distanceToZonePathEnd,
70
+ )
71
+ }
71
72
}
72
73
}
73
- }
74
74
75
- // when a route ends at a buffer stop, unterminated blocks are expected,
76
- // as the buffer stop sort of acts as a closed signal. when a route does not
77
- // end with a buffer stop, blocks are expected to end with the route.
78
- // such blocks are not valid, and can be fixed by adding a delimiter signal
79
- // right before the end of the route.
80
- val routeEndsAtBufferStop = rawSignalingInfra.isBufferStop(routeExitDet.value)
81
- for (curBlock in currentBlocks) {
82
- if (curBlock.zonePaths.size == 0 ) continue
83
- if (curBlock.signals.size == 0 ) continue
75
+ // when a route ends at a buffer stop, unterminated blocks are expected,
76
+ // as the buffer stop sort of acts as a closed signal. when a route does not
77
+ // end with a buffer stop, blocks are expected to end with the route.
78
+ // such blocks are not valid, and can be fixed by adding a delimiter signal
79
+ // right before the end of the route.
80
+ val routeEndsAtBufferStop = rawSignalingInfra.isBufferStop(routeExitDet.value)
81
+ for (curBlock in currentBlocks) {
82
+ if (curBlock.zonePaths.size == 0 ) continue
83
+ if (curBlock.signals.size == 0 ) continue
84
84
85
- val lastZonePath = curBlock.zonePaths[curBlock.zonePaths.size - 1 ]
86
- assert (routeExitDet == rawSignalingInfra.getZonePathExit(lastZonePath))
87
- if (! routeEndsAtBufferStop)
88
- logger.debug {
89
- " unterminated block at end of route ${rawSignalingInfra.getRouteName(route)} "
90
- }
91
- block(
92
- curBlock.startAtBufferStop,
93
- true ,
94
- curBlock.zonePaths,
95
- curBlock.signals,
96
- curBlock.signalPositions
97
- )
85
+ val lastZonePath = curBlock.zonePaths[curBlock.zonePaths.size - 1 ]
86
+ assert (routeExitDet == rawSignalingInfra.getZonePathExit(lastZonePath))
87
+ if (! routeEndsAtBufferStop)
88
+ logger.debug {
89
+ " unterminated block at end of route ${rawSignalingInfra.getRouteName(route)} "
90
+ }
91
+ block(
92
+ curBlock.startAtBufferStop,
93
+ true ,
94
+ curBlock.zonePaths,
95
+ curBlock.signals,
96
+ curBlock.signalPositions
97
+ )
98
+ }
98
99
}
99
100
}
100
- }
101
+ missingSignalLogAggregator.logAggregatedSummary()
102
+ return result
101
103
}
102
104
103
105
data class AssociatedDetector (val detector : DirDetectorId , val distance : Distance )
@@ -210,14 +212,15 @@ private fun getInitPartialBlocks(
210
212
loadedSignalInfra : LoadedSignalInfra ,
211
213
entrySignals : IdxMap <SignalingSystemId , AssociatedSignal >? ,
212
214
entryDet : DirDetectorId ,
215
+ missingSignalLogAggregator : LogAggregator ,
213
216
): MutableList <PartialBlock > {
214
217
val initialBlocks = mutableListOf<PartialBlock >()
215
218
val isBufferStop = rawSignalingInfra.isBufferStop(entryDet.value)
216
219
if (entrySignals == null ) {
217
220
if (! isBufferStop)
218
- logger.debug {
221
+ missingSignalLogAggregator.registerError(
219
222
" no signal at non buffer stop ${rawSignalingInfra.getDetectorName(entryDet.value)} :${entryDet.direction} "
220
- }
223
+ )
221
224
initialBlocks.add(
222
225
PartialBlock (
223
226
true ,
0 commit comments