From 827a3394df525107526c26a8a9c7b1753cc9c73b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=B3lik=20Uszasty?= Date: Sun, 20 Feb 2022 22:41:31 +0100 Subject: [PATCH] Reworked some actions durin cab (de)activation --- DynObj.cpp | 26 ++++++++++++++++++++++++-- McZapkie/MOVER.h | 14 +++++++++++++- McZapkie/Mover.cpp | 23 +++++++++++++++++++++-- Train.cpp | 3 +++ 4 files changed, 61 insertions(+), 5 deletions(-) diff --git a/DynObj.cpp b/DynObj.cpp index cdc43145..54a92da4 100644 --- a/DynObj.cpp +++ b/DynObj.cpp @@ -3947,6 +3947,26 @@ bool TDynamicObject::Update(double dt, double dt1) toggle_lights(); } + if (MoverParameters->InactiveCabPantsCheck) + { + auto p = FindPantographCarrier(); + bool isAnyPantUp = false; + if (p) + { + for each (auto item in p->MoverParameters->Pantographs) + { + isAnyPantUp |= item.is_active; + } + if (isAnyPantUp) + { + MoverParameters->OperatePantographValve(end::front, operation_t::enable); + MoverParameters->OperatePantographValve(end::rear, operation_t::enable); + } + } + MoverParameters->InactiveCabPantsCheck = false; + } + + if (MoverParameters->DerailReason > 0) { switch (MoverParameters->DerailReason) @@ -6855,11 +6875,13 @@ void TDynamicObject::Damage(char flag) void TDynamicObject::SetLights() { auto const isfrontcaboccupied { MoverParameters->CabOccupied * DirectionGet() >= 0 }; + int const automaticmarkers { MoverParameters->CabActive == 0 && ( MoverParameters->InactiveCabFlag & activation::redmarkers ) + ? light::redmarker_left + light::redmarker_right : 0 }; int const front { ( isfrontcaboccupied ? end::front : end::rear ) }; int const rear { 1 - front }; auto const lightpos { MoverParameters->LightsPos - 1 }; - auto const frontlights { MoverParameters->Lights[ front ][ lightpos ] }; - auto const rearlights { MoverParameters->Lights[ rear ][ lightpos ] }; + auto const frontlights { automaticmarkers > 0 ? automaticmarkers : MoverParameters->Lights[ front ][ lightpos ] }; + auto const rearlights { automaticmarkers > 0 ? automaticmarkers : MoverParameters->Lights[ rear ][ lightpos ] }; auto *vehicle { GetFirstDynamic( MoverParameters->CabOccupied >= 0 ? end::front : end::rear, coupling::control ) }; while( vehicle != nullptr ) { // set lights on given side if there's no coupling with another vehicle, turn them off otherwise diff --git a/McZapkie/MOVER.h b/McZapkie/MOVER.h index fc0c829c..597d87fe 100644 --- a/McZapkie/MOVER.h +++ b/McZapkie/MOVER.h @@ -267,6 +267,17 @@ enum relay_t { electrodynamicbrakesoverload = 1 << 7, }; +// functions during activation/deactivation +enum activation { + emergencybrake = 1 << 0, + mirrors = 1 << 1, + pantographsup = 1 << 2, + redmarkers = 1 << 3, + doorpermition = 1 << 4, + springbrakeon = 1 << 5, + springbrakeoff = 1 << 6, +}; + //szczególne typy pojazdów (inna obsługa) dla zmiennej TrainType //zamienione na flagi bitowe, aby szybko wybierać grupę (np. EZT+SZT) // TODO: convert to enums, they're used as specific checks anyway @@ -1512,7 +1523,8 @@ public: int CabOccupied = 0; //numer kabiny, w ktorej jest obsada (zwykle jedna na skład) // TODO: move to TController bool CabMaster = false; //czy pojazd jest nadrzędny w składzie bool AutomaticCabActivation = true; //czy zmostkowany rozrzad przelacza sie sam przy zmianie kabiny - bool InactivaCabEmergencyBrake = false; //czy bez aktywacji włącza się nagłe + int InactiveCabFlag = 0; //co sie dzieje przy dezaktywacji kabiny + bool InactiveCabPantsCheck = false; //niech DynamicObject sprawdzi pantografy double LastSwitchingTime = 0.0; /*czas ostatniego przelaczania czegos*/ int WarningSignal = 0; // 0: nie trabi, 1,2,4: trabi bool DepartureSignal = false; /*sygnal odjazdu*/ diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index e7e4a15f..189469b3 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -2689,6 +2689,10 @@ bool TMoverParameters::CabActivisation( bool const Enforce ) CabMaster = true; SecuritySystem.Status |= s_waiting; // activate the alerter TODO: make it part of control based cab selection SendCtrlToNext("CabActivisation", 1, CabActive); + if (InactiveCabFlag & activation::springbrakeoff) + { + SpringBrakeActivate(false); + } } return OK; } @@ -2710,6 +2714,20 @@ bool TMoverParameters::CabDeactivisation( bool const Enforce ) OK = Enforce || ((CabActive == CabOccupied) && CabMaster); // o ile obsada jest w kabinie ze sterowaniem if (OK) { + if (InactiveCabFlag & activation::springbrakeon) + { + SpringBrakeActivate(true); + } + if (InactiveCabFlag & activation::pantographsup) + { + InactiveCabPantsCheck = true; + } + if (InactiveCabFlag & activation::doorpermition) + { + PermitDoors(side::right, true, range_t::consist); + PermitDoors(side::left, true, range_t::consist); + } + CabActive = 0; DirAbsolute = DirActive * CabActive; CabMaster = false; @@ -4455,7 +4473,8 @@ void TMoverParameters::UpdatePipePressure(double dt) || ( true == TestFlag( EngDmgFlag, 32 ) ) */ || ( true == s_CAtestebrake ) - || ( ( 0 == CabActive ) && InactivaCabEmergencyBrake ) + || ( ( 0 == CabActive ) + && ( InactiveCabFlag & activation::emergencybrake ) ) || ( ( SpringBrakeDriveEmergencyVel >= 0 ) && ( Vel > SpringBrakeDriveEmergencyVel ) && ( SpringBrake.IsActive ) ) @@ -10390,7 +10409,7 @@ void TMoverParameters::LoadFIZ_Cntrl( std::string const &line ) { extract_value( BackwardsBranchesAllowed, "BackwardsBranchesAllowed", line, "" ); extract_value( AutomaticCabActivation, "AutomaticCabActivation", line, "" ); - extract_value( InactivaCabEmergencyBrake, "InactivaCabEmergencyBrake", line, "" ); + extract_value( InactiveCabFlag, "InactiveCabFlag", line, "" ); extract_value( StopBrakeDecc, "SBD", line, "" ); extract_value( ReleaseParkingBySpringBrake, "ReleaseParkingBySpringBrake", line, "" ); diff --git a/Train.cpp b/Train.cpp index 9b8c061e..7b74e0c3 100644 --- a/Train.cpp +++ b/Train.cpp @@ -2416,6 +2416,9 @@ void TTrain::OnCommand_cabactivationdisable(TTrain *Train, command_data const &C } Train->mvOccupied->CabDeactivisation(); + if ((Train->mvOccupied->LightsPosNo > 0) && (Train->mvOccupied->InactiveCabFlag & activation::redmarkers)) { + Train->Dynamic()->SetLights(); + } } else if (Command.action == GLFW_RELEASE) { if (Train->ggCabActivationButton.type() == TGaugeType::push) {