hive -> guh

This commit is contained in:
Simon Stürz 2014-03-31 20:33:30 +02:00
parent 61a7a68ee0
commit be4ee5c14d
66 changed files with 142 additions and 188 deletions

View File

@ -1,15 +0,0 @@
cmake_minimum_required(VERSION 2.8.9)
project(Hive C CXX)
set(CMAKE_AUTOMOC ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-permissive -pedantic -Wall -Wextra -fPIC")
include(FindPkgConfig)
find_package(Qt5Core)
add_subdirectory(libhive)
add_subdirectory(server)

View File

@ -1,11 +0,0 @@
TEMPLATE=subdirs
SUBDIRS += libhive server plugins tests
server.depends = libhive plugins
plugins.depends = libhive
tests.depends = libhive
doc.depends = libhive server
doc.commands = cd $$top_srcdir/doc; qdoc config.qdocconf
QMAKE_EXTRA_TARGETS += doc

View File

@ -3,8 +3,8 @@
\title All Modules \title All Modules
\table 80% \table 80%
\row \li \l{libhive} \li Common data types and plugin interfaces \row \li \l{libguh} \li Common data types and plugin interfaces
\row \li \l{Hive server} \li The Hive server daemon implementation \row \li \l{guh server} \li The guh server daemon implementation
\endtable \endtable
*/ */

View File

@ -1,30 +1,30 @@
/*! /*!
\page index.html \page index.html
\title Hive Developer Documentation \title guh Developer Documentation
\section1 Summary \section1 Summary
The Hive backend service consists of three main modules: The guh backend service consists of three main modules:
\list \list
\li \l{libhive} \li \l{libguh}
\list \list
\li \l{Types}{Types used in the hive system} \li \l{Types}{Types used in the guh system}
\li \l{Device Plugins}{The Device Plugin API} \li \l{Device Plugins}{The Device Plugin API}
\endlist \endlist
\li \l{Hive server} \li \l{guh server}
\list \list
\li \l{Hive Core} \li \l{guh Core}
\li \l{JSONRPC Interface} \li \l{JSONRPC Interface}
\li \l{Rules} \li \l{Rules}
\endlist \endlist
\li \l{Plugins}. \li \l{Plugins}.
\list \list
\li \l{RF 433 MHz} (TODO: is actually in libhive) \li \l{RF 433 MHz} (TODO: is actually in libguh)
\endlist \endlist
\endlist \endlist
\section2 Quicklinks \section2 Quicklinks
\list \list
\li \l{All Hive Classes} \li \l{All guh Classes}
\endlist \endlist
*/ */

7
doc/guhcore.qdoc Normal file
View File

@ -0,0 +1,7 @@
/*!
\page guhcore-index.html
\title guh Core
\annotatedlist core
*/

View File

@ -1,10 +1,10 @@
/*! /*!
\module server \module server
\title Hive server \title guh server
The Hive server is the instance that communicates with the hardware and provides a JSONRPC interface The guh server is the instance that communicates with the hardware and provides a JSONRPC interface
for communicating with the UI. It consists of those parts: for communicating with the UI. It consists of those parts:
\section3 Hive core \section3 guh core
\annotatedlist core \annotatedlist core
\section3 JSRONRPC Interface \section3 JSRONRPC Interface

View File

@ -1,7 +0,0 @@
/*!
\page hivecore-index.html
\title Hive Core
\annotatedlist core
*/

View File

@ -1,6 +1,6 @@
/*! /*!
\module libhive \module libguh
\title libhive \title libguh
\section1 Types \section1 Types
\annotatedlist types \annotatedlist types

11
guh.pro Normal file
View File

@ -0,0 +1,11 @@
TEMPLATE=subdirs
SUBDIRS += libguh server plugins tests
server.depends = libguh plugins
plugins.depends = libguh
tests.depends = libguh
doc.depends = libguh server
doc.commands = cd $$top_srcdir/doc; qdoc config.qdocconf
QMAKE_EXTRA_TARGETS += doc

View File

@ -3,7 +3,7 @@
\brief Holds information required to execute an action described by a \l{ActionType}. \brief Holds information required to execute an action described by a \l{ActionType}.
\ingroup types \ingroup types
\inmodule libhive \inmodule libguh
It is bound to a \l{Device} and an \l{ActionType} and holds the parameters It is bound to a \l{Device} and an \l{ActionType} and holds the parameters
for the execution of the action. for the execution of the action.

View File

@ -3,7 +3,7 @@
\brief Describes an \l{Action} for a \l{Device}. \brief Describes an \l{Action} for a \l{Device}.
\ingroup types \ingroup types
\inmodule libhive \inmodule libguh
ActionTypes are contained in \l{DeviceClass} templates returned ActionTypes are contained in \l{DeviceClass} templates returned
by \l{DevicePlugin}{DevicePlugins} in order to describe the hardware supported by \l{DevicePlugin}{DevicePlugins} in order to describe the hardware supported

View File

@ -3,7 +3,7 @@
\brief A Device represents a installed and configured hardware device. \brief A Device represents a installed and configured hardware device.
\ingroup devices \ingroup devices
\inmodule libhive \inmodule libguh
This class holds the values for configured devices. It is associated with a \{DeviceClass} which This class holds the values for configured devices. It is associated with a \{DeviceClass} which
can be used to get more details about the device. can be used to get more details about the device.

View File

@ -3,7 +3,7 @@
\brief Describes \l{Device}{Devices}. \brief Describes \l{Device}{Devices}.
\ingroup devices \ingroup devices
\inmodule libhive \inmodule libguh
It holds information general information about devices and their vendors and It holds information general information about devices and their vendors and
describes what actions, events and states a device supports. As this is describes what actions, events and states a device supports. As this is

View File

@ -3,7 +3,7 @@
\brief The main entry point when interacting with \l{Device}{Devices} \brief The main entry point when interacting with \l{Device}{Devices}
\ingroup devices \ingroup devices
\inmodule libhive \inmodule libguh
The DeviceManager holds all information about supported and configured Devices in the system. The DeviceManager holds all information about supported and configured Devices in the system.
@ -50,7 +50,7 @@
/*! \fn void DeviceManager::emitEvent(const Event &event) /*! \fn void DeviceManager::emitEvent(const Event &event)
The DeviceManager will emit a \l{Event} described in \a event whenever a Device The DeviceManager will emit a \l{Event} described in \a event whenever a Device
creates one. Normally only \l{HiveCore} should connect to this and execute actions creates one. Normally only \l{GuhCore} should connect to this and execute actions
after checking back with the \{RulesEngine}. Exceptions might be monitoring interfaces after checking back with the \{RulesEngine}. Exceptions might be monitoring interfaces
or similar, but you should never directly react to this in a \l{DevicePlugin}. or similar, but you should never directly react to this in a \l{DevicePlugin}.
*/ */
@ -69,8 +69,8 @@
#include <QSettings> #include <QSettings>
#include <QStringList> #include <QStringList>
/*! Constructs the DeviceManager with the given \a parent. There should only be one DeviceManager in the system created by \l{HiveCore}. /*! Constructs the DeviceManager with the given \a parent. There should only be one DeviceManager in the system created by \l{GuhCore}.
Use \c HiveCore::instance()->deviceManager() instead to access the DeviceManager. Use \c GuhCore::instance()->deviceManager() instead to access the DeviceManager.
*/ */
DeviceManager::DeviceManager(QObject *parent) : DeviceManager::DeviceManager(QObject *parent) :
QObject(parent), QObject(parent),
@ -288,7 +288,7 @@ void DeviceManager::timerEvent()
DeviceClass deviceClass = m_supportedDevices.value(device->deviceClassId()); DeviceClass deviceClass = m_supportedDevices.value(device->deviceClassId());
DevicePlugin *plugin = m_devicePlugins.value(deviceClass.pluginId()); DevicePlugin *plugin = m_devicePlugins.value(deviceClass.pluginId());
if (plugin->requiredHardware().testFlag(HardwareResourceTimer)) { if (plugin->requiredHardware().testFlag(HardwareResourceTimer)) {
plugin->hiveTimer(); plugin->guhTimer();
} }
} }
} }

View File

@ -3,7 +3,7 @@
\brief This is the base class interface for device plugins. \brief This is the base class interface for device plugins.
\ingroup devices \ingroup devices
\inmodule libhive \inmodule libguh
When implementing a new plugin, start by subclassing this and implementing the following When implementing a new plugin, start by subclassing this and implementing the following
pure virtual methods: \l{DevicePlugin::pluginName()}, \l{DevicePlugin::pluginId()}, pure virtual methods: \l{DevicePlugin::pluginName()}, \l{DevicePlugin::pluginId()},
@ -29,7 +29,7 @@ pure virtual methods: \l{DevicePlugin::pluginName()}, \l{DevicePlugin::pluginId(
/*! /*!
\fn DeviceManager::HardwareResources DevicePlugin::requiredHardware() const \fn DeviceManager::HardwareResources DevicePlugin::requiredHardware() const
Return flags describing the common hardware resources required by this plugin. Return flags describing the common hardware resources required by this plugin.
\sa DevicePlugin::transmitData(), DevicePlugin::radioData(), DevicePlugin::hiveTimer() \sa DevicePlugin::transmitData(), DevicePlugin::radioData(), DevicePlugin::guhTimer()
*/ */
/*! /*!
@ -39,7 +39,7 @@ pure virtual methods: \l{DevicePlugin::pluginName()}, \l{DevicePlugin::pluginId(
*/ */
/*! /*!
\fn void DevicePlugin::hiveTimer() \fn void DevicePlugin::guhTimer()
If the plugin has requested the timer using \l{DevicePlugin::requiredHardware()}, this slot will be called If the plugin has requested the timer using \l{DevicePlugin::requiredHardware()}, this slot will be called
on timer events. on timer events.
*/ */
@ -54,7 +54,7 @@ pure virtual methods: \l{DevicePlugin::pluginName()}, \l{DevicePlugin::pluginId(
\fn void DevicePlugin::emitEvent(const Event &event) \fn void DevicePlugin::emitEvent(const Event &event)
To produce a new event in the system, create a new \l{Event} and emit it with \a event. To produce a new event in the system, create a new \l{Event} and emit it with \a event.
Usually events are emitted in response to incoming data or other other events happening, Usually events are emitted in response to incoming data or other other events happening,
such as \l{DevicePlugin::radioData()} or \l{DevicePlugin::hiveTimer()}. Find a configured such as \l{DevicePlugin::radioData()} or \l{DevicePlugin::guhTimer()}. Find a configured
\l{Device} from the \l{DeviceManager} and get its \l{EventType}{EventTypes}, then \l{Device} from the \l{DeviceManager} and get its \l{EventType}{EventTypes}, then
create a \l{Event} complying to that \l{EventType} and emit it here. create a \l{Event} complying to that \l{EventType} and emit it here.
*/ */

View File

@ -28,7 +28,7 @@ public:
// Hardware input // Hardware input
virtual void radioData(QList<int> rawData) {Q_UNUSED(rawData)} virtual void radioData(QList<int> rawData) {Q_UNUSED(rawData)}
virtual void hiveTimer() {} virtual void guhTimer() {}
virtual QVariantMap configuration() const; virtual QVariantMap configuration() const;
virtual void setConfiguration(const QVariantMap &configuration); virtual void setConfiguration(const QVariantMap &configuration);
@ -52,6 +52,6 @@ private:
friend class DeviceManager; friend class DeviceManager;
}; };
Q_DECLARE_INTERFACE(DevicePlugin, "org.hiveyourhome.DevicePlugin") Q_DECLARE_INTERFACE(DevicePlugin, "org.guhyourhome.DevicePlugin")
#endif #endif

View File

@ -3,7 +3,7 @@
\brief Holds information required to emit a event described by a \l{EventType}. \brief Holds information required to emit a event described by a \l{EventType}.
\ingroup types \ingroup types
\inmodule libhive \inmodule libguh
It is bound to a \l{Device} and a \l{EventType} and holds the parameters It is bound to a \l{Device} and a \l{EventType} and holds the parameters
for the event that happened. for the event that happened.

View File

@ -3,7 +3,7 @@
\brief Describes a \l{Event} for a \l{Device}. \brief Describes a \l{Event} for a \l{Device}.
\ingroup types \ingroup types
\inmodule libhive \inmodule libguh
\sa Event \sa Event
*/ */

View File

@ -2,7 +2,7 @@
\class Gpio \class Gpio
\brief The Gpio class helps to interact with the gpio pins of the Raspberry Pi. \brief The Gpio class helps to interact with the gpio pins of the Raspberry Pi.
\inmodule libhive \inmodule libguh
The Raspberry Pi offers lower-level interfaces (GPIO's) intended to connect more directly The Raspberry Pi offers lower-level interfaces (GPIO's) intended to connect more directly
with chips and subsystem modules. General Purpose Input/Output (a.k.a. GPIO) is a generic with chips and subsystem modules. General Purpose Input/Output (a.k.a. GPIO) is a generic

View File

@ -1,4 +1,4 @@
TARGET = hive TARGET = guh
TEMPLATE = lib TEMPLATE = lib
CONFIG += c++11 CONFIG += c++11

View File

@ -4,7 +4,7 @@
\l{http://tech.jolowe.se/home-automation-rf-protocols/} \l{http://tech.jolowe.se/home-automation-rf-protocols/}
\inmodule libhive \inmodule libguh
*/ */

View File

@ -3,7 +3,7 @@
\brief Holds the parameters of a State of a \l{Device}. \brief Holds the parameters of a State of a \l{Device}.
\ingroup types \ingroup types
\inmodule libhive \inmodule libguh
States hold the state values for devices. A State is associated to a \l{Device} by States hold the state values for devices. A State is associated to a \l{Device} by
the \l{State::deviceId()} and represents the value of a state described in a \l{StateType} the \l{State::deviceId()} and represents the value of a state described in a \l{StateType}

View File

@ -3,7 +3,7 @@
\brief Describes a \l{State} for a \l{Device}. \brief Describes a \l{State} for a \l{Device}.
\ingroup types \ingroup types
\inmodule libhive \inmodule libguh
\sa State \sa State
*/ */

View File

@ -1,14 +0,0 @@
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
)
set(libhive_SRCS
device.cpp
deviceclass.cpp
deviceplugin.cpp
)
add_library(libhive ${libhive_SRCS})
qt5_use_modules(libhive Network)

View File

@ -1,6 +1,6 @@
include (../../plugins.pri) include (../../plugins.pri)
TARGET = $$qtLibraryTarget(hive_devicepluginconrad) TARGET = $$qtLibraryTarget(guh_devicepluginconrad)
SOURCES += \ SOURCES += \
devicepluginconrad.cpp devicepluginconrad.cpp

View File

@ -7,7 +7,7 @@ class DevicePluginConrad : public DevicePlugin
{ {
Q_OBJECT Q_OBJECT
Q_PLUGIN_METADATA(IID "org.hiveyourhome.DevicePlugin" FILE "devicepluginconrad.json") Q_PLUGIN_METADATA(IID "org.guhyourhome.DevicePlugin" FILE "devicepluginconrad.json")
Q_INTERFACES(DevicePlugin) Q_INTERFACES(DevicePlugin)
public: public:

View File

@ -7,7 +7,7 @@ class DevicePluginElro : public DevicePlugin
{ {
Q_OBJECT Q_OBJECT
Q_PLUGIN_METADATA(IID "org.hiveyourhome.DevicePlugin" FILE "devicepluginelro.json") Q_PLUGIN_METADATA(IID "org.guhyourhome.DevicePlugin" FILE "devicepluginelro.json")
Q_INTERFACES(DevicePlugin) Q_INTERFACES(DevicePlugin)
public: public:

View File

@ -1,6 +1,6 @@
include(../../plugins.pri) include(../../plugins.pri)
TARGET = $$qtLibraryTarget(hive_devicepluginelro) TARGET = $$qtLibraryTarget(guh_devicepluginelro)
SOURCES += \ SOURCES += \
devicepluginelro.cpp devicepluginelro.cpp

View File

@ -7,7 +7,7 @@ class DevicePluginIntertechno : public DevicePlugin
{ {
Q_OBJECT Q_OBJECT
Q_PLUGIN_METADATA(IID "org.hiveyourhome.DevicePlugin" FILE "devicepluginintertechno.json") Q_PLUGIN_METADATA(IID "org.guhyourhome.DevicePlugin" FILE "devicepluginintertechno.json")
Q_INTERFACES(DevicePlugin) Q_INTERFACES(DevicePlugin)
public: public:

View File

@ -1,6 +1,6 @@
include (../../plugins.pri) include (../../plugins.pri)
TARGET = $$qtLibraryTarget(hive_devicepluginintertechno) TARGET = $$qtLibraryTarget(guh_devicepluginintertechno)
SOURCES += \ SOURCES += \
devicepluginintertechno.cpp devicepluginintertechno.cpp

View File

@ -8,7 +8,7 @@ class DevicePluginMeisterAnker : public DevicePlugin
{ {
Q_OBJECT Q_OBJECT
Q_PLUGIN_METADATA(IID "org.hiveyourhome.DevicePlugin" FILE "devicepluginmeisteranker.json") Q_PLUGIN_METADATA(IID "org.guhyourhome.DevicePlugin" FILE "devicepluginmeisteranker.json")
Q_INTERFACES(DevicePlugin) Q_INTERFACES(DevicePlugin)
public: public:

View File

@ -1,6 +1,6 @@
include(../../plugins.pri) include(../../plugins.pri)
TARGET = $$qtLibraryTarget(hive_devicepluginmeisteranker) TARGET = $$qtLibraryTarget(guh_devicepluginmeisteranker)
SOURCES += \ SOURCES += \
devicepluginmeisteranker.cpp devicepluginmeisteranker.cpp

View File

@ -74,7 +74,7 @@ QUuid DevicePluginWifiDetector::pluginId() const
return pluginUuid; return pluginUuid;
} }
void DevicePluginWifiDetector::hiveTimer() void DevicePluginWifiDetector::guhTimer()
{ {
QProcess *p = new QProcess(this); QProcess *p = new QProcess(this);
connect(p, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(processFinished(int,QProcess::ExitStatus))); connect(p, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(processFinished(int,QProcess::ExitStatus)));

View File

@ -9,7 +9,7 @@ class DevicePluginWifiDetector : public DevicePlugin
{ {
Q_OBJECT Q_OBJECT
Q_PLUGIN_METADATA(IID "org.hiveyourhome.DevicePlugin" FILE "devicepluginwifidetector.json") Q_PLUGIN_METADATA(IID "org.guhyourhome.DevicePlugin" FILE "devicepluginwifidetector.json")
Q_INTERFACES(DevicePlugin) Q_INTERFACES(DevicePlugin)
public: public:
@ -21,7 +21,7 @@ public:
QString pluginName() const override; QString pluginName() const override;
QUuid pluginId() const override; QUuid pluginId() const override;
void hiveTimer() override; void guhTimer() override;
private slots: private slots:
void processFinished(int exitCode, QProcess::ExitStatus exitStatus); void processFinished(int exitCode, QProcess::ExitStatus exitStatus);

View File

@ -1,6 +1,6 @@
include(../../plugins.pri) include(../../plugins.pri)
TARGET = $$qtLibraryTarget(hive_devicepluginwifidetector) TARGET = $$qtLibraryTarget(guh_devicepluginwifidetector)
SOURCES += \ SOURCES += \
devicepluginwifidetector.cpp devicepluginwifidetector.cpp

View File

@ -1,6 +1,6 @@
TEMPLATE = lib TEMPLATE = lib
CONFIG += plugin static c++11 CONFIG += plugin static c++11
INCLUDEPATH += ../../../libhive INCLUDEPATH += ../../../libguh
LIBS += -L../../../libhive -lhive LIBS += -L../../../libguh -lguh

View File

@ -1,10 +1,10 @@
#!/bin/sh #!/bin/sh
CODE_DIR=Hive CODE_DIR=guh
BUILD_DIR=builddir BUILD_DIR=builddir
USER=root USER=root
USER_ID=0 USER_ID=0
PASSWORD=hive PASSWORD=guh
BINARY=hive BINARY=guh
TARGET_IP=${TARGET_IP-10.10.10.125} TARGET_IP=${TARGET_IP-10.10.10.125}
TARGET_SSH_PORT=22 TARGET_SSH_PORT=22
TARGET_DEBUG_PORT=3768 TARGET_DEBUG_PORT=3768
@ -57,7 +57,7 @@ build() {
} }
run() { run() {
exec_with_ssh "LD_LIBRARY_PATH=$CODE_DIR/$BUILD_DIR/libhive $CODE_DIR/$BUILD_DIR/server/$BINARY" exec_with_ssh "LD_LIBRARY_PATH=$CODE_DIR/$BUILD_DIR/libguh $CODE_DIR/$BUILD_DIR/server/$BINARY"
} }
set -- `getopt -n$0 -u -a --longoptions="setup,gdbhelp" "sgh" "$@"` set -- `getopt -n$0 -u -a --longoptions="setup,gdbhelp" "sgh" "$@"`

View File

@ -1,17 +0,0 @@
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/libhive
)
set(hive_SRCS
main.cpp
hivecore.cpp
jsonrpcserver.cpp
tcpserver.cpp
radio433.cpp
)
add_executable(hive ${hive_SRCS})
target_link_libraries(hive libhive)
qt5_use_modules(hive Network)

View File

@ -1,47 +1,47 @@
/*! /*!
\class HiveCore \class GuhCore
\brief The main entry point for the Hive Server and the place where all the messages are dispatched. \brief The main entry point for the Guh Server and the place where all the messages are dispatched.
\ingroup core \ingroup core
\inmodule server \inmodule server
HiveCore is a singleton instance and the main entry point of the Hive daemon. It is responsible to GuhCore is a singleton instance and the main entry point of the Guh daemon. It is responsible to
instantiate, set up and connect all the other components. instantiate, set up and connect all the other components.
*/ */
#include "hivecore.h" #include "guhcore.h"
#include "jsonrpcserver.h" #include "jsonrpcserver.h"
#include "devicemanager.h" #include "devicemanager.h"
#include "ruleengine.h" #include "ruleengine.h"
#include <QDebug> #include <QDebug>
HiveCore* HiveCore::s_instance = 0; GuhCore* GuhCore::s_instance = 0;
/*! Returns a pointer to the single \l{HiveCore} instance.*/ /*! Returns a pointer to the single \l{GuhCore} instance.*/
HiveCore *HiveCore::instance() GuhCore *GuhCore::instance()
{ {
if (!s_instance) { if (!s_instance) {
s_instance = new HiveCore(); s_instance = new GuhCore();
} }
return s_instance; return s_instance;
} }
/*! Returns a pointer to the \l{DeviceManager} instance owned by HiveCore.*/ /*! Returns a pointer to the \l{DeviceManager} instance owned by GuhCore.*/
DeviceManager *HiveCore::deviceManager() const DeviceManager *GuhCore::deviceManager() const
{ {
return m_deviceManager; return m_deviceManager;
} }
/*! Returns a pointer to the \l{RuleEngine} instance owned by HiveCore.*/ /*! Returns a pointer to the \l{RuleEngine} instance owned by GuhCore.*/
RuleEngine *HiveCore::ruleEngine() const RuleEngine *GuhCore::ruleEngine() const
{ {
return m_ruleEngine; return m_ruleEngine;
} }
/*! Constructs HiveCore with the given \a parent. This is private. /*! Constructs GuhCore with the given \a parent. This is private.
Use \l{HiveCore::instance()} to access the single instance.*/ Use \l{GuhCore::instance()} to access the single instance.*/
HiveCore::HiveCore(QObject *parent) : GuhCore::GuhCore(QObject *parent) :
QObject(parent) QObject(parent)
{ {
@ -60,13 +60,13 @@ HiveCore::HiveCore(QObject *parent) :
qDebug() << "*****************************************"; qDebug() << "*****************************************";
m_jsonServer = new JsonRPCServer(this); m_jsonServer = new JsonRPCServer(this);
connect(m_deviceManager, &DeviceManager::emitEvent, this, &HiveCore::gotSignal); connect(m_deviceManager, &DeviceManager::emitEvent, this, &GuhCore::gotSignal);
} }
/*! Connected to the DeviceManager's emitEvent signal. Events received in /*! Connected to the DeviceManager's emitEvent signal. Events received in
here will be evaluated by the \l{RuleEngine} and the according \l{Action}{Actions} are executed.*/ here will be evaluated by the \l{RuleEngine} and the according \l{Action}{Actions} are executed.*/
void HiveCore::gotSignal(const Event &event) void GuhCore::gotSignal(const Event &event)
{ {
foreach (const Action &action, m_ruleEngine->evaluateEvent(event)) { foreach (const Action &action, m_ruleEngine->evaluateEvent(event)) {
m_deviceManager->executeAction(action); m_deviceManager->executeAction(action);

View File

@ -10,18 +10,18 @@ class JsonRPCServer;
class DeviceManager; class DeviceManager;
class RuleEngine; class RuleEngine;
class HiveCore : public QObject class GuhCore : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
static HiveCore* instance(); static GuhCore* instance();
DeviceManager* deviceManager() const; DeviceManager* deviceManager() const;
RuleEngine *ruleEngine() const; RuleEngine *ruleEngine() const;
private: private:
explicit HiveCore(QObject *parent = 0); explicit GuhCore(QObject *parent = 0);
static HiveCore *s_instance; static GuhCore *s_instance;
JsonRPCServer *m_jsonServer; JsonRPCServer *m_jsonServer;
DeviceManager *m_deviceManager; DeviceManager *m_deviceManager;

View File

@ -1,7 +1,7 @@
#include "actionhandler.h" #include "actionhandler.h"
#include "devicemanager.h" #include "devicemanager.h"
#include "hivecore.h" #include "guhcore.h"
#include "action.h" #include "action.h"
#include <QDebug> #include <QDebug>
@ -42,7 +42,7 @@ QVariantMap ActionHandler::ExecuteAction(const QVariantMap &params)
QVariantMap returns; QVariantMap returns;
DeviceManager::DeviceError error = HiveCore::instance()->deviceManager()->executeAction(action); DeviceManager::DeviceError error = GuhCore::instance()->deviceManager()->executeAction(action);
switch (error) { switch (error) {
case DeviceManager::DeviceErrorNoError: case DeviceManager::DeviceErrorNoError:

View File

@ -1,7 +1,7 @@
#include "devicehandler.h" #include "devicehandler.h"
#include "deviceclass.h" #include "deviceclass.h"
#include "hivecore.h" #include "guhcore.h"
#include "devicemanager.h" #include "devicemanager.h"
#include "deviceplugin.h" #include "deviceplugin.h"
@ -85,7 +85,7 @@ QVariantMap DeviceHandler::GetSupportedDevices(const QVariantMap &params) const
Q_UNUSED(params) Q_UNUSED(params)
QVariantMap returns; QVariantMap returns;
QVariantList supportedDeviceList; QVariantList supportedDeviceList;
foreach (const DeviceClass &deviceClass, HiveCore::instance()->deviceManager()->supportedDevices()) { foreach (const DeviceClass &deviceClass, GuhCore::instance()->deviceManager()->supportedDevices()) {
supportedDeviceList.append(JsonTypes::packDeviceClass(deviceClass)); supportedDeviceList.append(JsonTypes::packDeviceClass(deviceClass));
} }
returns.insert("deviceClasses", supportedDeviceList); returns.insert("deviceClasses", supportedDeviceList);
@ -97,7 +97,7 @@ QVariantMap DeviceHandler::GetPlugins(const QVariantMap &params) const
Q_UNUSED(params) Q_UNUSED(params)
QVariantMap returns; QVariantMap returns;
QVariantList plugins; QVariantList plugins;
foreach (DevicePlugin *plugin, HiveCore::instance()->deviceManager()->plugins()) { foreach (DevicePlugin *plugin, GuhCore::instance()->deviceManager()->plugins()) {
QVariantMap pluginMap; QVariantMap pluginMap;
pluginMap.insert("id", plugin->pluginId()); pluginMap.insert("id", plugin->pluginId());
pluginMap.insert("name", plugin->pluginName()); pluginMap.insert("name", plugin->pluginName());
@ -112,7 +112,7 @@ QVariantMap DeviceHandler::SetPluginParams(const QVariantMap &params)
{ {
QUuid pluginId = params.value("pluginId").toUuid(); QUuid pluginId = params.value("pluginId").toUuid();
QVariantMap pluginParams = params.value("pluginParams").toMap(); QVariantMap pluginParams = params.value("pluginParams").toMap();
HiveCore::instance()->deviceManager()->plugin(pluginId)->setConfiguration(pluginParams); GuhCore::instance()->deviceManager()->plugin(pluginId)->setConfiguration(pluginParams);
return QVariantMap(); return QVariantMap();
} }
@ -120,7 +120,7 @@ QVariantMap DeviceHandler::AddConfiguredDevice(const QVariantMap &params)
{ {
QUuid deviceClass = params.value("deviceClassId").toUuid(); QUuid deviceClass = params.value("deviceClassId").toUuid();
QVariantMap deviceParams = params.value("deviceParams").toMap(); QVariantMap deviceParams = params.value("deviceParams").toMap();
DeviceManager::DeviceError status = HiveCore::instance()->deviceManager()->addConfiguredDevice(deviceClass, deviceParams); DeviceManager::DeviceError status = GuhCore::instance()->deviceManager()->addConfiguredDevice(deviceClass, deviceParams);
QVariantMap returns; QVariantMap returns;
switch(status) { switch(status) {
case DeviceManager::DeviceErrorNoError: case DeviceManager::DeviceErrorNoError:
@ -150,7 +150,7 @@ QVariantMap DeviceHandler::GetConfiguredDevices(const QVariantMap &params) const
Q_UNUSED(params) Q_UNUSED(params)
QVariantMap returns; QVariantMap returns;
QVariantList configuredDeviceList; QVariantList configuredDeviceList;
foreach (Device *device, HiveCore::instance()->deviceManager()->configuredDevices()) { foreach (Device *device, GuhCore::instance()->deviceManager()->configuredDevices()) {
configuredDeviceList.append(JsonTypes::packDevice(device)); configuredDeviceList.append(JsonTypes::packDevice(device));
} }
returns.insert("devices", configuredDeviceList); returns.insert("devices", configuredDeviceList);
@ -162,7 +162,7 @@ QVariantMap DeviceHandler::GetEventTypes(const QVariantMap &params) const
QVariantMap returns; QVariantMap returns;
QVariantList eventList; QVariantList eventList;
DeviceClass deviceClass = HiveCore::instance()->deviceManager()->findDeviceClass(params.value("deviceClassId").toUuid()); DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(params.value("deviceClassId").toUuid());
foreach (const EventType &eventType, deviceClass.events()) { foreach (const EventType &eventType, deviceClass.events()) {
eventList.append(JsonTypes::packEventType(eventType)); eventList.append(JsonTypes::packEventType(eventType));
} }
@ -175,7 +175,7 @@ QVariantMap DeviceHandler::GetActionTypes(const QVariantMap &params) const
QVariantMap returns; QVariantMap returns;
QVariantList actionList; QVariantList actionList;
DeviceClass deviceClass = HiveCore::instance()->deviceManager()->findDeviceClass(params.value("deviceClassId").toUuid()); DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(params.value("deviceClassId").toUuid());
foreach (const ActionType &actionType, deviceClass.actions()) { foreach (const ActionType &actionType, deviceClass.actions()) {
actionList.append(JsonTypes::packActionType(actionType)); actionList.append(JsonTypes::packActionType(actionType));
} }

View File

@ -8,7 +8,7 @@
#endif #endif
#include "jsonhandler.h" #include "jsonhandler.h"
#include "hivecore.h" #include "guhcore.h"
#include "devicemanager.h" #include "devicemanager.h"
#include "deviceplugin.h" #include "deviceplugin.h"
#include "deviceclass.h" #include "deviceclass.h"

View File

@ -1,6 +1,6 @@
#include "ruleshandler.h" #include "ruleshandler.h"
#include "hivecore.h" #include "guhcore.h"
#include "ruleengine.h" #include "ruleengine.h"
#include <QDebug> #include <QDebug>
@ -45,7 +45,7 @@ QVariantMap RulesHandler::GetRules(const QVariantMap &params)
Q_UNUSED(params) Q_UNUSED(params)
QVariantList rulesList; QVariantList rulesList;
foreach (const Rule &rule, HiveCore::instance()->ruleEngine()->rules()) { foreach (const Rule &rule, GuhCore::instance()->ruleEngine()->rules()) {
qDebug() << "got rule" << rule.id(); qDebug() << "got rule" << rule.id();
QVariantMap ruleMap = JsonTypes::packRule(rule); QVariantMap ruleMap = JsonTypes::packRule(rule);
rulesList.append(ruleMap); rulesList.append(ruleMap);
@ -82,7 +82,7 @@ QVariantMap RulesHandler::AddRule(const QVariantMap &params)
return returns; return returns;
} }
switch(HiveCore::instance()->ruleEngine()->addRule(event, actions)) { switch(GuhCore::instance()->ruleEngine()->addRule(event, actions)) {
case RuleEngine::RuleErrorNoError: case RuleEngine::RuleErrorNoError:
returns.insert("success", true); returns.insert("success", true);
break; break;
@ -105,7 +105,7 @@ QVariantMap RulesHandler::RemoveRule(const QVariantMap &params)
{ {
QVariantMap returns; QVariantMap returns;
QUuid ruleId = params.value("ruleId").toUuid(); QUuid ruleId = params.value("ruleId").toUuid();
switch (HiveCore::instance()->ruleEngine()->removeRule(ruleId)) { switch (GuhCore::instance()->ruleEngine()->removeRule(ruleId)) {
case RuleEngine::RuleErrorNoError: case RuleEngine::RuleErrorNoError:
returns.insert("success", true); returns.insert("success", true);
break; break;

View File

@ -1,5 +1,5 @@
#include <QCoreApplication> #include <QCoreApplication>
#include <hivecore.h> #include <guhcore.h>
#include <QtPlugin> #include <QtPlugin>
@ -13,9 +13,9 @@ int main(int argc, char *argv[])
{ {
QCoreApplication a(argc, argv); QCoreApplication a(argc, argv);
a.setOrganizationName("hiveyourhome"); a.setOrganizationName("guhyourhome");
HiveCore::instance(); GuhCore::instance();
return a.exec(); return a.exec();
} }

View File

@ -34,7 +34,7 @@
#include "ruleengine.h" #include "ruleengine.h"
#include "hivecore.h" #include "guhcore.h"
#include "devicemanager.h" #include "devicemanager.h"
#include "device.h" #include "device.h"
@ -45,7 +45,7 @@
#include <QCoreApplication> #include <QCoreApplication>
/*! Constructs the RuleEngine with the given \a parent. Although it wouldn't harm to have multiple RuleEngines, there is one /*! Constructs the RuleEngine with the given \a parent. Although it wouldn't harm to have multiple RuleEngines, there is one
instance available from \l{HiveCore}. This one should be used instead of creating multiple ones. instance available from \l{GuhCore}. This one should be used instead of creating multiple ones.
*/ */
RuleEngine::RuleEngine(QObject *parent) : RuleEngine::RuleEngine(QObject *parent) :
QObject(parent) QObject(parent)
@ -104,7 +104,7 @@ QList<Action> RuleEngine::evaluateEvent(const Event &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).states()) {
Device *device = HiveCore::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;
@ -136,14 +136,14 @@ RuleEngine::RuleError RuleEngine::addRule(const Event &event, const QList<Action
RuleEngine::RuleError RuleEngine::addRule(const Event &event, const QList<State> &states, const QList<Action> &actions) RuleEngine::RuleError RuleEngine::addRule(const Event &event, const QList<State> &states, const QList<Action> &actions)
{ {
qDebug() << "adding rule: Event:" << event.eventTypeId() << "with" << actions.count() << "actions"; qDebug() << "adding rule: Event:" << event.eventTypeId() << "with" << actions.count() << "actions";
DeviceClass eventDeviceClass = HiveCore::instance()->deviceManager()->findDeviceClassforEvent(event.eventTypeId()); DeviceClass eventDeviceClass = GuhCore::instance()->deviceManager()->findDeviceClassforEvent(event.eventTypeId());
Device *device = HiveCore::instance()->deviceManager()->findConfiguredDevice(event.deviceId()); Device *device = GuhCore::instance()->deviceManager()->findConfiguredDevice(event.deviceId());
if (!device) { if (!device) {
qWarning() << "Cannot create rule. No configured device for eventTypeId" << event.eventTypeId(); qWarning() << "Cannot create rule. No configured device for eventTypeId" << event.eventTypeId();
return RuleErrorDeviceNotFound; return RuleErrorDeviceNotFound;
} }
DeviceClass deviceClass = HiveCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId()); DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId());
qDebug() << "found deviceClass" << deviceClass.name(); qDebug() << "found deviceClass" << deviceClass.name();
bool eventTypeFound = false; bool eventTypeFound = false;

View File

@ -1,4 +1,4 @@
SOURCES += $$top_srcdir/server/hivecore.cpp \ SOURCES += $$top_srcdir/server/guhcore.cpp \
$$top_srcdir/server/tcpserver.cpp \ $$top_srcdir/server/tcpserver.cpp \
$$top_srcdir/server/ruleengine.cpp \ $$top_srcdir/server/ruleengine.cpp \
$$top_srcdir/server/rule.cpp \ $$top_srcdir/server/rule.cpp \
@ -9,7 +9,7 @@ SOURCES += $$top_srcdir/server/hivecore.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
HEADERS += $$top_srcdir/server/hivecore.h \ HEADERS += $$top_srcdir/server/guhcore.h \
$$top_srcdir/server/tcpserver.h \ $$top_srcdir/server/tcpserver.h \
$$top_srcdir/server/ruleengine.h \ $$top_srcdir/server/ruleengine.h \
$$top_srcdir/server/rule.h \ $$top_srcdir/server/rule.h \

View File

@ -1,7 +1,7 @@
TARGET = hive TARGET = guh
TEMPLATE = app TEMPLATE = app
INCLUDEPATH += ../libhive jsonrpc INCLUDEPATH += ../libguh jsonrpc
target.path = /usr/bin target.path = /usr/bin
INSTALLS += target INSTALLS += target
@ -9,14 +9,14 @@ INSTALLS += target
QT += network QT += network
CONFIG += c++11 CONFIG += c++11
LIBS += -L$$top_builddir/libhive/ -lhive LIBS += -L$$top_builddir/libguh/ -lguh
include(server.pri) include(server.pri)
SOURCES += main.cpp SOURCES += main.cpp
# FIXME: Drop this and link them dynamically # FIXME: Drop this and link them dynamically
LIBS += -L../plugins/deviceplugins/elro/ -lhive_devicepluginelro LIBS += -L../plugins/deviceplugins/elro/ -lguh_devicepluginelro
LIBS += -L../plugins/deviceplugins/intertechno/ -lhive_devicepluginintertechno LIBS += -L../plugins/deviceplugins/intertechno/ -lguh_devicepluginintertechno
LIBS += -L../plugins/deviceplugins/meisteranker/ -lhive_devicepluginmeisteranker LIBS += -L../plugins/deviceplugins/meisteranker/ -lguh_devicepluginmeisteranker
LIBS += -L../plugins/deviceplugins/wifidetector/ -lhive_devicepluginwifidetector LIBS += -L../plugins/deviceplugins/wifidetector/ -lguh_devicepluginwifidetector
LIBS += -L../plugins/deviceplugins/conrad -lhive_devicepluginconrad LIBS += -L../plugins/deviceplugins/conrad -lguh_devicepluginconrad

View File

@ -1,11 +1,11 @@
TARGET = hivetests TARGET = guhtests
QT += testlib network QT += testlib network
CONFIG += testcase c++11 CONFIG += testcase c++11
DEFINES += TESTING_ENABLED DEFINES += TESTING_ENABLED
INCLUDEPATH += $$top_srcdir/server/ $$top_srcdir/server/jsonrpc $$top_srcdir/libhive $$top_srcdir/tests/auto/ INCLUDEPATH += $$top_srcdir/server/ $$top_srcdir/server/jsonrpc $$top_srcdir/libguh $$top_srcdir/tests/auto/
LIBS += -L$$top_builddir/libhive/ -lhive LIBS += -L$$top_builddir/libguh/ -lguh
QMAKE_LFLAGS += -Wl,--rpath=$$top_builddir/libhive QMAKE_LFLAGS += -Wl,--rpath=$$top_builddir/libguh
include($$top_srcdir/server/server.pri) include($$top_srcdir/server/server.pri)
@ -14,4 +14,4 @@ SOURCES += testjsonrpc.cpp \
HEADERS += mocktcpserver.h HEADERS += mocktcpserver.h
LIBS += -L../mocks/mockdeviceplugin/ -lhive_devicepluginmockdevice LIBS += -L../mocks/mockdeviceplugin/ -lguh_devicepluginmockdevice

View File

@ -1,4 +1,4 @@
#include "hivecore.h" #include "guhcore.h"
#include "devicemanager.h" #include "devicemanager.h"
#include "mocktcpserver.h" #include "mocktcpserver.h"
@ -33,17 +33,17 @@ private:
void TestJSONRPC::initTestcase() void TestJSONRPC::initTestcase()
{ {
QCoreApplication::instance()->setOrganizationName("hiveyourhome-test"); QCoreApplication::instance()->setOrganizationName("guhyourhome-test");
qDebug() << "creating core"; qDebug() << "creating core";
HiveCore::instance(); GuhCore::instance();
qDebug() << "creating spy"; qDebug() << "creating spy";
// Wait for the DeviceManager to signal that it has loaded plugins and everything // Wait for the DeviceManager to signal that it has loaded plugins and everything
QSignalSpy spy(HiveCore::instance()->deviceManager(), SIGNAL(loaded())); QSignalSpy spy(GuhCore::instance()->deviceManager(), SIGNAL(loaded()));
QVERIFY(spy.isValid()); QVERIFY(spy.isValid());
QVERIFY(spy.wait()); QVERIFY(spy.wait());
// If Hive should create more than one TcpServer at some point, this needs to be updated. // If Guh should create more than one TcpServer at some point, this needs to be updated.
QCOMPARE(MockTcpServer::servers().count(), 1); QCOMPARE(MockTcpServer::servers().count(), 1);
m_mockTcpServer = MockTcpServer::servers().first(); m_mockTcpServer = MockTcpServer::servers().first();
m_clientId = QUuid::createUuid(); m_clientId = QUuid::createUuid();

View File

@ -74,7 +74,7 @@ QUuid DevicePluginMockDevice::pluginId() const
return pluginUuid; return pluginUuid;
} }
void DevicePluginMockDevice::hiveTimer() void DevicePluginMockDevice::guhTimer()
{ {
} }

View File

@ -7,7 +7,7 @@ class DevicePluginMockDevice: public DevicePlugin
{ {
Q_OBJECT Q_OBJECT
Q_PLUGIN_METADATA(IID "org.hiveyourhome.DevicePlugin" FILE "devicepluginmockdevice.json") Q_PLUGIN_METADATA(IID "org.guhyourhome.DevicePlugin" FILE "devicepluginmockdevice.json")
Q_INTERFACES(DevicePlugin) Q_INTERFACES(DevicePlugin)
public: public:
@ -19,7 +19,7 @@ public:
QString pluginName() const override; QString pluginName() const override;
QUuid pluginId() const override; QUuid pluginId() const override;
void hiveTimer() override; void guhTimer() override;
}; };

View File

@ -1,6 +1,6 @@
include($$top_srcdir/plugins/plugins.pri) include($$top_srcdir/plugins/plugins.pri)
TARGET = $$qtLibraryTarget(hive_devicepluginmockdevice) TARGET = $$qtLibraryTarget(guh_devicepluginmockdevice)
SOURCES += \ SOURCES += \
devicepluginmockdevice.cpp devicepluginmockdevice.cpp