From 97af1e7d74cadb28f46f1561b90d4b8bc19b2e9e Mon Sep 17 00:00:00 2001 From: milek7 Date: Thu, 6 Jan 2022 15:49:46 +0100 Subject: [PATCH] fixes after merge --- Driver.cpp | 6 +++--- McZapkie/MOVER.h | 6 +++--- McZapkie/Mover.cpp | 20 +++++++++----------- Train.cpp | 4 ++-- Train.h | 2 +- 5 files changed, 18 insertions(+), 20 deletions(-) diff --git a/Driver.cpp b/Driver.cpp index 3970ab68..f7b37c2d 100644 --- a/Driver.cpp +++ b/Driver.cpp @@ -881,7 +881,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN eSignNext = nullptr; IsAtPassengerStop = false; IsScheduledPassengerStopVisible = false; - mvOccupied->SecuritySystem.SHPLock = false; + mvOccupied->SecuritySystem.set_cabsignal_lock(false); // te flagi są ustawiane tutaj, w razie potrzeby iDrivigFlags &= ~(moveTrackEnd | moveSwitchFound | moveSignalFound | /*moveSpeedLimitFound*/ moveStopPointFound ); @@ -1424,7 +1424,7 @@ TController::TableUpdateEvent( double &Velocity, TCommandType &Command, TSpeedPo // thus we're doing a more precise check in such situation (we presume direction change takes place only if the vehicle is standing still) if( ( mvOccupied->Vel > EU07_AI_NOMOVEMENT ) || ( false == ismagnetpassed ) ) { - mvOccupied->SecuritySystem.SHPLock |= ( !AIControllFlag ); // don't make life difficult for the ai, but a human driver is a fair game + mvOccupied->SecuritySystem.set_cabsignal_lock(!AIControllFlag); // don't make life difficult for the ai, but a human driver is a fair game PutCommand( Point.evEvent->input_text(), Point.evEvent->input_value( 1 ), @@ -1434,7 +1434,7 @@ TController::TableUpdateEvent( double &Velocity, TCommandType &Command, TSpeedPo } if( ismagnetpassed ) { Point.Clear(); - mvOccupied->SecuritySystem.SHPLock = false; + mvOccupied->SecuritySystem.set_cabsignal_lock(false); } return true; } diff --git a/McZapkie/MOVER.h b/McZapkie/MOVER.h index b82ee8ef..1970ab31 100644 --- a/McZapkie/MOVER.h +++ b/McZapkie/MOVER.h @@ -648,6 +648,7 @@ class TSecuritySystem bool enabled = false; bool is_sifa = false; // Sifa-like pedal device, with inverted input for convenient keyboard usage bool separate_acknowledge = false; // cabsignal reset button is separate from vigilance + bool cabsignal_lock = false; double vigilance_timer = 0.0; double alert_timer = 0.0; @@ -669,6 +670,7 @@ public: void cabsignal_reset(); void update(double dt, double Vel, bool pwr); void set_cabsignal(); + void set_cabsignal_lock(bool); bool is_blinking() const; bool is_vigilance_blinking() const; bool is_cabsignal_blinking() const; @@ -677,11 +679,9 @@ public: bool is_braking() const; bool is_engine_blocked() const; bool radiostop_available() const; - bool system_available() const; void load(std::string const &line, double Vmax); - bool SHPLock = false; - double MagnetLocation; + double MagnetLocation = 0.0; }; struct TTransmision diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index 7fcd46e0..22194b56 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -95,7 +95,7 @@ void TSecuritySystem::acknowledge_press() { } vigilance_timer = 0.0; - if (!separate_acknowledge && cabsignal_active) { + if (!separate_acknowledge && cabsignal_active && !cabsignal_lock) { cabsignal_active = false; alert_timer = 0.0; } @@ -110,7 +110,7 @@ void TSecuritySystem::acknowledge_release() { } void TSecuritySystem::cabsignal_reset() { - if (cabsignal_active) { + if (cabsignal_active && !cabsignal_lock) { cabsignal_active = false; alert_timer = 0.0; } @@ -192,12 +192,12 @@ bool TSecuritySystem::is_cabsignal_beeping() const { } bool TSecuritySystem::is_braking() const { + if (!power && (vigilance_enabled || cabsignal_enabled || radiostop_enabled)) + return true; + if (!enabled) return false; - if (!power && (vigilance_enabled || cabsignal_enabled)) - return true; - return alert_timer > SoundSignalDelay + EmergencyBrakeDelay; } @@ -205,8 +205,8 @@ bool TSecuritySystem::radiostop_available() const { return radiostop_enabled; } -bool TSecuritySystem::system_available() const { - return vigilance_enabled || cabsignal_enabled; +void TSecuritySystem::set_cabsignal_lock(bool v) { + cabsignal_lock = v; } bool TSecuritySystem::is_engine_blocked() const { @@ -234,6 +234,7 @@ void TSecuritySystem::load(std::string const &line, double Vmax) { extract_value( EmergencyBrakeDelay, "EmergencyBrakeDelay", line, "" ); extract_value( MaxHoldTime, "MaxHoldTime", line, "" ); extract_value( radiostop_enabled, "RadioStop", line, "" ); + extract_value( MagnetLocation, "MagnetLocation", line, "" ); } double TableInterpolation(std::map &Map, double Parameter) @@ -4450,7 +4451,6 @@ void TMoverParameters::UpdatePipePressure(double dt) // ulepszony hamulec bezp. EmergencyValveFlow = 0.0; - auto const securitysystempresent { SecuritySystem.radiostop_available() || SecuritySystem.system_available() }; auto const lowvoltagepower { Power24vIsAvailable || Power110vIsAvailable }; if( (( true == RadioStopFlag ) @@ -4468,9 +4468,7 @@ void TMoverParameters::UpdatePipePressure(double dt) */ || ( ( SpringBrakeDriveEmergencyVel >= 0 ) && ( Vel > SpringBrakeDriveEmergencyVel ) - && ( SpringBrake.IsActive ) ) - || ( ( true == securitysystempresent ) - && ( false == lowvoltagepower ) ) ) { + && ( SpringBrake.IsActive ) ) ) { EmergencyValveFlow = PF( 0, PipePress, 0.15 ) * dt; } dpMainValve += EmergencyValveFlow; diff --git a/Train.cpp b/Train.cpp index fbaa360b..70c4f8e8 100644 --- a/Train.cpp +++ b/Train.cpp @@ -7873,7 +7873,7 @@ void TTrain::update_sounds_radio() { } void TTrain::update_screens() { - if (fScreenTimer > Global.PythonScreenUpdateRate * 0.001f) { + if (fScreenTimer > std::max(Global.PythonScreenUpdateRate, ScreenUpdateRate) * 0.001f) { fScreenTimer = 0.f; for (auto const &screen : m_screens) { auto state_dict = GetTrainState(screen.parameters); @@ -8282,7 +8282,7 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName) } else if (token == "pyscreenupdatetime:") { parser.getTokens(); - parser >> fScreenUpdateRate; + parser >> ScreenUpdateRate; } // btLampkaUnknown.Init("unknown",mdKabina,false); } while ( ( token != "" ) diff --git a/Train.h b/Train.h index 4be07fa8..8a531a21 100644 --- a/Train.h +++ b/Train.h @@ -789,7 +789,7 @@ private: float fConverterTimer; // hunter-261211: dla przekaznika float fMainRelayTimer; // hunter-141211: zalaczanie WSa z opoznieniem float fScreenTimer { 0.f }; - int fScreenUpdateRate { 0 }; // vehicle specific python screen update rate override + int ScreenUpdateRate { 0 }; // vehicle specific python screen update rate override // McZapkie-240302 - przyda sie do tachometru float fTachoVelocity{ 0.0f };