#ifndef CLIMBINGRACE_H #define CLIMBINGRACE_H #include #include #include #include #include #include #include "headers/appsettings.h" #include "headers/speedtimer.h" class ClimbingRace : public QObject { Q_OBJECT Q_PROPERTY(int state READ getState NOTIFY stateChanged) Q_PROPERTY(int mode READ getMode NOTIFY modeChanged) 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) Q_PROPERTY(int nextStartAction READ getNextStartAction NOTIFY nextStartActionChanged) Q_PROPERTY(QVariantMap baseStationProperties READ getBaseStationProperties NOTIFY baseStationPropertiesChanged) public: explicit ClimbingRace(QObject *parent = nullptr); enum RaceMode { LOCAL, REMOTE }; RaceMode mode; private: AppSettings * appSettings; ScStwClient * scStwClient; QMediaPlayer * player; QTimer * timerTextRefreshTimer; QTimer * nextStartActionTimer; QDateTime *date; QList speedTimers; ScStw::NextStartAction nextStartAction; ScStw::RaceState state; double nextStartActionDelayProgress; // only used in remote mode: double nextStartActionDelayStartedAt; double nextStartActionTotalDelay; // helper vars QVariantList qmlTimers; private slots: // helper functions void playSoundsAndStartRace(); bool playSound(QString path); void setState(ScStw::RaceState newState); void refreshMode(); void refreshTimerText(); bool refreshRemoteTimers(QVariantList timers); signals: void nextStartActionChanged(); void nextStartActionDelayProgressChanged(); void stateChanged(int state); void modeChanged(); void timerTextChanged(); void baseStationStateChanged(); void baseStationConnectionsChanged(); void baseStationPropertiesChanged(); public slots: Q_INVOKABLE int startRace(); Q_INVOKABLE int stopRace(int type); Q_INVOKABLE int resetRace(); // base station sync void handleBaseStationSignal(ScStw::SignalKey key, QVariant data); Q_INVOKABLE bool pairConnectedUsbExtensions(); // functions for qml Q_INVOKABLE int getState(); Q_INVOKABLE int getMode(); Q_INVOKABLE QVariant getTimerTextList(); Q_INVOKABLE double getNextStartActionDelayProgress(); Q_INVOKABLE int getNextStartAction(); Q_INVOKABLE void writeSetting(QString key, QVariant value); Q_INVOKABLE QString readSetting(QString key); Q_INVOKABLE void connectBaseStation(); Q_INVOKABLE void disconnectBaseStation(); Q_INVOKABLE QString getBaseStationState(); Q_INVOKABLE QVariant getBaseStationConnections(); Q_INVOKABLE QVariantMap getBaseStationProperties(); Q_INVOKABLE bool updateBasestationFirmware(); Q_INVOKABLE bool updateBasestationTime(); // athlete management Q_INVOKABLE QVariant getAthletes(); Q_INVOKABLE bool createAthlete( QString userName, QString fullName ); Q_INVOKABLE bool deleteAthlete( QString userName ); Q_INVOKABLE bool selectAthlete( QString userName, int timerId ); Q_INVOKABLE QVariant getResults( QString userName ); Q_INVOKABLE bool reloadBaseStationIpAdress(); }; #endif // CLIMBINGRACE_H