forked from dresden-elektronik/deconz-rest-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rest_node_base.h
112 lines (99 loc) · 3.21 KB
/
rest_node_base.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
* Copyright (c) 2017-2020 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 REST_NODE_BASE_H
#define REST_NODE_BASE_H
#include <QDateTime>
#include <deconz.h>
/*! \class NodeValue
Holds bookkeeping data for numeric ZCL values.
*/
class NodeValue
{
public:
enum UpdateType { UpdateInvalid, UpdateByZclReport, UpdateByZclRead };
NodeValue() :
updateType(UpdateInvalid),
endpoint(0),
clusterId(0),
attributeId(0),
minInterval(0),
maxInterval(0),
zclSeqNum(0)
{
value.u64 = 0;
}
bool isValid() const { return updateType != UpdateInvalid; }
QDateTime timestamp;
QDateTime timestampLastReport;
QDateTime timestampLastReadRequest;
QDateTime timestampLastConfigured;
UpdateType updateType;
quint8 endpoint;
quint16 clusterId;
quint16 attributeId;
quint16 minInterval;
quint16 maxInterval;
quint8 zclSeqNum; // sequence number for configure reporting
deCONZ::NumericUnion value;
};
/*! \class RestNodeBase
The base class for all device representations.
*/
class RestNodeBase
{
public:
RestNodeBase();
virtual ~RestNodeBase();
deCONZ::Node *node();
void setNode(deCONZ::Node *node);
deCONZ::Address &address();
const deCONZ::Address &address() const;
virtual bool isAvailable() const;
bool needSaveDatabase() const;
void setNeedSaveDatabase(bool needSave);
const QString &id() const;
void setId(const QString &id);
const QString &uniqueId() const;
void setUniqueId(const QString &uid);
bool mustRead(uint32_t readFlags);
void enableRead(uint32_t readFlags);
void clearRead(uint32_t readFlags);
const QTime &nextReadTime(uint32_t item) const;
void setNextReadTime(uint32_t item, const QTime &time);
int lastRead(uint32_t item) const;
void setLastRead(uint32_t item, int lastRead);
int lastAttributeReportBind() const;
void setLastAttributeReportBind(int lastBind);
bool mgmtBindSupported() const;
void setMgmtBindSupported(bool supported);
void setZclValue(NodeValue::UpdateType updateType, quint8 endpoint, quint16 clusterId, quint16 attributeId, const deCONZ::NumericUnion &value);
const NodeValue &getZclValue(quint16 clusterId, quint16 attributeId, quint8 endpoint = 0) const;
NodeValue &getZclValue(quint16 clusterId, quint16 attributeId, quint8 endpoint = 0);
std::vector<NodeValue> &zclValues();
const std::vector<NodeValue> &zclValues() const;
const QDateTime &lastRx() const;
void rx();
private:
deCONZ::Node *m_node;
deCONZ::Address m_addr;
QString m_id;
QString m_uid;
bool m_mgmtBindSupported;
bool m_needSaveDatabase;
uint32_t m_read; // bitmap of READ_* flags
std::vector<int> m_lastRead; // copy of idleTotalCounter
int m_lastAttributeReportBind; // copy of idleTotalCounter
std::vector<QTime> m_nextReadTime;
QDateTime m_lastRx;
NodeValue m_invalidValue;
std::vector<NodeValue> m_values;
QTime m_invalidTime;
};
#endif // REST_NODE_BASE_H