forked from dresden-elektronik/deconz-rest-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
poll_manager.h
71 lines (60 loc) · 1.39 KB
/
poll_manager.h
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
* Copyright (c) 2017 dresden elektronik ingenieurtechnik gmbh.
* All rights reserved.
*
* The software in this package is published under the terms of the BSD
* style license a copy of which has been included with this distribution in
* the LICENSE.txt file.
*
*/
#ifndef POLL_MANAGER_H
#define POLL_MANAGER_H
#include <QObject>
#include <QDateTime>
#include <vector>
#include <deconz.h>
class QTimer;
class DeRestPluginPrivate;
class RestNodeBase;
/*! \class PollItem
Item representing a node in the polling queue.
*/
class PollItem
{
public:
// Resource related
QString id;
const char *prefix;
std::vector<const char*> items;
QDateTime tStart;
// APS
quint8 endpoint;
deCONZ::Address address;
};
/*! \class PollManager
Service to handle periodically polling of nodes.
*/
class PollManager : public QObject
{
Q_OBJECT
public:
enum PollState {
StateIdle,
StateWait
};
explicit PollManager(QObject *parent = 0);
void poll(RestNodeBase *restNode, const QDateTime &tStart = QDateTime());
void delay(int ms);
signals:
public slots:
void apsdeDataConfirm(const deCONZ::ApsDataConfirm &conf);
void pollTimerFired();
private:
QTimer *timer;
std::vector<PollItem> items;
DeRestPluginPrivate *plugin;
PollState pollState;
quint8 apsReqId;
deCONZ::Address dstAddr;
};
#endif // POLL_MANAGER_H