From 2589cff5f49bc98b9bdaa64331f86377fe3e5d52 Mon Sep 17 00:00:00 2001 From: jerrrrycho Date: Wed, 11 Nov 2026 15:00:41 +0100 Subject: [PATCH] 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