forked from u236/homed-service-zigbee
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.h
68 lines (45 loc) · 2.36 KB
/
action.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
#ifndef ACTION_H
#define ACTION_H
#include <QSharedPointer>
#include <QVariant>
#include "property.h"
class ActionObject;
typedef QSharedPointer <ActionObject> Action;
class ActionObject : public AbstractMetaObject
{
public:
ActionObject(const QString &name, quint16 clusterId, quint16 manufacturerCode = 0, QList <quint16> attributes = {}) :
AbstractMetaObject(name), m_clusterId(clusterId), m_manufacturerCode(manufacturerCode), m_transactionId(0), m_properyUpdated(false), m_attributes(attributes) {}
ActionObject(const QString &name, quint16 clusterId, quint16 manufacturerCode, quint16 attributeId) :
AbstractMetaObject(name), m_clusterId(clusterId), m_manufacturerCode(manufacturerCode), m_transactionId(0), m_properyUpdated(false), m_attributes({attributeId}) {}
ActionObject(const QString &name, quint16 clusterId, quint16 manufacturerCode, QList <QString> actions) :
AbstractMetaObject(name), m_clusterId(clusterId), m_manufacturerCode(manufacturerCode), m_transactionId(0), m_properyUpdated(false), m_actions(actions) {}
virtual ~ActionObject(void) {}
virtual QByteArray request(const QString &name, const QVariant &data) = 0;
inline quint16 clusterId(void) { return m_clusterId; }
inline quint16 manufacturerCode(void) { return m_manufacturerCode; }
inline bool propertyUpdated(void) { return m_properyUpdated; }
inline QList <quint16> &attributes(void) { return m_attributes; }
inline QList <QString> &actions(void) { return m_actions; }
static void registerMetaTypes(void);
protected:
quint16 m_clusterId, m_manufacturerCode;
quint8 m_transactionId;
bool m_properyUpdated;
QList <quint16> m_attributes;
QList <QString> m_actions;
Property endpointProperty(const QString &name = QString());
QByteArray writeAttribute(quint8 dataType, void *value, size_t length);
qint8 listIndex(const QList <QString> &list, const QVariant &value);
int enumIndex(const QString name, const QVariant &value);
};
class EnumAction : public ActionObject
{
public:
EnumAction(const QString &name, quint16 clusterId, quint16 manufacturerCode, quint16 attributeId, quint8 dataType) :
ActionObject(name, clusterId, manufacturerCode, attributeId), m_dataType(dataType) {}
QByteArray request(const QString &name, const QVariant &data) override;
private:
quint8 m_dataType;
};
#endif