From 26c640eeafad9ae4d65763123ef25a7248d7abc4 Mon Sep 17 00:00:00 2001 From: Hirek Date: Mon, 6 Jan 2025 19:45:21 +0100 Subject: [PATCH 1/9] Add cab activated light i-cabactived in mmd --- Train.cpp | 11 ++++++++++- Train.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Train.cpp b/Train.cpp index bd7d87cc..5a974580 100644 --- a/Train.cpp +++ b/Train.cpp @@ -7367,6 +7367,14 @@ bool TTrain::Update( double const Deltatime ) btLampkaPoslizg.Turn( false ); } + // Lampka aktywowanej kabiny + if (mvControlled->CabActive != 0) { + btCabActived.Turn(true); + } + else { + btCabActived.Turn(false); + } + if( true == lowvoltagepower ) { // McZapkie-141102: SHP i czuwak, TODO: sygnalizacja kabinowa if( mvOccupied->SecuritySystem.is_vigilance_blinking() ) { @@ -10069,7 +10077,8 @@ bool TTrain::initialize_button(cParser &Parser, std::string const &Label, int co { "i-universal6:", btUniversals[ 6 ] }, { "i-universal7:", btUniversals[ 7 ] }, { "i-universal8:", btUniversals[ 8 ] }, - { "i-universal9:", btUniversals[ 9 ] } + { "i-universal9:", btUniversals[ 9 ] }, + { "i-cabactived", btCabActived } }; { auto lookup = lights.find( Label ); diff --git a/Train.h b/Train.h index 11235468..f3d3f36f 100644 --- a/Train.h +++ b/Train.h @@ -771,6 +771,7 @@ public: // reszta może by?publiczna TButton btLampkaRearRightLight; TButton btLampkaRearLeftEndLight; TButton btLampkaRearRightEndLight; + TButton btCabActived; // other TButton btLampkaMalfunction; TButton btLampkaMalfunctionB; From ba34a4cd87c071989e606c36f28b4071c32e36a8 Mon Sep 17 00:00:00 2001 From: Hirek Date: Mon, 6 Jan 2025 19:46:11 +0100 Subject: [PATCH 2/9] Add missing ":" at end of i-cabactivated --- Train.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Train.cpp b/Train.cpp index 5a974580..e9656ede 100644 --- a/Train.cpp +++ b/Train.cpp @@ -10078,7 +10078,8 @@ bool TTrain::initialize_button(cParser &Parser, std::string const &Label, int co { "i-universal7:", btUniversals[ 7 ] }, { "i-universal8:", btUniversals[ 8 ] }, { "i-universal9:", btUniversals[ 9 ] }, - { "i-cabactived", btCabActived } + { "i-cabactived:", btCabActived }, + }; { auto lookup = lights.find( Label ); From eeb3387b333d8751bd209146e2b6ec133fcfaf69 Mon Sep 17 00:00:00 2001 From: Hirek Date: Mon, 6 Jan 2025 19:49:29 +0100 Subject: [PATCH 3/9] Add working light to indicate any active compressor i-compressorany: in mmd --- Train.cpp | 8 +++++++- Train.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Train.cpp b/Train.cpp index e9656ede..c7b2a93f 100644 --- a/Train.cpp +++ b/Train.cpp @@ -7367,6 +7367,12 @@ bool TTrain::Update( double const Deltatime ) btLampkaPoslizg.Turn( false ); } + // Lampka pracujacej sprezacki + if (mvControlled->CompressorFlag || mvOccupied->CompressorFlag) + btCompressors.Turn(true); + else + btCompressors.Turn(false); + // Lampka aktywowanej kabiny if (mvControlled->CabActive != 0) { btCabActived.Turn(true); @@ -10079,7 +10085,7 @@ bool TTrain::initialize_button(cParser &Parser, std::string const &Label, int co { "i-universal8:", btUniversals[ 8 ] }, { "i-universal9:", btUniversals[ 9 ] }, { "i-cabactived:", btCabActived }, - + {"i-compressor:", btCompressors } }; { auto lookup = lights.find( Label ); diff --git a/Train.h b/Train.h index f3d3f36f..4e045600 100644 --- a/Train.h +++ b/Train.h @@ -772,6 +772,7 @@ public: // reszta może by?publiczna TButton btLampkaRearLeftEndLight; TButton btLampkaRearRightEndLight; TButton btCabActived; + TButton btCompressors; // lampka pracy jakiejkolwiek sprezarki // other TButton btLampkaMalfunction; TButton btLampkaMalfunctionB; From d72c709fff4310197ddbecbc1d4e7e4602392c06 Mon Sep 17 00:00:00 2001 From: Hirek Date: Mon, 6 Jan 2025 20:05:11 +0100 Subject: [PATCH 4/9] Add random 0 speed from range 0-4 on tachometerb --- Train.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Train.cpp b/Train.cpp index c7b2a93f..64cccf3e 100644 --- a/Train.cpp +++ b/Train.cpp @@ -6949,10 +6949,11 @@ bool TTrain::Update( double const Deltatime ) // pomiar, pol sekundy ustawienie if (ff != fTachoTimer) // jesli w tej sekundzie nie zmienial { - if (fTachoVelocity > 1) // jedzie - fTachoVelocityJump = fTachoVelocity + (2.0 - LocalRandom(3) + LocalRandom(3)) * 0.5; - else - fTachoVelocityJump = 0; // stoi + if (fTachoVelocity >= 5) // jedzie + fTachoVelocityJump = fTachoVelocity + (2.0 - LocalRandom(3) + LocalRandom(3)) * 0.5; + else if (2 < fTachoVelocity < 5) + fTachoVelocityJump = Random(0, 4); // tu ma sie bujac jak wariat i zatrzymac na jakiejs predkosci + // fTachoVelocityJump = 0; // stoi fTachoTimer = ff; // juz zmienil } } @@ -10085,7 +10086,7 @@ bool TTrain::initialize_button(cParser &Parser, std::string const &Label, int co { "i-universal8:", btUniversals[ 8 ] }, { "i-universal9:", btUniversals[ 9 ] }, { "i-cabactived:", btCabActived }, - {"i-compressor:", btCompressors } + {"i-compressorany:", btCompressors } }; { auto lookup = lights.find( Label ); From 10e7f21520c9b4ae82e0cc09c234ddd128f7e0e2 Mon Sep 17 00:00:00 2001 From: Hirek Date: Mon, 6 Jan 2025 20:05:38 +0100 Subject: [PATCH 5/9] Fix logic for low tachometerb speeds --- Train.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Train.cpp b/Train.cpp index 64cccf3e..936c98e9 100644 --- a/Train.cpp +++ b/Train.cpp @@ -6951,7 +6951,7 @@ bool TTrain::Update( double const Deltatime ) { if (fTachoVelocity >= 5) // jedzie fTachoVelocityJump = fTachoVelocity + (2.0 - LocalRandom(3) + LocalRandom(3)) * 0.5; - else if (2 < fTachoVelocity < 5) + else if (1 <= fTachoVelocity < 5) fTachoVelocityJump = Random(0, 4); // tu ma sie bujac jak wariat i zatrzymac na jakiejs predkosci // fTachoVelocityJump = 0; // stoi fTachoTimer = ff; // juz zmienil From 105e6283821ab8a30a981974ae5c56fda1781d8a Mon Sep 17 00:00:00 2001 From: Hirek Date: Mon, 6 Jan 2025 20:14:30 +0100 Subject: [PATCH 6/9] Another random stop variable randomization logic fix --- Train.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Train.cpp b/Train.cpp index 936c98e9..446a3fbe 100644 --- a/Train.cpp +++ b/Train.cpp @@ -6951,7 +6951,7 @@ bool TTrain::Update( double const Deltatime ) { if (fTachoVelocity >= 5) // jedzie fTachoVelocityJump = fTachoVelocity + (2.0 - LocalRandom(3) + LocalRandom(3)) * 0.5; - else if (1 <= fTachoVelocity < 5) + else if (fTachoVelocity < 5 && fTachoVelocity > 1) fTachoVelocityJump = Random(0, 4); // tu ma sie bujac jak wariat i zatrzymac na jakiejs predkosci // fTachoVelocityJump = 0; // stoi fTachoTimer = ff; // juz zmienil From d66d4751c22c7de454fd8180ec1f583c0c80cc88 Mon Sep 17 00:00:00 2001 From: Hirek Date: Mon, 6 Jan 2025 20:27:25 +0100 Subject: [PATCH 7/9] Add logic for defining max analog tacho display speed MaxTachoSpeed in Cntrl. section in fiz --- McZapkie/MOVER.h | 1 + McZapkie/Mover.cpp | 4 ++++ Train.cpp | 8 +++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/McZapkie/MOVER.h b/McZapkie/MOVER.h index 29e3f0b4..8d469041 100644 --- a/McZapkie/MOVER.h +++ b/McZapkie/MOVER.h @@ -1191,6 +1191,7 @@ public: int Lights[2][17]; // pozycje świateł, przód - tył, 1 .. 16 int ScndInMain{ 0 }; /*zaleznosc bocznika od nastawnika*/ bool MBrake = false; /*Czy jest hamulec reczny*/ + double maxTachoSpeed = 0.0; // maksymalna predkosc na tarczce predkosciomierza analogowego double StopBrakeDecc = 0.0; bool ReleaseParkingBySpringBrake { false }; bool ReleaseParkingBySpringBrakeWhenDoorIsOpen{ false }; diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index 886209a9..7d030eed 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -10540,6 +10540,10 @@ void TMoverParameters::LoadFIZ_Cntrl( std::string const &line ) { } // mbrake extract_value( MBrake, "ManualBrake", line, "" ); + + // maksymalna predkosc dostepna na tarczce predkosciomierza + extract_value(maxTachoSpeed, "MaxTachoSpeed", line, ""); + // dynamicbrake { std::map dynamicbrakes{ diff --git a/Train.cpp b/Train.cpp index 446a3fbe..f460a309 100644 --- a/Train.cpp +++ b/Train.cpp @@ -6943,7 +6943,13 @@ bool TTrain::Update( double const Deltatime ) // McZapkie: predkosc wyswietlana na tachometrze brana jest z obrotow kol auto const maxtacho { 3.0 }; - fTachoVelocity = static_cast( std::min( std::abs(11.31 * mvControlled->WheelDiameter * mvControlled->nrot), mvControlled->Vmax * 1.05) ); + + double maxSpeed = mvControlled->Vmax * 1.05; // zachowanie starej logiki jak nie ma definicji max tarczki + if (mvOccupied->maxTachoSpeed != 0) + { + maxSpeed = mvOccupied->maxTachoSpeed; + } + fTachoVelocity = static_cast(std::min(std::abs(11.31 * mvControlled->WheelDiameter * mvControlled->nrot), maxSpeed)); { // skacze osobna zmienna float ff = simulation::Time.data().wSecond; // skacze co sekunde - pol sekundy // pomiar, pol sekundy ustawienie From b8d7d4b09651c348b8ed4f50a93dff4e6ddb9915 Mon Sep 17 00:00:00 2001 From: Hirek Date: Mon, 6 Jan 2025 20:46:27 +0100 Subject: [PATCH 8/9] Add variable door lock speed DoorLockSpeed in Doors: section in fiz --- McZapkie/MOVER.h | 1 + McZapkie/Mover.cpp | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/McZapkie/MOVER.h b/McZapkie/MOVER.h index 8d469041..7d048d5f 100644 --- a/McZapkie/MOVER.h +++ b/McZapkie/MOVER.h @@ -959,6 +959,7 @@ private: std::array instances; // door on the right and left side of the vehicle // ld outputs bool is_locked { false }; + double doorLockSpeed = 10.0; // predkosc przy ktorej wyzwalana jest blokada drzwi }; struct water_heater { diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index 7d030eed..87545bc2 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -8617,8 +8617,7 @@ TMoverParameters::update_doors( double const Deltatime ) { Doors.is_locked = ( true == Doors.has_lock ) - && ( true == Doors.lock_enabled ) - && ( Vel >= 10.0 ); + && ( true == Doors.lock_enabled ) && (Vel >= doorLockSpeed); for( auto &door : Doors.instances ) { // revoke permit if... @@ -10292,7 +10291,7 @@ void TMoverParameters::LoadFIZ_Doors( std::string const &line ) { extract_value( Doors.has_warning, "DoorClosureWarning", line, "" ); extract_value( Doors.has_autowarning, "DoorClosureWarningAuto", line, "" ); extract_value( Doors.has_lock, "DoorBlocked", line, "" ); - + extract_value(Doors.doorLockSpeed, "DoorLockSpeed", line, ""); { auto const remotedoorcontrol { ( Doors.open_control == control_t::driver ) From b58a137f66073bd34bf0aa6350e2390b0f682361 Mon Sep 17 00:00:00 2001 From: Hirek Date: Mon, 6 Jan 2025 20:50:49 +0100 Subject: [PATCH 9/9] Fix compilation error (badly assigned variable) --- McZapkie/Mover.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index 87545bc2..53c535cb 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -8617,7 +8617,7 @@ TMoverParameters::update_doors( double const Deltatime ) { Doors.is_locked = ( true == Doors.has_lock ) - && ( true == Doors.lock_enabled ) && (Vel >= doorLockSpeed); + && ( true == Doors.lock_enabled ) && (Vel >= Doors.doorLockSpeed); for( auto &door : Doors.instances ) { // revoke permit if...