mirror of https://github.com/nymea/nymea.git
hive -> guh
parent
61a7a68ee0
commit
be4ee5c14d
|
|
@ -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)
|
||||
|
||||
11
Hive.pro
11
Hive.pro
|
|
@ -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
|
||||
|
|
@ -3,8 +3,8 @@
|
|||
\title All Modules
|
||||
|
||||
\table 80%
|
||||
\row \li \l{libhive} \li Common data types and plugin interfaces
|
||||
\row \li \l{Hive server} \li The Hive server daemon implementation
|
||||
\row \li \l{libguh} \li Common data types and plugin interfaces
|
||||
\row \li \l{guh server} \li The guh server daemon implementation
|
||||
\endtable
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -1,30 +1,30 @@
|
|||
/*!
|
||||
\page index.html
|
||||
\title Hive Developer Documentation
|
||||
\title guh Developer Documentation
|
||||
|
||||
\section1 Summary
|
||||
The Hive backend service consists of three main modules:
|
||||
The guh backend service consists of three main modules:
|
||||
|
||||
\list
|
||||
\li \l{libhive}
|
||||
\li \l{libguh}
|
||||
\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}
|
||||
\endlist
|
||||
\li \l{Hive server}
|
||||
\li \l{guh server}
|
||||
\list
|
||||
\li \l{Hive Core}
|
||||
\li \l{guh Core}
|
||||
\li \l{JSONRPC Interface}
|
||||
\li \l{Rules}
|
||||
\endlist
|
||||
\li \l{Plugins}.
|
||||
\list
|
||||
\li \l{RF 433 MHz} (TODO: is actually in libhive)
|
||||
\li \l{RF 433 MHz} (TODO: is actually in libguh)
|
||||
\endlist
|
||||
\endlist
|
||||
|
||||
\section2 Quicklinks
|
||||
\list
|
||||
\li \l{All Hive Classes}
|
||||
\li \l{All guh Classes}
|
||||
\endlist
|
||||
*/
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
/*!
|
||||
\page guhcore-index.html
|
||||
\title guh Core
|
||||
|
||||
\annotatedlist core
|
||||
*/
|
||||
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
/*!
|
||||
\module server
|
||||
\title Hive server
|
||||
The Hive server is the instance that communicates with the hardware and provides a JSONRPC interface
|
||||
\title guh server
|
||||
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:
|
||||
|
||||
\section3 Hive core
|
||||
\section3 guh core
|
||||
\annotatedlist core
|
||||
|
||||
\section3 JSRONRPC Interface
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
/*!
|
||||
\page hivecore-index.html
|
||||
\title Hive Core
|
||||
|
||||
\annotatedlist core
|
||||
*/
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/*!
|
||||
\module libhive
|
||||
\title libhive
|
||||
\module libguh
|
||||
\title libguh
|
||||
|
||||
\section1 Types
|
||||
\annotatedlist types
|
||||
|
|
@ -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
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
\brief Holds information required to execute an action described by a \l{ActionType}.
|
||||
|
||||
\ingroup types
|
||||
\inmodule libhive
|
||||
\inmodule libguh
|
||||
|
||||
It is bound to a \l{Device} and an \l{ActionType} and holds the parameters
|
||||
for the execution of the action.
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
\brief Describes an \l{Action} for a \l{Device}.
|
||||
|
||||
\ingroup types
|
||||
\inmodule libhive
|
||||
\inmodule libguh
|
||||
|
||||
ActionTypes are contained in \l{DeviceClass} templates returned
|
||||
by \l{DevicePlugin}{DevicePlugins} in order to describe the hardware supported
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
\brief A Device represents a installed and configured hardware device.
|
||||
|
||||
\ingroup devices
|
||||
\inmodule libhive
|
||||
\inmodule libguh
|
||||
|
||||
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.
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
\brief Describes \l{Device}{Devices}.
|
||||
|
||||
\ingroup devices
|
||||
\inmodule libhive
|
||||
\inmodule libguh
|
||||
|
||||
It holds information general information about devices and their vendors and
|
||||
describes what actions, events and states a device supports. As this is
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
\brief The main entry point when interacting with \l{Device}{Devices}
|
||||
|
||||
\ingroup devices
|
||||
\inmodule libhive
|
||||
\inmodule libguh
|
||||
|
||||
The DeviceManager holds all information about supported and configured Devices in the system.
|
||||
|
||||
|
|
@ -50,7 +50,7 @@
|
|||
|
||||
/*! \fn void DeviceManager::emitEvent(const Event &event)
|
||||
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
|
||||
or similar, but you should never directly react to this in a \l{DevicePlugin}.
|
||||
*/
|
||||
|
|
@ -69,8 +69,8 @@
|
|||
#include <QSettings>
|
||||
#include <QStringList>
|
||||
|
||||
/*! Constructs the DeviceManager with the given \a parent. There should only be one DeviceManager in the system created by \l{HiveCore}.
|
||||
Use \c HiveCore::instance()->deviceManager() instead to access the DeviceManager.
|
||||
/*! Constructs the DeviceManager with the given \a parent. There should only be one DeviceManager in the system created by \l{GuhCore}.
|
||||
Use \c GuhCore::instance()->deviceManager() instead to access the DeviceManager.
|
||||
*/
|
||||
DeviceManager::DeviceManager(QObject *parent) :
|
||||
QObject(parent),
|
||||
|
|
@ -288,7 +288,7 @@ void DeviceManager::timerEvent()
|
|||
DeviceClass deviceClass = m_supportedDevices.value(device->deviceClassId());
|
||||
DevicePlugin *plugin = m_devicePlugins.value(deviceClass.pluginId());
|
||||
if (plugin->requiredHardware().testFlag(HardwareResourceTimer)) {
|
||||
plugin->hiveTimer();
|
||||
plugin->guhTimer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
\brief This is the base class interface for device plugins.
|
||||
|
||||
\ingroup devices
|
||||
\inmodule libhive
|
||||
\inmodule libguh
|
||||
|
||||
When implementing a new plugin, start by subclassing this and implementing the following
|
||||
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
|
||||
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
|
||||
on timer events.
|
||||
*/
|
||||
|
|
@ -54,7 +54,7 @@ pure virtual methods: \l{DevicePlugin::pluginName()}, \l{DevicePlugin::pluginId(
|
|||
\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.
|
||||
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
|
||||
create a \l{Event} complying to that \l{EventType} and emit it here.
|
||||
*/
|
||||
|
|
@ -28,7 +28,7 @@ public:
|
|||
|
||||
// Hardware input
|
||||
virtual void radioData(QList<int> rawData) {Q_UNUSED(rawData)}
|
||||
virtual void hiveTimer() {}
|
||||
virtual void guhTimer() {}
|
||||
|
||||
virtual QVariantMap configuration() const;
|
||||
virtual void setConfiguration(const QVariantMap &configuration);
|
||||
|
|
@ -52,6 +52,6 @@ private:
|
|||
|
||||
friend class DeviceManager;
|
||||
};
|
||||
Q_DECLARE_INTERFACE(DevicePlugin, "org.hiveyourhome.DevicePlugin")
|
||||
Q_DECLARE_INTERFACE(DevicePlugin, "org.guhyourhome.DevicePlugin")
|
||||
|
||||
#endif
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
\brief Holds information required to emit a event described by a \l{EventType}.
|
||||
|
||||
\ingroup types
|
||||
\inmodule libhive
|
||||
\inmodule libguh
|
||||
|
||||
It is bound to a \l{Device} and a \l{EventType} and holds the parameters
|
||||
for the event that happened.
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
\brief Describes a \l{Event} for a \l{Device}.
|
||||
|
||||
\ingroup types
|
||||
\inmodule libhive
|
||||
\inmodule libguh
|
||||
|
||||
\sa Event
|
||||
*/
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
\class Gpio
|
||||
\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
|
||||
with chips and subsystem modules. General Purpose Input/Output (a.k.a. GPIO) is a generic
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
TARGET = hive
|
||||
TARGET = guh
|
||||
TEMPLATE = lib
|
||||
|
||||
CONFIG += c++11
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
\l{http://tech.jolowe.se/home-automation-rf-protocols/}
|
||||
|
||||
\inmodule libhive
|
||||
\inmodule libguh
|
||||
|
||||
*/
|
||||
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
\brief Holds the parameters of a State of a \l{Device}.
|
||||
|
||||
\ingroup types
|
||||
\inmodule libhive
|
||||
\inmodule libguh
|
||||
|
||||
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}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
\brief Describes a \l{State} for a \l{Device}.
|
||||
|
||||
\ingroup types
|
||||
\inmodule libhive
|
||||
\inmodule libguh
|
||||
|
||||
\sa State
|
||||
*/
|
||||
|
|
@ -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)
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
include (../../plugins.pri)
|
||||
|
||||
TARGET = $$qtLibraryTarget(hive_devicepluginconrad)
|
||||
TARGET = $$qtLibraryTarget(guh_devicepluginconrad)
|
||||
|
||||
SOURCES += \
|
||||
devicepluginconrad.cpp
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class DevicePluginConrad : public DevicePlugin
|
|||
{
|
||||
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)
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class DevicePluginElro : public DevicePlugin
|
|||
{
|
||||
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)
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
include(../../plugins.pri)
|
||||
|
||||
TARGET = $$qtLibraryTarget(hive_devicepluginelro)
|
||||
TARGET = $$qtLibraryTarget(guh_devicepluginelro)
|
||||
|
||||
SOURCES += \
|
||||
devicepluginelro.cpp
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class DevicePluginIntertechno : public DevicePlugin
|
|||
{
|
||||
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)
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
include (../../plugins.pri)
|
||||
|
||||
TARGET = $$qtLibraryTarget(hive_devicepluginintertechno)
|
||||
TARGET = $$qtLibraryTarget(guh_devicepluginintertechno)
|
||||
|
||||
SOURCES += \
|
||||
devicepluginintertechno.cpp
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ class DevicePluginMeisterAnker : public DevicePlugin
|
|||
{
|
||||
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)
|
||||
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
include(../../plugins.pri)
|
||||
|
||||
TARGET = $$qtLibraryTarget(hive_devicepluginmeisteranker)
|
||||
TARGET = $$qtLibraryTarget(guh_devicepluginmeisteranker)
|
||||
|
||||
SOURCES += \
|
||||
devicepluginmeisteranker.cpp
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ QUuid DevicePluginWifiDetector::pluginId() const
|
|||
return pluginUuid;
|
||||
}
|
||||
|
||||
void DevicePluginWifiDetector::hiveTimer()
|
||||
void DevicePluginWifiDetector::guhTimer()
|
||||
{
|
||||
QProcess *p = new QProcess(this);
|
||||
connect(p, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(processFinished(int,QProcess::ExitStatus)));
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class DevicePluginWifiDetector : public DevicePlugin
|
|||
{
|
||||
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)
|
||||
|
||||
public:
|
||||
|
|
@ -21,7 +21,7 @@ public:
|
|||
QString pluginName() const override;
|
||||
QUuid pluginId() const override;
|
||||
|
||||
void hiveTimer() override;
|
||||
void guhTimer() override;
|
||||
|
||||
private slots:
|
||||
void processFinished(int exitCode, QProcess::ExitStatus exitStatus);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
include(../../plugins.pri)
|
||||
|
||||
TARGET = $$qtLibraryTarget(hive_devicepluginwifidetector)
|
||||
TARGET = $$qtLibraryTarget(guh_devicepluginwifidetector)
|
||||
|
||||
SOURCES += \
|
||||
devicepluginwifidetector.cpp
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
TEMPLATE = lib
|
||||
CONFIG += plugin static c++11
|
||||
|
||||
INCLUDEPATH += ../../../libhive
|
||||
LIBS += -L../../../libhive -lhive
|
||||
INCLUDEPATH += ../../../libguh
|
||||
LIBS += -L../../../libguh -lguh
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
#!/bin/sh
|
||||
CODE_DIR=Hive
|
||||
CODE_DIR=guh
|
||||
BUILD_DIR=builddir
|
||||
USER=root
|
||||
USER_ID=0
|
||||
PASSWORD=hive
|
||||
BINARY=hive
|
||||
PASSWORD=guh
|
||||
BINARY=guh
|
||||
TARGET_IP=${TARGET_IP-10.10.10.125}
|
||||
TARGET_SSH_PORT=22
|
||||
TARGET_DEBUG_PORT=3768
|
||||
|
|
@ -57,7 +57,7 @@ build() {
|
|||
}
|
||||
|
||||
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" "$@"`
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
@ -1,47 +1,47 @@
|
|||
/*!
|
||||
\class HiveCore
|
||||
\brief The main entry point for the Hive Server and the place where all the messages are dispatched.
|
||||
\class GuhCore
|
||||
\brief The main entry point for the Guh Server and the place where all the messages are dispatched.
|
||||
|
||||
\ingroup core
|
||||
\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.
|
||||
*/
|
||||
|
||||
#include "hivecore.h"
|
||||
#include "guhcore.h"
|
||||
#include "jsonrpcserver.h"
|
||||
#include "devicemanager.h"
|
||||
#include "ruleengine.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
HiveCore* HiveCore::s_instance = 0;
|
||||
GuhCore* GuhCore::s_instance = 0;
|
||||
|
||||
/*! Returns a pointer to the single \l{HiveCore} instance.*/
|
||||
HiveCore *HiveCore::instance()
|
||||
/*! Returns a pointer to the single \l{GuhCore} instance.*/
|
||||
GuhCore *GuhCore::instance()
|
||||
{
|
||||
if (!s_instance) {
|
||||
s_instance = new HiveCore();
|
||||
s_instance = new GuhCore();
|
||||
}
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
/*! Returns a pointer to the \l{DeviceManager} instance owned by HiveCore.*/
|
||||
DeviceManager *HiveCore::deviceManager() const
|
||||
/*! Returns a pointer to the \l{DeviceManager} instance owned by GuhCore.*/
|
||||
DeviceManager *GuhCore::deviceManager() const
|
||||
{
|
||||
return m_deviceManager;
|
||||
}
|
||||
|
||||
/*! Returns a pointer to the \l{RuleEngine} instance owned by HiveCore.*/
|
||||
RuleEngine *HiveCore::ruleEngine() const
|
||||
/*! Returns a pointer to the \l{RuleEngine} instance owned by GuhCore.*/
|
||||
RuleEngine *GuhCore::ruleEngine() const
|
||||
{
|
||||
return m_ruleEngine;
|
||||
}
|
||||
|
||||
/*! Constructs HiveCore with the given \a parent. This is private.
|
||||
Use \l{HiveCore::instance()} to access the single instance.*/
|
||||
HiveCore::HiveCore(QObject *parent) :
|
||||
/*! Constructs GuhCore with the given \a parent. This is private.
|
||||
Use \l{GuhCore::instance()} to access the single instance.*/
|
||||
GuhCore::GuhCore(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
|
||||
|
|
@ -60,13 +60,13 @@ HiveCore::HiveCore(QObject *parent) :
|
|||
qDebug() << "*****************************************";
|
||||
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
|
||||
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)) {
|
||||
m_deviceManager->executeAction(action);
|
||||
|
|
@ -10,18 +10,18 @@ class JsonRPCServer;
|
|||
class DeviceManager;
|
||||
class RuleEngine;
|
||||
|
||||
class HiveCore : public QObject
|
||||
class GuhCore : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static HiveCore* instance();
|
||||
static GuhCore* instance();
|
||||
|
||||
DeviceManager* deviceManager() const;
|
||||
RuleEngine *ruleEngine() const;
|
||||
|
||||
private:
|
||||
explicit HiveCore(QObject *parent = 0);
|
||||
static HiveCore *s_instance;
|
||||
explicit GuhCore(QObject *parent = 0);
|
||||
static GuhCore *s_instance;
|
||||
|
||||
JsonRPCServer *m_jsonServer;
|
||||
DeviceManager *m_deviceManager;
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#include "actionhandler.h"
|
||||
|
||||
#include "devicemanager.h"
|
||||
#include "hivecore.h"
|
||||
#include "guhcore.h"
|
||||
#include "action.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
|
@ -42,7 +42,7 @@ QVariantMap ActionHandler::ExecuteAction(const QVariantMap ¶ms)
|
|||
|
||||
|
||||
QVariantMap returns;
|
||||
DeviceManager::DeviceError error = HiveCore::instance()->deviceManager()->executeAction(action);
|
||||
DeviceManager::DeviceError error = GuhCore::instance()->deviceManager()->executeAction(action);
|
||||
|
||||
switch (error) {
|
||||
case DeviceManager::DeviceErrorNoError:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include "devicehandler.h"
|
||||
|
||||
#include "deviceclass.h"
|
||||
#include "hivecore.h"
|
||||
#include "guhcore.h"
|
||||
#include "devicemanager.h"
|
||||
#include "deviceplugin.h"
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ QVariantMap DeviceHandler::GetSupportedDevices(const QVariantMap ¶ms) const
|
|||
Q_UNUSED(params)
|
||||
QVariantMap returns;
|
||||
QVariantList supportedDeviceList;
|
||||
foreach (const DeviceClass &deviceClass, HiveCore::instance()->deviceManager()->supportedDevices()) {
|
||||
foreach (const DeviceClass &deviceClass, GuhCore::instance()->deviceManager()->supportedDevices()) {
|
||||
supportedDeviceList.append(JsonTypes::packDeviceClass(deviceClass));
|
||||
}
|
||||
returns.insert("deviceClasses", supportedDeviceList);
|
||||
|
|
@ -97,7 +97,7 @@ QVariantMap DeviceHandler::GetPlugins(const QVariantMap ¶ms) const
|
|||
Q_UNUSED(params)
|
||||
QVariantMap returns;
|
||||
QVariantList plugins;
|
||||
foreach (DevicePlugin *plugin, HiveCore::instance()->deviceManager()->plugins()) {
|
||||
foreach (DevicePlugin *plugin, GuhCore::instance()->deviceManager()->plugins()) {
|
||||
QVariantMap pluginMap;
|
||||
pluginMap.insert("id", plugin->pluginId());
|
||||
pluginMap.insert("name", plugin->pluginName());
|
||||
|
|
@ -112,7 +112,7 @@ QVariantMap DeviceHandler::SetPluginParams(const QVariantMap ¶ms)
|
|||
{
|
||||
QUuid pluginId = params.value("pluginId").toUuid();
|
||||
QVariantMap pluginParams = params.value("pluginParams").toMap();
|
||||
HiveCore::instance()->deviceManager()->plugin(pluginId)->setConfiguration(pluginParams);
|
||||
GuhCore::instance()->deviceManager()->plugin(pluginId)->setConfiguration(pluginParams);
|
||||
return QVariantMap();
|
||||
}
|
||||
|
||||
|
|
@ -120,7 +120,7 @@ QVariantMap DeviceHandler::AddConfiguredDevice(const QVariantMap ¶ms)
|
|||
{
|
||||
QUuid deviceClass = params.value("deviceClassId").toUuid();
|
||||
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;
|
||||
switch(status) {
|
||||
case DeviceManager::DeviceErrorNoError:
|
||||
|
|
@ -150,7 +150,7 @@ QVariantMap DeviceHandler::GetConfiguredDevices(const QVariantMap ¶ms) const
|
|||
Q_UNUSED(params)
|
||||
QVariantMap returns;
|
||||
QVariantList configuredDeviceList;
|
||||
foreach (Device *device, HiveCore::instance()->deviceManager()->configuredDevices()) {
|
||||
foreach (Device *device, GuhCore::instance()->deviceManager()->configuredDevices()) {
|
||||
configuredDeviceList.append(JsonTypes::packDevice(device));
|
||||
}
|
||||
returns.insert("devices", configuredDeviceList);
|
||||
|
|
@ -162,7 +162,7 @@ QVariantMap DeviceHandler::GetEventTypes(const QVariantMap ¶ms) const
|
|||
QVariantMap returns;
|
||||
|
||||
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()) {
|
||||
eventList.append(JsonTypes::packEventType(eventType));
|
||||
}
|
||||
|
|
@ -175,7 +175,7 @@ QVariantMap DeviceHandler::GetActionTypes(const QVariantMap ¶ms) const
|
|||
QVariantMap returns;
|
||||
|
||||
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()) {
|
||||
actionList.append(JsonTypes::packActionType(actionType));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#endif
|
||||
#include "jsonhandler.h"
|
||||
|
||||
#include "hivecore.h"
|
||||
#include "guhcore.h"
|
||||
#include "devicemanager.h"
|
||||
#include "deviceplugin.h"
|
||||
#include "deviceclass.h"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include "ruleshandler.h"
|
||||
|
||||
#include "hivecore.h"
|
||||
#include "guhcore.h"
|
||||
#include "ruleengine.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
|
@ -45,7 +45,7 @@ QVariantMap RulesHandler::GetRules(const QVariantMap ¶ms)
|
|||
Q_UNUSED(params)
|
||||
|
||||
QVariantList rulesList;
|
||||
foreach (const Rule &rule, HiveCore::instance()->ruleEngine()->rules()) {
|
||||
foreach (const Rule &rule, GuhCore::instance()->ruleEngine()->rules()) {
|
||||
qDebug() << "got rule" << rule.id();
|
||||
QVariantMap ruleMap = JsonTypes::packRule(rule);
|
||||
rulesList.append(ruleMap);
|
||||
|
|
@ -82,7 +82,7 @@ QVariantMap RulesHandler::AddRule(const QVariantMap ¶ms)
|
|||
return returns;
|
||||
}
|
||||
|
||||
switch(HiveCore::instance()->ruleEngine()->addRule(event, actions)) {
|
||||
switch(GuhCore::instance()->ruleEngine()->addRule(event, actions)) {
|
||||
case RuleEngine::RuleErrorNoError:
|
||||
returns.insert("success", true);
|
||||
break;
|
||||
|
|
@ -105,7 +105,7 @@ QVariantMap RulesHandler::RemoveRule(const QVariantMap ¶ms)
|
|||
{
|
||||
QVariantMap returns;
|
||||
QUuid ruleId = params.value("ruleId").toUuid();
|
||||
switch (HiveCore::instance()->ruleEngine()->removeRule(ruleId)) {
|
||||
switch (GuhCore::instance()->ruleEngine()->removeRule(ruleId)) {
|
||||
case RuleEngine::RuleErrorNoError:
|
||||
returns.insert("success", true);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#include <QCoreApplication>
|
||||
#include <hivecore.h>
|
||||
#include <guhcore.h>
|
||||
|
||||
#include <QtPlugin>
|
||||
|
||||
|
|
@ -13,9 +13,9 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
QCoreApplication a(argc, argv);
|
||||
|
||||
a.setOrganizationName("hiveyourhome");
|
||||
a.setOrganizationName("guhyourhome");
|
||||
|
||||
HiveCore::instance();
|
||||
GuhCore::instance();
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
#include "ruleengine.h"
|
||||
|
||||
#include "hivecore.h"
|
||||
#include "guhcore.h"
|
||||
#include "devicemanager.h"
|
||||
#include "device.h"
|
||||
|
||||
|
|
@ -45,7 +45,7 @@
|
|||
#include <QCoreApplication>
|
||||
|
||||
/*! 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) :
|
||||
QObject(parent)
|
||||
|
|
@ -104,7 +104,7 @@ QList<Action> RuleEngine::evaluateEvent(const Event &event)
|
|||
bool statesMatching = true;
|
||||
qDebug() << "checking 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) {
|
||||
qWarning() << "Device referenced in rule cannot be found";
|
||||
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)
|
||||
{
|
||||
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) {
|
||||
qWarning() << "Cannot create rule. No configured device for eventTypeId" << event.eventTypeId();
|
||||
return RuleErrorDeviceNotFound;
|
||||
}
|
||||
DeviceClass deviceClass = HiveCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId());
|
||||
DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(device->deviceClassId());
|
||||
qDebug() << "found deviceClass" << deviceClass.name();
|
||||
|
||||
bool eventTypeFound = false;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
SOURCES += $$top_srcdir/server/hivecore.cpp \
|
||||
SOURCES += $$top_srcdir/server/guhcore.cpp \
|
||||
$$top_srcdir/server/tcpserver.cpp \
|
||||
$$top_srcdir/server/ruleengine.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/actionhandler.cpp
|
||||
|
||||
HEADERS += $$top_srcdir/server/hivecore.h \
|
||||
HEADERS += $$top_srcdir/server/guhcore.h \
|
||||
$$top_srcdir/server/tcpserver.h \
|
||||
$$top_srcdir/server/ruleengine.h \
|
||||
$$top_srcdir/server/rule.h \
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
TARGET = hive
|
||||
TARGET = guh
|
||||
TEMPLATE = app
|
||||
|
||||
INCLUDEPATH += ../libhive jsonrpc
|
||||
INCLUDEPATH += ../libguh jsonrpc
|
||||
|
||||
target.path = /usr/bin
|
||||
INSTALLS += target
|
||||
|
|
@ -9,14 +9,14 @@ INSTALLS += target
|
|||
QT += network
|
||||
CONFIG += c++11
|
||||
|
||||
LIBS += -L$$top_builddir/libhive/ -lhive
|
||||
LIBS += -L$$top_builddir/libguh/ -lguh
|
||||
|
||||
include(server.pri)
|
||||
SOURCES += main.cpp
|
||||
|
||||
# FIXME: Drop this and link them dynamically
|
||||
LIBS += -L../plugins/deviceplugins/elro/ -lhive_devicepluginelro
|
||||
LIBS += -L../plugins/deviceplugins/intertechno/ -lhive_devicepluginintertechno
|
||||
LIBS += -L../plugins/deviceplugins/meisteranker/ -lhive_devicepluginmeisteranker
|
||||
LIBS += -L../plugins/deviceplugins/wifidetector/ -lhive_devicepluginwifidetector
|
||||
LIBS += -L../plugins/deviceplugins/conrad -lhive_devicepluginconrad
|
||||
LIBS += -L../plugins/deviceplugins/elro/ -lguh_devicepluginelro
|
||||
LIBS += -L../plugins/deviceplugins/intertechno/ -lguh_devicepluginintertechno
|
||||
LIBS += -L../plugins/deviceplugins/meisteranker/ -lguh_devicepluginmeisteranker
|
||||
LIBS += -L../plugins/deviceplugins/wifidetector/ -lguh_devicepluginwifidetector
|
||||
LIBS += -L../plugins/deviceplugins/conrad -lguh_devicepluginconrad
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
TARGET = hivetests
|
||||
TARGET = guhtests
|
||||
QT += testlib network
|
||||
CONFIG += testcase c++11
|
||||
DEFINES += TESTING_ENABLED
|
||||
|
||||
INCLUDEPATH += $$top_srcdir/server/ $$top_srcdir/server/jsonrpc $$top_srcdir/libhive $$top_srcdir/tests/auto/
|
||||
LIBS += -L$$top_builddir/libhive/ -lhive
|
||||
QMAKE_LFLAGS += -Wl,--rpath=$$top_builddir/libhive
|
||||
INCLUDEPATH += $$top_srcdir/server/ $$top_srcdir/server/jsonrpc $$top_srcdir/libguh $$top_srcdir/tests/auto/
|
||||
LIBS += -L$$top_builddir/libguh/ -lguh
|
||||
QMAKE_LFLAGS += -Wl,--rpath=$$top_builddir/libguh
|
||||
|
||||
include($$top_srcdir/server/server.pri)
|
||||
|
||||
|
|
@ -14,4 +14,4 @@ SOURCES += testjsonrpc.cpp \
|
|||
|
||||
HEADERS += mocktcpserver.h
|
||||
|
||||
LIBS += -L../mocks/mockdeviceplugin/ -lhive_devicepluginmockdevice
|
||||
LIBS += -L../mocks/mockdeviceplugin/ -lguh_devicepluginmockdevice
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "hivecore.h"
|
||||
#include "guhcore.h"
|
||||
#include "devicemanager.h"
|
||||
#include "mocktcpserver.h"
|
||||
|
||||
|
|
@ -33,17 +33,17 @@ private:
|
|||
|
||||
void TestJSONRPC::initTestcase()
|
||||
{
|
||||
QCoreApplication::instance()->setOrganizationName("hiveyourhome-test");
|
||||
QCoreApplication::instance()->setOrganizationName("guhyourhome-test");
|
||||
qDebug() << "creating core";
|
||||
HiveCore::instance();
|
||||
GuhCore::instance();
|
||||
qDebug() << "creating spy";
|
||||
|
||||
// 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.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);
|
||||
m_mockTcpServer = MockTcpServer::servers().first();
|
||||
m_clientId = QUuid::createUuid();
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ QUuid DevicePluginMockDevice::pluginId() const
|
|||
return pluginUuid;
|
||||
}
|
||||
|
||||
void DevicePluginMockDevice::hiveTimer()
|
||||
void DevicePluginMockDevice::guhTimer()
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class DevicePluginMockDevice: public DevicePlugin
|
|||
{
|
||||
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)
|
||||
|
||||
public:
|
||||
|
|
@ -19,7 +19,7 @@ public:
|
|||
QString pluginName() const override;
|
||||
QUuid pluginId() const override;
|
||||
|
||||
void hiveTimer() override;
|
||||
void guhTimer() override;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
include($$top_srcdir/plugins/plugins.pri)
|
||||
|
||||
TARGET = $$qtLibraryTarget(hive_devicepluginmockdevice)
|
||||
TARGET = $$qtLibraryTarget(guh_devicepluginmockdevice)
|
||||
|
||||
SOURCES += \
|
||||
devicepluginmockdevice.cpp
|
||||
|
|
|
|||
Loading…
Reference in New Issue