mirror of https://github.com/nymea/nymea.git
make things more typesafe
parent
4f679b3bc3
commit
415a48d659
|
|
@ -77,9 +77,9 @@
|
|||
|
||||
#include "hardware/radio433.h"
|
||||
|
||||
#include "device.h"
|
||||
#include "deviceclass.h"
|
||||
#include "deviceplugin.h"
|
||||
#include "plugin/device.h"
|
||||
#include "plugin/deviceclass.h"
|
||||
#include "plugin/deviceplugin.h"
|
||||
|
||||
#include <QPluginLoader>
|
||||
#include <QtPlugin>
|
||||
|
|
@ -132,7 +132,7 @@ QList<DeviceClass> DeviceManager::supportedDevices() const
|
|||
Optionally you can supply an id yourself if you must keep track of the added device. If you don't supply it, a new one will
|
||||
be generated.
|
||||
*/
|
||||
DeviceManager::DeviceError DeviceManager::addConfiguredDevice(const QUuid &deviceClassId, const QVariantMap ¶ms, const QUuid id)
|
||||
DeviceManager::DeviceError DeviceManager::addConfiguredDevice(const DeviceClassId &deviceClassId, const QVariantMap ¶ms, const DeviceId id)
|
||||
{
|
||||
DeviceClass deviceClass = findDeviceClass(deviceClassId);
|
||||
if (deviceClass.id().isNull()) {
|
||||
|
|
@ -236,10 +236,11 @@ DeviceClass DeviceManager::findDeviceClassforEvent(const QUuid &eventTypeId) con
|
|||
}
|
||||
}
|
||||
}
|
||||
return DeviceClass(QUuid(), QUuid());
|
||||
return DeviceClass();
|
||||
}
|
||||
|
||||
/*! For conveninece, this returns the \{DeviceClass} with the id given by \a deviceClassId. */
|
||||
/*! For conveninece, this returns the \{DeviceClass} with the id given by \a deviceClassId.
|
||||
Note: The returned DeviceClass may be invalid.*/
|
||||
DeviceClass DeviceManager::findDeviceClass(const QUuid &deviceClassId) const
|
||||
{
|
||||
foreach (const DeviceClass &deviceClass, m_supportedDevices) {
|
||||
|
|
@ -247,7 +248,7 @@ DeviceClass DeviceManager::findDeviceClass(const QUuid &deviceClassId) const
|
|||
return deviceClass;
|
||||
}
|
||||
}
|
||||
return DeviceClass(QUuid(), QUuid());
|
||||
return DeviceClass();
|
||||
}
|
||||
|
||||
/*! Execute the given \{Action}.
|
||||
|
|
@ -285,6 +286,15 @@ void DeviceManager::loadPlugins()
|
|||
if (pluginIface) {
|
||||
qDebug() << "*** Loaded plugin" << pluginIface->pluginName();
|
||||
pluginIface->initPlugin(this);
|
||||
foreach (const Vendor &vendor, pluginIface->supportedVendors()) {
|
||||
qDebug() << "* Loaded vendor:" << vendor.name();
|
||||
if (m_supportedVendors.contains(vendor.id())) {
|
||||
qWarning() << "X Duplicate vendor" << vendor.name() << " Ignoring...";
|
||||
continue;
|
||||
}
|
||||
m_supportedVendors.insert(vendor.id(), vendor);
|
||||
}
|
||||
|
||||
foreach (const DeviceClass &deviceClass, pluginIface->supportedDevices()) {
|
||||
qDebug() << "* Loaded device class:" << deviceClass.name();
|
||||
m_supportedDevices.insert(deviceClass.id(), deviceClass);
|
||||
|
|
@ -301,7 +311,7 @@ void DeviceManager::loadConfiguredDevices()
|
|||
qDebug() << "loading devices from" << settings.fileName();
|
||||
foreach (const QString &idString, settings.childGroups()) {
|
||||
settings.beginGroup(idString);
|
||||
Device *device = new Device(settings.value("pluginid").toUuid(), QUuid(idString), settings.value("deviceClassId").toUuid(), this);
|
||||
Device *device = new Device(settings.value("pluginid").toUuid(), DeviceId(idString), DeviceClassId(settings.value("deviceClassId").toString()), this);
|
||||
device->setName(settings.value("devicename").toString());
|
||||
device->setParams(settings.value("params").toMap());
|
||||
settings.endGroup();
|
||||
|
|
@ -19,7 +19,8 @@
|
|||
#ifndef DEVICEMANAGER_H
|
||||
#define DEVICEMANAGER_H
|
||||
|
||||
#include "deviceclass.h"
|
||||
#include "plugin/deviceclass.h"
|
||||
#include "plugin/device.h"
|
||||
|
||||
#include "types/event.h"
|
||||
#include "types/action.h"
|
||||
|
|
@ -63,7 +64,7 @@ public:
|
|||
QList<DeviceClass> supportedDevices() const;
|
||||
|
||||
QList<Device*> configuredDevices() const;
|
||||
DeviceError addConfiguredDevice(const QUuid &deviceClassId, const QVariantMap ¶ms, const QUuid id = QUuid::createUuid());
|
||||
DeviceError addConfiguredDevice(const DeviceClassId &deviceClassId, const QVariantMap ¶ms, const DeviceId id = DeviceId::createDeviceId());
|
||||
DeviceError removeConfiguredDevice(const QUuid &deviceId);
|
||||
|
||||
Device* findConfiguredDevice(const QUuid &id) const;
|
||||
|
|
@ -8,8 +8,8 @@ INSTALLS += target
|
|||
|
||||
SOURCES += plugin/device.cpp \
|
||||
plugin/deviceclass.cpp \
|
||||
plugin/devicemanager.cpp \
|
||||
plugin/deviceplugin.cpp \
|
||||
devicemanager.cpp \
|
||||
hardware/radio433.cpp \
|
||||
hardware/gpio.cpp \
|
||||
types/action.cpp \
|
||||
|
|
@ -22,8 +22,8 @@ SOURCES += plugin/device.cpp \
|
|||
|
||||
HEADERS += plugin/device.h \
|
||||
plugin/deviceclass.h \
|
||||
plugin/devicemanager.h \
|
||||
plugin/deviceplugin.h \
|
||||
devicemanager.h \
|
||||
hardware/radio433.h \
|
||||
hardware/gpio.h \
|
||||
types/action.h \
|
||||
|
|
@ -32,5 +32,6 @@ HEADERS += plugin/device.h \
|
|||
types/statetype.h \
|
||||
types/eventtype.h \
|
||||
types/event.h \
|
||||
types/vendor.h
|
||||
types/vendor.h \
|
||||
types/typeutils.h
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
#include <QDebug>
|
||||
|
||||
Device::Device(const QUuid &pluginId, const QUuid &id, const QUuid &deviceClassId, QObject *parent):
|
||||
Device::Device(const QUuid &pluginId, const DeviceId &id, const DeviceClassId &deviceClassId, QObject *parent):
|
||||
QObject(parent),
|
||||
m_id(id),
|
||||
m_deviceClassId(deviceClassId),
|
||||
|
|
@ -42,9 +42,9 @@ Device::Device(const QUuid &pluginId, const QUuid &id, const QUuid &deviceClassI
|
|||
|
||||
}
|
||||
|
||||
Device::Device(const QUuid &pluginId, const QUuid &deviceClassId, QObject *parent):
|
||||
Device::Device(const QUuid &pluginId, const DeviceClassId &deviceClassId, QObject *parent):
|
||||
QObject(parent),
|
||||
m_id(QUuid::createUuid()),
|
||||
m_id(DeviceId::createDeviceId()),
|
||||
m_deviceClassId(deviceClassId),
|
||||
m_pluginId(pluginId)
|
||||
{
|
||||
|
|
@ -52,13 +52,13 @@ Device::Device(const QUuid &pluginId, const QUuid &deviceClassId, QObject *paren
|
|||
}
|
||||
|
||||
/*! Returns the id of this Device. */
|
||||
QUuid Device::id() const
|
||||
DeviceId Device::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
/*! Returns the deviceClassId of the associated \l{DeviceClass}. */
|
||||
QUuid Device::deviceClassId() const
|
||||
DeviceClassId Device::deviceClassId() const
|
||||
{
|
||||
return m_deviceClassId;
|
||||
}
|
||||
|
|
@ -129,7 +129,7 @@ QVariant Device::stateValue(const QUuid &stateTypeId) const
|
|||
}
|
||||
|
||||
/*! For convenience, this finds the \l{State} matching the given \a stateTypeId in this Device and sets the current value to \a value. */
|
||||
void Device::setStateValue(const QUuid &stateTypeId, const QVariant &value)
|
||||
void Device::setStateValue(const StateTypeId &stateTypeId, const QVariant &value)
|
||||
{
|
||||
for (int i = 0; i < m_states.count(); ++i) {
|
||||
if (m_states.at(i).stateTypeId() == stateTypeId) {
|
||||
|
|
|
|||
|
|
@ -19,12 +19,16 @@
|
|||
#ifndef DEVICE_H
|
||||
#define DEVICE_H
|
||||
|
||||
#include "typeutils.h"
|
||||
|
||||
#include "plugin/deviceclass.h"
|
||||
#include "types/state.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QUuid>
|
||||
#include <QVariant>
|
||||
|
||||
|
||||
class Device: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
@ -32,8 +36,8 @@ class Device: public QObject
|
|||
friend class DeviceManager;
|
||||
|
||||
public:
|
||||
QUuid id() const;
|
||||
QUuid deviceClassId() const;
|
||||
DeviceId id() const;
|
||||
DeviceClassId deviceClassId() const;
|
||||
QUuid pluginId() const;
|
||||
|
||||
QString name() const;
|
||||
|
|
@ -47,18 +51,18 @@ public:
|
|||
|
||||
bool hasState(const QUuid &stateTypeId) const;
|
||||
QVariant stateValue(const QUuid &stateTypeId) const;
|
||||
void setStateValue(const QUuid &stateTypeId, const QVariant &value);
|
||||
void setStateValue(const StateTypeId &stateTypeId, const QVariant &value);
|
||||
|
||||
signals:
|
||||
void stateValueChanged(const QUuid &stateTypeId, const QVariant &value);
|
||||
|
||||
private:
|
||||
Device(const QUuid &pluginId, const QUuid &id, const QUuid &deviceClassId, QObject *parent = 0);
|
||||
Device(const QUuid &pluginId, const QUuid &deviceClassId, QObject *parent = 0);
|
||||
Device(const QUuid &pluginId, const DeviceId &id, const DeviceClassId &deviceClassId, QObject *parent = 0);
|
||||
Device(const QUuid &pluginId, const DeviceClassId &deviceClassId, QObject *parent = 0);
|
||||
|
||||
private:
|
||||
QUuid m_id;
|
||||
QUuid m_deviceClassId;
|
||||
DeviceId m_id;
|
||||
DeviceClassId m_deviceClassId;
|
||||
QUuid m_pluginId;
|
||||
QString m_name;
|
||||
QVariantMap m_params;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
Generate a new uuid (e.g. uuidgen) and hardode it into the plugin. The id
|
||||
should never change or it will appear as a new DeviceClass in the system.
|
||||
*/
|
||||
DeviceClass::DeviceClass(const QUuid &pluginId, const QUuid &id):
|
||||
DeviceClass::DeviceClass(const QUuid &pluginId, const VendorId &vendor, const DeviceClassId &id):
|
||||
m_id(id),
|
||||
m_pluginId(pluginId)
|
||||
{
|
||||
|
|
@ -47,21 +47,27 @@ DeviceClass::DeviceClass(const QUuid &pluginId, const QUuid &id):
|
|||
}
|
||||
|
||||
/*! Returns the id of this DeviceClass. */
|
||||
QUuid DeviceClass::id() const
|
||||
DeviceClassId DeviceClass::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
/*! Returns the VendorId for this DeviceClass */
|
||||
VendorId DeviceClass::vendorId() const
|
||||
{
|
||||
return m_vendorId;
|
||||
}
|
||||
|
||||
/*! Returns the pluginId this DeviceClass is managed by. */
|
||||
QUuid DeviceClass::pluginId() const
|
||||
{
|
||||
return m_pluginId;
|
||||
}
|
||||
|
||||
/*! Returns true if this DeviceClass's id and pluginId are valid uuids. */
|
||||
/*! Returns true if this DeviceClass's id, vendorId and pluginId are valid uuids. */
|
||||
bool DeviceClass::isValid() const
|
||||
{
|
||||
return !m_id.isNull() && !m_pluginId.isNull();
|
||||
return !m_id.isNull() && !m_vendorId.isNull() && !m_pluginId.isNull();
|
||||
}
|
||||
|
||||
/*! Returns the name of this DeviceClass's. This is visible to the user. */
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@
|
|||
#ifndef DEVICECLASS_H
|
||||
#define DEVICECLASS_H
|
||||
|
||||
#include "typeutils.h"
|
||||
#include "types/vendor.h"
|
||||
#include "types/eventtype.h"
|
||||
#include "types/actiontype.h"
|
||||
#include "types/statetype.h"
|
||||
|
|
@ -29,9 +31,10 @@
|
|||
class DeviceClass
|
||||
{
|
||||
public:
|
||||
DeviceClass(const QUuid &pluginId = QUuid(), const QUuid &id = QUuid());
|
||||
DeviceClass(const QUuid &pluginId = QUuid(), const VendorId &vendor = VendorId(), const DeviceClassId &id = DeviceClassId());
|
||||
|
||||
QUuid id() const;
|
||||
DeviceClassId id() const;
|
||||
VendorId vendorId() const;
|
||||
QUuid pluginId() const;
|
||||
bool isValid() const;
|
||||
|
||||
|
|
@ -53,7 +56,8 @@ public:
|
|||
bool operator==(const DeviceClass &device) const;
|
||||
|
||||
private:
|
||||
QUuid m_id;
|
||||
DeviceClassId m_id;
|
||||
VendorId m_vendorId;
|
||||
QUuid m_pluginId;
|
||||
QString m_name;
|
||||
QList<StateType> m_states;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
#include "action.h"
|
||||
|
||||
/*! Construct an Action with the given \a deviceId and \a actionTypeId */
|
||||
Action::Action(const QUuid &deviceId, const QUuid &actionTypeId) :
|
||||
Action::Action(const DeviceId &deviceId, const ActionTypeId &actionTypeId) :
|
||||
m_actionTypeId(actionTypeId),
|
||||
m_deviceId(deviceId)
|
||||
{
|
||||
|
|
@ -46,13 +46,13 @@ bool Action::isValid() const
|
|||
}
|
||||
|
||||
/*! Returns the actionTypeId for this Action */
|
||||
QUuid Action::actionTypeId() const
|
||||
ActionTypeId Action::actionTypeId() const
|
||||
{
|
||||
return m_actionTypeId;
|
||||
}
|
||||
|
||||
/*! Returns the deviceId this Action is associated with.*/
|
||||
QUuid Action::deviceId() const
|
||||
DeviceId Action::deviceId() const
|
||||
{
|
||||
return m_deviceId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,25 +19,26 @@
|
|||
#ifndef ACTION_H
|
||||
#define ACTION_H
|
||||
|
||||
#include <QUuid>
|
||||
#include "typeutils.h"
|
||||
|
||||
#include <QVariantList>
|
||||
|
||||
class Action
|
||||
{
|
||||
public:
|
||||
explicit Action(const QUuid &deviceId, const QUuid &actionTypeId);
|
||||
explicit Action(const DeviceId &deviceId, const ActionTypeId &actionTypeId);
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
QUuid actionTypeId() const;
|
||||
QUuid deviceId() const;
|
||||
ActionTypeId actionTypeId() const;
|
||||
DeviceId deviceId() const;
|
||||
|
||||
QVariantMap params() const;
|
||||
void setParams(const QVariantMap ¶ms);
|
||||
|
||||
private:
|
||||
QUuid m_actionTypeId;
|
||||
QUuid m_deviceId;
|
||||
ActionTypeId m_actionTypeId;
|
||||
DeviceId m_deviceId;
|
||||
QVariantMap m_params;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -34,13 +34,13 @@
|
|||
#include "actiontype.h"
|
||||
|
||||
/*! Constructs an ActionType with the given \a id.*/
|
||||
ActionType::ActionType(const QUuid &id):
|
||||
ActionType::ActionType(const ActionTypeId &id):
|
||||
m_id(id)
|
||||
{
|
||||
}
|
||||
|
||||
/*! Returns the id of this ActionType.*/
|
||||
QUuid ActionType::id() const
|
||||
ActionTypeId ActionType::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,15 +19,16 @@
|
|||
#ifndef ACTIONTYPE_H
|
||||
#define ACTIONTYPE_H
|
||||
|
||||
#include <QUuid>
|
||||
#include "typeutils.h"
|
||||
|
||||
#include <QVariantList>
|
||||
|
||||
class ActionType
|
||||
{
|
||||
public:
|
||||
ActionType(const QUuid &id);
|
||||
ActionType(const ActionTypeId &id);
|
||||
|
||||
QUuid id() const;
|
||||
ActionTypeId id() const;
|
||||
|
||||
QString name() const;
|
||||
void setName(const QString &name);
|
||||
|
|
@ -36,7 +37,7 @@ public:
|
|||
void setParameters(const QVariantList ¶meters);
|
||||
|
||||
private:
|
||||
QUuid m_id;
|
||||
ActionTypeId m_id;
|
||||
QString m_name;
|
||||
|
||||
QVariantList m_parameters;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
/*! Constructs a Event reflecting the \l{Event} given by \a EventTypeId, associated with
|
||||
the \l{Device} given by \a deviceId and the parameters given by \a params. The parameters must
|
||||
match the description in the reflecting \l{Event}.*/
|
||||
Event::Event(const QUuid &eventTypeId, const QUuid &deviceId, const QVariantMap ¶ms):
|
||||
Event::Event(const EventTypeId &eventTypeId, const DeviceId &deviceId, const QVariantMap ¶ms):
|
||||
m_eventTypeId(eventTypeId),
|
||||
m_deviceId(deviceId),
|
||||
m_params(params)
|
||||
|
|
@ -44,13 +44,13 @@ Event::Event(const QUuid &eventTypeId, const QUuid &deviceId, const QVariantMap
|
|||
}
|
||||
|
||||
/*! Returns the id of the \l{EventType} which describes this Event.*/
|
||||
QUuid Event::eventTypeId() const
|
||||
EventTypeId Event::eventTypeId() const
|
||||
{
|
||||
return m_eventTypeId;
|
||||
}
|
||||
|
||||
/*! Returns the id of the \l{Device} associated with this Event.*/
|
||||
QUuid Event::deviceId() const
|
||||
DeviceId Event::deviceId() const
|
||||
{
|
||||
return m_deviceId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,17 +19,18 @@
|
|||
#ifndef EVENT_H
|
||||
#define EVENT_H
|
||||
|
||||
#include "typeutils.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QUuid>
|
||||
#include <QVariantList>
|
||||
|
||||
class Event
|
||||
{
|
||||
public:
|
||||
Event(const QUuid &eventTypeId, const QUuid &deviceId, const QVariantMap ¶ms);
|
||||
Event(const EventTypeId &eventTypeId, const DeviceId &deviceId, const QVariantMap ¶ms);
|
||||
|
||||
QUuid eventTypeId() const;
|
||||
QUuid deviceId() const;
|
||||
EventTypeId eventTypeId() const;
|
||||
DeviceId deviceId() const;
|
||||
|
||||
QVariantMap params() const;
|
||||
void setParams(const QVariantMap ¶ms);
|
||||
|
|
@ -37,8 +38,8 @@ public:
|
|||
bool operator ==(const Event &other) const;
|
||||
|
||||
private:
|
||||
QUuid m_eventTypeId;
|
||||
QUuid m_deviceId;
|
||||
EventTypeId m_eventTypeId;
|
||||
DeviceId m_deviceId;
|
||||
QVariantMap m_params;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -29,13 +29,13 @@
|
|||
#include "eventtype.h"
|
||||
|
||||
/*! Constructs a EventType object with the given \a id. */
|
||||
EventType::EventType(const QUuid &id):
|
||||
EventType::EventType(const EventTypeId &id):
|
||||
m_id(id)
|
||||
{
|
||||
}
|
||||
|
||||
/*! Returns the id. */
|
||||
QUuid EventType::id() const
|
||||
EventTypeId EventType::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,15 +19,16 @@
|
|||
#ifndef TRIGGERTYPE_H
|
||||
#define TRIGGERTYPE_H
|
||||
|
||||
#include <QUuid>
|
||||
#include "typeutils.h"
|
||||
|
||||
#include <QVariantMap>
|
||||
|
||||
class EventType
|
||||
{
|
||||
public:
|
||||
EventType(const QUuid &id);
|
||||
EventType(const EventTypeId &id);
|
||||
|
||||
QUuid id() const;
|
||||
EventTypeId id() const;
|
||||
|
||||
QString name() const;
|
||||
void setName(const QString &name);
|
||||
|
|
@ -36,7 +37,7 @@ public:
|
|||
void setParameters(const QVariantList ¶meters);
|
||||
|
||||
private:
|
||||
QUuid m_id;
|
||||
EventTypeId m_id;
|
||||
QString m_name;
|
||||
|
||||
QVariantList m_parameters;
|
||||
|
|
|
|||
|
|
@ -33,20 +33,20 @@
|
|||
|
||||
/*! Constructs a State reflecting the \l{StateType} given by \a stateTypeId
|
||||
and associated with the \l{Device} given by \a deviceId */
|
||||
State::State(const QUuid &stateTypeId, const QUuid &deviceId):
|
||||
State::State(const StateTypeId &stateTypeId, const DeviceId &deviceId):
|
||||
m_stateTypeId(stateTypeId),
|
||||
m_deviceId(deviceId)
|
||||
{
|
||||
}
|
||||
|
||||
/*! Returns the id of the StateType describing this State. */
|
||||
QUuid State::stateTypeId() const
|
||||
StateTypeId State::stateTypeId() const
|
||||
{
|
||||
return m_stateTypeId;
|
||||
}
|
||||
|
||||
/*! Returns the id of the StateType describing this State. */
|
||||
QUuid State::deviceId() const
|
||||
DeviceId State::deviceId() const
|
||||
{
|
||||
return m_deviceId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,23 +19,24 @@
|
|||
#ifndef STATE_H
|
||||
#define STATE_H
|
||||
|
||||
#include <QUuid>
|
||||
#include "typeutils.h"
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
class State
|
||||
{
|
||||
public:
|
||||
State(const QUuid &stateTypeId, const QUuid &deviceId);
|
||||
State(const StateTypeId &stateTypeId, const DeviceId &deviceId);
|
||||
|
||||
QUuid stateTypeId() const;
|
||||
QUuid deviceId() const;
|
||||
StateTypeId stateTypeId() const;
|
||||
DeviceId deviceId() const;
|
||||
|
||||
QVariant value() const;
|
||||
void setValue(const QVariant &value);
|
||||
|
||||
private:
|
||||
QUuid m_stateTypeId;
|
||||
QUuid m_deviceId;
|
||||
StateTypeId m_stateTypeId;
|
||||
DeviceId m_deviceId;
|
||||
QVariant m_value;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -31,13 +31,13 @@
|
|||
/*! Constructs a State with the given \a id.
|
||||
When creating a \l{DevicePlugin} generate a new uuid for each StateType you define and
|
||||
hardcode it into the plugin. */
|
||||
StateType::StateType(const QUuid &id):
|
||||
StateType::StateType(const StateTypeId &id):
|
||||
m_id(id)
|
||||
{
|
||||
}
|
||||
|
||||
/*! Returns the id of the StateType.*/
|
||||
QUuid StateType::id() const
|
||||
StateTypeId StateType::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,15 +19,16 @@
|
|||
#ifndef STATETYPE_H
|
||||
#define STATETYPE_H
|
||||
|
||||
#include <QUuid>
|
||||
#include "typeutils.h"
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
class StateType
|
||||
{
|
||||
public:
|
||||
StateType(const QUuid &id);
|
||||
StateType(const StateTypeId &id);
|
||||
|
||||
QUuid id() const;
|
||||
StateTypeId id() const;
|
||||
|
||||
QString name() const;
|
||||
void setName(const QString &name);
|
||||
|
|
@ -39,7 +40,7 @@ public:
|
|||
void setDefaultValue(const QVariant &defaultValue);
|
||||
|
||||
private:
|
||||
QUuid m_id;
|
||||
StateTypeId m_id;
|
||||
QString m_name;
|
||||
QVariant::Type m_type;
|
||||
QVariant m_defaultValue;
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
#include "vendor.h"
|
||||
|
||||
Vendor::Vendor(const QUuid &id, const QString &name):
|
||||
Vendor::Vendor(const VendorId &id, const QString &name):
|
||||
m_id(id),
|
||||
m_name(name)
|
||||
{
|
||||
}
|
||||
|
||||
QUuid Vendor::id() const
|
||||
VendorId Vendor::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
void Vendor::setId(const QUuid &id)
|
||||
void Vendor::setId(const VendorId &id)
|
||||
{
|
||||
m_id = id;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,22 +1,23 @@
|
|||
#ifndef VENDOR_H
|
||||
#define VENDOR_H
|
||||
|
||||
#include <QUuid>
|
||||
#include "typeutils.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
class Vendor
|
||||
{
|
||||
public:
|
||||
Vendor(const QUuid &id, const QString &name = QString());
|
||||
Vendor(const VendorId &id, const QString &name = QString());
|
||||
|
||||
QUuid id() const;
|
||||
void setId(const QUuid &id);
|
||||
VendorId id() const;
|
||||
void setId(const VendorId &id);
|
||||
|
||||
QString name() const;
|
||||
void setName(const QString &name);
|
||||
|
||||
private:
|
||||
QUuid m_id;
|
||||
VendorId m_id;
|
||||
QString m_name;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
#ifndef TYPEUTILS_H
|
||||
#define TYPEUTILS_H
|
||||
|
||||
#include <QUuid>
|
||||
|
||||
#define DECLARE_TYPE_ID(type) class type##Id: public QUuid \
|
||||
{ \
|
||||
public: \
|
||||
type##Id(const QString &uuid): QUuid(uuid) {} \
|
||||
type##Id(): QUuid() {} \
|
||||
static type##Id create##type##Id() { return type##Id(QUuid::createUuid().toString()); } \
|
||||
static type##Id fromUuid(const QUuid &uuid) { return type##Id(uuid.toString()); } \
|
||||
};
|
||||
|
||||
DECLARE_TYPE_ID(Device)
|
||||
DECLARE_TYPE_ID(DeviceClass)
|
||||
|
||||
DECLARE_TYPE_ID(Vendor)
|
||||
|
||||
DECLARE_TYPE_ID(EventType)
|
||||
DECLARE_TYPE_ID(StateType)
|
||||
DECLARE_TYPE_ID(ActionType)
|
||||
|
||||
|
||||
#endif // TYPEUTILS_H
|
||||
|
|
@ -52,16 +52,16 @@
|
|||
|
||||
#include "devicepluginconrad.h"
|
||||
|
||||
#include "devicemanager.h"
|
||||
#include "plugin/device.h"
|
||||
#include "plugin/devicemanager.h"
|
||||
#include "hardware/radio433.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
|
||||
|
||||
QUuid conradVendorId = QUuid("986cf06f-3ef1-4271-b2a3-2cc277ebecb6");
|
||||
QUuid conradRemoteId = QUuid("17cd2492-28ab-4827-ba6e-5ef35be23f1b");
|
||||
VendorId conradVendorId = VendorId("986cf06f-3ef1-4271-b2a3-2cc277ebecb6");
|
||||
DeviceClassId conradRemoteId = DeviceClassId("17cd2492-28ab-4827-ba6e-5ef35be23f1b");
|
||||
|
||||
DevicePluginConrad::DevicePluginConrad()
|
||||
{
|
||||
|
|
@ -82,7 +82,7 @@ QList<DeviceClass> DevicePluginConrad::supportedDevices() const
|
|||
|
||||
// =======================================
|
||||
// Remote
|
||||
DeviceClass deviceClassConradRemote(pluginId(), conradRemoteId);
|
||||
DeviceClass deviceClassConradRemote(pluginId(), conradVendorId, conradRemoteId);
|
||||
deviceClassConradRemote.setName("Conrad Remote");
|
||||
|
||||
QVariantList deviceParamsRemote;
|
||||
|
|
|
|||
|
|
@ -52,18 +52,18 @@
|
|||
|
||||
#include "devicepluginelro.h"
|
||||
|
||||
#include "devicemanager.h"
|
||||
#include "plugin/device.h"
|
||||
#include "plugin/devicemanager.h"
|
||||
#include "hardware/radio433.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
|
||||
QUuid elroVendorId = QUuid("435a13a0-65ca-4f0c-94c1-e5873b258db5");
|
||||
QUuid mumbiVendorId = QUuid("5f91c01c-0168-4bdf-a5ed-37cb6971b775");
|
||||
VendorId elroVendorId = VendorId("435a13a0-65ca-4f0c-94c1-e5873b258db5");
|
||||
VendorId mumbiVendorId = VendorId("5f91c01c-0168-4bdf-a5ed-37cb6971b775");
|
||||
|
||||
QUuid elroRemoteId = QUuid("d85c1ef4-197c-4053-8e40-707aa671d302");
|
||||
QUuid elroSwitchId = QUuid("308ae6e6-38b3-4b3a-a513-3199da2764f8");
|
||||
DeviceClassId elroRemoteId = DeviceClassId("d85c1ef4-197c-4053-8e40-707aa671d302");
|
||||
DeviceClassId elroSwitchId = DeviceClassId("308ae6e6-38b3-4b3a-a513-3199da2764f8");
|
||||
|
||||
DevicePluginElro::DevicePluginElro()
|
||||
{
|
||||
|
|
@ -88,7 +88,7 @@ QList<DeviceClass> DevicePluginElro::supportedDevices() const
|
|||
|
||||
// =======================================
|
||||
// Remote
|
||||
DeviceClass deviceClassElroRemote(pluginId(), elroRemoteId);
|
||||
DeviceClass deviceClassElroRemote(pluginId(), elroVendorId, elroRemoteId);
|
||||
deviceClassElroRemote.setName("Elro Remote");
|
||||
|
||||
QVariantList deviceParamsRemote;
|
||||
|
|
@ -119,27 +119,27 @@ QList<DeviceClass> DevicePluginElro::supportedDevices() const
|
|||
param.insert("type", "bool");
|
||||
paramsRemote.append(param);
|
||||
|
||||
EventType buttonAEvent(QUuid("9dd3f862-35f3-4b69-954e-fa3c8bd68e39"));
|
||||
EventType buttonAEvent(EventTypeId("9dd3f862-35f3-4b69-954e-fa3c8bd68e39"));
|
||||
buttonAEvent.setName("A");
|
||||
buttonAEvent.setParameters(paramsRemote);
|
||||
buttonEvents.append(buttonAEvent);
|
||||
|
||||
EventType buttonBEvent(QUuid("733226eb-91ba-4e37-9d78-12c87eb5e763"));
|
||||
EventType buttonBEvent(EventTypeId("733226eb-91ba-4e37-9d78-12c87eb5e763"));
|
||||
buttonBEvent.setName("B");
|
||||
buttonBEvent.setParameters(paramsRemote);
|
||||
buttonEvents.append(buttonBEvent);
|
||||
|
||||
EventType buttonCEvent(QUuid("47aaeaec-485a-4775-a543-33f339fd28c8"));
|
||||
EventType buttonCEvent(EventTypeId("47aaeaec-485a-4775-a543-33f339fd28c8"));
|
||||
buttonCEvent.setName("C");
|
||||
buttonCEvent.setParameters(paramsRemote);
|
||||
buttonEvents.append(buttonCEvent);
|
||||
|
||||
EventType buttonDEvent(QUuid("db3d484c-add9-44ab-80a4-a0664e0c87c8"));
|
||||
EventType buttonDEvent(EventTypeId("db3d484c-add9-44ab-80a4-a0664e0c87c8"));
|
||||
buttonDEvent.setName("D");
|
||||
buttonDEvent.setParameters(paramsRemote);
|
||||
buttonEvents.append(buttonDEvent);
|
||||
|
||||
EventType buttonEEvent(QUuid("eb914aac-fb73-4ee2-9f1b-c34b2f6cc24a"));
|
||||
EventType buttonEEvent(EventTypeId("eb914aac-fb73-4ee2-9f1b-c34b2f6cc24a"));
|
||||
buttonEEvent.setName("E");
|
||||
buttonEEvent.setParameters(paramsRemote);
|
||||
buttonEvents.append(buttonEEvent);
|
||||
|
|
@ -149,7 +149,7 @@ QList<DeviceClass> DevicePluginElro::supportedDevices() const
|
|||
|
||||
// =======================================
|
||||
// Switch
|
||||
DeviceClass deviceClassElroSwitch(pluginId(), elroSwitchId);
|
||||
DeviceClass deviceClassElroSwitch(pluginId(), elroVendorId, elroSwitchId);
|
||||
deviceClassElroSwitch.setName("Elro Power Switch");
|
||||
|
||||
QVariantList deviceParamsSwitch;
|
||||
|
|
@ -196,7 +196,7 @@ QList<DeviceClass> DevicePluginElro::supportedDevices() const
|
|||
|
||||
QList<ActionType> switchActions;
|
||||
|
||||
ActionType powerAction(QUuid("31c9758e-6567-4f89-85bb-29e1a7c55d44"));
|
||||
ActionType powerAction(ActionTypeId("31c9758e-6567-4f89-85bb-29e1a7c55d44"));
|
||||
powerAction.setName("power");
|
||||
powerAction.setParameters(actionParamsSwitch);
|
||||
switchActions.append(powerAction);
|
||||
|
|
|
|||
|
|
@ -158,15 +158,15 @@
|
|||
#include "devicepluginintertechno.h"
|
||||
|
||||
#include "plugin/device.h"
|
||||
#include "plugin/devicemanager.h"
|
||||
#include "devicemanager.h"
|
||||
#include "hardware/radio433.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
|
||||
QUuid intertechnoVendorId = QUuid("6a852bc2-34dd-4f4c-9ac9-dd4c32ddbcba");
|
||||
QUuid intertechnoRemote = QUuid("ab73ad2f-6594-45a3-9063-8f72d365c5e5");
|
||||
QUuid intertechnoSwitch = QUuid("324219e8-7c53-41b5-b314-c2900cd15252");
|
||||
VendorId intertechnoVendorId = VendorId("6a852bc2-34dd-4f4c-9ac9-dd4c32ddbcba");
|
||||
DeviceClassId intertechnoRemote = DeviceClassId("ab73ad2f-6594-45a3-9063-8f72d365c5e5");
|
||||
DeviceClassId intertechnoSwitch = DeviceClassId("324219e8-7c53-41b5-b314-c2900cd15252");
|
||||
|
||||
DevicePluginIntertechno::DevicePluginIntertechno()
|
||||
{
|
||||
|
|
@ -185,7 +185,7 @@ QList<DeviceClass> DevicePluginIntertechno::supportedDevices() const
|
|||
|
||||
// =======================================
|
||||
// Remote
|
||||
DeviceClass deviceClassIntertechnoRemote(pluginId(), intertechnoRemote);
|
||||
DeviceClass deviceClassIntertechnoRemote(pluginId(), intertechnoVendorId, intertechnoRemote);
|
||||
deviceClassIntertechnoRemote.setName("Intertechno Remote");
|
||||
|
||||
QVariantList remoteParams;
|
||||
|
|
@ -219,82 +219,82 @@ QList<DeviceClass> DevicePluginIntertechno::supportedDevices() const
|
|||
* |___|___|___|____|
|
||||
*/
|
||||
|
||||
EventType button1Event("785c1b30-a3f2-4696-af7c-d532acf3d6f7");
|
||||
EventType button1Event(EventTypeId("785c1b30-a3f2-4696-af7c-d532acf3d6f7"));
|
||||
button1Event.setName("1");
|
||||
button1Event.setParameters(paramsRemote);
|
||||
buttonEvents.append(button1Event);
|
||||
|
||||
EventType button2Event("1d42c850-7b43-452f-b205-e1aac14eb3ee");
|
||||
EventType button2Event(EventTypeId("1d42c850-7b43-452f-b205-e1aac14eb3ee"));
|
||||
button2Event.setName("2");
|
||||
button2Event.setParameters(paramsRemote);
|
||||
buttonEvents.append(button2Event);
|
||||
|
||||
EventType button3Event("77a4780e-2355-4a77-870d-2f675bf986ce");
|
||||
EventType button3Event(EventTypeId("77a4780e-2355-4a77-870d-2f675bf986ce"));
|
||||
button3Event.setName("3");
|
||||
button3Event.setParameters(paramsRemote);
|
||||
buttonEvents.append(button3Event);
|
||||
|
||||
EventType button4Event("bd6a8b4b-f946-4f3b-992f-e7cff10187b8");
|
||||
EventType button4Event(EventTypeId("bd6a8b4b-f946-4f3b-992f-e7cff10187b8"));
|
||||
button4Event.setName("4");
|
||||
button4Event.setParameters(paramsRemote);
|
||||
buttonEvents.append(button4Event);
|
||||
|
||||
EventType button5Event("0f20782e-0acc-45f1-8c42-5dc5f5b29f1b");
|
||||
EventType button5Event(EventTypeId("0f20782e-0acc-45f1-8c42-5dc5f5b29f1b"));
|
||||
button5Event.setName("5");
|
||||
button5Event.setParameters(paramsRemote);
|
||||
buttonEvents.append(button5Event);
|
||||
|
||||
EventType button6Event("f7cb439a-0528-4905-9583-06b6bfeb3ba1");
|
||||
EventType button6Event(EventTypeId("f7cb439a-0528-4905-9583-06b6bfeb3ba1"));
|
||||
button6Event.setName("6");
|
||||
button6Event.setParameters(paramsRemote);
|
||||
buttonEvents.append(button6Event);
|
||||
|
||||
EventType button7Event("a0b0d8d8-2b43-4897-98e0-05b6b408a950");
|
||||
EventType button7Event(EventTypeId("a0b0d8d8-2b43-4897-98e0-05b6b408a950"));
|
||||
button7Event.setName("7");
|
||||
button7Event.setParameters(paramsRemote);
|
||||
buttonEvents.append(button7Event);
|
||||
|
||||
EventType button8Event("ae5833a2-bc43-4462-ae47-e45dac1fb0ce");
|
||||
EventType button8Event(EventTypeId("ae5833a2-bc43-4462-ae47-e45dac1fb0ce"));
|
||||
button8Event.setName("8");
|
||||
button8Event.setParameters(paramsRemote);
|
||||
buttonEvents.append(button8Event);
|
||||
|
||||
EventType button9Event("52c13828-d047-4256-b488-0bf84abbc87c");
|
||||
EventType button9Event(EventTypeId("52c13828-d047-4256-b488-0bf84abbc87c"));
|
||||
button9Event.setName("9");
|
||||
button9Event.setParameters(paramsRemote);
|
||||
buttonEvents.append(button9Event);
|
||||
|
||||
EventType button10Event("22c5afbc-835e-47cc-8211-4429eb9d9fee");
|
||||
EventType button10Event(EventTypeId("22c5afbc-835e-47cc-8211-4429eb9d9fee"));
|
||||
button10Event.setName("10");
|
||||
button10Event.setParameters(paramsRemote);
|
||||
buttonEvents.append(button10Event);
|
||||
|
||||
EventType button11Event("6bec5cbc-8bfb-4c6c-8ac8-f8e7723fd5aa");
|
||||
EventType button11Event(EventTypeId("6bec5cbc-8bfb-4c6c-8ac8-f8e7723fd5aa"));
|
||||
button11Event.setName("11");
|
||||
button11Event.setParameters(paramsRemote);
|
||||
buttonEvents.append(button11Event);
|
||||
|
||||
EventType button12Event("8b71edd2-8135-4c8b-bf44-380efadf1942");
|
||||
EventType button12Event(EventTypeId("8b71edd2-8135-4c8b-bf44-380efadf1942"));
|
||||
button12Event.setName("12");
|
||||
button12Event.setParameters(paramsRemote);
|
||||
buttonEvents.append(button12Event);
|
||||
|
||||
EventType button13Event("192f36a4-1e58-41aa-9618-83d46e329a4b");
|
||||
EventType button13Event(EventTypeId("192f36a4-1e58-41aa-9618-83d46e329a4b"));
|
||||
button13Event.setName("13");
|
||||
button13Event.setParameters(paramsRemote);
|
||||
buttonEvents.append(button13Event);
|
||||
|
||||
EventType button14Event("6c76de60-5e19-4a29-b027-e71e66caa2d6");
|
||||
EventType button14Event(EventTypeId("6c76de60-5e19-4a29-b027-e71e66caa2d6"));
|
||||
button14Event.setName("14");
|
||||
button14Event.setParameters(paramsRemote);
|
||||
buttonEvents.append(button14Event);
|
||||
|
||||
EventType button15Event("c2f56c10-1f81-4477-88fa-fc0f4a6383df");
|
||||
EventType button15Event(EventTypeId("c2f56c10-1f81-4477-88fa-fc0f4a6383df"));
|
||||
button15Event.setName("15");
|
||||
button15Event.setParameters(paramsRemote);
|
||||
buttonEvents.append(button15Event);
|
||||
|
||||
EventType button16Event("5d2eb3f8-4cd4-4c71-9c0c-e0b685e168e4");
|
||||
EventType button16Event(EventTypeId("5d2eb3f8-4cd4-4c71-9c0c-e0b685e168e4"));
|
||||
button16Event.setName("16");
|
||||
button16Event.setParameters(paramsRemote);
|
||||
buttonEvents.append(button16Event);
|
||||
|
|
@ -305,7 +305,7 @@ QList<DeviceClass> DevicePluginIntertechno::supportedDevices() const
|
|||
|
||||
// =======================================
|
||||
// Switch
|
||||
DeviceClass deviceClassIntertechnoSwitch(pluginId(), intertechnoSwitch);
|
||||
DeviceClass deviceClassIntertechnoSwitch(pluginId(), intertechnoVendorId, intertechnoSwitch);
|
||||
deviceClassIntertechnoSwitch.setName("Intertechno Switch");
|
||||
|
||||
QVariantList switchDeviceParams;
|
||||
|
|
@ -330,7 +330,7 @@ QList<DeviceClass> DevicePluginIntertechno::supportedDevices() const
|
|||
paramSwitch.insert("type", "bool");
|
||||
paramsSwitch.append(paramSwitch);
|
||||
|
||||
ActionType switchActionPower(QUuid("df19fb51-c3cd-4b95-8d88-ebbb535f4789"));
|
||||
ActionType switchActionPower(ActionTypeId("df19fb51-c3cd-4b95-8d88-ebbb535f4789"));
|
||||
switchActionPower.setName("power");
|
||||
switchActionPower.setParameters(paramsSwitch);
|
||||
switchActions.append(switchActionPower);
|
||||
|
|
|
|||
|
|
@ -43,14 +43,14 @@
|
|||
#include "devicepluginmeisteranker.h"
|
||||
|
||||
#include "plugin/device.h"
|
||||
#include "plugin/devicemanager.h"
|
||||
#include "devicemanager.h"
|
||||
#include "hardware/radio433.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
|
||||
QUuid meisterAnkerVendorId = QUuid("c181e749-5f72-4e25-a0af-094633abd7d5");
|
||||
QUuid thermometer = QUuid("e37e9f34-95b9-4a22-ae4f-e8b874eec871");
|
||||
VendorId meisterAnkerVendorId = VendorId("c181e749-5f72-4e25-a0af-094633abd7d5");
|
||||
DeviceClassId thermometer = DeviceClassId("e37e9f34-95b9-4a22-ae4f-e8b874eec871");
|
||||
|
||||
DevicePluginMeisterAnker::DevicePluginMeisterAnker()
|
||||
{
|
||||
|
|
@ -61,6 +61,7 @@ QList<Vendor> DevicePluginMeisterAnker::supportedVendors() const
|
|||
QList<Vendor> ret;
|
||||
Vendor meisterAnker(meisterAnkerVendorId, "Meister Anker");
|
||||
ret.append(meisterAnker);
|
||||
return ret;
|
||||
}
|
||||
|
||||
QList<DeviceClass> DevicePluginMeisterAnker::supportedDevices() const
|
||||
|
|
@ -68,7 +69,7 @@ QList<DeviceClass> DevicePluginMeisterAnker::supportedDevices() const
|
|||
QList<DeviceClass> ret;
|
||||
|
||||
// Thermometer
|
||||
DeviceClass deviceClassMeisterAnkerThermometer(pluginId(), thermometer);
|
||||
DeviceClass deviceClassMeisterAnkerThermometer(pluginId(), meisterAnkerVendorId, thermometer);
|
||||
deviceClassMeisterAnkerThermometer.setName("Meister Anker Thermometer");
|
||||
|
||||
QVariantList thermometerParams;
|
||||
|
|
@ -84,12 +85,12 @@ QList<DeviceClass> DevicePluginMeisterAnker::supportedDevices() const
|
|||
|
||||
QList<StateType> thermometerStates;
|
||||
|
||||
StateType tempState("a9849491-25f4-43a3-a6fe-3bfce43d6332");
|
||||
StateType tempState(StateTypeId("a9849491-25f4-43a3-a6fe-3bfce43d6332"));
|
||||
tempState.setName("Temperature");
|
||||
tempState.setType(QVariant::Double);
|
||||
thermometerStates.append(tempState);
|
||||
|
||||
StateType batteryState("ebf951ba-75ca-47ac-ba3c-ea9ec1e7bbd1");
|
||||
StateType batteryState(StateTypeId("ebf951ba-75ca-47ac-ba3c-ea9ec1e7bbd1"));
|
||||
batteryState.setName("Battery");
|
||||
batteryState.setType(QVariant::Bool);
|
||||
thermometerStates.append(batteryState);
|
||||
|
|
@ -104,7 +105,7 @@ QList<DeviceClass> DevicePluginMeisterAnker::supportedDevices() const
|
|||
paramThermometer.insert("type", "double");
|
||||
paramsThermometer.append(paramThermometer);
|
||||
|
||||
EventType temperatureEvent(QUuid("174ab4d5-2ef0-491b-a55b-c895cedff80e"));
|
||||
EventType temperatureEvent(EventTypeId("174ab4d5-2ef0-491b-a55b-c895cedff80e"));
|
||||
temperatureEvent.setName("temperature");
|
||||
temperatureEvent.setParameters(paramsThermometer);
|
||||
thermometerEvents.append(temperatureEvent);
|
||||
|
|
@ -115,7 +116,7 @@ QList<DeviceClass> DevicePluginMeisterAnker::supportedDevices() const
|
|||
paramThermometerBat.insert("type", "bool");
|
||||
paramsThermometerBat.append(paramThermometerBat);
|
||||
|
||||
EventType batteryStatusEvent(QUuid("c376b532-993f-41c7-acc7-02b409136d32"));
|
||||
EventType batteryStatusEvent(EventTypeId("c376b532-993f-41c7-acc7-02b409136d32"));
|
||||
batteryStatusEvent.setName("batteryStatus");
|
||||
batteryStatusEvent.setParameters(paramsThermometerBat);
|
||||
thermometerEvents.append(batteryStatusEvent);
|
||||
|
|
|
|||
|
|
@ -20,18 +20,19 @@
|
|||
#include "httpdaemon.h"
|
||||
|
||||
#include "plugin/device.h"
|
||||
#include "plugin/devicemanager.h"
|
||||
#include "devicemanager.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
|
||||
QUuid guhVendorId = QUuid("2062d64d-3232-433c-88bc-0d33c0ba2ba6");
|
||||
QUuid mockEvent1Id = QUuid("45bf3752-0fc6-46b9-89fd-ffd878b5b22b");
|
||||
QUuid mockEvent2Id = QUuid("863d5920-b1cf-4eb9-88bd-8f7b8583b1cf");
|
||||
QUuid mockIntStateId = QUuid("80baec19-54de-4948-ac46-31eabfaceb83");
|
||||
QUuid mockBoolStateId = QUuid("9dd6a97c-dfd1-43dc-acbd-367932742310");
|
||||
QUuid mockAction1Id = QUuid("dea0f4e1-65e3-4981-8eaa-2701c53a9185");
|
||||
QUuid mockAction2Id = QUuid("defd3ed6-1a0d-400b-8879-a0202cf39935");
|
||||
VendorId guhVendorId = VendorId("2062d64d-3232-433c-88bc-0d33c0ba2ba6");
|
||||
DeviceClassId mockDeviceId = DeviceClassId("753f0d32-0468-4d08-82ed-1964aab03298");
|
||||
EventTypeId mockEvent1Id = EventTypeId("45bf3752-0fc6-46b9-89fd-ffd878b5b22b");
|
||||
EventTypeId mockEvent2Id = EventTypeId("863d5920-b1cf-4eb9-88bd-8f7b8583b1cf");
|
||||
StateTypeId mockIntStateId = StateTypeId("80baec19-54de-4948-ac46-31eabfaceb83");
|
||||
StateTypeId mockBoolStateId = StateTypeId("9dd6a97c-dfd1-43dc-acbd-367932742310");
|
||||
ActionTypeId mockAction1Id = ActionTypeId("dea0f4e1-65e3-4981-8eaa-2701c53a9185");
|
||||
ActionTypeId mockAction2Id = ActionTypeId("defd3ed6-1a0d-400b-8879-a0202cf39935");
|
||||
|
||||
DevicePluginMock::DevicePluginMock()
|
||||
{
|
||||
|
|
@ -49,7 +50,7 @@ QList<DeviceClass> DevicePluginMock::supportedDevices() const
|
|||
{
|
||||
QList<DeviceClass> ret;
|
||||
|
||||
DeviceClass deviceClassMock(pluginId(), QUuid("753f0d32-0468-4d08-82ed-1964aab03298"));
|
||||
DeviceClass deviceClassMock(pluginId(), guhVendorId, mockDeviceId);
|
||||
deviceClassMock.setName("Mock Device");
|
||||
|
||||
QVariantList mockParams;
|
||||
|
|
@ -149,7 +150,7 @@ void DevicePluginMock::executeAction(Device *device, const Action &action)
|
|||
m_daemons.value(device)->actionExecuted(action.actionTypeId());
|
||||
}
|
||||
|
||||
void DevicePluginMock::setState(const QUuid &stateTypeId, const QVariant &value)
|
||||
void DevicePluginMock::setState(const StateTypeId &stateTypeId, const QVariant &value)
|
||||
{
|
||||
HttpDaemon *daemon = qobject_cast<HttpDaemon*>(sender());
|
||||
if (!daemon) {
|
||||
|
|
@ -160,7 +161,7 @@ void DevicePluginMock::setState(const QUuid &stateTypeId, const QVariant &value)
|
|||
device->setStateValue(stateTypeId, value);
|
||||
}
|
||||
|
||||
void DevicePluginMock::triggerEvent(const QUuid &id)
|
||||
void DevicePluginMock::triggerEvent(const EventTypeId &id)
|
||||
{
|
||||
HttpDaemon *daemon = qobject_cast<HttpDaemon*>(sender());
|
||||
if (!daemon) {
|
||||
|
|
|
|||
|
|
@ -49,8 +49,8 @@ public slots:
|
|||
void executeAction(Device *device, const Action &action) override;
|
||||
|
||||
private slots:
|
||||
void setState(const QUuid &stateTypeId, const QVariant &value);
|
||||
void triggerEvent(const QUuid &id);
|
||||
void setState(const StateTypeId &stateTypeId, const QVariant &value);
|
||||
void triggerEvent(const EventTypeId &id);
|
||||
|
||||
private:
|
||||
QHash<Device*, HttpDaemon*> m_daemons;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
#include "devicepluginweatherground.h"
|
||||
|
||||
#include "plugin/device.h"
|
||||
#include "plugin/devicemanager.h"
|
||||
#include "devicemanager.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
// Key: 779a480dea5163c6
|
||||
|
||||
QUuid weathergroundVendorId = QUuid("68f84197-b158-4d24-9d7b-709cfff843c1");
|
||||
VendorId weathergroundVendorId = VendorId("68f84197-b158-4d24-9d7b-709cfff843c1");
|
||||
|
||||
DevicePluginWeatherground::DevicePluginWeatherground()
|
||||
{
|
||||
|
|
@ -47,7 +47,7 @@ QList<DeviceClass> DevicePluginWeatherground::supportedDevices() const
|
|||
{
|
||||
QList<DeviceClass> ret;
|
||||
|
||||
DeviceClass deviceClassWeatherground(pluginId(), QUuid("af2e15f0-650e-4452-b379-fa76a2dc46c6"));
|
||||
DeviceClass deviceClassWeatherground(pluginId(), weathergroundVendorId, DeviceClassId("af2e15f0-650e-4452-b379-fa76a2dc46c6"));
|
||||
deviceClassWeatherground.setName("Weather");
|
||||
|
||||
QVariantList weatherParams;
|
||||
|
|
@ -63,67 +63,67 @@ QList<DeviceClass> DevicePluginWeatherground::supportedDevices() const
|
|||
|
||||
|
||||
QList<ActionType> weatherActions;
|
||||
ActionType updateWeather(QUuid("a1dc271a-a993-4d9b-adfc-4fbb58cbecb9"));
|
||||
ActionType updateWeather(ActionTypeId("a1dc271a-a993-4d9b-adfc-4fbb58cbecb9"));
|
||||
updateWeather.setName("refresh");
|
||||
weatherActions.append(updateWeather);
|
||||
|
||||
|
||||
QList<StateType> weatherStates;
|
||||
StateType updateTimeState(QUuid("09b091f5-d830-4739-b8f0-df96101cabc6"));
|
||||
StateType updateTimeState(StateTypeId("09b091f5-d830-4739-b8f0-df96101cabc6"));
|
||||
updateTimeState.setName("last update");
|
||||
updateTimeState.setType(QVariant::DateTime);
|
||||
updateTimeState.setDefaultValue(QDateTime(QDate(1999,1,1),QTime(0,0,0)));
|
||||
weatherStates.append(updateTimeState);
|
||||
|
||||
StateType temperatureState(QUuid("97ffaa0b-4302-43a5-9aa5-00a5efe321c0"));
|
||||
StateType temperatureState(StateTypeId("97ffaa0b-4302-43a5-9aa5-00a5efe321c0"));
|
||||
temperatureState.setName("temperature [°C]");
|
||||
temperatureState.setType(QVariant::Double);
|
||||
temperatureState.setDefaultValue(-999.9);
|
||||
weatherStates.append(temperatureState);
|
||||
|
||||
StateType humidityState(QUuid("2e925181-69b7-4201-9160-11ca4afecc41"));
|
||||
StateType humidityState(StateTypeId("2e925181-69b7-4201-9160-11ca4afecc41"));
|
||||
humidityState.setName("humidity [%]");
|
||||
humidityState.setType(QVariant::Int);
|
||||
humidityState.setDefaultValue(0);
|
||||
weatherStates.append(humidityState);
|
||||
|
||||
StateType sunsetState(QUuid("a8e6601e-c9de-43c8-9a0e-9688cb66ae6d"));
|
||||
StateType sunsetState(StateTypeId("a8e6601e-c9de-43c8-9a0e-9688cb66ae6d"));
|
||||
sunsetState.setName("sunset");
|
||||
sunsetState.setType(QVariant::Time);
|
||||
sunsetState.setDefaultValue(QTime(0,0,0));
|
||||
weatherStates.append(sunsetState);
|
||||
|
||||
StateType sunriseState(QUuid("8e81d15a-3231-415b-8fba-5f6a02259cc1"));
|
||||
StateType sunriseState(StateTypeId("8e81d15a-3231-415b-8fba-5f6a02259cc1"));
|
||||
sunriseState.setName("sunrise");
|
||||
sunriseState.setType(QVariant::Time);
|
||||
sunriseState.setDefaultValue(QTime(0,0,0));
|
||||
weatherStates.append(sunriseState);
|
||||
|
||||
StateType windSpeedState(QUuid("546880b9-c4c8-4dc1-b589-ac9c76240009"));
|
||||
StateType windSpeedState(StateTypeId("546880b9-c4c8-4dc1-b589-ac9c76240009"));
|
||||
windSpeedState.setName("wind speed [km/h]");
|
||||
windSpeedState.setType(QVariant::Double);
|
||||
windSpeedState.setDefaultValue(0);
|
||||
weatherStates.append(windSpeedState);
|
||||
|
||||
StateType windDirectionState(QUuid("e05e6015-4ed8-4fb1-a18e-1a09be272556"));
|
||||
StateType windDirectionState(StateTypeId("e05e6015-4ed8-4fb1-a18e-1a09be272556"));
|
||||
windDirectionState.setName("wind direction");
|
||||
windDirectionState.setType(QVariant::String);
|
||||
windDirectionState.setDefaultValue("-");
|
||||
weatherStates.append(windDirectionState);
|
||||
|
||||
StateType currentlyState(QUuid("6032cb3b-fe52-4006-aa8b-d5c1e6d500e3"));
|
||||
StateType currentlyState(StateTypeId("6032cb3b-fe52-4006-aa8b-d5c1e6d500e3"));
|
||||
currentlyState.setName("current weather");
|
||||
currentlyState.setType(QVariant::String);
|
||||
currentlyState.setDefaultValue("-");
|
||||
weatherStates.append(currentlyState);
|
||||
|
||||
StateType ageOfMoonState(QUuid("e49fe057-98ac-4a38-9aa3-8e8ff260c162"));
|
||||
StateType ageOfMoonState(StateTypeId("e49fe057-98ac-4a38-9aa3-8e8ff260c162"));
|
||||
ageOfMoonState.setName("age of moon [days]");
|
||||
ageOfMoonState.setType(QVariant::Int);
|
||||
ageOfMoonState.setDefaultValue(-1);
|
||||
weatherStates.append(ageOfMoonState);
|
||||
|
||||
StateType moonIlluminatedState(QUuid("d8688eb5-5d4f-4c85-9338-d86c7c2069a8"));
|
||||
StateType moonIlluminatedState(StateTypeId("d8688eb5-5d4f-4c85-9338-d86c7c2069a8"));
|
||||
moonIlluminatedState.setName("moon illuminated [%]");
|
||||
moonIlluminatedState.setType(QVariant::Int);
|
||||
moonIlluminatedState.setDefaultValue(-1);
|
||||
|
|
|
|||
|
|
@ -19,15 +19,15 @@
|
|||
#include "devicepluginwifidetector.h"
|
||||
|
||||
#include "plugin/device.h"
|
||||
#include "plugin/devicemanager.h"
|
||||
#include "devicemanager.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
|
||||
extern QUuid guhVendorId;
|
||||
extern VendorId guhVendorId;
|
||||
QUuid pluginUuid = QUuid("8e0f791e-b273-4267-8605-b7c2f55a68ab");
|
||||
QUuid detectorId = QUuid("bd216356-f1ec-4324-9785-6982d2174e17");
|
||||
QUuid inRangeStateTypeId = QUuid("cb43e1b5-4f61-4538-bfa2-c33055c542cf");
|
||||
DeviceClassId detectorId = DeviceClassId("bd216356-f1ec-4324-9785-6982d2174e17");
|
||||
StateTypeId inRangeStateTypeId = StateTypeId("cb43e1b5-4f61-4538-bfa2-c33055c542cf");
|
||||
|
||||
DevicePluginWifiDetector::DevicePluginWifiDetector()
|
||||
{
|
||||
|
|
@ -45,7 +45,7 @@ QList<DeviceClass> DevicePluginWifiDetector::supportedDevices() const
|
|||
{
|
||||
QList<DeviceClass> ret;
|
||||
|
||||
DeviceClass deviceClassWifiDetector(pluginId(), detectorId);
|
||||
DeviceClass deviceClassWifiDetector(pluginId(), guhVendorId, detectorId);
|
||||
deviceClassWifiDetector.setName("WiFi Device");
|
||||
|
||||
QVariantList detectorParams;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
#include "jsonrpcserver.h"
|
||||
#include "ruleengine.h"
|
||||
|
||||
#include "plugin/devicemanager.h"
|
||||
#include "devicemanager.h"
|
||||
#include "plugin/device.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
#include "actionhandler.h"
|
||||
|
||||
#include "guhcore.h"
|
||||
#include "plugin/devicemanager.h"
|
||||
#include "devicemanager.h"
|
||||
#include "types/action.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
|
@ -49,8 +49,8 @@ QString ActionHandler::name() const
|
|||
QVariantMap ActionHandler::ExecuteAction(const QVariantMap ¶ms)
|
||||
{
|
||||
|
||||
QUuid deviceId = params.value("deviceId").toUuid();
|
||||
QUuid actionTypeId = params.value("actionTypeId").toUuid();
|
||||
DeviceId deviceId(params.value("deviceId").toString());
|
||||
ActionTypeId actionTypeId(params.value("actionTypeId").toString());
|
||||
QVariantMap actionParams = params.value("params").toMap();
|
||||
|
||||
Action action(deviceId, actionTypeId);
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@
|
|||
|
||||
#include "devicehandler.h"
|
||||
#include "guhcore.h"
|
||||
#include "devicemanager.h"
|
||||
#include "plugin/device.h"
|
||||
#include "plugin/deviceclass.h"
|
||||
#include "plugin/devicemanager.h"
|
||||
#include "plugin/deviceplugin.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
|
@ -176,9 +176,9 @@ QVariantMap DeviceHandler::SetPluginParams(const QVariantMap ¶ms)
|
|||
|
||||
QVariantMap DeviceHandler::AddConfiguredDevice(const QVariantMap ¶ms)
|
||||
{
|
||||
QUuid deviceClass = params.value("deviceClassId").toUuid();
|
||||
DeviceClassId deviceClass(params.value("deviceClassId").toString());
|
||||
QVariantMap deviceParams = params.value("deviceParams").toMap();
|
||||
QUuid newDeviceId = QUuid::createUuid();
|
||||
DeviceId newDeviceId = DeviceId::createDeviceId();
|
||||
DeviceManager::DeviceError status = GuhCore::instance()->deviceManager()->addConfiguredDevice(deviceClass, deviceParams, newDeviceId);
|
||||
QVariantMap returns;
|
||||
switch(status) {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
#include "jsonhandler.h"
|
||||
|
||||
#include "guhcore.h"
|
||||
#include "plugin/devicemanager.h"
|
||||
#include "devicemanager.h"
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "plugin/deviceclass.h"
|
||||
#include "plugin/device.h"
|
||||
|
|
|
|||
|
|
@ -80,8 +80,8 @@ QVariantMap RulesHandler::AddRule(const QVariantMap ¶ms)
|
|||
{
|
||||
QVariantMap eventMap = params.value("event").toMap();
|
||||
|
||||
QUuid eventTypeId = eventMap.value("eventTypeId").toUuid();
|
||||
QUuid eventDeviceId = eventMap.value("deviceId").toUuid();
|
||||
EventTypeId eventTypeId(eventMap.value("eventTypeId").toString());
|
||||
DeviceId eventDeviceId(eventMap.value("deviceId").toString());
|
||||
QVariantMap eventParams = eventMap.value("params").toMap();
|
||||
Event event(eventTypeId, eventDeviceId, eventParams);
|
||||
|
||||
|
|
@ -90,7 +90,7 @@ QVariantMap RulesHandler::AddRule(const QVariantMap ¶ms)
|
|||
qDebug() << "got action list" << actionList.count();
|
||||
foreach (const QVariant &actionVariant, actionList) {
|
||||
QVariantMap actionMap = actionVariant.toMap();
|
||||
Action action(actionMap.value("deviceId").toUuid(), actionMap.value("actionTypeId").toUuid());
|
||||
Action action(DeviceId(actionMap.value("deviceId").toString()), ActionTypeId(actionMap.value("actionTypeId").toString()));
|
||||
action.setParams(actionMap.value("params").toMap());
|
||||
actions.append(action);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@
|
|||
|
||||
#include "guhcore.h"
|
||||
|
||||
#include "plugin/devicemanager.h"
|
||||
#include "devicemanager.h"
|
||||
#include "plugin/device.h"
|
||||
|
||||
#include <QSettings>
|
||||
|
|
@ -78,14 +78,16 @@ RuleEngine::RuleEngine(QObject *parent) :
|
|||
settings.beginGroup(idString);
|
||||
|
||||
settings.beginGroup("event");
|
||||
Event event(settings.value("eventTypeId").toUuid(), settings.value("deviceId").toUuid(), settings.value("params").toMap());
|
||||
EventTypeId eventTypeId(settings.value("eventTypeId").toString());
|
||||
DeviceId deviceId(settings.value("deviceId").toString());
|
||||
Event event(eventTypeId, deviceId, settings.value("params").toMap());
|
||||
settings.endGroup();
|
||||
|
||||
settings.beginGroup("states");
|
||||
QList<State> states;
|
||||
foreach (const QString &stateTypeIdString, settings.childGroups()) {
|
||||
settings.beginGroup(stateTypeIdString);
|
||||
State state(stateTypeIdString, settings.value("deviceId").toUuid());
|
||||
State state(StateTypeId(stateTypeIdString), DeviceId(settings.value("deviceId").toString()));
|
||||
state.setValue(settings.value("value"));
|
||||
settings.endGroup();
|
||||
states.append(state);
|
||||
|
|
@ -96,7 +98,7 @@ RuleEngine::RuleEngine(QObject *parent) :
|
|||
QList<Action> actions;
|
||||
foreach (const QString &actionIdString, settings.childGroups()) {
|
||||
settings.beginGroup(actionIdString);
|
||||
Action action = Action(settings.value("deviceId").toUuid(), settings.value("actionTypeId").toUuid());
|
||||
Action action = Action(DeviceId(settings.value("deviceId").toString()), ActionTypeId(settings.value("actionTypeId").toString()));
|
||||
action.setParams(settings.value("params").toMap());
|
||||
settings.endGroup();
|
||||
actions.append(action);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
***************************************************************************/
|
||||
|
||||
#include "guhcore.h"
|
||||
#include "plugin/devicemanager.h"
|
||||
#include "devicemanager.h"
|
||||
#include "mocktcpserver.h"
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
|
|
|
|||
Loading…
Reference in New Issue