This repository has been archived on 2024-06-03. You can view files and clone it, but cannot push or open issues or pull requests.
shared-libraries/ScStwLibraries/headers/scstwtimer.h

67 lines
1.4 KiB
C
Raw Normal View History

#ifndef SCSTWTIMER_H
#define SCSTWTIMER_H
#include <QObject>
#include <QDateTime>
#include <QDebug>
2020-04-14 00:08:58 +02:00
#include <QTimer>
#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();
2020-04-14 00:08:58 +02:00
bool start(double timeOfStart);
bool cancel();
bool stop();
bool stop(TimerState);
bool reset();
// --- helper functions ---
TimerState getState();
double getCurrentTime();
double getReactionTime();
void setDisabled(bool disabled);
protected slots:
2020-04-14 00:08:58 +02:00
void handleClimberStart(double timeOfStart);
bool stop(StopReason reason);
// --- helper functions ---
void setState(TimerState newState);
signals:
void stateChanged();
void startCanceled(bool falseStart);
void reactionTimeChanged();
void stopRequested();
2020-04-14 00:08:58 +02:00
void requestEnableChange(ScStwTimer* timer);
};
#endif // SCSTWTIMER_H