mirror of https://github.com/nymea/nymea.git
restructure lib a bit. added initial code for the new rules stuff
parent
cf9d460bad
commit
4f679b3bc3
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include <QObject>
|
||||
#include <QThread>
|
||||
#include <gpio.h>
|
||||
#include <hardware/gpio.h>
|
||||
|
||||
#define RC_MAX_CHANGES 67
|
||||
|
||||
|
|
@ -6,29 +6,31 @@ CONFIG += c++11
|
|||
target.path = /usr/lib
|
||||
INSTALLS += target
|
||||
|
||||
SOURCES += device.cpp \
|
||||
deviceclass.cpp \
|
||||
devicemanager.cpp \
|
||||
deviceplugin.cpp \
|
||||
radio433.cpp \
|
||||
gpio.cpp \
|
||||
action.cpp \
|
||||
actiontype.cpp \
|
||||
state.cpp \
|
||||
statetype.cpp \
|
||||
eventtype.cpp \
|
||||
event.cpp
|
||||
SOURCES += plugin/device.cpp \
|
||||
plugin/deviceclass.cpp \
|
||||
plugin/devicemanager.cpp \
|
||||
plugin/deviceplugin.cpp \
|
||||
hardware/radio433.cpp \
|
||||
hardware/gpio.cpp \
|
||||
types/action.cpp \
|
||||
types/actiontype.cpp \
|
||||
types/state.cpp \
|
||||
types/statetype.cpp \
|
||||
types/eventtype.cpp \
|
||||
types/event.cpp \
|
||||
types/vendor.cpp
|
||||
|
||||
HEADERS += device.h \
|
||||
deviceclass.h \
|
||||
devicemanager.h \
|
||||
deviceplugin.h \
|
||||
radio433.h \
|
||||
gpio.h \
|
||||
action.h \
|
||||
actiontype.h \
|
||||
state.h \
|
||||
statetype.h \
|
||||
eventtype.h \
|
||||
event.h
|
||||
HEADERS += plugin/device.h \
|
||||
plugin/deviceclass.h \
|
||||
plugin/devicemanager.h \
|
||||
plugin/deviceplugin.h \
|
||||
hardware/radio433.h \
|
||||
hardware/gpio.h \
|
||||
types/action.h \
|
||||
types/actiontype.h \
|
||||
types/state.h \
|
||||
types/statetype.h \
|
||||
types/eventtype.h \
|
||||
types/event.h \
|
||||
types/vendor.h
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
#ifndef DEVICE_H
|
||||
#define DEVICE_H
|
||||
|
||||
#include "state.h"
|
||||
#include "types/state.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QUuid>
|
||||
|
|
@ -19,9 +19,9 @@
|
|||
#ifndef DEVICECLASS_H
|
||||
#define DEVICECLASS_H
|
||||
|
||||
#include "eventtype.h"
|
||||
#include "actiontype.h"
|
||||
#include "statetype.h"
|
||||
#include "types/eventtype.h"
|
||||
#include "types/actiontype.h"
|
||||
#include "types/statetype.h"
|
||||
|
||||
#include <QList>
|
||||
#include <QUuid>
|
||||
|
|
@ -75,7 +75,7 @@
|
|||
|
||||
#include "devicemanager.h"
|
||||
|
||||
#include "radio433.h"
|
||||
#include "hardware/radio433.h"
|
||||
|
||||
#include "device.h"
|
||||
#include "deviceclass.h"
|
||||
|
|
@ -116,6 +116,11 @@ DevicePlugin *DeviceManager::plugin(const QUuid &id) const
|
|||
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. */
|
||||
QList<DeviceClass> DeviceManager::supportedDevices() const
|
||||
{
|
||||
|
|
@ -20,8 +20,10 @@
|
|||
#define DEVICEMANAGER_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 <QTimer>
|
||||
|
|
@ -57,6 +59,7 @@ public:
|
|||
|
||||
QList<DevicePlugin*> plugins() const;
|
||||
DevicePlugin* plugin(const QUuid &id) const;
|
||||
QList<Vendor> supportedVendors() const;
|
||||
QList<DeviceClass> supportedDevices() const;
|
||||
|
||||
QList<Device*> configuredDevices() const;
|
||||
|
|
@ -90,6 +93,7 @@ private slots:
|
|||
private:
|
||||
bool setupDevice(Device *device);
|
||||
|
||||
QHash<QUuid, Vendor> m_supportedVendors;
|
||||
QHash<QUuid, DeviceClass> m_supportedDevices;
|
||||
QList<Device*> m_configuredDevices;
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ pure virtual methods: \l{DevicePlugin::pluginName()}, \l{DevicePlugin::pluginId(
|
|||
#include "deviceplugin.h"
|
||||
|
||||
#include "devicemanager.h"
|
||||
#include "radio433.h"
|
||||
#include "hardware/radio433.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
|
@ -21,8 +21,10 @@
|
|||
|
||||
#include "devicemanager.h"
|
||||
#include "deviceclass.h"
|
||||
#include "event.h"
|
||||
#include "action.h"
|
||||
|
||||
#include "types/event.h"
|
||||
#include "types/action.h"
|
||||
#include "types/vendor.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
|
|
@ -41,6 +43,7 @@ public:
|
|||
virtual QString pluginName() const = 0;
|
||||
virtual QUuid pluginId() const = 0;
|
||||
|
||||
virtual QList<Vendor> supportedVendors() const = 0;
|
||||
virtual QList<DeviceClass> supportedDevices() const = 0;
|
||||
virtual DeviceManager::HardwareResources requiredHardware() const = 0;
|
||||
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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 "device.h"
|
||||
#include "devicemanager.h"
|
||||
#include "radio433.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");
|
||||
|
||||
|
||||
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
|
||||
{
|
||||
// TODO: load list from config with static uuid
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
#ifndef DEVICEPLUGINCONRAD_H
|
||||
#define DEVICEPLUGINCONRAD_H
|
||||
|
||||
#include "deviceplugin.h"
|
||||
#include "plugin/deviceplugin.h"
|
||||
|
||||
class DevicePluginConrad : public DevicePlugin
|
||||
{
|
||||
|
|
@ -31,6 +31,7 @@ class DevicePluginConrad : public DevicePlugin
|
|||
public:
|
||||
explicit DevicePluginConrad();
|
||||
|
||||
QList<Vendor> supportedVendors() const override;
|
||||
QList<DeviceClass> supportedDevices() const override;
|
||||
DeviceManager::HardwareResources requiredHardware() const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -52,13 +52,16 @@
|
|||
|
||||
#include "devicepluginelro.h"
|
||||
|
||||
#include "device.h"
|
||||
#include "devicemanager.h"
|
||||
#include "radio433.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");
|
||||
|
||||
QUuid elroRemoteId = QUuid("d85c1ef4-197c-4053-8e40-707aa671d302");
|
||||
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
|
||||
{
|
||||
// TODO: load list from config with static uuid
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
#ifndef DEVICEPLUGINELRO_H
|
||||
#define DEVICEPLUGINELRO_H
|
||||
|
||||
#include "deviceplugin.h"
|
||||
#include "plugin/deviceplugin.h"
|
||||
|
||||
class DevicePluginElro : public DevicePlugin
|
||||
{
|
||||
|
|
@ -31,6 +31,7 @@ class DevicePluginElro : public DevicePlugin
|
|||
public:
|
||||
explicit DevicePluginElro();
|
||||
|
||||
QList<Vendor> supportedVendors() const override;
|
||||
QList<DeviceClass> supportedDevices() const override;
|
||||
DeviceManager::HardwareResources requiredHardware() const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -157,13 +157,14 @@
|
|||
|
||||
#include "devicepluginintertechno.h"
|
||||
|
||||
#include "device.h"
|
||||
#include "devicemanager.h"
|
||||
#include "radio433.h"
|
||||
#include "plugin/device.h"
|
||||
#include "plugin/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");
|
||||
|
||||
|
|
@ -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> ret;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
#ifndef DEVICEPLUGININTERTECHNO_H
|
||||
#define DEVICEPLUGININTERTECHNO_H
|
||||
|
||||
#include "deviceplugin.h"
|
||||
#include "plugin/deviceplugin.h"
|
||||
|
||||
class DevicePluginIntertechno : public DevicePlugin
|
||||
{
|
||||
|
|
@ -31,6 +31,7 @@ class DevicePluginIntertechno : public DevicePlugin
|
|||
public:
|
||||
explicit DevicePluginIntertechno();
|
||||
|
||||
QList<Vendor> supportedVendors() const override;
|
||||
QList<DeviceClass> supportedDevices() const override;
|
||||
DeviceManager::HardwareResources requiredHardware() const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -42,19 +42,27 @@
|
|||
|
||||
#include "devicepluginmeisteranker.h"
|
||||
|
||||
#include "device.h"
|
||||
#include "devicemanager.h"
|
||||
#include "radio433.h"
|
||||
#include "plugin/device.h"
|
||||
#include "plugin/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");
|
||||
|
||||
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> ret;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
#ifndef DEVICEPLUGINMEISTERANKER_H
|
||||
#define DEVICEPLUGINMEISTERANKER_H
|
||||
|
||||
#include "deviceplugin.h"
|
||||
#include "plugin/deviceplugin.h"
|
||||
|
||||
|
||||
class DevicePluginMeisterAnker : public DevicePlugin
|
||||
|
|
@ -32,6 +32,7 @@ class DevicePluginMeisterAnker : public DevicePlugin
|
|||
public:
|
||||
explicit DevicePluginMeisterAnker();
|
||||
|
||||
QList<Vendor> supportedVendors() const override;
|
||||
QList<DeviceClass> supportedDevices() const override;
|
||||
DeviceManager::HardwareResources requiredHardware() const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -19,12 +19,13 @@
|
|||
#include "devicepluginmock.h"
|
||||
#include "httpdaemon.h"
|
||||
|
||||
#include "device.h"
|
||||
#include "devicemanager.h"
|
||||
#include "plugin/device.h"
|
||||
#include "plugin/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");
|
||||
|
|
@ -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> ret;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
#ifndef DEVICEPLUGINMOCK_H
|
||||
#define DEVICEPLUGINMOCK_H
|
||||
|
||||
#include "deviceplugin.h"
|
||||
#include "plugin/deviceplugin.h"
|
||||
|
||||
#include <QProcess>
|
||||
|
||||
|
|
@ -35,6 +35,7 @@ class DevicePluginMock : public DevicePlugin
|
|||
public:
|
||||
explicit DevicePluginMock();
|
||||
|
||||
QList<Vendor> supportedVendors() const override;
|
||||
QList<DeviceClass> supportedDevices() const override;
|
||||
DeviceManager::HardwareResources requiredHardware() const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
#include "httpdaemon.h"
|
||||
|
||||
#include "device.h"
|
||||
#include "deviceclass.h"
|
||||
#include "deviceplugin.h"
|
||||
#include "statetype.h"
|
||||
#include "plugin/device.h"
|
||||
#include "plugin/deviceclass.h"
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "types/statetype.h"
|
||||
|
||||
#include <QTcpSocket>
|
||||
#include <QDebug>
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@
|
|||
|
||||
#include "devicepluginweatherground.h"
|
||||
|
||||
#include "device.h"
|
||||
#include "devicemanager.h"
|
||||
#include "plugin/device.h"
|
||||
#include "plugin/devicemanager.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
|
|
@ -28,11 +28,21 @@
|
|||
|
||||
// Key: 779a480dea5163c6
|
||||
|
||||
QUuid weathergroundVendorId = QUuid("68f84197-b158-4d24-9d7b-709cfff843c1");
|
||||
|
||||
DevicePluginWeatherground::DevicePluginWeatherground()
|
||||
{
|
||||
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> ret;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
#ifndef DEVICEPLUGINWEATHERGROUND_H
|
||||
#define DEVICEPLUGINWEATHERGROUND_H
|
||||
|
||||
#include "deviceplugin.h"
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "weathergroundparser.h"
|
||||
|
||||
|
||||
|
|
@ -35,6 +35,7 @@ public:
|
|||
|
||||
WeathergroundParser *m_parser;
|
||||
|
||||
QList<Vendor> supportedVendors() const override;
|
||||
QList<DeviceClass> supportedDevices() const override;
|
||||
DeviceManager::HardwareResources requiredHardware() const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,12 +18,13 @@
|
|||
|
||||
#include "devicepluginwifidetector.h"
|
||||
|
||||
#include "device.h"
|
||||
#include "devicemanager.h"
|
||||
#include "plugin/device.h"
|
||||
#include "plugin/devicemanager.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
|
||||
extern QUuid 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");
|
||||
|
|
@ -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> ret;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
#ifndef DEVICEPLUGINWIFIDETECTOR_H
|
||||
#define DEVICEPLUGINWIFIDETECTOR_H
|
||||
|
||||
#include "deviceplugin.h"
|
||||
#include "plugin/deviceplugin.h"
|
||||
|
||||
#include <QProcess>
|
||||
|
||||
|
|
@ -33,6 +33,7 @@ class DevicePluginWifiDetector : public DevicePlugin
|
|||
public:
|
||||
explicit DevicePluginWifiDetector();
|
||||
|
||||
QList<Vendor> supportedVendors() const override;
|
||||
QList<DeviceClass> supportedDevices() const override;
|
||||
DeviceManager::HardwareResources requiredHardware() const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -29,9 +29,10 @@
|
|||
|
||||
#include "guhcore.h"
|
||||
#include "jsonrpcserver.h"
|
||||
#include "devicemanager.h"
|
||||
#include "ruleengine.h"
|
||||
#include "device.h"
|
||||
|
||||
#include "plugin/devicemanager.h"
|
||||
#include "plugin/device.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
#define GUHCORE_H
|
||||
|
||||
#include "rule.h"
|
||||
#include "event.h"
|
||||
#include "types/event.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@
|
|||
|
||||
#include "actionhandler.h"
|
||||
|
||||
#include "devicemanager.h"
|
||||
#include "guhcore.h"
|
||||
#include "action.h"
|
||||
#include "plugin/devicemanager.h"
|
||||
#include "types/action.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
|
|
|||
|
|
@ -17,11 +17,11 @@
|
|||
***************************************************************************/
|
||||
|
||||
#include "devicehandler.h"
|
||||
#include "device.h"
|
||||
#include "deviceclass.h"
|
||||
#include "guhcore.h"
|
||||
#include "devicemanager.h"
|
||||
#include "deviceplugin.h"
|
||||
#include "plugin/device.h"
|
||||
#include "plugin/deviceclass.h"
|
||||
#include "plugin/devicemanager.h"
|
||||
#include "plugin/deviceplugin.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
|
|
|||
|
|
@ -27,10 +27,10 @@
|
|||
#include "jsonhandler.h"
|
||||
|
||||
#include "guhcore.h"
|
||||
#include "devicemanager.h"
|
||||
#include "deviceplugin.h"
|
||||
#include "deviceclass.h"
|
||||
#include "device.h"
|
||||
#include "plugin/devicemanager.h"
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "plugin/deviceclass.h"
|
||||
#include "plugin/device.h"
|
||||
#include "rule.h"
|
||||
#include "ruleengine.h"
|
||||
|
||||
|
|
@ -104,7 +104,7 @@ QVariantMap JsonRPCServer::Introspect(const QVariantMap ¶ms) const
|
|||
foreach (JsonHandler *handler, m_handlers) {
|
||||
signalsMap.unite(handler->introspect(QMetaMethod::Signal));
|
||||
}
|
||||
data.insert("signals", signalsMap);
|
||||
data.insert("notifications", signalsMap);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,11 +19,12 @@
|
|||
#ifndef JSONRPCSERVER_H
|
||||
#define JSONRPCSERVER_H
|
||||
|
||||
#include "deviceclass.h"
|
||||
#include "action.h"
|
||||
#include "event.h"
|
||||
#include "plugin/deviceclass.h"
|
||||
#include "jsonhandler.h"
|
||||
|
||||
#include "types/action.h"
|
||||
#include "types/event.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QVariantMap>
|
||||
#include <QString>
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
#include "jsontypes.h"
|
||||
|
||||
#include "device.h"
|
||||
#include "plugin/device.h"
|
||||
|
||||
#include <QStringList>
|
||||
#include <QJsonDocument>
|
||||
|
|
@ -232,7 +232,7 @@ QVariantMap JsonTypes::packRule(const Rule &rule)
|
|||
{
|
||||
QVariantMap ruleMap;
|
||||
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()));
|
||||
QVariantList actionList;
|
||||
foreach (const Action &action, rule.actions()) {
|
||||
|
|
|
|||
|
|
@ -19,12 +19,13 @@
|
|||
#ifndef JSONTYPES_H
|
||||
#define JSONTYPES_H
|
||||
|
||||
#include "deviceclass.h"
|
||||
#include "event.h"
|
||||
#include "action.h"
|
||||
#include "actiontype.h"
|
||||
#include "plugin/deviceclass.h"
|
||||
#include "rule.h"
|
||||
|
||||
#include "types/event.h"
|
||||
#include "types/action.h"
|
||||
#include "types/actiontype.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <QVariantMap>
|
||||
|
|
|
|||
|
|
@ -19,9 +19,10 @@
|
|||
#ifndef RULE_H
|
||||
#define RULE_H
|
||||
|
||||
#include "state.h"
|
||||
#include "action.h"
|
||||
#include "event.h"
|
||||
#include "types/state.h"
|
||||
#include "types/action.h"
|
||||
#include "types/event.h"
|
||||
#include "stateevaluator.h"
|
||||
|
||||
#include <QUuid>
|
||||
|
||||
|
|
@ -47,6 +48,7 @@ private:
|
|||
QUuid m_id;
|
||||
Event m_event;
|
||||
QList<State> m_states;
|
||||
StateEvaluator stateEvaluator;
|
||||
QList<Action> m_actions;
|
||||
RuleType m_ruleType;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -53,8 +53,9 @@
|
|||
#include "ruleengine.h"
|
||||
|
||||
#include "guhcore.h"
|
||||
#include "devicemanager.h"
|
||||
#include "device.h"
|
||||
|
||||
#include "plugin/devicemanager.h"
|
||||
#include "plugin/device.h"
|
||||
|
||||
#include <QSettings>
|
||||
#include <QDebug>
|
||||
|
|
@ -117,28 +118,28 @@ RuleEngine::RuleEngine(QObject *parent) :
|
|||
QList<Action> RuleEngine::evaluateEvent(const Event &event)
|
||||
{
|
||||
QList<Action> actions;
|
||||
for (int i = 0; i < m_rules.count(); ++i) {
|
||||
if (m_rules.at(i).event() == event) {
|
||||
bool statesMatching = true;
|
||||
qDebug() << "checking states";
|
||||
foreach (const State &state, m_rules.at(i).states()) {
|
||||
Device *device = GuhCore::instance()->deviceManager()->findConfiguredDevice(state.deviceId());
|
||||
if (!device) {
|
||||
qWarning() << "Device referenced in rule cannot be found";
|
||||
break;
|
||||
}
|
||||
if (state.value() != device->stateValue(state.stateTypeId())) {
|
||||
statesMatching = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// for (int i = 0; i < m_rules.count(); ++i) {
|
||||
// if (m_rules.at(i).events().contains(event)) {
|
||||
// bool statesMatching = true;
|
||||
// qDebug() << "checking states";
|
||||
// foreach (const State &state, m_rules.at(i).stateChanges()) {
|
||||
// Device *device = GuhCore::instance()->deviceManager()->findConfiguredDevice(state.deviceId());
|
||||
// if (!device) {
|
||||
// qWarning() << "Device referenced in rule cannot be found";
|
||||
// break;
|
||||
// }
|
||||
// if (state.value() != device->stateValue(state.stateTypeId())) {
|
||||
// statesMatching = false;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
qDebug() << "states matching" << statesMatching;
|
||||
if (statesMatching) {
|
||||
actions.append(m_rules.at(i).actions());
|
||||
}
|
||||
}
|
||||
}
|
||||
// qDebug() << "states matching" << statesMatching;
|
||||
// if (statesMatching) {
|
||||
// actions.append(m_rules.at(i).actions());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
qDebug() << "found" << actions.count() << "actions";
|
||||
return actions;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
#define RULEENGINE_H
|
||||
|
||||
#include "rule.h"
|
||||
#include "event.h"
|
||||
#include "types/event.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ SOURCES += $$top_srcdir/server/guhcore.cpp \
|
|||
$$top_srcdir/server/jsonrpc/devicehandler.cpp \
|
||||
$$top_srcdir/server/jsonrpc/jsontypes.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 \
|
||||
$$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/jsontypes.h \
|
||||
$$top_srcdir/server/jsonrpc/ruleshandler.h \
|
||||
$$top_srcdir/server/jsonrpc/actionhandler.h
|
||||
$$top_srcdir/server/jsonrpc/actionhandler.h \
|
||||
$$top_srcdir/server/stateevaluator.h
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
#include "stateevaluator.h"
|
||||
|
||||
StateEvaluator::StateEvaluator()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -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 "devicemanager.h"
|
||||
#include "plugin/devicemanager.h"
|
||||
#include "mocktcpserver.h"
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
|
|
|
|||
Loading…
Reference in New Issue