From b10e6ccda32bb9bd465182d7c419eb9fbb97bb06 Mon Sep 17 00:00:00 2001 From: Hirek Date: Sun, 16 Feb 2025 21:10:32 +0100 Subject: [PATCH] Add distance counter double click to activate DCMB=[No] - Czy potrzebne jest podwojne nacisniecie DCDPP=[1.0] - W jakim czasie drugie nacisnienie ma nastapic od pierwszego, aby aktywowac pomiar --- McZapkie/MOVER.h | 21 +++++++++++---------- McZapkie/Mover.cpp | 3 +++ Train.cpp | 24 ++++++++++++++++++++++-- Train.h | 1 + 4 files changed, 37 insertions(+), 12 deletions(-) diff --git a/McZapkie/MOVER.h b/McZapkie/MOVER.h index 3de4f333..a9be5ce9 100644 --- a/McZapkie/MOVER.h +++ b/McZapkie/MOVER.h @@ -1205,16 +1205,17 @@ class TMoverParameters int LightsDefPos = 1; bool LightsWrap = false; 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 }; - bool SpringBrakeCutsOffDrive { true }; - double SpringBrakeDriveEmergencyVel { -1 }; - bool HideDirStatusWhenMoving { false }; // Czy gasic lampki kierunku powyzej predkosci zdefiniowanej przez HideDirStatusSpeed - int HideDirStatusSpeed{ 1 }; // Predkosc od ktorej lampki kierunku sa wylaczane + int ScndInMain{0}; /*zaleznosc bocznika od nastawnika*/ + bool MBrake = false; /*Czy jest hamulec reczny*/ + double StopBrakeDecc = 0.0; + bool ReleaseParkingBySpringBrake{false}; + bool ReleaseParkingBySpringBrakeWhenDoorIsOpen{false}; + bool SpringBrakeCutsOffDrive{true}; + double SpringBrakeDriveEmergencyVel{-1}; + bool HideDirStatusWhenMoving{false}; // Czy gasic lampki kierunku powyzej predkosci zdefiniowanej przez HideDirStatusSpeed + int HideDirStatusSpeed{1}; // Predkosc od ktorej lampki kierunku sa wylaczane + bool isDoubleClickForMeasureNeeded = {false}; // czy rozpoczecie pomiaru odleglosci odbywa sie po podwojnym wcisnienciu przycisku? + float DistanceCounterDoublePressPeriod = {1.f}; // czas w jakim nalezy podwojnie wcisnac przycisk, aby rozpoczac pomiar odleglosci TSecuritySystem SecuritySystem; int EmergencyBrakeWarningSignal{0}; // combined with basic WarningSignal when manual emergency brake is active TUniversalCtrlTable UniCtrlList; /*lista pozycji uniwersalnego nastawnika*/ diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index da05eef7..a14b3610 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -10628,6 +10628,9 @@ void TMoverParameters::LoadFIZ_Cntrl( std::string const &line ) { extract_value(HideDirStatusWhenMoving, "HideDirStatusWhenMoving", line, ""); extract_value(HideDirStatusSpeed, "HideDirStatusSpeed", line, ""); + extract_value(isDoubleClickForMeasureNeeded, "DCMB", line, ""); + extract_value(DistanceCounterDoublePressPeriod, "DCDPP", line, ""); + std::map starts { { "Disabled", start_t::disabled }, diff --git a/Train.cpp b/Train.cpp index 6dc6beb0..e0173468 100644 --- a/Train.cpp +++ b/Train.cpp @@ -1315,7 +1315,17 @@ void TTrain::OnCommand_distancecounteractivate( TTrain *Train, command_data cons // visual feedback Train->ggDistanceCounterButton.UpdateValue( 1.0, Train->dsbSwitch ); // activate or start anew - Train->m_distancecounter = 0.f; + if (Train->mvOccupied->isDoubleClickForMeasureNeeded) { + // handler tempomatu dla podwojnego kliku + if (Train->trainLenghtMeasureTimer >= 0.f) // jesli zdazylismy w czasie sekundy + Train->m_distancecounter = 0.f; // rozpoczynamy pomiar + else + Train->trainLenghtMeasureTimer = Train->mvOccupied->DistanceCounterDoublePressPeriod; // odpalamy zegarek od nowa + } + else { + // dla pojedynczego kliku + Train->m_distancecounter = 0.f; + } } else if( Command.action == GLFW_RELEASE ) { // visual feedback @@ -2869,7 +2879,7 @@ void TTrain::OnCommand_pantographvalvesoff( TTrain *Train, command_data const &C } else if( Command.action == GLFW_RELEASE ) { // visual feedback - // NOTE: pantvalves_sw: is a specialized button, with no toggle behavior support + // NOTE: pantvalves_sw: is a speciali zed button, with no toggle behavior support if (hasSeparateSwitches) Train->ggPantValvesOff.UpdateValue(0.f, Train->dsbSwitch); else @@ -6922,6 +6932,16 @@ bool TTrain::Update( double const Deltatime ) mvOccupied->OperateDoors( static_cast( idx ), true ); } } + + // train measurement timer + if (trainLenghtMeasureTimer >= 0.f) { + trainLenghtMeasureTimer -= Deltatime; + if (trainLenghtMeasureTimer < 0.f) + { + trainLenghtMeasureTimer = -1.f; + } + } + // helper variables if( DynamicObject->Mechanik != nullptr ) { m_doors = ( diff --git a/Train.h b/Train.h index 8a27584b..5a4f453f 100644 --- a/Train.h +++ b/Train.h @@ -882,6 +882,7 @@ private: bool m_dirbackward{ false }; // helper, true if direction set to backward bool m_doorpermits{ false }; // helper, true if any door permit is active float m_doorpermittimers[2] = { -1.f, -1.f }; + float trainLenghtMeasureTimer = { -1.f }; // ld substitute bool m_couplingdisconnect { false }; bool m_couplingdisconnectback { false };