102 lines
2.3 KiB
C++
102 lines
2.3 KiB
C++
#ifndef MANAGER_H
|
|
#define MANAGER_H
|
|
|
|
#include <QDebug>
|
|
#include <QObject>
|
|
#include <QFile>
|
|
|
|
#include <array>
|
|
#include <ostream>
|
|
#include <map>
|
|
|
|
struct WifiRttResult {
|
|
int success;
|
|
std::string mac;
|
|
int64_t timeMS;
|
|
int distMM;
|
|
int distStdDevMM;
|
|
int numAttemptedMeas;
|
|
int numSuccessfullMeas;
|
|
int rssi;
|
|
};
|
|
|
|
static QDebug operator<<(QDebug dbg, const WifiRttResult& v)
|
|
{
|
|
dbg << v.success << ";"
|
|
<< QString::fromStdString(v.mac) << ";"
|
|
<< v.timeMS << ";"
|
|
<< v.distMM << ";"
|
|
<< v.distStdDevMM << ";"
|
|
<< v.numSuccessfullMeas << "/" << v.numAttemptedMeas << ";"
|
|
<< v.rssi;
|
|
return dbg;
|
|
}
|
|
|
|
class Manager : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
private:
|
|
|
|
float _uwbDist[4];
|
|
|
|
bool _isRunning = false;
|
|
bool _logToDisk = false;
|
|
int _maxRuntime = 0;
|
|
|
|
std::shared_ptr<QFile> ftmLogger;
|
|
|
|
public:
|
|
Q_PROPERTY(bool isRunning READ getIsRunning NOTIFY isRunningChanged)
|
|
Q_PROPERTY(bool logToDisk READ getLogToDisk WRITE setLogToDisk NOTIFY logToDiskChanged)
|
|
|
|
Q_PROPERTY(int maxRuntime READ getMaxRuntime WRITE setMaxRuntime)
|
|
|
|
Q_PROPERTY(float uwbDist1 READ getUwbDist1() NOTIFY uwbDistChanged)
|
|
Q_PROPERTY(float uwbDist2 READ getUwbDist2() NOTIFY uwbDistChanged)
|
|
Q_PROPERTY(float uwbDist3 READ getUwbDist3() NOTIFY uwbDistChanged)
|
|
Q_PROPERTY(float uwbDist4 READ getUwbDist4() NOTIFY uwbDistChanged)
|
|
|
|
Q_INVOKABLE bool trigger();
|
|
Q_INVOKABLE void start();
|
|
Q_INVOKABLE void stop();
|
|
|
|
Q_INVOKABLE int runTimeInMs() const;
|
|
|
|
Q_INVOKABLE void test();
|
|
|
|
Q_INVOKABLE void manualCheckpoint();
|
|
|
|
void onWifiData(WifiRttResult result);
|
|
void onUWBData(std::vector<uchar> data);
|
|
|
|
private:
|
|
|
|
bool getIsRunning() const { return _isRunning; }
|
|
|
|
bool getLogToDisk() const { return _logToDisk; }
|
|
void setLogToDisk(bool v) { _logToDisk = v; emit logToDiskChanged(v); }
|
|
|
|
int getMaxRuntime() const { return _maxRuntime; }
|
|
void setMaxRuntime(int value) { _maxRuntime = value; }
|
|
|
|
float getUwbDist1() {return _uwbDist[0];}
|
|
float getUwbDist2() {return _uwbDist[1];}
|
|
float getUwbDist3() {return _uwbDist[2];}
|
|
float getUwbDist4() {return _uwbDist[3];}
|
|
|
|
signals:
|
|
|
|
void uwbDistChanged();
|
|
void newDistMeas(int idx, int value);
|
|
void logToDiskChanged(bool newValue);
|
|
void isRunningChanged();
|
|
|
|
public:
|
|
|
|
Manager();
|
|
|
|
};
|
|
|
|
#endif // MANAGER_H
|