mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 17:37:09 +01:00
242474dd11
- The lights switched on at each end (iLights) are LitLights(), changed
through SetLitLights(): the cab's switches, the AI's light patterns and the
scenery's toggles of the end signals all go through it.
- The exchange of the load, which TDynamicObject ran by setting the status, the
amount and the mass itself, goes through UnloadStep(), LoadStep(),
FinishLoadExchange() and AcknowledgeLoadExchange(), with the same arithmetic;
the change of the kind of the load is taken once (TakeLoadTypeChange()).
- The events the physics reports for the sounds to follow up are raised and
cleared by name (RaiseEventFlag(), ClearEventFlag(), ClearSoundFlags()).
No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
113 lines
5.4 KiB
C++
113 lines
5.4 KiB
C++
#include "stdafx.h"
|
|
#include "doctest.h"
|
|
#include "scenario.h"
|
|
#include "drive.h"
|
|
|
|
// characterisation of the auxiliary circuits of vehicles: the battery drained and charged, and the air of the
|
|
// pantographs kept in their own tank, whose pressure switch opens the line breaker, each in a scenario on real
|
|
// vehicles recorded in golden traces (data/golden/auxiliaries/)
|
|
|
|
using test::scenario;
|
|
using namespace test::channels;
|
|
|
|
namespace {
|
|
|
|
std::vector<test::channel> auxiliaries() {
|
|
return {
|
|
{"BatteryVoltage", [](auto const &M) { return M.lowVoltage.BatteryVoltage(); }},
|
|
{"Battery", [](auto const &M) { return M.lowVoltage.IsBatteryOn() ? 1.0 : 0.0; }},
|
|
{"ConverterFlag", [](auto const &M) { return M.converter.IsRunning() ? 1.0 : 0.0; }},
|
|
{"Power110vIsAvailable", [](auto const &M) { return M.lowVoltage.Is110vAvailable() ? 1.0 : 0.0; }},
|
|
{"PantPress", [](auto const &M) { return M.pantographAir.Pressure(); }},
|
|
{"PantVolume", [](auto const &M) { return M.pantographAir.Volume(); }},
|
|
{"PantCompFlag", [](auto const &M) { return M.pantographAir.IsCompressorRunning() ? 1.0 : 0.0; }},
|
|
{"PantPressSwitchActive", [](auto const &M) { return M.pantographAir.IsPressureSwitchPrimed() ? 1.0 : 0.0; }},
|
|
{"PantPressLockActive", [](auto const &M) { return M.pantographAir.IsPressureLockActive() ? 1.0 : 0.0; }},
|
|
};
|
|
}
|
|
|
|
} // namespace
|
|
|
|
TEST_CASE("auxiliaries: the battery drained by the lights and the pantographs' compressor, until nothing starts") {
|
|
// without the converter the battery falls quickly to 90 V, then slowly as the lights and the small compressor
|
|
// draw on it; at 70 V (110 / 1.57) it opens the line breaker, and the locomotive doesn't start again
|
|
scenario scenario{"auxiliaries/battery/eu07 drained", traction() + auxiliaries()};
|
|
scenario.add("4e_v1/4e", 1);
|
|
REQUIRE(scenario.start_up());
|
|
auto &eu07{scenario.cab()};
|
|
REQUIRE(eu07.lowVoltage.BatteryVoltage() == doctest::Approx(eu07.lowVoltage.config.nominalBatteryVoltage));
|
|
scenario.act("converter off, lights on, small compressor on");
|
|
eu07.ConverterSwitch(false);
|
|
eu07.SetLitLights(VehicleEnd::front, 1 | 2 | 4);
|
|
eu07.SetLitLights(VehicleEnd::rear, 16);
|
|
eu07.pantographAir.SwitchCompressor(true);
|
|
scenario.wait(30.0);
|
|
CHECK(eu07.lowVoltage.BatteryVoltage() < 0.83 * eu07.lowVoltage.config.nominalBatteryVoltage);
|
|
CHECK(eu07.lineBreaker.IsClosed());
|
|
scenario.wait(5000.0);
|
|
CHECK(eu07.lowVoltage.BatteryVoltage() < eu07.lowVoltage.config.nominalBatteryVoltage / 1.57);
|
|
CHECK_FALSE(eu07.lineBreaker.IsClosed());
|
|
scenario.act("start up again");
|
|
CHECK_FALSE(scenario.start_up());
|
|
CHECK(eu07.lowVoltage.BatteryVoltage() < eu07.lowVoltage.config.nominalBatteryVoltage / 1.57);
|
|
scenario.check();
|
|
}
|
|
|
|
TEST_CASE("auxiliaries: the battery switched off, and charged by the converter") {
|
|
scenario scenario{"auxiliaries/battery/eu07 switched off", traction() + auxiliaries()};
|
|
scenario.add("4e_v1/4e", 1);
|
|
REQUIRE(scenario.start_up());
|
|
auto &eu07{scenario.cab()};
|
|
scenario.act("converter off");
|
|
eu07.ConverterSwitch(false);
|
|
scenario.wait(10.0);
|
|
auto const discharged{eu07.lowVoltage.BatteryVoltage()};
|
|
CHECK(discharged < 0.83 * eu07.lowVoltage.config.nominalBatteryVoltage);
|
|
// the converter charges it back at once
|
|
scenario.act("converter on");
|
|
eu07.ConverterSwitch(true);
|
|
scenario.wait(10.0);
|
|
CHECK(eu07.lowVoltage.BatteryVoltage() == doctest::Approx(eu07.lowVoltage.config.nominalBatteryVoltage));
|
|
// switched off, the battery falls to 90 V at once, then holds
|
|
scenario.act("battery off");
|
|
eu07.MainSwitch(false);
|
|
eu07.ConverterSwitch(false);
|
|
eu07.BatterySwitch(false);
|
|
scenario.wait(10.0);
|
|
CHECK(eu07.lowVoltage.BatteryVoltage() == doctest::Approx(discharged).epsilon(0.01));
|
|
scenario.check();
|
|
}
|
|
|
|
TEST_CASE("auxiliaries: the pantographs on their own tank, leaking until the pressure switch opens the line breaker") {
|
|
// the pantographs cut off the main reservoir (bPantKurek3 off) are held up by the air of their own small tank,
|
|
// which leaks; under MinPress the pressure switch, primed at 4.6 bar, opens the line breaker. the small
|
|
// compressor pumps the tank up to 4.8 bar, priming the switch again. (an electric unit's switch turns its
|
|
// converter off instead; the EW58's pantographs have an automatic valve to the main reservoir, which keeps
|
|
// their tank up)
|
|
scenario scenario{"auxiliaries/pantograph tank/eu07", traction() + auxiliaries()};
|
|
scenario.add("4e_v1/4e", 1);
|
|
REQUIRE(scenario.start_up());
|
|
auto &eu07{scenario.cab()};
|
|
// started up on the small compressor, the tank gets joined to the main reservoir, which primes the switch
|
|
scenario.act("tank joined to the main reservoir");
|
|
eu07.pantographAir.ConnectToMainReservoir(true);
|
|
scenario.wait(30.0);
|
|
REQUIRE(eu07.pantographAir.IsPressureSwitchPrimed());
|
|
scenario.act("tank cut off the main reservoir");
|
|
eu07.pantographAir.ConnectToMainReservoir(false);
|
|
eu07.pantographAir.SwitchCompressor(false);
|
|
scenario.wait(600.0);
|
|
CHECK(eu07.pantographAir.Pressure() < eu07.EnginePowerSource.CollectorParameters.MinPress);
|
|
CHECK_FALSE(eu07.pantographAir.IsPressureSwitchPrimed());
|
|
CHECK_FALSE(eu07.lineBreaker.IsClosed());
|
|
scenario.act("small compressor on");
|
|
eu07.pantographAir.SwitchCompressor(true);
|
|
for (int i = 0; i < 60 && eu07.pantographAir.IsCompressorRunning(); ++i) {
|
|
scenario.wait(10.0);
|
|
}
|
|
CHECK_FALSE(eu07.pantographAir.IsCompressorRunning());
|
|
CHECK(eu07.pantographAir.Pressure() >= 4.6); // stopped at 4.8, leaking since
|
|
CHECK(eu07.pantographAir.IsPressureSwitchPrimed());
|
|
scenario.check();
|
|
}
|