From d210a75d518489c64e9c87d1088c4275849ab960 Mon Sep 17 00:00:00 2001 From: Dorian Zedler Date: Fri, 14 Aug 2020 17:02:53 +0200 Subject: [PATCH] some preperations for start procedure checks (#20) --- ScStwLibraries/headers/scstwrace.h | 1 + ScStwLibraries/headers/scstwtimer.h | 33 +++++++++++++++++++++++---- ScStwLibraries/sources/scstwtimer.cpp | 4 ++++ 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/ScStwLibraries/headers/scstwrace.h b/ScStwLibraries/headers/scstwrace.h index e3ddfb5..17213b1 100644 --- a/ScStwLibraries/headers/scstwrace.h +++ b/ScStwLibraries/headers/scstwrace.h @@ -57,6 +57,7 @@ public: explicit ScStwRace(QObject *parent = nullptr); enum RaceState { IDLE, STARTING, WAITING, RUNNING, STOPPED }; + // will become IDLE, PREPAIRING, WAITING, STARTING, RUNNING, STOPPED later Q_ENUM(RaceState) enum StartAction { None = -1, AtYourMarks = 0, Ready = 1, Start = 2 }; diff --git a/ScStwLibraries/headers/scstwtimer.h b/ScStwLibraries/headers/scstwtimer.h index 6b65a5a..ee82a10 100644 --- a/ScStwLibraries/headers/scstwtimer.h +++ b/ScStwLibraries/headers/scstwtimer.h @@ -82,6 +82,7 @@ public: LOST, /*!< Timer has lost */ FAILED, /*!< A false start occured */ CANCELLED, /*!< Timer was cancelled */ +// INCIDENT, /*!< There was a technical incident */ DISABLED /*!< Timer is disabled */ }; Q_ENUM(TimerState); @@ -90,10 +91,22 @@ public: * \brief The StopReason enum contains all possible reasons for a stop */ enum StopReason { - ManualStop, /*!< Timer was stopped manually */ - CancelStop, /*!< Timer was cancelled */ - FailStop, /*!< A false start occured */ - TopPadStop /*!< Timer was stopped by a physical trigger (eg. a ScStwExtension) */ + ManualStop, /*!< Timer was stopped manually */ + CancelStop, /*!< Timer was cancelled */ + FailStop, /*!< A false start occured */ + TopPadStop, /*!< Timer was stopped by a physical trigger (eg. a ScStwExtension) */ + TechnicalIncidentStop /*!< The timer was stopped due to a technical incident */ + }; + + /*! + * \brief The ReadyStatus enum contains all possible reasons for a timer not to be ready (>0) and the case that it is ready (0) + */ + enum ReadyState { + IsReady = 0, /*!< Timer is ready for start */ + NotInIdleState, /*!< Timer is not in IDLE state */ + IsDisabled, /*!< Timer is disabled */ + NotAllExtensionsConnected, /*!< Not all extension of the timer are conneted */ + NotAllClimbersReady /*!< The startpad of the timer is not triggered */ }; protected: @@ -305,6 +318,12 @@ public slots: */ bool getWantsToBeDisabled(); + /*! + * \brief Function to get the current ready status of a timer + * \return The current ready status + */ + virtual ScStwTimer::ReadyState getReadyState(); + protected slots: /*! @@ -373,6 +392,12 @@ signals: */ void wantsToBeDisabledChanged(ScStwTimer* timer, bool wantsToBeDisabled); + /*! + * \brief Emitted when the ready state of the timer changes + * \param readyState the new ReadyState + */ + void readyStateChanged(ReadyState readyState); + }; #endif // SCSTWTIMER_H diff --git a/ScStwLibraries/sources/scstwtimer.cpp b/ScStwLibraries/sources/scstwtimer.cpp index 1f03590..6a69f52 100644 --- a/ScStwLibraries/sources/scstwtimer.cpp +++ b/ScStwLibraries/sources/scstwtimer.cpp @@ -157,6 +157,10 @@ bool ScStwTimer::reset(){ return true; } +ScStwTimer::ReadyState ScStwTimer::getReadyState() { + return this->state == IDLE ? ScStwTimer::IsReady : ScStwTimer::NotInIdleState; +} + // ------------------------ // --- helper functions --- // ------------------------