From 62526e9d6a1b87fcb0f67cb36ba674a91da94f9c Mon Sep 17 00:00:00 2001 From: jerrrrycho Date: Sun, 8 Nov 2026 11:16:33 +0100 Subject: [PATCH] test(scenarios): the timetable cases check where the train stops, not how long Przystanek on td.scn is a technical stop of the td/rozklad timetable (pt): the AI doesn't wait there for the departure time but sets off as soon as it counts the train as standing at the W4, below 1 km/h. How long the speed then stays under 0.5 km/h is only how fast the brake releases. With the AI braking of #264 the trains creep up to the W4 at about 10 km/h on a light application and stood there for 1-5 s; the SN61 turns back at 0.36 km/h without stopping. The hold of 5 s (2 s for the SN61) failed for EP09, SN61 and Vectron and had well under a second to spare for others. The cases now check that the train comes down to 1 km/h, the AI's own standstill at a W4, 1380-1420 m from the start; every vehicle stops at 1397-1401 m, before and after #264. `stops` takes min_distance and max_distance for that. --- tests/scenarios/README.md | 14 ++++++++++---- tests/scenarios/cases/en57_td_timetable.json | 2 +- tests/scenarios/cases/ep09_td_timetable.json | 2 +- tests/scenarios/cases/et22_td_timetable.json | 2 +- tests/scenarios/cases/eu07_td_timetable.json | 2 +- tests/scenarios/cases/sm42_td_timetable.json | 2 +- tests/scenarios/cases/sn61_td_timetable.json | 2 +- tests/scenarios/cases/vectron_td_timetable.json | 2 +- tests/scenarios/run.py | 8 ++++++-- 9 files changed, 23 insertions(+), 13 deletions(-) diff --git a/tests/scenarios/README.md b/tests/scenarios/README.md index 8ad7e7470..8bd6f1a4a 100644 --- a/tests/scenarios/README.md +++ b/tests/scenarios/README.md @@ -168,7 +168,12 @@ scenery is newer. the one whose physicslog is checked. Other vehicles of the consist take names made from it, e.g. `{{vehicle}}_s`. The td.scn cases share two fragments, `td_timetable.scn` (route set, train runs to Przystanek) and `td_red_signal.scn` (no route, exit signal at stop), and differ -only in `vars.consist`. `td_red_signal_moving.scn` is the red signal one with the train +only in `vars.consist`. Przystanek is a technical stop in that timetable (`pt`), where the AI +doesn't wait for the departure time: it sets off as soon as it counts the train as standing at +the W4, which is below 1 km/h, so the train stands there for a few seconds at most, or doesn't +quite stop (since the AI braking of #264 the SN61 turns back at 0.4 km/h). The +timetable cases therefore check that the train comes down to 1 km/h, with no hold, 1380-1420 m +from the start (every vehicle stops at 1397-1401 m). `td_red_signal_moving.scn` is the red signal one with the train starting at `vars.velocity` km/h; with `track_friction` 0.03 it locks the wheels when braking and slides past the signal, so those cases set `test.fail_if_stop_overran no`. `td_red_signal_pass.scn` adds the `test_pass` event, which `test_mode_pass` puts as `event0` @@ -189,13 +194,14 @@ the row instead, logged by builds from this branch on. - `max_speed` `limit`, `tolerance`: never goes faster than `limit + tolerance`. - `brakes` `min_pressure`: after moving off, brake cylinder pressure reaches `min_pressure` bar (physicslog pressures are in bar whatever its header says; the brake pipe runs at 5.0). -- `stops` `moving_speed`, `stop_speed`, `hold`: after reaching `moving_speed`, stays at or - below `stop_speed` for `hold` seconds. +- `stops` `moving_speed`, `stop_speed`, `hold`, optional `min_distance`, `max_distance`: after + reaching `moving_speed`, stays at or below `stop_speed` for `hold` seconds; with the distances, + that stop has to be between them (metres travelled, as in `distance`). - `stays_stopped` `moving_speed`, `stop_speed`: after moving off and stopping, never goes above `stop_speed` again. - `distance` `min`, `max`: total distance travelled. The physicslog has no position, so the distance comes from integrating the speed; on td.scn every vehicle's first stop after - Stacja1 came out at 1400 m (+-3), and the red signal stop at 140 m. + Stacja1 came out at 1400 m (+-4), and the red signal stop at 140 m. - `slips` `within`: the lead vehicle's wheels slip or lock at some point (within `within` seconds if given), so a slippery rail case does what it's meant to. - `slip_clears` `moving_speed`, `stop_speed`, `within` (*vehicle speed*): once stopped after diff --git a/tests/scenarios/cases/en57_td_timetable.json b/tests/scenarios/cases/en57_td_timetable.json index ddd52af37..d4c4f26fa 100644 --- a/tests/scenarios/cases/en57_td_timetable.json +++ b/tests/scenarios/cases/en57_td_timetable.json @@ -16,6 +16,6 @@ { "type": "starts", "min_speed": 20, "within": 150 }, { "type": "max_speed", "limit": 90, "tolerance": 3 }, { "type": "brakes", "min_pressure": 0.5 }, - { "type": "stops", "moving_speed": 20, "stop_speed": 0.5, "hold": 5 } + { "type": "stops", "moving_speed": 20, "stop_speed": 1.0, "hold": 0, "min_distance": 1380, "max_distance": 1420 } ] } diff --git a/tests/scenarios/cases/ep09_td_timetable.json b/tests/scenarios/cases/ep09_td_timetable.json index dd130be3c..851b4dbfe 100644 --- a/tests/scenarios/cases/ep09_td_timetable.json +++ b/tests/scenarios/cases/ep09_td_timetable.json @@ -12,6 +12,6 @@ { "type": "starts", "min_speed": 20, "within": 150 }, { "type": "max_speed", "limit": 90, "tolerance": 3 }, { "type": "brakes", "min_pressure": 0.5 }, - { "type": "stops", "moving_speed": 20, "stop_speed": 0.5, "hold": 5 } + { "type": "stops", "moving_speed": 20, "stop_speed": 1.0, "hold": 0, "min_distance": 1380, "max_distance": 1420 } ] } diff --git a/tests/scenarios/cases/et22_td_timetable.json b/tests/scenarios/cases/et22_td_timetable.json index 004f5354d..47622c622 100644 --- a/tests/scenarios/cases/et22_td_timetable.json +++ b/tests/scenarios/cases/et22_td_timetable.json @@ -12,6 +12,6 @@ { "type": "starts", "min_speed": 20, "within": 150 }, { "type": "max_speed", "limit": 90, "tolerance": 3 }, { "type": "brakes", "min_pressure": 0.5 }, - { "type": "stops", "moving_speed": 20, "stop_speed": 0.5, "hold": 5 } + { "type": "stops", "moving_speed": 20, "stop_speed": 1.0, "hold": 0, "min_distance": 1380, "max_distance": 1420 } ] } diff --git a/tests/scenarios/cases/eu07_td_timetable.json b/tests/scenarios/cases/eu07_td_timetable.json index 2f23019fe..3774242cd 100644 --- a/tests/scenarios/cases/eu07_td_timetable.json +++ b/tests/scenarios/cases/eu07_td_timetable.json @@ -12,6 +12,6 @@ { "type": "starts", "min_speed": 20, "within": 150 }, { "type": "max_speed", "limit": 90, "tolerance": 3 }, { "type": "brakes", "min_pressure": 0.5 }, - { "type": "stops", "moving_speed": 20, "stop_speed": 0.5, "hold": 5 } + { "type": "stops", "moving_speed": 20, "stop_speed": 1.0, "hold": 0, "min_distance": 1380, "max_distance": 1420 } ] } diff --git a/tests/scenarios/cases/sm42_td_timetable.json b/tests/scenarios/cases/sm42_td_timetable.json index fc89be0fa..994f94c0e 100644 --- a/tests/scenarios/cases/sm42_td_timetable.json +++ b/tests/scenarios/cases/sm42_td_timetable.json @@ -12,6 +12,6 @@ { "type": "starts", "min_speed": 20, "within": 150 }, { "type": "max_speed", "limit": 90, "tolerance": 3 }, { "type": "brakes", "min_pressure": 0.5 }, - { "type": "stops", "moving_speed": 20, "stop_speed": 0.5, "hold": 5 } + { "type": "stops", "moving_speed": 20, "stop_speed": 1.0, "hold": 0, "min_distance": 1380, "max_distance": 1420 } ] } diff --git a/tests/scenarios/cases/sn61_td_timetable.json b/tests/scenarios/cases/sn61_td_timetable.json index 9fa4b18d8..1a03c31f8 100644 --- a/tests/scenarios/cases/sn61_td_timetable.json +++ b/tests/scenarios/cases/sn61_td_timetable.json @@ -12,6 +12,6 @@ { "type": "starts", "min_speed": 20, "within": 150 }, { "type": "max_speed", "limit": 90, "tolerance": 3 }, { "type": "brakes", "min_pressure": 0.5 }, - { "type": "stops", "moving_speed": 20, "stop_speed": 0.5, "hold": 2 } + { "type": "stops", "moving_speed": 20, "stop_speed": 1.0, "hold": 0, "min_distance": 1380, "max_distance": 1420 } ] } diff --git a/tests/scenarios/cases/vectron_td_timetable.json b/tests/scenarios/cases/vectron_td_timetable.json index 9948a09ef..04656a00f 100644 --- a/tests/scenarios/cases/vectron_td_timetable.json +++ b/tests/scenarios/cases/vectron_td_timetable.json @@ -12,6 +12,6 @@ { "type": "starts", "min_speed": 20, "within": 150 }, { "type": "max_speed", "limit": 90, "tolerance": 3 }, { "type": "brakes", "min_pressure": 0.5 }, - { "type": "stops", "moving_speed": 20, "stop_speed": 0.5, "hold": 5 } + { "type": "stops", "moving_speed": 20, "stop_speed": 1.0, "hold": 0, "min_distance": 1380, "max_distance": 1420 } ] } diff --git a/tests/scenarios/run.py b/tests/scenarios/run.py index 4c3383081..210d6c013 100644 --- a/tests/scenarios/run.py +++ b/tests/scenarios/run.py @@ -344,7 +344,7 @@ def check_brakes(rows, min_pressure, moving_speed=20): return False, f"brake cylinder pressure never reached {min_pressure} bar after moving off" -def check_stops(rows, moving_speed, stop_speed, hold): +def check_stops(rows, moving_speed, stop_speed, hold, min_distance=None, max_distance=None): start = _first_moving(rows, moving_speed) if start is None: return False, f"never reached {moving_speed} km/h" @@ -356,7 +356,11 @@ def check_stops(rows, moving_speed, stop_speed, hold): if stopped_at is None: stopped_at = i if r[COL_TIME] - rows[stopped_at][COL_TIME] >= hold: - return True, f"came to a stop at t={rows[stopped_at][COL_TIME]:.1f}s after {dist[stopped_at]:.0f} m" + where = dist[stopped_at] + detail = f"came to a stop at t={rows[stopped_at][COL_TIME]:.1f}s after {where:.0f} m" + if (min_distance is not None and where < min_distance) or (max_distance is not None and where > max_distance): + return False, f"{detail}, wanted between {min_distance} and {max_distance} m" + return True, detail else: stopped_at = None return False, f"did not stay below {stop_speed} km/h for {hold}s after moving off"