2018-07-25 00:32:20 +02:00
|
|
|
#ifndef BUZZERCONN_H
|
|
|
|
#define BUZZERCONN_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QDir>
|
|
|
|
#include <QUrl>
|
|
|
|
#include <QtNetwork>
|
|
|
|
#include <QAuthenticator>
|
|
|
|
#include <QDesktopServices>
|
|
|
|
#include <QDateTime>
|
2018-08-29 18:33:39 +02:00
|
|
|
#include <QtDebug>
|
2018-07-25 00:32:20 +02:00
|
|
|
|
|
|
|
typedef struct strReturnData{
|
|
|
|
int status_code;
|
|
|
|
QString text;
|
|
|
|
}ReturnData_t;
|
|
|
|
|
|
|
|
class BuzzerConn : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2018-08-28 23:03:35 +02:00
|
|
|
explicit BuzzerConn(QObject *parent = nullptr, QUrl ip = QUrl("http://192.168.4.1"));
|
2018-07-26 20:51:46 +02:00
|
|
|
double offset;
|
2018-07-25 00:32:20 +02:00
|
|
|
QList<double> latest_offsets;
|
2018-07-26 14:54:11 +02:00
|
|
|
double latest_button_pressed;
|
|
|
|
double starttime;
|
2018-07-25 00:32:20 +02:00
|
|
|
bool connected;
|
2018-07-26 20:51:46 +02:00
|
|
|
int connection_progress;
|
2018-08-28 23:03:35 +02:00
|
|
|
QUrl buzz_url;
|
2018-07-26 14:54:11 +02:00
|
|
|
|
2018-07-25 00:32:20 +02:00
|
|
|
private:
|
|
|
|
QNetworkAccessManager *networkManager;
|
2018-08-02 18:10:08 +02:00
|
|
|
QNetworkAccessManager *reloadNetworkManager;
|
2018-07-26 14:54:11 +02:00
|
|
|
QDateTime *date;
|
2018-07-25 00:32:20 +02:00
|
|
|
|
|
|
|
signals:
|
|
|
|
|
|
|
|
public slots:
|
2018-08-02 18:10:08 +02:00
|
|
|
ReturnData_t senddata(QNetworkAccessManager * NetMan, QUrl serviceUrl, int timeout);
|
|
|
|
//function to communicate with the buzzer
|
2018-08-02 12:50:55 +02:00
|
|
|
Q_INVOKABLE QList<double> gettimes(int timeout);
|
2018-08-02 18:10:08 +02:00
|
|
|
//function to get the times from the buzzer as a list with the normal network manager
|
2018-07-26 14:54:11 +02:00
|
|
|
Q_INVOKABLE bool connect();
|
2018-08-02 18:10:08 +02:00
|
|
|
//function to connect to buzzer
|
|
|
|
Q_INVOKABLE bool calcoffset(QList<double> times);
|
|
|
|
//function that calculates the average time offset between the buzzer and the device
|
2018-07-26 14:54:11 +02:00
|
|
|
Q_INVOKABLE bool buzzer_triggered();
|
2018-08-02 18:10:08 +02:00
|
|
|
//function that checks ih the buzzer has been pushed since the last call of this function
|
2018-07-26 14:54:11 +02:00
|
|
|
Q_INVOKABLE bool start();
|
2018-08-02 18:10:08 +02:00
|
|
|
//syncs the buzzer and the base to make a start possible
|
2018-07-26 14:54:11 +02:00
|
|
|
Q_INVOKABLE double get(QString key);
|
2018-08-02 18:10:08 +02:00
|
|
|
//can return some things (offset, lastpressed, currtime, connection_progress, connected)
|
2018-07-26 14:54:11 +02:00
|
|
|
Q_INVOKABLE QString test();
|
2018-08-02 18:10:08 +02:00
|
|
|
Q_INVOKABLE bool refresh();
|
|
|
|
//refreshed the connection to the buzzer
|
2018-07-25 00:32:20 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // BUZZERCONN_H
|