restructure lib a bit. added initial code for the new rules stuff
This commit is contained in:
parent
cf9d460bad
commit
4f679b3bc3
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <gpio.h>
|
#include <hardware/gpio.h>
|
||||||
|
|
||||||
#define RC_MAX_CHANGES 67
|
#define RC_MAX_CHANGES 67
|
||||||
|
|
||||||
@ -6,29 +6,31 @@ CONFIG += c++11
|
|||||||
target.path = /usr/lib
|
target.path = /usr/lib
|
||||||
INSTALLS += target
|
INSTALLS += target
|
||||||
|
|
||||||
SOURCES += device.cpp \
|
SOURCES += plugin/device.cpp \
|
||||||
deviceclass.cpp \
|
plugin/deviceclass.cpp \
|
||||||
devicemanager.cpp \
|
plugin/devicemanager.cpp \
|
||||||
deviceplugin.cpp \
|
plugin/deviceplugin.cpp \
|
||||||
radio433.cpp \
|
hardware/radio433.cpp \
|
||||||
gpio.cpp \
|
hardware/gpio.cpp \
|
||||||
action.cpp \
|
types/action.cpp \
|
||||||
actiontype.cpp \
|
types/actiontype.cpp \
|
||||||
state.cpp \
|
types/state.cpp \
|
||||||
statetype.cpp \
|
types/statetype.cpp \
|
||||||
eventtype.cpp \
|
types/eventtype.cpp \
|
||||||
event.cpp
|
types/event.cpp \
|
||||||
|
types/vendor.cpp
|
||||||
|
|
||||||
HEADERS += device.h \
|
HEADERS += plugin/device.h \
|
||||||
deviceclass.h \
|
plugin/deviceclass.h \
|
||||||
devicemanager.h \
|
plugin/devicemanager.h \
|
||||||
deviceplugin.h \
|
plugin/deviceplugin.h \
|
||||||
radio433.h \
|
hardware/radio433.h \
|
||||||
gpio.h \
|
hardware/gpio.h \
|
||||||
action.h \
|
types/action.h \
|
||||||
actiontype.h \
|
types/actiontype.h \
|
||||||
state.h \
|
types/state.h \
|
||||||
statetype.h \
|
types/statetype.h \
|
||||||
eventtype.h \
|
types/eventtype.h \
|
||||||
event.h
|
types/event.h \
|
||||||
|
types/vendor.h
|
||||||
|
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
#ifndef DEVICE_H
|
#ifndef DEVICE_H
|
||||||
#define DEVICE_H
|
#define DEVICE_H
|
||||||
|
|
||||||
#include "state.h"
|
#include "types/state.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
@ -19,9 +19,9 @@
|
|||||||
#ifndef DEVICECLASS_H
|
#ifndef DEVICECLASS_H
|
||||||
#define DEVICECLASS_H
|
#define DEVICECLASS_H
|
||||||
|
|
||||||
#include "eventtype.h"
|
#include "types/eventtype.h"
|
||||||
#include "actiontype.h"
|
#include "types/actiontype.h"
|
||||||
#include "statetype.h"
|
#include "types/statetype.h"
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
@ -75,7 +75,7 @@
|
|||||||
|
|
||||||
#include "devicemanager.h"
|
#include "devicemanager.h"
|
||||||
|
|
||||||
#include "radio433.h"
|
#include "hardware/radio433.h"
|
||||||
|
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
#include "deviceclass.h"
|
#include "deviceclass.h"
|
||||||
@ -116,6 +116,11 @@ DevicePlugin *DeviceManager::plugin(const QUuid &id) const
|
|||||||
return m_devicePlugins.value(id);
|
return m_devicePlugins.value(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<Vendor> DeviceManager::supportedVendors() const
|
||||||
|
{
|
||||||
|
return m_supportedVendors.values();
|
||||||
|
}
|
||||||
|
|
||||||
/*! Returns all the supported \l{DeviceClass}{DeviceClasses} by all \l{DevicePlugin}{DevicePlugins} loaded in the system. */
|
/*! Returns all the supported \l{DeviceClass}{DeviceClasses} by all \l{DevicePlugin}{DevicePlugins} loaded in the system. */
|
||||||
QList<DeviceClass> DeviceManager::supportedDevices() const
|
QList<DeviceClass> DeviceManager::supportedDevices() const
|
||||||
{
|
{
|
||||||
@ -20,8 +20,10 @@
|
|||||||
#define DEVICEMANAGER_H
|
#define DEVICEMANAGER_H
|
||||||
|
|
||||||
#include "deviceclass.h"
|
#include "deviceclass.h"
|
||||||
#include "event.h"
|
|
||||||
#include "action.h"
|
#include "types/event.h"
|
||||||
|
#include "types/action.h"
|
||||||
|
#include "types/vendor.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
@ -57,6 +59,7 @@ public:
|
|||||||
|
|
||||||
QList<DevicePlugin*> plugins() const;
|
QList<DevicePlugin*> plugins() const;
|
||||||
DevicePlugin* plugin(const QUuid &id) const;
|
DevicePlugin* plugin(const QUuid &id) const;
|
||||||
|
QList<Vendor> supportedVendors() const;
|
||||||
QList<DeviceClass> supportedDevices() const;
|
QList<DeviceClass> supportedDevices() const;
|
||||||
|
|
||||||
QList<Device*> configuredDevices() const;
|
QList<Device*> configuredDevices() const;
|
||||||
@ -90,6 +93,7 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
bool setupDevice(Device *device);
|
bool setupDevice(Device *device);
|
||||||
|
|
||||||
|
QHash<QUuid, Vendor> m_supportedVendors;
|
||||||
QHash<QUuid, DeviceClass> m_supportedDevices;
|
QHash<QUuid, DeviceClass> m_supportedDevices;
|
||||||
QList<Device*> m_configuredDevices;
|
QList<Device*> m_configuredDevices;
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ pure virtual methods: \l{DevicePlugin::pluginName()}, \l{DevicePlugin::pluginId(
|
|||||||
#include "deviceplugin.h"
|
#include "deviceplugin.h"
|
||||||
|
|
||||||
#include "devicemanager.h"
|
#include "devicemanager.h"
|
||||||
#include "radio433.h"
|
#include "hardware/radio433.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
@ -21,8 +21,10 @@
|
|||||||
|
|
||||||
#include "devicemanager.h"
|
#include "devicemanager.h"
|
||||||
#include "deviceclass.h"
|
#include "deviceclass.h"
|
||||||
#include "event.h"
|
|
||||||
#include "action.h"
|
#include "types/event.h"
|
||||||
|
#include "types/action.h"
|
||||||
|
#include "types/vendor.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
@ -41,6 +43,7 @@ public:
|
|||||||
virtual QString pluginName() const = 0;
|
virtual QString pluginName() const = 0;
|
||||||
virtual QUuid pluginId() const = 0;
|
virtual QUuid pluginId() const = 0;
|
||||||
|
|
||||||
|
virtual QList<Vendor> supportedVendors() const = 0;
|
||||||
virtual QList<DeviceClass> supportedDevices() const = 0;
|
virtual QList<DeviceClass> supportedDevices() const = 0;
|
||||||
virtual DeviceManager::HardwareResources requiredHardware() const = 0;
|
virtual DeviceManager::HardwareResources requiredHardware() const = 0;
|
||||||
|
|
||||||
27
libguh/types/vendor.cpp
Normal file
27
libguh/types/vendor.cpp
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#include "vendor.h"
|
||||||
|
|
||||||
|
Vendor::Vendor(const QUuid &id, const QString &name):
|
||||||
|
m_id(id),
|
||||||
|
m_name(name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QUuid Vendor::id() const
|
||||||
|
{
|
||||||
|
return m_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Vendor::setId(const QUuid &id)
|
||||||
|
{
|
||||||
|
m_id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Vendor::name() const
|
||||||
|
{
|
||||||
|
return m_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Vendor::setName(const QString &name)
|
||||||
|
{
|
||||||
|
m_name = name;
|
||||||
|
}
|
||||||
23
libguh/types/vendor.h
Normal file
23
libguh/types/vendor.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#ifndef VENDOR_H
|
||||||
|
#define VENDOR_H
|
||||||
|
|
||||||
|
#include <QUuid>
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
class Vendor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Vendor(const QUuid &id, const QString &name = QString());
|
||||||
|
|
||||||
|
QUuid id() const;
|
||||||
|
void setId(const QUuid &id);
|
||||||
|
|
||||||
|
QString name() const;
|
||||||
|
void setName(const QString &name);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QUuid m_id;
|
||||||
|
QString m_name;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VENDOR_H
|
||||||
@ -52,21 +52,29 @@
|
|||||||
|
|
||||||
#include "devicepluginconrad.h"
|
#include "devicepluginconrad.h"
|
||||||
|
|
||||||
#include "device.h"
|
#include "plugin/device.h"
|
||||||
#include "devicemanager.h"
|
#include "plugin/devicemanager.h"
|
||||||
#include "radio433.h"
|
#include "hardware/radio433.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
|
|
||||||
|
QUuid conradVendorId = QUuid("986cf06f-3ef1-4271-b2a3-2cc277ebecb6");
|
||||||
QUuid conradRemoteId = QUuid("17cd2492-28ab-4827-ba6e-5ef35be23f1b");
|
QUuid conradRemoteId = QUuid("17cd2492-28ab-4827-ba6e-5ef35be23f1b");
|
||||||
|
|
||||||
|
|
||||||
DevicePluginConrad::DevicePluginConrad()
|
DevicePluginConrad::DevicePluginConrad()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<Vendor> DevicePluginConrad::supportedVendors() const
|
||||||
|
{
|
||||||
|
QList<Vendor> ret;
|
||||||
|
Vendor conrad(conradVendorId, "Conrad Electronic SE");
|
||||||
|
ret.append(conrad);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
QList<DeviceClass> DevicePluginConrad::supportedDevices() const
|
QList<DeviceClass> DevicePluginConrad::supportedDevices() const
|
||||||
{
|
{
|
||||||
// TODO: load list from config with static uuid
|
// TODO: load list from config with static uuid
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
#ifndef DEVICEPLUGINCONRAD_H
|
#ifndef DEVICEPLUGINCONRAD_H
|
||||||
#define DEVICEPLUGINCONRAD_H
|
#define DEVICEPLUGINCONRAD_H
|
||||||
|
|
||||||
#include "deviceplugin.h"
|
#include "plugin/deviceplugin.h"
|
||||||
|
|
||||||
class DevicePluginConrad : public DevicePlugin
|
class DevicePluginConrad : public DevicePlugin
|
||||||
{
|
{
|
||||||
@ -31,6 +31,7 @@ class DevicePluginConrad : public DevicePlugin
|
|||||||
public:
|
public:
|
||||||
explicit DevicePluginConrad();
|
explicit DevicePluginConrad();
|
||||||
|
|
||||||
|
QList<Vendor> supportedVendors() const override;
|
||||||
QList<DeviceClass> supportedDevices() const override;
|
QList<DeviceClass> supportedDevices() const override;
|
||||||
DeviceManager::HardwareResources requiredHardware() const override;
|
DeviceManager::HardwareResources requiredHardware() const override;
|
||||||
|
|
||||||
|
|||||||
@ -52,13 +52,16 @@
|
|||||||
|
|
||||||
#include "devicepluginelro.h"
|
#include "devicepluginelro.h"
|
||||||
|
|
||||||
#include "device.h"
|
#include "plugin/device.h"
|
||||||
#include "devicemanager.h"
|
#include "plugin/devicemanager.h"
|
||||||
#include "radio433.h"
|
#include "hardware/radio433.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
|
QUuid elroVendorId = QUuid("435a13a0-65ca-4f0c-94c1-e5873b258db5");
|
||||||
|
QUuid mumbiVendorId = QUuid("5f91c01c-0168-4bdf-a5ed-37cb6971b775");
|
||||||
|
|
||||||
QUuid elroRemoteId = QUuid("d85c1ef4-197c-4053-8e40-707aa671d302");
|
QUuid elroRemoteId = QUuid("d85c1ef4-197c-4053-8e40-707aa671d302");
|
||||||
QUuid elroSwitchId = QUuid("308ae6e6-38b3-4b3a-a513-3199da2764f8");
|
QUuid elroSwitchId = QUuid("308ae6e6-38b3-4b3a-a513-3199da2764f8");
|
||||||
|
|
||||||
@ -66,6 +69,18 @@ DevicePluginElro::DevicePluginElro()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<Vendor> DevicePluginElro::supportedVendors() const
|
||||||
|
{
|
||||||
|
QList<Vendor> ret;
|
||||||
|
Vendor elro(elroVendorId, "Electronic Roos");
|
||||||
|
ret.append(elro);
|
||||||
|
|
||||||
|
Vendor mumbi(mumbiVendorId, "Mumbi");
|
||||||
|
ret.append(mumbi);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
QList<DeviceClass> DevicePluginElro::supportedDevices() const
|
QList<DeviceClass> DevicePluginElro::supportedDevices() const
|
||||||
{
|
{
|
||||||
// TODO: load list from config with static uuid
|
// TODO: load list from config with static uuid
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
#ifndef DEVICEPLUGINELRO_H
|
#ifndef DEVICEPLUGINELRO_H
|
||||||
#define DEVICEPLUGINELRO_H
|
#define DEVICEPLUGINELRO_H
|
||||||
|
|
||||||
#include "deviceplugin.h"
|
#include "plugin/deviceplugin.h"
|
||||||
|
|
||||||
class DevicePluginElro : public DevicePlugin
|
class DevicePluginElro : public DevicePlugin
|
||||||
{
|
{
|
||||||
@ -31,6 +31,7 @@ class DevicePluginElro : public DevicePlugin
|
|||||||
public:
|
public:
|
||||||
explicit DevicePluginElro();
|
explicit DevicePluginElro();
|
||||||
|
|
||||||
|
QList<Vendor> supportedVendors() const override;
|
||||||
QList<DeviceClass> supportedDevices() const override;
|
QList<DeviceClass> supportedDevices() const override;
|
||||||
DeviceManager::HardwareResources requiredHardware() const override;
|
DeviceManager::HardwareResources requiredHardware() const override;
|
||||||
|
|
||||||
|
|||||||
@ -157,13 +157,14 @@
|
|||||||
|
|
||||||
#include "devicepluginintertechno.h"
|
#include "devicepluginintertechno.h"
|
||||||
|
|
||||||
#include "device.h"
|
#include "plugin/device.h"
|
||||||
#include "devicemanager.h"
|
#include "plugin/devicemanager.h"
|
||||||
#include "radio433.h"
|
#include "hardware/radio433.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
|
QUuid intertechnoVendorId = QUuid("6a852bc2-34dd-4f4c-9ac9-dd4c32ddbcba");
|
||||||
QUuid intertechnoRemote = QUuid("ab73ad2f-6594-45a3-9063-8f72d365c5e5");
|
QUuid intertechnoRemote = QUuid("ab73ad2f-6594-45a3-9063-8f72d365c5e5");
|
||||||
QUuid intertechnoSwitch = QUuid("324219e8-7c53-41b5-b314-c2900cd15252");
|
QUuid intertechnoSwitch = QUuid("324219e8-7c53-41b5-b314-c2900cd15252");
|
||||||
|
|
||||||
@ -171,6 +172,13 @@ DevicePluginIntertechno::DevicePluginIntertechno()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<Vendor> DevicePluginIntertechno::supportedVendors() const
|
||||||
|
{
|
||||||
|
QList<Vendor> ret;
|
||||||
|
Vendor intertechno(intertechnoVendorId, "Intertechno");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
QList<DeviceClass> DevicePluginIntertechno::supportedDevices() const
|
QList<DeviceClass> DevicePluginIntertechno::supportedDevices() const
|
||||||
{
|
{
|
||||||
QList<DeviceClass> ret;
|
QList<DeviceClass> ret;
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
#ifndef DEVICEPLUGININTERTECHNO_H
|
#ifndef DEVICEPLUGININTERTECHNO_H
|
||||||
#define DEVICEPLUGININTERTECHNO_H
|
#define DEVICEPLUGININTERTECHNO_H
|
||||||
|
|
||||||
#include "deviceplugin.h"
|
#include "plugin/deviceplugin.h"
|
||||||
|
|
||||||
class DevicePluginIntertechno : public DevicePlugin
|
class DevicePluginIntertechno : public DevicePlugin
|
||||||
{
|
{
|
||||||
@ -31,6 +31,7 @@ class DevicePluginIntertechno : public DevicePlugin
|
|||||||
public:
|
public:
|
||||||
explicit DevicePluginIntertechno();
|
explicit DevicePluginIntertechno();
|
||||||
|
|
||||||
|
QList<Vendor> supportedVendors() const override;
|
||||||
QList<DeviceClass> supportedDevices() const override;
|
QList<DeviceClass> supportedDevices() const override;
|
||||||
DeviceManager::HardwareResources requiredHardware() const override;
|
DeviceManager::HardwareResources requiredHardware() const override;
|
||||||
|
|
||||||
|
|||||||
@ -42,19 +42,27 @@
|
|||||||
|
|
||||||
#include "devicepluginmeisteranker.h"
|
#include "devicepluginmeisteranker.h"
|
||||||
|
|
||||||
#include "device.h"
|
#include "plugin/device.h"
|
||||||
#include "devicemanager.h"
|
#include "plugin/devicemanager.h"
|
||||||
#include "radio433.h"
|
#include "hardware/radio433.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
|
QUuid meisterAnkerVendorId = QUuid("c181e749-5f72-4e25-a0af-094633abd7d5");
|
||||||
QUuid thermometer = QUuid("e37e9f34-95b9-4a22-ae4f-e8b874eec871");
|
QUuid thermometer = QUuid("e37e9f34-95b9-4a22-ae4f-e8b874eec871");
|
||||||
|
|
||||||
DevicePluginMeisterAnker::DevicePluginMeisterAnker()
|
DevicePluginMeisterAnker::DevicePluginMeisterAnker()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<Vendor> DevicePluginMeisterAnker::supportedVendors() const
|
||||||
|
{
|
||||||
|
QList<Vendor> ret;
|
||||||
|
Vendor meisterAnker(meisterAnkerVendorId, "Meister Anker");
|
||||||
|
ret.append(meisterAnker);
|
||||||
|
}
|
||||||
|
|
||||||
QList<DeviceClass> DevicePluginMeisterAnker::supportedDevices() const
|
QList<DeviceClass> DevicePluginMeisterAnker::supportedDevices() const
|
||||||
{
|
{
|
||||||
QList<DeviceClass> ret;
|
QList<DeviceClass> ret;
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
#ifndef DEVICEPLUGINMEISTERANKER_H
|
#ifndef DEVICEPLUGINMEISTERANKER_H
|
||||||
#define DEVICEPLUGINMEISTERANKER_H
|
#define DEVICEPLUGINMEISTERANKER_H
|
||||||
|
|
||||||
#include "deviceplugin.h"
|
#include "plugin/deviceplugin.h"
|
||||||
|
|
||||||
|
|
||||||
class DevicePluginMeisterAnker : public DevicePlugin
|
class DevicePluginMeisterAnker : public DevicePlugin
|
||||||
@ -32,6 +32,7 @@ class DevicePluginMeisterAnker : public DevicePlugin
|
|||||||
public:
|
public:
|
||||||
explicit DevicePluginMeisterAnker();
|
explicit DevicePluginMeisterAnker();
|
||||||
|
|
||||||
|
QList<Vendor> supportedVendors() const override;
|
||||||
QList<DeviceClass> supportedDevices() const override;
|
QList<DeviceClass> supportedDevices() const override;
|
||||||
DeviceManager::HardwareResources requiredHardware() const override;
|
DeviceManager::HardwareResources requiredHardware() const override;
|
||||||
|
|
||||||
|
|||||||
@ -19,12 +19,13 @@
|
|||||||
#include "devicepluginmock.h"
|
#include "devicepluginmock.h"
|
||||||
#include "httpdaemon.h"
|
#include "httpdaemon.h"
|
||||||
|
|
||||||
#include "device.h"
|
#include "plugin/device.h"
|
||||||
#include "devicemanager.h"
|
#include "plugin/devicemanager.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
|
QUuid guhVendorId = QUuid("2062d64d-3232-433c-88bc-0d33c0ba2ba6");
|
||||||
QUuid mockEvent1Id = QUuid("45bf3752-0fc6-46b9-89fd-ffd878b5b22b");
|
QUuid mockEvent1Id = QUuid("45bf3752-0fc6-46b9-89fd-ffd878b5b22b");
|
||||||
QUuid mockEvent2Id = QUuid("863d5920-b1cf-4eb9-88bd-8f7b8583b1cf");
|
QUuid mockEvent2Id = QUuid("863d5920-b1cf-4eb9-88bd-8f7b8583b1cf");
|
||||||
QUuid mockIntStateId = QUuid("80baec19-54de-4948-ac46-31eabfaceb83");
|
QUuid mockIntStateId = QUuid("80baec19-54de-4948-ac46-31eabfaceb83");
|
||||||
@ -36,6 +37,14 @@ DevicePluginMock::DevicePluginMock()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<Vendor> DevicePluginMock::supportedVendors() const
|
||||||
|
{
|
||||||
|
QList<Vendor> ret;
|
||||||
|
Vendor guh(guhVendorId, "guh");
|
||||||
|
ret.append(guh);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
QList<DeviceClass> DevicePluginMock::supportedDevices() const
|
QList<DeviceClass> DevicePluginMock::supportedDevices() const
|
||||||
{
|
{
|
||||||
QList<DeviceClass> ret;
|
QList<DeviceClass> ret;
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
#ifndef DEVICEPLUGINMOCK_H
|
#ifndef DEVICEPLUGINMOCK_H
|
||||||
#define DEVICEPLUGINMOCK_H
|
#define DEVICEPLUGINMOCK_H
|
||||||
|
|
||||||
#include "deviceplugin.h"
|
#include "plugin/deviceplugin.h"
|
||||||
|
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
|
||||||
@ -35,6 +35,7 @@ class DevicePluginMock : public DevicePlugin
|
|||||||
public:
|
public:
|
||||||
explicit DevicePluginMock();
|
explicit DevicePluginMock();
|
||||||
|
|
||||||
|
QList<Vendor> supportedVendors() const override;
|
||||||
QList<DeviceClass> supportedDevices() const override;
|
QList<DeviceClass> supportedDevices() const override;
|
||||||
DeviceManager::HardwareResources requiredHardware() const override;
|
DeviceManager::HardwareResources requiredHardware() const override;
|
||||||
|
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
#include "httpdaemon.h"
|
#include "httpdaemon.h"
|
||||||
|
|
||||||
#include "device.h"
|
#include "plugin/device.h"
|
||||||
#include "deviceclass.h"
|
#include "plugin/deviceclass.h"
|
||||||
#include "deviceplugin.h"
|
#include "plugin/deviceplugin.h"
|
||||||
#include "statetype.h"
|
#include "types/statetype.h"
|
||||||
|
|
||||||
#include <QTcpSocket>
|
#include <QTcpSocket>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|||||||
@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
#include "devicepluginweatherground.h"
|
#include "devicepluginweatherground.h"
|
||||||
|
|
||||||
#include "device.h"
|
#include "plugin/device.h"
|
||||||
#include "devicemanager.h"
|
#include "plugin/devicemanager.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
@ -28,11 +28,21 @@
|
|||||||
|
|
||||||
// Key: 779a480dea5163c6
|
// Key: 779a480dea5163c6
|
||||||
|
|
||||||
|
QUuid weathergroundVendorId = QUuid("68f84197-b158-4d24-9d7b-709cfff843c1");
|
||||||
|
|
||||||
DevicePluginWeatherground::DevicePluginWeatherground()
|
DevicePluginWeatherground::DevicePluginWeatherground()
|
||||||
{
|
{
|
||||||
m_parser = new WeathergroundParser(this);
|
m_parser = new WeathergroundParser(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<Vendor> DevicePluginWeatherground::supportedVendors() const
|
||||||
|
{
|
||||||
|
QList<Vendor> ret;
|
||||||
|
Vendor weatherground(weathergroundVendorId, "weatherground");
|
||||||
|
ret.append(weatherground);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
QList<DeviceClass> DevicePluginWeatherground::supportedDevices() const
|
QList<DeviceClass> DevicePluginWeatherground::supportedDevices() const
|
||||||
{
|
{
|
||||||
QList<DeviceClass> ret;
|
QList<DeviceClass> ret;
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
#ifndef DEVICEPLUGINWEATHERGROUND_H
|
#ifndef DEVICEPLUGINWEATHERGROUND_H
|
||||||
#define DEVICEPLUGINWEATHERGROUND_H
|
#define DEVICEPLUGINWEATHERGROUND_H
|
||||||
|
|
||||||
#include "deviceplugin.h"
|
#include "plugin/deviceplugin.h"
|
||||||
#include "weathergroundparser.h"
|
#include "weathergroundparser.h"
|
||||||
|
|
||||||
|
|
||||||
@ -35,6 +35,7 @@ public:
|
|||||||
|
|
||||||
WeathergroundParser *m_parser;
|
WeathergroundParser *m_parser;
|
||||||
|
|
||||||
|
QList<Vendor> supportedVendors() const override;
|
||||||
QList<DeviceClass> supportedDevices() const override;
|
QList<DeviceClass> supportedDevices() const override;
|
||||||
DeviceManager::HardwareResources requiredHardware() const override;
|
DeviceManager::HardwareResources requiredHardware() const override;
|
||||||
|
|
||||||
|
|||||||
@ -18,12 +18,13 @@
|
|||||||
|
|
||||||
#include "devicepluginwifidetector.h"
|
#include "devicepluginwifidetector.h"
|
||||||
|
|
||||||
#include "device.h"
|
#include "plugin/device.h"
|
||||||
#include "devicemanager.h"
|
#include "plugin/devicemanager.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
|
extern QUuid guhVendorId;
|
||||||
QUuid pluginUuid = QUuid("8e0f791e-b273-4267-8605-b7c2f55a68ab");
|
QUuid pluginUuid = QUuid("8e0f791e-b273-4267-8605-b7c2f55a68ab");
|
||||||
QUuid detectorId = QUuid("bd216356-f1ec-4324-9785-6982d2174e17");
|
QUuid detectorId = QUuid("bd216356-f1ec-4324-9785-6982d2174e17");
|
||||||
QUuid inRangeStateTypeId = QUuid("cb43e1b5-4f61-4538-bfa2-c33055c542cf");
|
QUuid inRangeStateTypeId = QUuid("cb43e1b5-4f61-4538-bfa2-c33055c542cf");
|
||||||
@ -32,6 +33,14 @@ DevicePluginWifiDetector::DevicePluginWifiDetector()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<Vendor> DevicePluginWifiDetector::supportedVendors() const
|
||||||
|
{
|
||||||
|
QList<Vendor> ret;
|
||||||
|
Vendor guh(guhVendorId, "guh");
|
||||||
|
ret.append(guh);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
QList<DeviceClass> DevicePluginWifiDetector::supportedDevices() const
|
QList<DeviceClass> DevicePluginWifiDetector::supportedDevices() const
|
||||||
{
|
{
|
||||||
QList<DeviceClass> ret;
|
QList<DeviceClass> ret;
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
#ifndef DEVICEPLUGINWIFIDETECTOR_H
|
#ifndef DEVICEPLUGINWIFIDETECTOR_H
|
||||||
#define DEVICEPLUGINWIFIDETECTOR_H
|
#define DEVICEPLUGINWIFIDETECTOR_H
|
||||||
|
|
||||||
#include "deviceplugin.h"
|
#include "plugin/deviceplugin.h"
|
||||||
|
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
|
||||||
@ -33,6 +33,7 @@ class DevicePluginWifiDetector : public DevicePlugin
|
|||||||
public:
|
public:
|
||||||
explicit DevicePluginWifiDetector();
|
explicit DevicePluginWifiDetector();
|
||||||
|
|
||||||
|
QList<Vendor> supportedVendors() const override;
|
||||||
QList<DeviceClass> supportedDevices() const override;
|
QList<DeviceClass> supportedDevices() const override;
|
||||||
DeviceManager::HardwareResources requiredHardware() const override;
|
DeviceManager::HardwareResources requiredHardware() const override;
|
||||||
|
|
||||||
|
|||||||
@ -29,9 +29,10 @@
|
|||||||
|
|
||||||
#include "guhcore.h"
|
#include "guhcore.h"
|
||||||
#include "jsonrpcserver.h"
|
#include "jsonrpcserver.h"
|
||||||
#include "devicemanager.h"
|
|
||||||
#include "ruleengine.h"
|
#include "ruleengine.h"
|
||||||
#include "device.h"
|
|
||||||
|
#include "plugin/devicemanager.h"
|
||||||
|
#include "plugin/device.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
#define GUHCORE_H
|
#define GUHCORE_H
|
||||||
|
|
||||||
#include "rule.h"
|
#include "rule.h"
|
||||||
#include "event.h"
|
#include "types/event.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
|||||||
@ -18,9 +18,9 @@
|
|||||||
|
|
||||||
#include "actionhandler.h"
|
#include "actionhandler.h"
|
||||||
|
|
||||||
#include "devicemanager.h"
|
|
||||||
#include "guhcore.h"
|
#include "guhcore.h"
|
||||||
#include "action.h"
|
#include "plugin/devicemanager.h"
|
||||||
|
#include "types/action.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
|||||||
@ -17,11 +17,11 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include "devicehandler.h"
|
#include "devicehandler.h"
|
||||||
#include "device.h"
|
|
||||||
#include "deviceclass.h"
|
|
||||||
#include "guhcore.h"
|
#include "guhcore.h"
|
||||||
#include "devicemanager.h"
|
#include "plugin/device.h"
|
||||||
#include "deviceplugin.h"
|
#include "plugin/deviceclass.h"
|
||||||
|
#include "plugin/devicemanager.h"
|
||||||
|
#include "plugin/deviceplugin.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
|||||||
@ -27,10 +27,10 @@
|
|||||||
#include "jsonhandler.h"
|
#include "jsonhandler.h"
|
||||||
|
|
||||||
#include "guhcore.h"
|
#include "guhcore.h"
|
||||||
#include "devicemanager.h"
|
#include "plugin/devicemanager.h"
|
||||||
#include "deviceplugin.h"
|
#include "plugin/deviceplugin.h"
|
||||||
#include "deviceclass.h"
|
#include "plugin/deviceclass.h"
|
||||||
#include "device.h"
|
#include "plugin/device.h"
|
||||||
#include "rule.h"
|
#include "rule.h"
|
||||||
#include "ruleengine.h"
|
#include "ruleengine.h"
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ QVariantMap JsonRPCServer::Introspect(const QVariantMap ¶ms) const
|
|||||||
foreach (JsonHandler *handler, m_handlers) {
|
foreach (JsonHandler *handler, m_handlers) {
|
||||||
signalsMap.unite(handler->introspect(QMetaMethod::Signal));
|
signalsMap.unite(handler->introspect(QMetaMethod::Signal));
|
||||||
}
|
}
|
||||||
data.insert("signals", signalsMap);
|
data.insert("notifications", signalsMap);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,11 +19,12 @@
|
|||||||
#ifndef JSONRPCSERVER_H
|
#ifndef JSONRPCSERVER_H
|
||||||
#define JSONRPCSERVER_H
|
#define JSONRPCSERVER_H
|
||||||
|
|
||||||
#include "deviceclass.h"
|
#include "plugin/deviceclass.h"
|
||||||
#include "action.h"
|
|
||||||
#include "event.h"
|
|
||||||
#include "jsonhandler.h"
|
#include "jsonhandler.h"
|
||||||
|
|
||||||
|
#include "types/action.h"
|
||||||
|
#include "types/event.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|||||||
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#include "jsontypes.h"
|
#include "jsontypes.h"
|
||||||
|
|
||||||
#include "device.h"
|
#include "plugin/device.h"
|
||||||
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
@ -232,7 +232,7 @@ QVariantMap JsonTypes::packRule(const Rule &rule)
|
|||||||
{
|
{
|
||||||
QVariantMap ruleMap;
|
QVariantMap ruleMap;
|
||||||
ruleMap.insert("id", rule.id());
|
ruleMap.insert("id", rule.id());
|
||||||
ruleMap.insert("event", JsonTypes::packEvent(rule.event()));
|
// ruleMap.insert("event", JsonTypes::packEvent(rule.event()));
|
||||||
ruleMap.insert("ruleType", s_ruleTypes.at(rule.ruleType()));
|
ruleMap.insert("ruleType", s_ruleTypes.at(rule.ruleType()));
|
||||||
QVariantList actionList;
|
QVariantList actionList;
|
||||||
foreach (const Action &action, rule.actions()) {
|
foreach (const Action &action, rule.actions()) {
|
||||||
|
|||||||
@ -19,12 +19,13 @@
|
|||||||
#ifndef JSONTYPES_H
|
#ifndef JSONTYPES_H
|
||||||
#define JSONTYPES_H
|
#define JSONTYPES_H
|
||||||
|
|
||||||
#include "deviceclass.h"
|
#include "plugin/deviceclass.h"
|
||||||
#include "event.h"
|
|
||||||
#include "action.h"
|
|
||||||
#include "actiontype.h"
|
|
||||||
#include "rule.h"
|
#include "rule.h"
|
||||||
|
|
||||||
|
#include "types/event.h"
|
||||||
|
#include "types/action.h"
|
||||||
|
#include "types/actiontype.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
|
|||||||
@ -19,9 +19,10 @@
|
|||||||
#ifndef RULE_H
|
#ifndef RULE_H
|
||||||
#define RULE_H
|
#define RULE_H
|
||||||
|
|
||||||
#include "state.h"
|
#include "types/state.h"
|
||||||
#include "action.h"
|
#include "types/action.h"
|
||||||
#include "event.h"
|
#include "types/event.h"
|
||||||
|
#include "stateevaluator.h"
|
||||||
|
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
|
|
||||||
@ -47,6 +48,7 @@ private:
|
|||||||
QUuid m_id;
|
QUuid m_id;
|
||||||
Event m_event;
|
Event m_event;
|
||||||
QList<State> m_states;
|
QList<State> m_states;
|
||||||
|
StateEvaluator stateEvaluator;
|
||||||
QList<Action> m_actions;
|
QList<Action> m_actions;
|
||||||
RuleType m_ruleType;
|
RuleType m_ruleType;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -53,8 +53,9 @@
|
|||||||
#include "ruleengine.h"
|
#include "ruleengine.h"
|
||||||
|
|
||||||
#include "guhcore.h"
|
#include "guhcore.h"
|
||||||
#include "devicemanager.h"
|
|
||||||
#include "device.h"
|
#include "plugin/devicemanager.h"
|
||||||
|
#include "plugin/device.h"
|
||||||
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@ -117,28 +118,28 @@ RuleEngine::RuleEngine(QObject *parent) :
|
|||||||
QList<Action> RuleEngine::evaluateEvent(const Event &event)
|
QList<Action> RuleEngine::evaluateEvent(const Event &event)
|
||||||
{
|
{
|
||||||
QList<Action> actions;
|
QList<Action> actions;
|
||||||
for (int i = 0; i < m_rules.count(); ++i) {
|
// for (int i = 0; i < m_rules.count(); ++i) {
|
||||||
if (m_rules.at(i).event() == event) {
|
// if (m_rules.at(i).events().contains(event)) {
|
||||||
bool statesMatching = true;
|
// bool statesMatching = true;
|
||||||
qDebug() << "checking states";
|
// qDebug() << "checking states";
|
||||||
foreach (const State &state, m_rules.at(i).states()) {
|
// foreach (const State &state, m_rules.at(i).stateChanges()) {
|
||||||
Device *device = GuhCore::instance()->deviceManager()->findConfiguredDevice(state.deviceId());
|
// Device *device = GuhCore::instance()->deviceManager()->findConfiguredDevice(state.deviceId());
|
||||||
if (!device) {
|
// if (!device) {
|
||||||
qWarning() << "Device referenced in rule cannot be found";
|
// qWarning() << "Device referenced in rule cannot be found";
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
if (state.value() != device->stateValue(state.stateTypeId())) {
|
// if (state.value() != device->stateValue(state.stateTypeId())) {
|
||||||
statesMatching = false;
|
// statesMatching = false;
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
qDebug() << "states matching" << statesMatching;
|
// qDebug() << "states matching" << statesMatching;
|
||||||
if (statesMatching) {
|
// if (statesMatching) {
|
||||||
actions.append(m_rules.at(i).actions());
|
// actions.append(m_rules.at(i).actions());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
qDebug() << "found" << actions.count() << "actions";
|
qDebug() << "found" << actions.count() << "actions";
|
||||||
return actions;
|
return actions;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
#define RULEENGINE_H
|
#define RULEENGINE_H
|
||||||
|
|
||||||
#include "rule.h"
|
#include "rule.h"
|
||||||
#include "event.h"
|
#include "types/event.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
|||||||
@ -7,7 +7,8 @@ SOURCES += $$top_srcdir/server/guhcore.cpp \
|
|||||||
$$top_srcdir/server/jsonrpc/devicehandler.cpp \
|
$$top_srcdir/server/jsonrpc/devicehandler.cpp \
|
||||||
$$top_srcdir/server/jsonrpc/jsontypes.cpp \
|
$$top_srcdir/server/jsonrpc/jsontypes.cpp \
|
||||||
$$top_srcdir/server/jsonrpc/ruleshandler.cpp \
|
$$top_srcdir/server/jsonrpc/ruleshandler.cpp \
|
||||||
$$top_srcdir/server/jsonrpc/actionhandler.cpp
|
$$top_srcdir/server/jsonrpc/actionhandler.cpp \
|
||||||
|
$$top_srcdir/server/stateevaluator.cpp
|
||||||
|
|
||||||
HEADERS += $$top_srcdir/server/guhcore.h \
|
HEADERS += $$top_srcdir/server/guhcore.h \
|
||||||
$$top_srcdir/server/tcpserver.h \
|
$$top_srcdir/server/tcpserver.h \
|
||||||
@ -18,4 +19,5 @@ HEADERS += $$top_srcdir/server/guhcore.h \
|
|||||||
$$top_srcdir/server/jsonrpc/devicehandler.h \
|
$$top_srcdir/server/jsonrpc/devicehandler.h \
|
||||||
$$top_srcdir/server/jsonrpc/jsontypes.h \
|
$$top_srcdir/server/jsonrpc/jsontypes.h \
|
||||||
$$top_srcdir/server/jsonrpc/ruleshandler.h \
|
$$top_srcdir/server/jsonrpc/ruleshandler.h \
|
||||||
$$top_srcdir/server/jsonrpc/actionhandler.h
|
$$top_srcdir/server/jsonrpc/actionhandler.h \
|
||||||
|
$$top_srcdir/server/stateevaluator.h
|
||||||
|
|||||||
7
server/stateevaluator.cpp
Normal file
7
server/stateevaluator.cpp
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#include "stateevaluator.h"
|
||||||
|
|
||||||
|
StateEvaluator::StateEvaluator()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
33
server/stateevaluator.h
Normal file
33
server/stateevaluator.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#ifndef STATEEVALUATOR_H
|
||||||
|
#define STATEEVALUATOR_H
|
||||||
|
|
||||||
|
#include "types/state.h"
|
||||||
|
|
||||||
|
//class EvaluatorEntry
|
||||||
|
//{
|
||||||
|
//public:
|
||||||
|
// EvaluatorEntry();
|
||||||
|
|
||||||
|
// QUuid stateTypeId;
|
||||||
|
// QUuid deviceId;
|
||||||
|
//// Rule::Operator operation;
|
||||||
|
// QVariant value;
|
||||||
|
//};
|
||||||
|
|
||||||
|
//class EvaluatorChain
|
||||||
|
//{
|
||||||
|
|
||||||
|
//};
|
||||||
|
|
||||||
|
class StateEvaluator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
StateEvaluator();
|
||||||
|
|
||||||
|
private:
|
||||||
|
// EvaluatorEntry m_entry;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // STATEEVALUATOR_H
|
||||||
@ -17,7 +17,7 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include "guhcore.h"
|
#include "guhcore.h"
|
||||||
#include "devicemanager.h"
|
#include "plugin/devicemanager.h"
|
||||||
#include "mocktcpserver.h"
|
#include "mocktcpserver.h"
|
||||||
|
|
||||||
#include <QtTest/QtTest>
|
#include <QtTest/QtTest>
|
||||||
|
|||||||
Reference in New Issue
Block a user