mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-27 21:45:16 +01:00
* 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
39 lines
2.1 KiB
C++
39 lines
2.1 KiB
C++
/*
|
|
This Source Code Form is subject to the
|
|
terms of the Mozilla Public License, v.
|
|
2.0. If a copy of the MPL was not
|
|
distributed with this file, You can
|
|
obtain one at
|
|
http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
// when a point of the AI's speed table (a signal above all) counts as passed by the train: the test mode's
|
|
// "signal passed at danger" and the blackbox record of passed signals (TController::CheckSignalPassed)
|
|
namespace signal_passing {
|
|
|
|
// how far behind the head a point found by the scan of a moving train may lie and still count as one the head
|
|
// had ahead [m]. GetDistanceToEvent() finds the distance in steps of a metre from the position of the memory
|
|
// cell, so a signal just ahead of the head may come out a little behind it
|
|
inline constexpr double moving_tolerance { 5.0 };
|
|
|
|
// whether a point the scan finds Distance [m] ahead of the head (negative: behind it) counts as one the head had
|
|
// ahead. a moving train may be just passing it, so a point up to moving_tolerance behind counts. a standing train
|
|
// isn't passing anything: a point found behind its head was passed before (a train set or stopped past a signal),
|
|
// and counts only once an update finds it ahead.
|
|
// known gap: the distance can be off by about half a metre (GetDistanceToEvent() takes the nearest of samples a
|
|
// metre apart), so a train standing a few decimetres short of a signal may find it just behind the head, and if it
|
|
// then runs past it at stop, that isn't reported. a tolerance for a standing train wouldn't close it: the first
|
|
// update marks a point behind the head elapsed (TSpeedPos::Update()), so such a train would be reported as passing
|
|
// the signal at once, while it stands short of it. the AI stops 8-15 m short of a signal
|
|
bool seen_ahead_when_found( double Distance, bool Standing );
|
|
|
|
// whether the head had the point ahead, after an update finds it Distance [m] ahead of the head
|
|
bool seen_ahead_on_update( double Distance, bool Seenahead );
|
|
|
|
// whether an update of a point reports it as passed: it became elapsed in this update, and the head had it ahead
|
|
bool passed_now( bool Elapsedbefore, bool Elapsed, bool Seenahead );
|
|
|
|
} // namespace signal_passing
|