Merge branch 'master' of https://github.com/HiveFive/Hive
This commit is contained in:
commit
29627726ba
@ -37,6 +37,16 @@ void DeviceClass::setName(const QString &name)
|
|||||||
m_name = name;
|
m_name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<StateType> DeviceClass::states() const
|
||||||
|
{
|
||||||
|
return m_states;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceClass::setStates(const QList<StateType> &states)
|
||||||
|
{
|
||||||
|
m_states = states;
|
||||||
|
}
|
||||||
|
|
||||||
QList<TriggerType> DeviceClass::triggers() const
|
QList<TriggerType> DeviceClass::triggers() const
|
||||||
{
|
{
|
||||||
return m_triggers;
|
return m_triggers;
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "triggertype.h"
|
#include "triggertype.h"
|
||||||
#include "actiontype.h"
|
#include "actiontype.h"
|
||||||
|
#include "statetype.h"
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
@ -20,6 +21,9 @@ public:
|
|||||||
QString name() const;
|
QString name() const;
|
||||||
void setName(const QString &name);
|
void setName(const QString &name);
|
||||||
|
|
||||||
|
QList<StateType> states() const;
|
||||||
|
void setStates(const QList<StateType> &states);
|
||||||
|
|
||||||
QList<TriggerType> triggers() const;
|
QList<TriggerType> triggers() const;
|
||||||
void setTriggers(const QList<TriggerType> &triggers);
|
void setTriggers(const QList<TriggerType> &triggers);
|
||||||
|
|
||||||
@ -35,6 +39,7 @@ private:
|
|||||||
QUuid m_id;
|
QUuid m_id;
|
||||||
QUuid m_pluginId;
|
QUuid m_pluginId;
|
||||||
QString m_name;
|
QString m_name;
|
||||||
|
QList<StateType> m_states;
|
||||||
QList<TriggerType> m_triggers;
|
QList<TriggerType> m_triggers;
|
||||||
QList<ActionType> m_actions;
|
QList<ActionType> m_actions;
|
||||||
QVariantList m_params;
|
QVariantList m_params;
|
||||||
|
|||||||
@ -16,6 +16,8 @@ SOURCES += device.cpp \
|
|||||||
triggertype.cpp \
|
triggertype.cpp \
|
||||||
action.cpp \
|
action.cpp \
|
||||||
actiontype.cpp \
|
actiontype.cpp \
|
||||||
|
state.cpp \
|
||||||
|
statetype.cpp
|
||||||
|
|
||||||
HEADERS += device.h \
|
HEADERS += device.h \
|
||||||
deviceclass.h \
|
deviceclass.h \
|
||||||
@ -27,4 +29,6 @@ HEADERS += device.h \
|
|||||||
triggertype.h \
|
triggertype.h \
|
||||||
action.h \
|
action.h \
|
||||||
actiontype.h \
|
actiontype.h \
|
||||||
|
state.h \
|
||||||
|
statetype.h
|
||||||
|
|
||||||
|
|||||||
5
libhive/state.cpp
Normal file
5
libhive/state.cpp
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#include "state.h"
|
||||||
|
|
||||||
|
State::State(const QUuid &stateTypeId)
|
||||||
|
{
|
||||||
|
}
|
||||||
22
libhive/state.h
Normal file
22
libhive/state.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#ifndef STATE_H
|
||||||
|
#define STATE_H
|
||||||
|
|
||||||
|
#include <QUuid>
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
|
class State
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
State(const QUuid &stateTypeId);
|
||||||
|
|
||||||
|
QUuid stateTypeId() const;
|
||||||
|
|
||||||
|
QVariant value() const;
|
||||||
|
void setValue(const QVariant &value);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QUuid m_stateTypeId;
|
||||||
|
QVariant m_value;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // STATE_H
|
||||||
31
libhive/statetype.cpp
Normal file
31
libhive/statetype.cpp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#include "statetype.h"
|
||||||
|
|
||||||
|
StateType::StateType(const QUuid &id):
|
||||||
|
m_id(id)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QUuid StateType::id() const
|
||||||
|
{
|
||||||
|
return m_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString StateType::name() const
|
||||||
|
{
|
||||||
|
return m_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
void StateType::setName(const QString &name)
|
||||||
|
{
|
||||||
|
m_name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant::Type StateType::type() const
|
||||||
|
{
|
||||||
|
return m_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
void StateType::setType(const QVariant::Type &type)
|
||||||
|
{
|
||||||
|
m_type = type;
|
||||||
|
}
|
||||||
26
libhive/statetype.h
Normal file
26
libhive/statetype.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#ifndef STATETYPE_H
|
||||||
|
#define STATETYPE_H
|
||||||
|
|
||||||
|
#include <QUuid>
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
|
class StateType
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
StateType(const QUuid &id);
|
||||||
|
|
||||||
|
QUuid id() const;
|
||||||
|
|
||||||
|
QString name() const;
|
||||||
|
void setName(const QString &name);
|
||||||
|
|
||||||
|
QVariant::Type type() const;
|
||||||
|
void setType(const QVariant::Type &type);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QUuid m_id;
|
||||||
|
QString m_name;
|
||||||
|
QVariant::Type m_type;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // STATETYPE_H
|
||||||
@ -29,7 +29,21 @@ QList<DeviceClass> DevicePluginMeisterAnker::supportedDevices() const
|
|||||||
thermometerParams.append(idParam);
|
thermometerParams.append(idParam);
|
||||||
|
|
||||||
deviceClassMeisterAnkerThermometer.setParams(thermometerParams);
|
deviceClassMeisterAnkerThermometer.setParams(thermometerParams);
|
||||||
|
|
||||||
|
QList<StateType> thermometerStates;
|
||||||
|
|
||||||
|
StateType tempState("a9849491-25f4-43a3-a6fe-3bfce43d6332");
|
||||||
|
tempState.setName("Temperature");
|
||||||
|
tempState.setType(QVariant::Double);
|
||||||
|
thermometerStates.append(tempState);
|
||||||
|
|
||||||
|
StateType batteryState("ebf951ba-75ca-47ac-ba3c-ea9ec1e7bbd1");
|
||||||
|
batteryState.setName("Battery");
|
||||||
|
batteryState.setType(QVariant::Bool);
|
||||||
|
thermometerStates.append(batteryState);
|
||||||
|
|
||||||
|
deviceClassMeisterAnkerThermometer.setStates(thermometerStates);
|
||||||
|
|
||||||
QList<TriggerType> thermometerTriggers;
|
QList<TriggerType> thermometerTriggers;
|
||||||
|
|
||||||
QVariantList paramsThermometer;
|
QVariantList paramsThermometer;
|
||||||
|
|||||||
@ -194,6 +194,15 @@ QVariantMap JsonRPCServer::packDeviceClass(const DeviceClass &deviceClass)
|
|||||||
QVariantMap variant;
|
QVariantMap variant;
|
||||||
variant.insert("name", deviceClass.name());
|
variant.insert("name", deviceClass.name());
|
||||||
variant.insert("id", deviceClass.id());
|
variant.insert("id", deviceClass.id());
|
||||||
|
QVariantList stateTypes;
|
||||||
|
foreach (const StateType &stateType, deviceClass.states()) {
|
||||||
|
QVariantMap stateMap;
|
||||||
|
stateMap.insert("id", stateType.id().toString());
|
||||||
|
stateMap.insert("name", stateType.name());
|
||||||
|
stateMap.insert("type", QVariant::typeToName(stateType.type()));
|
||||||
|
|
||||||
|
stateTypes.append(stateMap);
|
||||||
|
}
|
||||||
QVariantList triggerTypes;
|
QVariantList triggerTypes;
|
||||||
foreach (const TriggerType &triggerType, deviceClass.triggers()) {
|
foreach (const TriggerType &triggerType, deviceClass.triggers()) {
|
||||||
QVariantMap triggerMap;
|
QVariantMap triggerMap;
|
||||||
@ -204,7 +213,6 @@ QVariantMap JsonRPCServer::packDeviceClass(const DeviceClass &deviceClass)
|
|||||||
triggerTypes.append(triggerMap);
|
triggerTypes.append(triggerMap);
|
||||||
}
|
}
|
||||||
QVariantList actionTypes;
|
QVariantList actionTypes;
|
||||||
qDebug() << "*******************" << deviceClass.actions().count();
|
|
||||||
foreach (const ActionType &actionType, deviceClass.actions()) {
|
foreach (const ActionType &actionType, deviceClass.actions()) {
|
||||||
QVariantMap actionMap;
|
QVariantMap actionMap;
|
||||||
actionMap.insert("id", actionType.id().toString());
|
actionMap.insert("id", actionType.id().toString());
|
||||||
@ -214,6 +222,7 @@ QVariantMap JsonRPCServer::packDeviceClass(const DeviceClass &deviceClass)
|
|||||||
actionTypes.append(actionMap);
|
actionTypes.append(actionMap);
|
||||||
}
|
}
|
||||||
variant.insert("params", deviceClass.params());
|
variant.insert("params", deviceClass.params());
|
||||||
|
variant.insert("states", stateTypes);
|
||||||
variant.insert("triggers", triggerTypes);
|
variant.insert("triggers", triggerTypes);
|
||||||
variant.insert("actions", actionTypes);
|
variant.insert("actions", actionTypes);
|
||||||
return variant;
|
return variant;
|
||||||
|
|||||||
Reference in New Issue
Block a user