-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcondworker.h
More file actions
50 lines (37 loc) · 1.04 KB
/
condworker.h
File metadata and controls
50 lines (37 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef CONDWORKER_H
#define CONDWORKER_H
#include <QObject>
#include <QQueue>
#include <QTime>
#include <QTimer>
// Queues the commands used by CondInterface for sending to meter.
// Used exact same layout as PumpCommandWorker
class CondInterface;
struct CondReading {
double value = 0.0;
QString units;
QTime timestamp;
CondReading() = default;
CondReading(double v, const QString& u, const QTime& t = QTime::currentTime())
: value(v), units(u), timestamp(t) {}
};
class CondWorker : public QObject
{
Q_OBJECT
public:
explicit CondWorker(CondInterface* interface, QObject* parent = nullptr);
signals:
void condCommandReady(QString cmd);
public slots:
void enqueueCommand(const QString& cmd);public slots:
void initialize(); // slot to set up the timer
private slots:
void onResponseReceived(CondReading response);
private:
void processNext();
QTimer* timeoutTimer;
QQueue<QString> commandQueue;
CondInterface* condInterface;
bool processing = false;
};
#endif // CONDWORKER_H