diff --git a/Gauge.cpp b/Gauge.cpp index a283c3bc..2788a4b2 100644 --- a/Gauge.cpp +++ b/Gauge.cpp @@ -216,9 +216,12 @@ TGauge::Load_mapping( cParser &Input ) { if( key == "type:" ) { auto const gaugetype { Input.getToken( true, "\n\r\t ,;" ) }; m_type = ( + gaugetype == "push" ? TGaugeType::push : gaugetype == "impulse" ? TGaugeType::push : gaugetype == "return" ? TGaugeType::push : gaugetype == "delayed" ? TGaugeType::push_delayed : + gaugetype == "pushtoggle" ? TGaugeType::pushtoggle : + gaugetype == "toggle" ? TGaugeType::toggle : TGaugeType::toggle ); // default } else if( key == "soundinc:" ) { diff --git a/Gauge.h b/Gauge.h index f14bd129..a215227d 100644 --- a/Gauge.h +++ b/Gauge.h @@ -21,9 +21,10 @@ enum class TGaugeAnimation { gt_Digital // licznik cyfrowy, np. kilometrów }; -enum class TGaugeType { - toggle, +enum class TGaugeType : int { + toggle = 1, push, + pushtoggle = ( toggle | push ), push_delayed }; diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index f8c06269..a7b989c6 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -3743,10 +3743,12 @@ void TMoverParameters::CompressorCheck(double dt) { CompressorPower == 0 ? Mains : CompressorPower == 3 ? Mains : ( compressorowner != nullptr ) && ( compressorowner->ConverterFlag ) ) }; - auto const compressorallow { + // TBD: split CompressorAllow into separate enable/disable flags, inherit compressor from basic_device + auto const compressorenable { ( CompressorAllowLocal ) && ( ( CompressorStart == start_t::automatic ) || ( ( compressorowner != nullptr ) && ( compressorowner->CompressorAllow ) ) ) }; + auto const compressordisable { false == compressorenable }; auto const pressureistoolow { Compressor < MinCompressorF }; auto const pressureistoohigh { Compressor > MaxCompressorF }; @@ -3772,9 +3774,10 @@ void TMoverParameters::CompressorCheck(double dt) { auto const compressorflag { CompressorFlag }; CompressorFlag = ( compressorpower ) + && ( false == compressordisable ) && ( ( false == governorlock ) || ( CompressorPower == 3 ) ) && ( ( CompressorFlag ) - || ( ( compressorallow ) && ( LastSwitchingTime > CtrlDelay ) ) ); + || ( ( compressorenable ) && ( LastSwitchingTime > CtrlDelay ) ) ); if( ( CompressorFlag ) && ( CompressorFlag != compressorflag ) ) { // jeśli została załączona to trzeba ograniczyć ponowne włączenie @@ -3943,7 +3946,7 @@ void TMoverParameters::UpdatePipePressure(double dt) || ( true == s_CAtestebrake ) || ( ( true == securitysystempresent ) && ( false == lowvoltagepower ) ) ) { - dpMainValve = dpMainValve + PF( 0, PipePress, 0.15 ) * dt; + dpMainValve += PF( 0, PipePress, 0.15 ) * dt; } // 0.2*Spg Pipe->Flow(-dpMainValve); diff --git a/Train.cpp b/Train.cpp index b417eee8..b85389da 100644 --- a/Train.cpp +++ b/Train.cpp @@ -1610,27 +1610,43 @@ void TTrain::OnCommand_autosandboxdeactivate(TTrain *Train, command_data const & void TTrain::OnCommand_epbrakecontroltoggle( TTrain *Train, command_data const &Command ) { + if( Command.action == GLFW_REPEAT ) { return; } + + auto const ispush{ ( static_cast( Train->ggEPFuseButton.type() ) & static_cast( TGaugeType::push ) ) != 0 }; + auto const istoggle{ ( static_cast( Train->ggEPFuseButton.type() ) & static_cast( TGaugeType::toggle ) ) != 0 }; + if( Command.action == GLFW_PRESS ) { - // only reacting to press, so the switch doesn't flip back and forth if key is held down - if( false == Train->mvOccupied->EpFuse ) { - // turn on + if( istoggle ) { + // switch state + if( false == Train->mvOccupied->EpFuse ) { + // turn on + if( Train->mvOccupied->EpFuseSwitch( true ) ) { + // audio feedback + Train->dsbPneumaticSwitch.play(); + }; + } + else { + //turn off + Train->mvOccupied->EpFuseSwitch( false ); + } + } + else if( ispush ) { + // potentially turn on if( Train->mvOccupied->EpFuseSwitch( true ) ) { // audio feedback Train->dsbPneumaticSwitch.play(); - // visual feedback - // NOTE: there's no button for ep brake control switch - // TBD, TODO: add ep brake control switch? - } + }; } - else { - //turn off - if( Train->mvOccupied->EpFuseSwitch( false ) ) { - // audio feedback - Train->dsbPneumaticSwitch.play(); - // visual feedback - // NOTE: there's no button for ep brake control switch - // TBD, TODO: add ep brake control switch? - } + // visual feedback + Train->ggEPFuseButton.UpdateValue( ( + ispush ? 1.0f : // push or pushtoggle + Train->mvOccupied->EpFuse ? 1.0f : 0.0f ), // toggle + Train->dsbSwitch ); + } + else if( Command.action == GLFW_RELEASE ) { + if( ispush ) { + // return the switch to neutral position + Train->ggEPFuseButton.UpdateValue( 0.0f, Train->dsbSwitch ); } } } @@ -6668,6 +6684,7 @@ bool TTrain::Update( double const Deltatime ) ggUniveralBrakeButton1.Update(); ggUniveralBrakeButton2.Update(); ggUniveralBrakeButton3.Update(); + ggEPFuseButton.Update(); ggAntiSlipButton.Update(); ggSandButton.Update(); ggAutoSandButton.Update(); @@ -7924,6 +7941,7 @@ void TTrain::clear_cab_controls() ggUniveralBrakeButton1.Clear(); ggUniveralBrakeButton2.Clear(); ggUniveralBrakeButton3.Clear(); + ggEPFuseButton.Clear(); ggSandButton.Clear(); ggAutoSandButton.Clear(); ggAntiSlipButton.Clear(); @@ -7936,7 +7954,7 @@ void TTrain::clear_cab_controls() ggSpeedControlIncreaseButton.Clear(); ggSpeedControlDecreaseButton.Clear(); ggSpeedControlPowerIncreaseButton.Clear(); - ggSpeedControlDecreaseButton.Clear(); + ggSpeedControlPowerDecreaseButton.Clear(); for (auto &speedctrlbutton : ggSpeedCtrlButtons) { speedctrlbutton.Clear(); } @@ -8540,7 +8558,8 @@ bool TTrain::initialize_button(cParser &Parser, std::string const &Label, int co { "i-doorpermit_left:", &mvOccupied->Doors.instances[ ( cab_to_end() == end::front ? side::left : side::right ) ].open_permit }, { "i-doorpermit_right:", &mvOccupied->Doors.instances[ ( cab_to_end() == end::front ? side::right : side::left ) ].open_permit }, { "i-doorstep:", &mvOccupied->Doors.step_enabled }, - { "i-mainpipelock:", &mvOccupied->LockPipe } + { "i-mainpipelock:", &mvOccupied->LockPipe }, + { "i-battery:", &mvOccupied->Battery } }; { auto lookup = autolights.find( Label ); @@ -8616,6 +8635,7 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con { "universalbrake1_bt:", ggUniveralBrakeButton1 }, { "universalbrake2_bt:", ggUniveralBrakeButton2 }, { "universalbrake3_bt:", ggUniveralBrakeButton3 }, + { "epbrake_bt:", ggEPFuseButton }, { "sand_bt:", ggSandButton }, { "autosandallow_sw:", ggAutoSandButton }, { "antislip_bt:", ggAntiSlipButton }, diff --git a/Train.h b/Train.h index ff7b7c82..ae72ee1b 100644 --- a/Train.h +++ b/Train.h @@ -449,6 +449,7 @@ public: // reszta może by?publiczna TGauge ggUniveralBrakeButton1; TGauge ggUniveralBrakeButton2; TGauge ggUniveralBrakeButton3; + TGauge ggEPFuseButton; TGauge ggSandButton; // guzik piasecznicy TGauge ggAutoSandButton; // przełącznik piasecznicy TGauge ggAntiSlipButton; diff --git a/drivermouseinput.cpp b/drivermouseinput.cpp index 73c8a18e..94ed3b07 100644 --- a/drivermouseinput.cpp +++ b/drivermouseinput.cpp @@ -605,6 +605,9 @@ drivermouse_input::default_bindings() { { "universalbrake3_bt:",{ user_command::universalbrakebutton3, user_command::none } }, + { "epbrake_bt:",{ + user_command::epbrakecontroltoggle, + user_command::none } }, { "sand_bt:", { user_command::sandboxactivate, user_command::none } }, diff --git a/translation.cpp b/translation.cpp index 282c451a..0010d472 100644 --- a/translation.cpp +++ b/translation.cpp @@ -111,6 +111,10 @@ init() { "line breaker", "alerter", "independent brake releaser", + "spring brake", + "spring brake", + "spring brake", + "electro-pneumatic brake", "sandbox", "wheelspin brake", "horn", @@ -281,6 +285,10 @@ init() { "wylacznik szybki", "czuwak", "odluzniacz", + "hamulec sprezynowy", + "hamulec sprezynowy", + "hamulec sprezynowy", + "hamulec elektropneumatyczny", "piasecznica", "hamulec przeciwposlizgowy", "syrena", @@ -404,6 +412,10 @@ init() { "main_on_bt:", "security_reset_bt:", "releaser_bt:", + "springbraketoggle_bt:", + "springbrakeon_bt:", + "springbrakeoff_bt:", + "epbrake_bt:", "sand_bt:", "antislip_bt:", "horn_bt:", diff --git a/translation.h b/translation.h index 4abcd9e6..77da90b3 100644 --- a/translation.h +++ b/translation.h @@ -100,6 +100,10 @@ enum string { cab_main_on_bt, cab_security_reset_bt, cab_releaser_bt, + cab_springbrake_bt, + cab_springbrakeon_bt, + cab_springbrakeoff_bt, + cab_epbrake_bt, cab_sand_bt, cab_antislip_bt, cab_horn_bt, diff --git a/version.h b/version.h index 0e5f4a0e..525cd064 100644 --- a/version.h +++ b/version.h @@ -1,5 +1,5 @@ #pragma once #define VERSION_MAJOR 20 -#define VERSION_MINOR 104 +#define VERSION_MINOR 106 #define VERSION_REVISION 0