2019-03-07 17:18:24 +01:00
|
|
|
#ifndef CLIMBINGRACE_H
|
|
|
|
#define CLIMBINGRACE_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QSound>
|
|
|
|
#include <QSoundEffect>
|
|
|
|
#include <QMediaPlayer>
|
|
|
|
#include "headers/baseconn.h"
|
|
|
|
#include "headers/appsettings.h"
|
|
|
|
#include "headers/speedtimer.h"
|
|
|
|
|
|
|
|
class ClimbingRace : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
Q_PROPERTY(int state READ getState NOTIFY stateChanged)
|
2019-03-24 21:16:16 +01:00
|
|
|
Q_PROPERTY(int mode READ getMode NOTIFY modeChanged)
|
2019-03-07 17:18:24 +01:00
|
|
|
Q_PROPERTY(QVariant timers READ getTimerTextList NOTIFY timerTextChanged)
|
|
|
|
Q_PROPERTY(QString baseStationState READ getBaseStationState NOTIFY baseStationStateChanged)
|
|
|
|
Q_PROPERTY(QVariant baseStationConnections READ getBaseStationConnections NOTIFY baseStationConnectionsChanged)
|
|
|
|
Q_PROPERTY(double nextStartActionDelayProgress READ getNextStartActionDelayProgress NOTIFY nextStartActionDelayProgressChanged)
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit ClimbingRace(QObject *parent = nullptr);
|
|
|
|
|
|
|
|
enum raceState { IDLE, STARTING, RUNNING, STOPPED };
|
|
|
|
raceState state;
|
|
|
|
|
|
|
|
enum raceMode { LOCAL, REMOTE };
|
|
|
|
raceMode mode;
|
|
|
|
|
|
|
|
private:
|
|
|
|
AppSettings * appSettings;
|
|
|
|
BaseConn * baseConn;
|
|
|
|
|
|
|
|
QMediaPlayer * player;
|
|
|
|
|
|
|
|
QTimer * baseStationSyncTimer;
|
|
|
|
QTimer * timerTextRefreshTimer;
|
|
|
|
QTimer * nextStartActionTimer;
|
|
|
|
|
2019-03-24 21:16:16 +01:00
|
|
|
QDateTime *date;
|
|
|
|
|
2019-03-07 17:18:24 +01:00
|
|
|
QList<SpeedTimer *> speedTimers;
|
|
|
|
|
|
|
|
int nextStartAction;
|
|
|
|
// 0 : 'at your marks'
|
|
|
|
// 1 : 'ready'
|
|
|
|
// 2 : 'start'
|
|
|
|
|
|
|
|
double nextStartActionDelayProgress;
|
|
|
|
|
|
|
|
// helper vars
|
|
|
|
QVariantList qmlTimers;
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
// helper functions
|
|
|
|
void playSoundsAndStartRace();
|
|
|
|
bool playSound(QString path);
|
|
|
|
void setState(raceState newState);
|
|
|
|
void refreshMode();
|
|
|
|
void refreshTimerText();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void nextStartActionChanged(int nextStartAction);
|
|
|
|
void nextStartActionDelayProgressChanged();
|
|
|
|
|
|
|
|
void stateChanged(int state);
|
2019-03-24 21:16:16 +01:00
|
|
|
void modeChanged();
|
2019-03-07 17:18:24 +01:00
|
|
|
void timerTextChanged();
|
|
|
|
void baseStationStateChanged();
|
|
|
|
void baseStationConnectionsChanged();
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
Q_INVOKABLE int startRace();
|
|
|
|
Q_INVOKABLE int stopRace(int type);
|
|
|
|
Q_INVOKABLE int resetRace();
|
|
|
|
|
|
|
|
void syncWithBaseStation();
|
|
|
|
|
|
|
|
// functions for qml
|
|
|
|
Q_INVOKABLE int getState();
|
2019-03-24 21:16:16 +01:00
|
|
|
Q_INVOKABLE int getMode();
|
2019-03-07 17:18:24 +01:00
|
|
|
Q_INVOKABLE QVariant getTimerTextList();
|
|
|
|
Q_INVOKABLE double getNextStartActionDelayProgress();
|
|
|
|
|
|
|
|
Q_INVOKABLE void writeSetting(QString key, QVariant value);
|
|
|
|
Q_INVOKABLE QString readSetting(QString key);
|
|
|
|
|
|
|
|
Q_INVOKABLE bool connectBaseStation();
|
|
|
|
Q_INVOKABLE QString getBaseStationState();
|
|
|
|
Q_INVOKABLE QVariant getBaseStationConnections();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CLIMBINGRACE_H
|