From f34f912b38248b2c75ee54f34195076d1b1a4805 Mon Sep 17 00:00:00 2001 From: jerrrrycho Date: Sat, 7 Nov 2026 20:36:25 +0100 Subject: [PATCH 1/4] feat: interlock the line contactors with the section fans, own-converter lamp (eu07/maszyna#460) On the ET42 the fans of each section run off that section's converter: the section fan switch of the cab is bound to converterlocal_sw. The line contactors of a section with its fans switched off must not close. - New optional Cntrl. key LineContactorsInterlock=Converter|MotorBlowers. MotorConnectorsCheck() then also needs the vehicle's own converter (ConverterFlag, not the trainset's shared 110 V), or all its motor blowers, running. It is checked per vehicle, so only that section stays off, and switching the fans off on the way opens its contactors. Without the key nothing changes. - New optional lamp i-converteraoff:, lit while the converter of the vehicle with the cab is off. i-converteroff: follows the shared 110 V, so with one ET42 section's fans off it stayed dark. i-converterboff: already covers the other section. SVN data, to change once this is released (old data works as before): - dynamic/pkp/et42_v2/112e-a.fiz, 112e-b.fiz: LineContactorsInterlock=Converter in the Cntrl. line. - dynamic/pkp/et42_v2/112e-a.mmd.inc, 112e-b.mmd.inc: i-converter: nadm_przetw -> i-converteraoff: nadm_przetw, i-converterb: nadm_przetw_b -> i-converterboff: nadm_przetw_b, i-compressor: sprezarka -> i-compressoroff: sprezarka, i-compressorb: sprezarka_b -> i-compressorboff: sprezarka_b (the compressor "off" lamps already light with the compressor switched off or stopped by its pressure governor). (eu07/maszyna#460) --- McZapkie/MOVER.h | 13 +++ McZapkie/Mover.cpp | 23 +++- tests/unit/test_line_contactors_interlock.cpp | 110 ++++++++++++++++++ vehicle/Train.cpp | 4 + vehicle/Train.h | 1 + 5 files changed, 150 insertions(+), 1 deletion(-) create mode 100644 tests/unit/test_line_contactors_interlock.cpp diff --git a/McZapkie/MOVER.h b/McZapkie/MOVER.h index 199c65a0c..c7d9cdbec 100644 --- a/McZapkie/MOVER.h +++ b/McZapkie/MOVER.h @@ -279,6 +279,16 @@ enum class operation_t /// Disable button release transition. disable_off, }; +/// What else the line contactors of a vehicle need before they can close (LineContactorsInterlock in the Cntrl. section). +enum class line_contactors_interlock +{ + /// Nothing more, the legacy behaviour. + none, + /// The converter of the vehicle itself running, where it drives the traction motor fans (ET42). + converter, + /// The traction motor blowers of the vehicle running. + motor_blowers +}; /// Auto-start method for ancillary devices (mutually exclusive). enum class start_t { @@ -2152,6 +2162,7 @@ class TMoverParameters start_t GroundRelayStart{start_t::manual}; // relay activation method bool StLinFlag = false; /*!o styczniki liniowe*/ bool StLinSwitchOff{false}; // state of the button forcing motor connectors open + line_contactors_interlock LineContactorsInterlock{line_contactors_interlock::none}; // what else the line contactors need to close bool ResistorsFlag = false; /*!o jazda rezystorowa*/ double RventRot = 0.0; /*!s obroty wentylatorow rozruchowych*/ double PantographVoltage{0.0}; // voltage supplied to pantographs @@ -2466,6 +2477,8 @@ class TMoverParameters { return false == StLinFlag && MainCircuitLampsEnabled(); } + // whether the devices the line contactors are interlocked with (LineContactorsInterlock) let them close + bool LineContactorsInterlockReleased() const; // whether the pumps a joint oil and fuel pump switch works, those not started automatically, are all switched on bool OilFuelPumpsEnabled() const { diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index 330e8eb8f..f5f88a681 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -7148,7 +7148,21 @@ bool TMoverParameters::MotorConnectorsCheck() auto const connectorsoff{false == Mains || true == FuseFlag || true == StLinSwitchOff || DirActive == 0}; - return false == connectorsoff; + return false == connectorsoff && LineContactorsInterlockReleased(); +} + +bool TMoverParameters::LineContactorsInterlockReleased() const +{ + switch (LineContactorsInterlock) + { + case line_contactors_interlock::converter: + // 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; }); + default: + return true; + } } bool TMoverParameters::OperatePantographsValve(operation_t const State, range_t const Notify) @@ -11001,6 +11015,13 @@ void TMoverParameters::LoadFIZ_Cntrl(std::string const &line) MotorBlowers[end::rear].start_type = lookup != starts.end() ? lookup->second : start_t::manual; MotorBlowers[end::front].start_type = MotorBlowers[end::rear].start_type; } + // what else the line contactors need to close + { + std::map> const interlocks{{"Converter", line_contactors_interlock::converter}, + {"MotorBlowers", line_contactors_interlock::motor_blowers}}; + auto lookup = interlocks.find(extract_value("LineContactorsInterlock", line)); + LineContactorsInterlock = lookup != interlocks.end() ? lookup->second : line_contactors_interlock::none; + } // compartment lights { auto lookup = starts.find(extract_value("CompartmentLightsStart", line)); diff --git a/tests/unit/test_line_contactors_interlock.cpp b/tests/unit/test_line_contactors_interlock.cpp new file mode 100644 index 000000000..a34bcac7d --- /dev/null +++ b/tests/unit/test_line_contactors_interlock.cpp @@ -0,0 +1,110 @@ +#include "stdafx.h" +#include "doctest.h" +#include "consist.h" +#include "drive.h" +#include "vehicle.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. + +using test::definition; +using test::vehicle; + +namespace { + +// a vehicle whose line contactors could close, but for the interlock +vehicle ready(std::string_view const Interlock) { + auto loaded{definition::load("wagon")}; + if (false == Interlock.empty()) { + loaded.set("Cntrl", "LineContactorsInterlock", std::string{Interlock}); + } + vehicle locomotive{loaded}; + locomotive->Mains = true; + locomotive->DirActive = 1; + locomotive->PipePress = 5.0; + locomotive->BrakePress = 0.0; + return locomotive; +} + +test::track const line{0.15, 0.0, test::catenary_3kv}; + +} // namespace + +TEST_CASE("line contactors interlock: read from the Cntrl. section, none by default") { + CHECK(ready("")->LineContactorsInterlock == line_contactors_interlock::none); + CHECK(ready("Converter")->LineContactorsInterlock == line_contactors_interlock::converter); + CHECK(ready("MotorBlowers")->LineContactorsInterlock == line_contactors_interlock::motor_blowers); + CHECK(ready("Something")->LineContactorsInterlock == line_contactors_interlock::none); +} + +TEST_CASE("line contactors interlock: without one the converter and the blowers don't matter, as before") { + auto locomotive{ready("")}; + locomotive->ConverterFlag = false; + for (auto &blower : locomotive->MotorBlowers) { + blower.is_active = false; + } + CHECK(locomotive->MotorConnectorsCheck()); +} + +TEST_CASE("line contactors interlock: on the converter, they close only with the vehicle's own converter running") { + auto locomotive{ready("Converter")}; + locomotive->ConverterFlag = false; + locomotive->Power110vIsAvailable = true; // the 110 V from the other section doesn't run this one's fans + CHECK_FALSE(locomotive->MotorConnectorsCheck()); + locomotive->ConverterFlag = true; + CHECK(locomotive->MotorConnectorsCheck()); + locomotive->Mains = false; // the other conditions still hold + CHECK_FALSE(locomotive->MotorConnectorsCheck()); +} + +TEST_CASE("line contactors interlock: on the motor blowers, they close only with all of them running") { + auto locomotive{ready("MotorBlowers")}; + locomotive->MotorBlowers[end::front].is_active = true; + locomotive->MotorBlowers[end::rear].is_active = false; + CHECK_FALSE(locomotive->MotorConnectorsCheck()); + locomotive->MotorBlowers[end::rear].is_active = true; + CHECK(locomotive->MotorConnectorsCheck()); +} + +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); + et42.add(definition::fiz("et42_v2/112e-b").set("Cntrl", "LineContactorsInterlock", "Converter")); + auto driven{test::driving(et42)}; + REQUIRE(test::start_up(driven, line)); + auto &front{et42[0].mover()}; + auto &rear{et42[1].mover()}; + REQUIRE(front.ConverterFlag); + REQUIRE(rear.ConverterFlag); + + // the fans of the rear section switched off with its own switch, the 110 V of the front one still reaches it + rear.ConverterAllowLocal = false; + test::drive(driven, line, 2.0); + REQUIRE_FALSE(rear.ConverterFlag); + CHECK(rear.Power110vIsAvailable); + + test::release_brakes(driven.cab); + for (int i = 0; i < 3 && driven.cab.DirActive <= 0; ++i) { + driven.cab.DirectionForward(); + } + test::drive(driven, line, 20.0); + driven.controlling.IncMainCtrl(1); + // as the AI does, it waits at the first position for the contactors (their delay, the pressure switch) + for (int i = 0; i < 90 && false == front.StLinFlag; ++i) { + test::drive(driven, line, 1.0); + } + CHECK(front.StLinFlag); + CHECK_FALSE(rear.StLinFlag); + + // the fans back on, the section starts too + rear.ConverterAllowLocal = true; + test::drive(driven, line, 10.0); + REQUIRE(rear.ConverterFlag); + CHECK(rear.StLinFlag); + + // and the fans switched off on the way open its line contactors again + rear.ConverterAllowLocal = false; + test::drive(driven, line, 2.0); + CHECK_FALSE(rear.StLinFlag); + CHECK(front.StLinFlag); +} diff --git a/vehicle/Train.cpp b/vehicle/Train.cpp index 201b8972f..2926d74fc 100644 --- a/vehicle/Train.cpp +++ b/vehicle/Train.cpp @@ -8975,6 +8975,7 @@ bool TTrain::Update(double const Deltatime) btLampkaPrzetw.Turn(mvOccupied->Power110vIsAvailable); btLampkaPrzetwOff.Turn(!mvOccupied->Power110vIsAvailable); + btLampkaPrzetwAOff.Turn(!mvControlled->ConverterFlag); btLampkaNadmPrzetw.Turn(Dynamic()->Mechanik ? Dynamic()->Mechanik->IsAnyConverterOverloadRelayOpen : mvControlled->ConvOvldFlag); btLampkaOpory.Turn(mvControlled->StLinFlag && mvControlled->ResistorsFlagCheck()); @@ -9147,6 +9148,7 @@ bool TTrain::Update(double const Deltatime) btLampkaNapNastHam.Turn(false); btLampkaPrzetw.Turn(false); btLampkaPrzetwOff.Turn(false); + btLampkaPrzetwAOff.Turn(false); btLampkaNadmPrzetw.Turn(false); btLampkaSprezarka.Turn(false); btLampkaSprezarkaOff.Turn(false); @@ -11131,6 +11133,7 @@ void TTrain::clear_cab_controls() btLampkaPrzetw.Clear(); btLampkaPrzetwB.Clear(); btLampkaPrzetwBOff.Clear(); + btLampkaPrzetwAOff.Clear(); btLampkaPrzekRozn.Clear(); btLampkaPrzekRoznPom.Clear(); btLampkaUkrotnienie.Clear(); @@ -11546,6 +11549,7 @@ bool TTrain::initialize_button(cParser &Parser, std::string const &Label, int co {"i-conv_ovld:", btLampkaNadmPrzetw}, {"i-converter:", btLampkaPrzetw}, {"i-converteroff:", btLampkaPrzetwOff}, + {"i-converteraoff:", btLampkaPrzetwAOff}, {"i-converterb:", btLampkaPrzetwB}, {"i-converterboff:", btLampkaPrzetwBOff}, {"i-diff_relay:", btLampkaPrzekRozn}, diff --git a/vehicle/Train.h b/vehicle/Train.h index 009b349b4..df5dcfb76 100644 --- a/vehicle/Train.h +++ b/vehicle/Train.h @@ -709,6 +709,7 @@ public: // reszta może by?publiczna TButton btLampkaNadmPrzetw; TButton btLampkaPrzetw; TButton btLampkaPrzetwOff; + TButton btLampkaPrzetwAOff; // the converter of this very unit off, where the trainset shares its 110 V (ET42 section fans) TButton btLampkaPrzekRozn; // TODO: implement TButton btLampkaPrzekRoznPom; // TODO: implement TButton btLampkaNadmSil; From d50f51cdff0cce82cc71c385e61eb47cde42f7fb Mon Sep 17 00:00:00 2001 From: jerrrrycho Date: Sat, 7 Nov 2026 20:41:06 +0100 Subject: [PATCH 2/4] feat: ET22 louvre lamp, lit until the main reservoir opens the louvres (eu07/maszyna#451) The ET22 cab binds its louvre lamp to i-voltbrake: (voltage on the brake controller) as a stand-in. The real lamp goes out once the main compressors have filled the main reservoir to about 5 bar and the pneumatic louvres of the motor fans open. - New optional lamp i-louvresclosed:, lit (with low voltage power) while the main reservoir pressure is below LouvresOpenPressure. - New optional Cntrl. key LouvresOpenPressure [bar], 5.0 by default, so the .mmd change alone is enough. - i-vent_trim: (btLampkaWentZaluzje, never driven) is left alone, because the WMB10 binds it and would suddenly light up. SVN data, to change once this is released (old data works as before): - dynamic/pkp/et22_v3/201eo.mmd.inc, 201eo_160ec.mmd.inc, 201ek.mmd: i-voltbrake: lampka_zaluzje -> i-louvresclosed: lampka_zaluzje - dynamic/pkp/et22-2000_v2/201em.mmd: i-voltbrake: zaluzje -> i-louvresclosed: zaluzje (eu07/maszyna#451) --- McZapkie/MOVER.h | 6 ++++++ McZapkie/Mover.cpp | 1 + tests/unit/test_line_contactors_interlock.cpp | 16 ++++++++++++++++ vehicle/Train.cpp | 4 ++++ vehicle/Train.h | 1 + 5 files changed, 28 insertions(+) diff --git a/McZapkie/MOVER.h b/McZapkie/MOVER.h index c7d9cdbec..f7eb2fe56 100644 --- a/McZapkie/MOVER.h +++ b/McZapkie/MOVER.h @@ -2163,6 +2163,7 @@ class TMoverParameters bool StLinFlag = false; /*!o styczniki liniowe*/ bool StLinSwitchOff{false}; // state of the button forcing motor connectors open line_contactors_interlock LineContactorsInterlock{line_contactors_interlock::none}; // what else the line contactors need to close + double LouvresOpenPressure{5.0}; // main reservoir pressure [bar] at which the pneumatic louvres of the motor fans open (ET22) bool ResistorsFlag = false; /*!o jazda rezystorowa*/ double RventRot = 0.0; /*!s obroty wentylatorow rozruchowych*/ double PantographVoltage{0.0}; // voltage supplied to pantographs @@ -2477,6 +2478,11 @@ class TMoverParameters { return false == StLinFlag && MainCircuitLampsEnabled(); } + // whether the pneumatic louvres of the motor fans are still closed, the main reservoir short of the pressure that opens them + bool LouvresClosed() const + { + return Compressor < LouvresOpenPressure; + } // whether the devices the line contactors are interlocked with (LineContactorsInterlock) let them close bool LineContactorsInterlockReleased() const; // whether the pumps a joint oil and fuel pump switch works, those not started automatically, are all switched on diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index f5f88a681..a2845569c 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -11022,6 +11022,7 @@ void TMoverParameters::LoadFIZ_Cntrl(std::string const &line) auto lookup = interlocks.find(extract_value("LineContactorsInterlock", line)); LineContactorsInterlock = lookup != interlocks.end() ? lookup->second : line_contactors_interlock::none; } + extract_value(LouvresOpenPressure, "LouvresOpenPressure", line, ""); // compartment lights { auto lookup = starts.find(extract_value("CompartmentLightsStart", line)); diff --git a/tests/unit/test_line_contactors_interlock.cpp b/tests/unit/test_line_contactors_interlock.cpp index a34bcac7d..104d732e1 100644 --- a/tests/unit/test_line_contactors_interlock.cpp +++ b/tests/unit/test_line_contactors_interlock.cpp @@ -6,6 +6,7 @@ // 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) using test::definition; using test::vehicle; @@ -108,3 +109,18 @@ TEST_CASE("line contactors interlock: the ET42 section with its fans switched of CHECK_FALSE(rear.StLinFlag); CHECK(front.StLinFlag); } + +TEST_CASE("louvres: closed until the main reservoir reaches the pressure that opens them") { + vehicle et22{definition::fiz("et22_v3/201e-w")}; + CHECK(et22->LouvresOpenPressure == doctest::Approx(5.0)); // by default + et22->Compressor = 4.9; + CHECK(et22->LouvresClosed()); + et22->Compressor = 5.0; + CHECK_FALSE(et22->LouvresClosed()); + + vehicle given{definition::fiz("et22_v3/201e-w").set("Cntrl", "LouvresOpenPressure", 4.0)}; + given->Compressor = 4.5; + CHECK_FALSE(given->LouvresClosed()); + given->Compressor = 3.9; + CHECK(given->LouvresClosed()); +} diff --git a/vehicle/Train.cpp b/vehicle/Train.cpp index 2926d74fc..6a1e9f4a1 100644 --- a/vehicle/Train.cpp +++ b/vehicle/Train.cpp @@ -9112,6 +9112,7 @@ bool TTrain::Update(double const Deltatime) btLampkaEngineOverheat.Turn(mvControlled->dizel_heat.engine_is_hot); btLampkaMotorBlowers.Turn(mvControlled->MotorBlowers[end::front].is_active && mvControlled->MotorBlowers[end::rear].is_active); btLampkaCoolingFans.Turn(mvControlled->RventRot > 1.0); + btLampkaLouvresClosed.Turn(mvControlled->LouvresClosed()); btLampkaTempomat.Turn(mvOccupied->SpeedCtrlUnit.IsActive); btLampkaDistanceCounter.Turn(m_distancecounter >= 0.f); // universal devices state indicators @@ -9198,6 +9199,7 @@ bool TTrain::Update(double const Deltatime) btLampkaMalfunction.Turn(false); btLampkaMotorBlowers.Turn(false); btLampkaCoolingFans.Turn(false); + btLampkaLouvresClosed.Turn(false); btLampkaTempomat.Turn(false); btLampkaDistanceCounter.Turn(false); // universal devices state indicators @@ -11213,6 +11215,7 @@ void TTrain::clear_cab_controls() btLampkaMalfunctionB.Clear(); btLampkaMotorBlowers.Clear(); btLampkaCoolingFans.Clear(); + btLampkaLouvresClosed.Clear(); btLampkaTempomat.Clear(); btLampkaDistanceCounter.Clear(); @@ -11577,6 +11580,7 @@ bool TTrain::initialize_button(cParser &Parser, std::string const &Label, int co {"i-vent_trim:", btLampkaWentZaluzje}, {"i-motorblowers:", btLampkaMotorBlowers}, {"i-coolingfans:", btLampkaCoolingFans}, + {"i-louvresclosed:", btLampkaLouvresClosed}, {"i-tempomat:", btLampkaTempomat}, {"i-distancecounter:", btLampkaDistanceCounter}, {"i-trainheating:", btLampkaOgrzewanieSkladu}, diff --git a/vehicle/Train.h b/vehicle/Train.h index df5dcfb76..b2cc84f46 100644 --- a/vehicle/Train.h +++ b/vehicle/Train.h @@ -815,6 +815,7 @@ public: // reszta może by?publiczna TButton btLampkaMalfunctionB; TButton btLampkaMotorBlowers; TButton btLampkaCoolingFans; + TButton btLampkaLouvresClosed; // ET22, the pneumatic louvres of the motor fans not open yet TButton btLampkaTempomat; TButton btLampkaDistanceCounter; From efe5b682f797f510a57e913ef106ce45de7928f0 Mon Sep 17 00:00:00 2001 From: jerrrrycho Date: Wed, 11 Nov 2026 15:00:27 +0100 Subject: [PATCH 3/4] fix: line contactors interlocked with speed-started blowers close at a standstill With LineContactorsInterlock=MotorBlowers the line contactors waited for every motor blower to run. A blower with MotorBlowersStartVelocity starts only with the vehicle moving and the motors drawing current, so standing it never ran, the contactors never closed, no current flowed and the vehicle couldn't start at all; the same after a stop longer than MotorBlowersSustainTime. - For a blower with a start velocity the interlock now asks whether it is switched on and has power (not switched off, switched on where the driver starts it, its power source present), instead of whether it runs. Blowers without a start velocity still have to run. - The power source of a blower (battery: 24 V, converter: 110 V, else the main circuit) is one function, MotorBlowerPowerIsAvailable(), used by MotorBlowersCheck() and the interlock. None of the three needs the line contactors closed: the battery and the converter run before them, and the main circuit is the line breaker they need anyway. (eu07/maszyna#460) --- McZapkie/MOVER.h | 2 + McZapkie/Mover.cpp | 28 ++- tests/unit/test_line_contactors_interlock.cpp | 174 ++++++++++++++++++ 3 files changed, 200 insertions(+), 4 deletions(-) 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); From 2589cff5f49bc98b9bdaa64331f86377fe3e5d52 Mon Sep 17 00:00:00 2001 From: jerrrrycho Date: Wed, 11 Nov 2026 15:00:41 +0100 Subject: [PATCH 4/4] fix(ai): the AI switches the local converter of an interlocked section back on The player switches the fans of the own ET42 section off (converterlocal_sw) and hands the train to the AI. The AI only works the main converter switch, and takes the converters for running as the other section's is, but with LineContactorsInterlock=Converter the line contactors of the own section stay open and the AI waits at the first controller position forever. - Switching the converters on (the converteron action), the AI also puts the local switch back on in the vehicles under its control whose line contactors wait for their own converter. - With such a switch off the AI doesn't take the engine for ready, so it goes back to preparing it, also when the switch is flipped while it drives. The human driver may still run with a section switched off. - Vehicles without the interlock are left as they were. The lever of the switch in the cab doesn't follow the AI, like the one of the main converter switch; it is set anew when the cab is entered. (eu07/maszyna#460) --- McZapkie/MOVER.h | 6 ++++++ application/driverhints.cpp | 8 ++++++++ tests/unit/test_line_contactors_interlock.cpp | 15 +++++++++++++++ vehicle/Driver.cpp | 9 +++++++-- 4 files changed, 36 insertions(+), 2 deletions(-) diff --git a/McZapkie/MOVER.h b/McZapkie/MOVER.h index 14f848c8d..d4f575287 100644 --- a/McZapkie/MOVER.h +++ b/McZapkie/MOVER.h @@ -2623,6 +2623,12 @@ class TMoverParameters } // whether the devices the line contactors are interlocked with (LineContactorsInterlock) let them close bool LineContactorsInterlockReleased() const; + // whether the line contactors wait for the converter of the vehicle, switched off with its local switch (converterlocal_sw). + // the AI driver doesn't leave it so: the converters of the other vehicles running, it would wait for the contactors forever + bool LineContactorsHeldByLocalConverterSwitch() const + { + return LineContactorsInterlock == line_contactors_interlock::converter && false == ConverterAllowLocal; + } // whether the vehicle has a driver's cab: it has the driver's brake valve (BrakeHandle in the Cntrl. section of the // .fiz), which the wagons and most cars of the units without a cab don't (a few copy the Cntrl. section of the cab // car, as the EN57 s car does). it's the vehicle type's, unlike the cab the scenario puts a driver in diff --git a/application/driverhints.cpp b/application/driverhints.cpp index ae39ede7a..0c6f02cc8 100644 --- a/application/driverhints.cpp +++ b/application/driverhints.cpp @@ -326,6 +326,14 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) case driver_hint::converteron: { if( AIControllFlag ) { mvOccupied->ConverterSwitch( true ); + // the local switch of the converter too, where the line contactors wait for the vehicle's own converter + // (LineContactorsInterlock): left off by the human driver, that vehicle would never take power + pVehicle->for_each( + coupling::control, + []( TDynamicObject * Vehicle ) { + auto *vehicle { Vehicle->MoverParameters }; + if( vehicle->LineContactorsHeldByLocalConverterSwitch() ) { + vehicle->ConverterAllowLocal = true; } } ); } remove_hint( driver_hint::converteroff ); hint( diff --git a/tests/unit/test_line_contactors_interlock.cpp b/tests/unit/test_line_contactors_interlock.cpp index 131c912ea..a025d4a69 100644 --- a/tests/unit/test_line_contactors_interlock.cpp +++ b/tests/unit/test_line_contactors_interlock.cpp @@ -241,6 +241,21 @@ TEST_CASE("line contactors interlock: a blower starting with the speed, switched CHECK(std::abs(mover.Im) > 0.5); } +TEST_CASE("line contactors interlock: held by the local converter switch only where they wait for that converter") { + // what the AI driver looks at to switch the converter of a section back on (TController, the converteron hint) + auto interlocked{ready("Converter")}; + CHECK_FALSE(interlocked->LineContactorsHeldByLocalConverterSwitch()); + interlocked->ConverterAllowLocal = false; + CHECK(interlocked->LineContactorsHeldByLocalConverterSwitch()); + + for (auto const *other : {"", "MotorBlowers"}) { + CAPTURE(other); + auto locomotive{ready(other)}; + locomotive->ConverterAllowLocal = false; + CHECK_FALSE(locomotive->LineContactorsHeldByLocalConverterSwitch()); + } +} + 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); diff --git a/vehicle/Driver.cpp b/vehicle/Driver.cpp index 03c471904..bbfd822d1 100644 --- a/vehicle/Driver.cpp +++ b/vehicle/Driver.cpp @@ -6587,11 +6587,14 @@ TController::determine_consist_state() { IsAnyConverterPresent = false; IsAnyConverterEnabled = false; IsAnyConverterExplicitlyEnabled = false; + // whether the line contactors of a vehicle wait for its own converter (LineContactorsInterlock), off with its local switch + auto islocalconverterswitchoff { false }; pVehicle->for_each( coupling::control, - [this]( TDynamicObject * Vehicle ) { + [this, &islocalconverterswitchoff]( TDynamicObject * Vehicle ) { auto const *vehicle { Vehicle->MoverParameters }; + islocalconverterswitchoff |= vehicle->LineContactorsHeldByLocalConverterSwitch(); IsAnyConverterOverloadRelayOpen |= vehicle->ConvOvldFlag; IsAnyMotorOverloadRelayOpen |= vehicle->FuseFlag; IsAnyGroundRelayOpen |= !vehicle->GroundRelay; @@ -6662,7 +6665,9 @@ TController::determine_consist_state() { false == IsAnyConverterOverloadRelayOpen && false == IsAnyLineBreakerOpen && ( false == IsAnyConverterPresent || true == IsAnyConverterEnabled ) - && ( false == IsAnyCompressorPresent || true == IsAnyCompressorEnabled ); + && ( false == IsAnyCompressorPresent || true == IsAnyCompressorEnabled ) + // the ai goes back to preparing the engine and switches that converter on, the human driver may run with it off + && ( false == AIControllFlag || false == islocalconverterswitchoff ); } void