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.
app/ScStwSrc/headers/scstwappbackend.h
2020-04-17 19:57:33 +02:00

90 lines
2.6 KiB
C++

#ifndef SCSTWAPPBACKEND_H
#define SCSTWAPPBACKEND_H
#include <QObject>
#include <scstwclient.h>
#include <scstwrace.h>
#include <ScStw.hpp>
#include "headers/appsettings.h"
class ScStwAppBackend : public QObject
{
Q_OBJECT
//Q_PROPERTY(int state READ getState NOTIFY stateChanged)
Q_PROPERTY(int mode READ getMode NOTIFY modeChanged)
//Q_PROPERTY(QString baseStationState READ getBaseStationState NOTIFY baseStationStateChanged)
Q_PROPERTY(ScStwRace* race READ getRace NOTIFY raceChanged)
Q_PROPERTY(QVariant baseStationConnections READ getBaseStationConnections NOTIFY baseStationConnectionsChanged)
Q_PROPERTY(QVariantMap baseStationProperties READ getBaseStationProperties NOTIFY baseStationPropertiesChanged)
public:
explicit ScStwAppBackend(QObject *parent = nullptr);
enum RaceMode { LOCAL, REMOTE };
private:
RaceMode mode;
AppSettings * appSettings;
ScStwClient * scStwClient;
QTimer * timerTextRefreshTimer;
// TODO: DOINEED? QTimer * nextStartActionTimer;
ScStwRace * localRace;
public slots:
// base station sync
//void handleBaseStationSignal(ScStw::SignalKey key, QVariant data);
Q_INVOKABLE bool pairConnectedUsbExtensions();
// functions for qml
Q_INVOKABLE ScStwRace *getRace();
//Q_INVOKABLE int getState();
Q_INVOKABLE int getMode();
Q_INVOKABLE void writeSetting(QString key, QVariant value);
Q_INVOKABLE void writeSetting(ScStw::BaseStationSetting key, QVariant value);
Q_INVOKABLE QString readSetting(QString key);
Q_INVOKABLE QString readSetting(ScStw::BaseStationSetting 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();
private slots:
void refreshTimerText();
void refreshMode();
void reloadRaceSettings();
signals:
void modeChanged();
void raceChanged();
void baseStationStateChanged();
void baseStationConnectionsChanged();
void baseStationPropertiesChanged();
};
#endif // SCSTWAPPBACKEND_H