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
Dorian Zedler 1570bd86c9
- some changes to file structure
- started to implement timer, race and sound management
2020-04-13 23:59:36 +02:00

64 lines
1.3 KiB
C++

#ifndef SCSTWTIMER_H
#define SCSTWTIMER_H
#include <QObject>
#include <QDateTime>
#include <QDebug>
#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