mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-18 01:15:58 +01:00
feat(simulation): the pass and the standstill wait for the train under test only
Both waited for every vehicle of the scenery to stand still, so on a scenery with AI traffic a test could pass only when the traffic happened to stand too, and the standstill end hardly ever came. A test scenery names the train under test with test.vehicle <name> in its config block (once for each train, if several): the pass and the standstill wait for the consists of these vehicles as they are at the moment, so a train the tested one couples to counts with it. A name the scenery doesn't have ends the test with the error code. Without test.vehicle every vehicle counts, as before. A signal passed at danger counts for every train either way. run.py puts the case's lead vehicle into test.vehicle. test_mode_standstill_traffic has the train under test standing on track 2 of Stacja1 while AI traffic leaves track 1 on the timetable: it ends on its 100 s standstill, where counting every vehicle runs into the 300 s timeout. Physicslogs of the other trains of a case (<something>_<vehicle>) are moved out of the game dir too.
This commit is contained in:
@@ -33,6 +33,11 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
namespace {
|
||||
|
||||
bool is_moving(TDynamicObject const *Vehicle)
|
||||
{
|
||||
return std::abs(Vehicle->GetVelocity()) > 0.01;
|
||||
}
|
||||
|
||||
// [s] of real time since the start of the simulator
|
||||
double elapsed_wall_time()
|
||||
{
|
||||
@@ -117,10 +122,25 @@ void test_manager::start()
|
||||
finish(test_result::error, "the scenery has no vehicles");
|
||||
return;
|
||||
}
|
||||
for (auto const &name : Global.test.vehicles)
|
||||
{
|
||||
if (simulation::Vehicles.find(name) == nullptr)
|
||||
{
|
||||
finish(test_result::error, std::format("the scenery has no vehicle {} (test.vehicle)", name));
|
||||
return;
|
||||
}
|
||||
}
|
||||
// a pause set by the scenery or the settings would never be lifted, nobody is there to press the key
|
||||
Global.iPause = 0;
|
||||
auto tested { std::string("every vehicle") };
|
||||
if (false == Global.test.vehicles.empty())
|
||||
{
|
||||
tested = "the consists of";
|
||||
for (auto const &name : Global.test.vehicles)
|
||||
tested += " " + name;
|
||||
}
|
||||
auto const walllimit { m_walllimit.load() };
|
||||
WriteLog(std::format("test: started, timeout {:.0f} s, real time limit {}, standstill {:.0f} s{}{}{}", Global.test.timeout,
|
||||
WriteLog(std::format("test: started, testing {}, timeout {:.0f} s, real time limit {}, standstill {:.0f} s{}{}{}", tested, Global.test.timeout,
|
||||
walllimit > 0.0 ? std::format("{:.0f} s", walllimit) : std::string("none"), Global.test.standstill,
|
||||
Global.test.pass_on_standstill ? ", standstill passes" : "",
|
||||
Global.test.fail_if_stop_overran ? "" : ", signals passed at danger allowed",
|
||||
@@ -132,8 +152,7 @@ void test_manager::update(double const Deltatime)
|
||||
if (false == m_started || m_finished)
|
||||
return;
|
||||
|
||||
test_frame frame { Deltatime, std::nullopt, {},
|
||||
std::ranges::none_of(simulation::Vehicles.sequence(), [](TDynamicObject const *Vehicle) { return std::abs(Vehicle->GetVelocity()) > 0.01; }) };
|
||||
test_frame frame { Deltatime, std::nullopt, {}, tested_trains_at_rest() };
|
||||
if (auto const *cell = simulation::Memory.find(std::string(result_cell)))
|
||||
{
|
||||
frame.reported = cell->Value1();
|
||||
@@ -156,11 +175,22 @@ void test_manager::update(double const Deltatime)
|
||||
}
|
||||
if (passrequested)
|
||||
{
|
||||
WriteLog(std::format("test: pass requested at {:.1f} s{}, waiting for every vehicle to stop", m_progress.time,
|
||||
WriteLog(std::format("test: pass requested at {:.1f} s{}, waiting for the tested trains to stop", m_progress.time,
|
||||
frame.reason.empty() ? std::string() : std::format(" ({})", frame.reason)));
|
||||
}
|
||||
}
|
||||
|
||||
bool test_manager::tested_trains_at_rest() const
|
||||
{
|
||||
if (Global.test.vehicles.empty())
|
||||
return std::ranges::none_of(simulation::Vehicles.sequence(), is_moving);
|
||||
// the consists as they are now: a train the tested one couples to joins it, one it leaves behind doesn't
|
||||
return std::ranges::none_of(Global.test.vehicles, [](std::string const &Name) {
|
||||
auto *vehicle { simulation::Vehicles.find(Name) };
|
||||
return vehicle != nullptr && vehicle->find_vehicle(coupling::coupler, is_moving) != nullptr;
|
||||
});
|
||||
}
|
||||
|
||||
void test_manager::signal_passed_at_danger(std::string_view const Vehicle, std::string_view const Signal)
|
||||
{
|
||||
auto const reason { std::format("{} passed signal {} at danger", Vehicle, Signal) };
|
||||
|
||||
Reference in New Issue
Block a user