diff --git a/McZapkie/MOVER.h b/McZapkie/MOVER.h index 5f649af35..14f848c8d 100644 --- a/McZapkie/MOVER.h +++ b/McZapkie/MOVER.h @@ -2688,6 +2688,8 @@ class TMoverParameters void FuelPumpCheck(double const Timestep); void OilPumpCheck(double const Timestep); void MotorBlowersCheck(double const Timestep); + // whether the circuit a traction motor blower runs off has power: the battery, the converter or the main circuit, by its start type + bool MotorBlowerPowerIsAvailable(cooling_fan const &Blower) const; void PantographsCheck(double const Timestep); void LightsCheck(double const Timestep); bool FuseOn(range_t const Notify = range_t::consist); // bezpiecznik nadamiary diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index 39b4bf5fc..e08251358 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -2403,9 +2403,7 @@ void TMoverParameters::MotorBlowersCheck(double const Timestep) } blower.is_active = // TODO: bind properly power source when ld is in place - (blower.start_type == start_t::battery ? Power24vIsAvailable : - blower.start_type == start_t::converter ? Power110vIsAvailable : - Mains) // power source + MotorBlowerPowerIsAvailable(blower) // power source // breaker condition disabled until it's implemented in the class data // && ( true == blower.breaker ) && false == disable && @@ -2435,6 +2433,19 @@ void TMoverParameters::MotorBlowersCheck(double const Timestep) } } +bool TMoverParameters::MotorBlowerPowerIsAvailable(cooling_fan const &Blower) const +{ + switch (Blower.start_type) + { + case start_t::battery: + return Power24vIsAvailable; + case start_t::converter: + return Power110vIsAvailable; + default: + return Mains; + } +} + void TMoverParameters::PantographsCheck(double const /*Timestep*/) { using enum start_t; @@ -7503,7 +7514,16 @@ bool TMoverParameters::LineContactorsInterlockReleased() const // the converter of this very vehicle, not the 110 V of the trainset: a section with its fans off doesn't start return ConverterFlag; case line_contactors_interlock::motor_blowers: - return std::ranges::all_of(MotorBlowers, [](auto const &Blower) { return Blower.is_active; }); + return std::ranges::all_of(MotorBlowers, [this](auto const &Blower) { + if (Blower.min_start_velocity < 0) + { + return Blower.is_active; + } + // a blower which starts with the speed and the motor current (MotorBlowersStartVelocity) can't run before + // the contactors close, nor after a stop longer than it keeps running for: it's enough that it's + // switched on and has power, so it starts once the vehicle moves + return MotorBlowerPowerIsAvailable(Blower) && false == Blower.is_disabled && (Blower.start_type == start_t::manual ? Blower.is_enabled : true); + }); default: return true; } diff --git a/tests/unit/test_line_contactors_interlock.cpp b/tests/unit/test_line_contactors_interlock.cpp index 104d732e1..131c912ea 100644 --- a/tests/unit/test_line_contactors_interlock.cpp +++ b/tests/unit/test_line_contactors_interlock.cpp @@ -4,6 +4,8 @@ #include "drive.h" #include "vehicle.h" +#include "McZapkie/hamulce.h" + // the line contactors interlocked with the fans of the traction motors (eu07/maszyna#460): on the ET42 the fans of a // section run off its own converter, and with them switched off the line contactors of that section don't close. // the louvres of the fans of the ET22 open with the air of the main reservoir (eu07/maszyna#451) @@ -67,6 +69,178 @@ TEST_CASE("line contactors interlock: on the motor blowers, they close only with CHECK(locomotive->MotorConnectorsCheck()); } +// a blower with MotorBlowersStartVelocity starts with the speed and the motor current, so it can't be running before +// the line contactors close, nor after a stop longer than it keeps running for (MotorBlowersSustainTime): the interlock +// takes it switched on and powered instead, or the vehicle would never take power + +TEST_CASE("line contactors interlock: a blower starting with the speed needs to be switched on and powered, not running") { + auto locomotive{ready("MotorBlowers")}; + for (auto &blower : locomotive->MotorBlowers) { + blower.min_start_velocity = 5.f; + blower.is_enabled = true; // switched on by the driver + blower.is_active = false; // the vehicle stands + } + REQUIRE(locomotive->MotorBlowers[end::front].start_type == start_t::manual); + CHECK(locomotive->MotorConnectorsCheck()); + + auto &rear{locomotive->MotorBlowers[end::rear]}; + SUBCASE("switched off, it holds the contactors open") { + rear.is_disabled = true; + CHECK_FALSE(locomotive->MotorConnectorsCheck()); + } + SUBCASE("not switched on, it holds the contactors open") { + rear.is_enabled = false; + CHECK_FALSE(locomotive->MotorConnectorsCheck()); + } + SUBCASE("off the converter, it needs the 110 V") { + rear.start_type = start_t::converter; + rear.is_enabled = false; // nothing for the driver to switch on + locomotive->Power110vIsAvailable = false; + CHECK_FALSE(locomotive->MotorConnectorsCheck()); + locomotive->Power110vIsAvailable = true; + CHECK(locomotive->MotorConnectorsCheck()); + } + SUBCASE("off the battery, it needs the 24 V") { + rear.start_type = start_t::battery; + locomotive->Power24vIsAvailable = false; + CHECK_FALSE(locomotive->MotorConnectorsCheck()); + locomotive->Power24vIsAvailable = true; + CHECK(locomotive->MotorConnectorsCheck()); + } + SUBCASE("one without a start velocity still has to run") { + rear.min_start_velocity = -1.f; + CHECK_FALSE(locomotive->MotorConnectorsCheck()); + rear.is_active = true; + CHECK(locomotive->MotorConnectorsCheck()); + } +} + +namespace { + +bool blowers_run(TMoverParameters const &Mover) { + return Mover.MotorBlowers[end::front].is_active && Mover.MotorBlowers[end::rear].is_active; +} + +// the driver's first power position, held until the line contactors close (their delay, the pressure switch) +bool close_line_contactors(test::driven const &Driven) { + Driven.controlling.IncMainCtrl(1); + for (int i = 0; i < 30 && false == Driven.controlling.StLinFlag; ++i) { + test::drive(Driven, line, 1.0); + } + return Driven.controlling.StLinFlag; +} + +// the brakes released and the cylinders empty enough for the pressure switch to let the vehicle start +void release(test::driven const &Driven) { + test::release_brakes(Driven.cab); + for (int i = 0; i < 90 && (Driven.controlling.BrakePress > 0.1 || Driven.controlling.PipePress < 4.8); ++i) { + test::drive(Driven, line, 1.0); + } +} + +} // namespace + +TEST_CASE("line contactors interlock: with blowers starting with the speed the vehicle starts from a standstill") { + // each of the circuits a blower runs off has power before the line contactors close + std::string starttype; + SUBCASE("blowers off the converter") { starttype = "Converter"; } + SUBCASE("blowers off the battery") { starttype = "Battery"; } + SUBCASE("blowers switched on by the driver, off the main circuit") { starttype = "Manual"; } + CAPTURE(starttype); + vehicle eu07{definition::fiz("4e_v1/4e") + .set("Cntrl", "LineContactorsInterlock", "MotorBlowers") + .set("Cntrl", "MotorBlowersStart", starttype) + .set("Engine", "MotorBlowersStartVelocity", 5.0) + .set("Engine", "MotorBlowersSustainTime", 10.0), + 0.0, "test", 1}; + auto &mover{eu07.mover()}; + REQUIRE(mover.LineContactorsInterlock == line_contactors_interlock::motor_blowers); + REQUIRE(mover.MotorBlowers[end::front].min_start_velocity == doctest::Approx(5.0)); + REQUIRE(mover.MotorBlowers[end::rear].sustain_time == doctest::Approx(10.0)); + auto driven{test::driving(eu07)}; + REQUIRE(test::start_up(driven, line)); + release(driven); + + // standing, the blowers don't run; the line contactors close all the same and the motors take current + REQUIRE(std::abs(eu07.speed()) < 0.1); + REQUIRE_FALSE(blowers_run(mover)); + CHECK(close_line_contactors(driven)); + CHECK(std::abs(mover.Im) > 0.5); + + // the blowers come on once the vehicle moves + for (int i = 0; i < 6; ++i) { + mover.IncMainCtrl(1); + test::drive(driven, line, 2.0); + } + for (int i = 0; i < 60 && eu07.speed() < 10.0; ++i) { + test::drive(driven, line, 1.0); + } + REQUIRE(eu07.speed() >= 10.0); + CHECK(blowers_run(mover)); + CHECK(mover.StLinFlag); + + // a stop longer than the blowers keep running for + while (mover.DecMainCtrl(1)) { + // down to zero + } + driven.cab.BrakeLevelSet(driven.cab.Handle->GetPos(bh_FB)); + for (int i = 0; i < 120 && std::abs(eu07.speed()) > 0.1; ++i) { + test::drive(driven, line, 1.0); + } + REQUIRE(std::abs(eu07.speed()) <= 0.1); + test::drive(driven, line, 15.0); + REQUIRE_FALSE(blowers_run(mover)); + REQUIRE_FALSE(mover.StLinFlag); + + // and the vehicle starts again + release(driven); + CHECK(close_line_contactors(driven)); + CHECK(std::abs(mover.Im) > 0.5); + for (int i = 0; i < 6; ++i) { + mover.IncMainCtrl(1); + test::drive(driven, line, 2.0); + } + for (int i = 0; i < 60 && eu07.speed() < 10.0; ++i) { + test::drive(driven, line, 1.0); + } + CHECK(eu07.speed() >= 10.0); + CHECK(blowers_run(mover)); +} + +TEST_CASE("line contactors interlock: a blower starting with the speed, switched off on the way, opens the contactors") { + vehicle eu07{definition::fiz("4e_v1/4e") + .set("Cntrl", "LineContactorsInterlock", "MotorBlowers") + .set("Cntrl", "MotorBlowersStart", "Manual") + .set("Engine", "MotorBlowersStartVelocity", 5.0) + .set("Engine", "MotorBlowersSustainTime", 10.0), + 0.0, "test", 1}; + auto &mover{eu07.mover()}; + auto driven{test::driving(eu07)}; + REQUIRE(test::start_up(driven, line)); + release(driven); + REQUIRE(close_line_contactors(driven)); + + // the switch of the rear blower: off, the contactors open and stay open, standing as well as later + REQUIRE(mover.MotorBlowersSwitchOff(true, end::rear)); + test::drive(driven, line, 2.0); + CHECK_FALSE(mover.StLinFlag); + CHECK(std::abs(mover.Im) < 0.5); + while (mover.DecMainCtrl(1)) { + // down to zero + } + test::drive(driven, line, 2.0); + CHECK_FALSE(close_line_contactors(driven)); + + // back on, the vehicle starts + REQUIRE(mover.MotorBlowersSwitchOff(false, end::rear)); + while (mover.DecMainCtrl(1)) { + // down to zero + } + test::drive(driven, line, 2.0); + CHECK(close_line_contactors(driven)); + CHECK(std::abs(mover.Im) > 0.5); +} + TEST_CASE("line contactors interlock: the ET42 section with its fans switched off doesn't start") { test::consist et42; et42.add(definition::fiz("et42_v2/112e-a").set("Cntrl", "LineContactorsInterlock", "Converter"), 1);