#ifndef SCSTWTIMER_H #define SCSTWTIMER_H #include #include #include #include "ScStw.hpp" class ScStwTimer : public QObject { Q_OBJECT public: explicit ScStwTimer(QObject *parent = nullptr); enum TimerState { IDLE, STARTING, WAITING, RUNNING, WON, LOST, FAILED, CANCELLED, DISABLED }; enum StopReason { ManualStop, CancelStop, FailStop, TopPadStop }; protected: TimerState state; // variables for capturing the time double startTime; double stopTime; double stoppedTime; double reactionTime; // values for the startpad double startPadTriggerTime; QDateTime *date; public slots: // --- main functionality --- bool start(); bool cancel(); bool stop(); bool stop(TimerState); bool reset(); // --- helper functions --- TimerState getState(); double getCurrentTime(); double getReactionTime(); void refreshDisableStatus(); void setDisabled(bool disabled); protected slots: bool stop(StopReason reason); // --- helper functions --- void setState(TimerState newState); signals: void stateChanged(); void startCanceled(bool falseStart); void reactionTimeChanged(); void stopRequested(); }; #endif // SCSTWTIMER_H