18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-27 21:45:16 +01:00
Files
maszyna/vehicle/signalpassing.cpp
jerrrrycho a3f4bd4f0d fix(ai): a train standing past a signal when its speed table is traced hasn't passed it (#473)
* fix(ai): a train standing past a signal when its speed table is traced hasn't passed it

Since #409 a point of the speed table found behind the head counts as passed only when the head had it ahead once,
but a point found up to 5 m behind the head still counted as seen ahead (SeenAheadTolerance), whether the train
moved or stood. A train set at a stand 0.5-4.5 m past a signal at stop therefore found the signal behind its head
at its first look ahead, the next update marked it elapsed, and the test mode ended with "signal passed at
danger" at 13.6 s with the train at 0 km/h (EU07 on td.scn at stacja1_j; set 6 m or 20 m past, no report).

The tolerance is kept for a moving train, which may be just passing a point found at its head. A standing train
passes nothing: a point found behind its head counts as seen ahead only once an update finds it ahead. The rule
moves out of TSpeedPos into vehicle/signalpassing.{h,cpp}, so it is unit tested; the blackbox record of passed
signals follows it as before.

Measured with the head set 0.5-6 m past and 0.5-2 m short of the signal on tor1k: the distance the scan finds is
the head's own distance from the memory cell (to the micrometre there), so a train standing 0.5 m short still
gets the signal ahead and passes it if it goes on.

Tests: tests/unit/test_signal_passing.cpp (6 cases), and the scenario cases test_mode_standing_1m_past_signal and
test_mode_standing_4m_past_signal (fragment td_past_red_signal.scn), which ended as signals passed at danger
before and run into their timeout now.

* test(scenarios): the shunting AI stops before a signal at stop on td.scn

Two cases for the shunting fix of #409, left out of it: an EU07 with no timetable (its AI shunts) starting at
30 km/h about 150 m before the exit signal stacja1_j at stop, alone (eu07_td_shunt_red_signal) and pushing three
coaches (eu07_td_shunt_push_red_signal), has to stop before the signal and stay there. They come from #340, whose
braking was sharper; run on the code of #409 they stop after 145 m and 141 m, with the signal 151 m from the
start, so the checks of #340 (no more than 150 m, below 40 km/h) hold as they were.

* fix(sonar): count the metres of the signal passing test in an integer

SonarCloud rule cpp:S2193 (a for loop counter of floating type) flagged the
loop that moves the head a metre at a time in tests/unit/test_signal_passing.cpp
and made the new reliability rating of the pull request fail the quality gate.
The counter is now an int; it took whole values only, so every case runs the
same number of steps as before.

* fix(ai): the gap of a standing train a few decimetres short of a signal noted at seen_ahead_when_found
2026-11-25 05:13:37 +01:00

719 B