From f2f152e5d35a896c5cd43046579e5d23038ea3b3 Mon Sep 17 00:00:00 2001 From: pwarszawski Date: Mon, 28 Sep 2026 20:53:58 +0200 Subject: [PATCH 1/3] AI: don't cut the power for a brake already released below 0.4 bar When the AI takes power after a brake release, determine_consist_state() marks the consist not Ready if any vehicle's distributor reports the lap or application state (b_hld | b_on), whatever the speed, and the sanity check in control_handles() then puts the master controller back to zero. A distributor stays in the lap position until the brake pipe has fully recharged, so a few seconds after a release, with 0.2-0.3 bar left in a cylinder, one wagon of a train is enough to throw an EU07 or EP09 that has just reached the 2nd-5th position back to zero; it starts again moments later. The check in motion was meant to be lenient (brake force over 10 kN), but the distributor state was applied at any speed. In motion it now counts only when the cylinder holds more than 0.4 bar, the UIC figure already used a few lines below for a released brake. At a stand the check is unchanged. Measured in real time against master, two runs of each scenery (a 20 per mille descent, flat and a 10 per mille climb with 32 consists each, and a descent with 15 freight trains of other wagon types), with a 20 km/h restriction one coach long: throttle-downs to zero in motion caused by readiness drop from 13 to 1, 7 to 2, 0 to 0 and 13 to 6. Each of those left has a wagon over 0.4 bar that is applying or lapped, or one still releasing with more than 10 kN at walking pace. No coupler broke; signal overruns, speeds in the restriction and rolling back on the climb are the same as on master within run-to-run spread. --- vehicle/Driver.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/vehicle/Driver.cpp b/vehicle/Driver.cpp index 9a6de859..7e92c7c9 100644 --- a/vehicle/Driver.cpp +++ b/vehicle/Driver.cpp @@ -5983,9 +5983,12 @@ TController::determine_consist_state() { auto const bp { std::max( 0.0, vehicle->BrakePress - ( vehicle->SpeedCtrlUnit.Parking ? vehicle->MaxBrakePress[ 0 ] * vehicle->StopBrakeDecc : 0.0 ) ) }; if (Ready) { // bo jak coś nie odhamowane, to dalej nie ma co sprawdzać - if( TestFlagAny(vehicle->Hamulec->GetBrakeStatus(), b_hld | b_on) - || ( vehicle->Vel < 1.0 ? bp > 0.4 : // ensure the brakes are sufficiently released when starting to move - vehicle->Fb * 0.001 > 10.0 ) ) { // once in motion we can make a more lenient check + auto const isbraking { TestFlagAny( vehicle->Hamulec->GetBrakeStatus(), b_hld | b_on ) }; + if( vehicle->Vel < 1.0 ? + isbraking || bp > 0.4 : // ensure the brakes are sufficiently released when starting to move + // once in motion a brake down to 0.4 bar counts as released (UIC), even if its distributor + // is still in the lap position while the brake pipe recharges + ( isbraking && bp > 0.4 ) || vehicle->Fb * 0.001 > 10.0 ) { Ready = false; } // Ra: odluźnianie przeładowanych lokomotyw, ciągniętych na zimno - prowizorka... From b71ad90c93ba909ca11c77b9cfe3b590616cadb8 Mon Sep 17 00:00:00 2001 From: pwarszawski Date: Sat, 3 Oct 2026 14:32:09 +0200 Subject: [PATCH 2/3] Declare isbraking in the init-statement of the if --- vehicle/Driver.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vehicle/Driver.cpp b/vehicle/Driver.cpp index a6223689..4b6d81ff 100644 --- a/vehicle/Driver.cpp +++ b/vehicle/Driver.cpp @@ -5901,8 +5901,8 @@ TController::determine_consist_state() { auto const bp { std::max( 0.0, vehicle->BrakePress - ( vehicle->SpeedCtrlUnit.Parking ? vehicle->MaxBrakePress[ 0 ] * vehicle->StopBrakeDecc : 0.0 ) ) }; if (Ready) { // bo jak coś nie odhamowane, to dalej nie ma co sprawdzać - auto const isbraking { TestFlagAny( vehicle->Hamulec->GetBrakeStatus(), b_hld | b_on ) }; - if( vehicle->Vel < 1.0 ? + if( auto const isbraking { TestFlagAny( vehicle->Hamulec->GetBrakeStatus(), b_hld | b_on ) }; + vehicle->Vel < 1.0 ? isbraking || bp > 0.4 : // ensure the brakes are sufficiently released when starting to move // once in motion a brake down to 0.4 bar counts as released (UIC), even if its distributor // is still in the lap position while the brake pipe recharges From 71a19f32fb101e987917c6fe75ad04ee04d26245 Mon Sep 17 00:00:00 2001 From: pwarszawski Date: Mon, 12 Oct 2026 06:54:17 +0200 Subject: [PATCH 3/3] Compare the brake force with 10 kN directly --- vehicle/Driver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vehicle/Driver.cpp b/vehicle/Driver.cpp index 4b6d81ff..2f40b2e1 100644 --- a/vehicle/Driver.cpp +++ b/vehicle/Driver.cpp @@ -5906,7 +5906,7 @@ TController::determine_consist_state() { isbraking || bp > 0.4 : // ensure the brakes are sufficiently released when starting to move // once in motion a brake down to 0.4 bar counts as released (UIC), even if its distributor // is still in the lap position while the brake pipe recharges - ( isbraking && bp > 0.4 ) || vehicle->Fb * 0.001 > 10.0 ) { + ( isbraking && bp > 0.4 ) || vehicle->Fb > 10000.0 ) { // 10 kN Ready = false; } // Ra: odluźnianie przeładowanych lokomotyw, ciągniętych na zimno - prowizorka...