Add a ScriptEngine
This commit is contained in:
parent
f562503d6d
commit
4c0c95b1a8
@ -26,6 +26,7 @@ HEADERS += nymeacore.h \
|
|||||||
ruleengine/stateevaluator.h \
|
ruleengine/stateevaluator.h \
|
||||||
ruleengine/ruleaction.h \
|
ruleengine/ruleaction.h \
|
||||||
ruleengine/ruleactionparam.h \
|
ruleengine/ruleactionparam.h \
|
||||||
|
scriptengine/scriptengine.h \
|
||||||
transportinterface.h \
|
transportinterface.h \
|
||||||
nymeaconfiguration.h \
|
nymeaconfiguration.h \
|
||||||
servermanager.h \
|
servermanager.h \
|
||||||
@ -101,6 +102,7 @@ SOURCES += nymeacore.cpp \
|
|||||||
ruleengine/stateevaluator.cpp \
|
ruleengine/stateevaluator.cpp \
|
||||||
ruleengine/ruleaction.cpp \
|
ruleengine/ruleaction.cpp \
|
||||||
ruleengine/ruleactionparam.cpp \
|
ruleengine/ruleactionparam.cpp \
|
||||||
|
scriptengine/scriptengine.cpp \
|
||||||
transportinterface.cpp \
|
transportinterface.cpp \
|
||||||
nymeaconfiguration.cpp \
|
nymeaconfiguration.cpp \
|
||||||
servermanager.cpp \
|
servermanager.cpp \
|
||||||
|
|||||||
@ -98,6 +98,7 @@
|
|||||||
#include "tagging/tagsstorage.h"
|
#include "tagging/tagsstorage.h"
|
||||||
#include "platform/platform.h"
|
#include "platform/platform.h"
|
||||||
#include "experiences/experiencemanager.h"
|
#include "experiences/experiencemanager.h"
|
||||||
|
#include "scriptengine/scriptengine.h"
|
||||||
|
|
||||||
#include "devices/devicemanagerimplementation.h"
|
#include "devices/devicemanagerimplementation.h"
|
||||||
#include "devices/device.h"
|
#include "devices/device.h"
|
||||||
@ -160,6 +161,8 @@ void NymeaCore::init() {
|
|||||||
qCDebug(dcApplication) << "Creating Rule Engine";
|
qCDebug(dcApplication) << "Creating Rule Engine";
|
||||||
m_ruleEngine = new RuleEngine(this);
|
m_ruleEngine = new RuleEngine(this);
|
||||||
|
|
||||||
|
new ScriptEngine(m_deviceManager, this);
|
||||||
|
|
||||||
qCDebug(dcApplication()) << "Creating Tags Storage";
|
qCDebug(dcApplication()) << "Creating Tags Storage";
|
||||||
m_tagsStorage = new TagsStorage(m_deviceManager, m_ruleEngine, this);
|
m_tagsStorage = new TagsStorage(m_deviceManager, m_ruleEngine, this);
|
||||||
|
|
||||||
|
|||||||
22
libnymea-core/scriptengine/scriptengine.cpp
Normal file
22
libnymea-core/scriptengine/scriptengine.cpp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#include "scriptengine.h"
|
||||||
|
#include "devices/devicemanager.h"
|
||||||
|
|
||||||
|
#include <QQmlApplicationEngine>
|
||||||
|
|
||||||
|
namespace nymeaserver {
|
||||||
|
|
||||||
|
ScriptEngine::ScriptEngine(DeviceManager *deviceManager, QObject *parent) : QObject(parent),
|
||||||
|
m_deviceManager(deviceManager)
|
||||||
|
{
|
||||||
|
loadScripts();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScriptEngine::loadScripts()
|
||||||
|
{
|
||||||
|
QString fileName = "/home/micha/Develop/nymea/tests/script.qml";
|
||||||
|
QQmlApplicationEngine *engine = new QQmlApplicationEngine(this);
|
||||||
|
|
||||||
|
engine->load(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
27
libnymea-core/scriptengine/scriptengine.h
Normal file
27
libnymea-core/scriptengine/scriptengine.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#ifndef SCRIPTENGINE_H
|
||||||
|
#define SCRIPTENGINE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
class DeviceManager;
|
||||||
|
|
||||||
|
namespace nymeaserver {
|
||||||
|
|
||||||
|
class ScriptEngine : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit ScriptEngine(DeviceManager *deviceManager, QObject *parent = nullptr);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
private:
|
||||||
|
void loadScripts();
|
||||||
|
|
||||||
|
private:
|
||||||
|
DeviceManager *m_deviceManager = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // SCRIPTENGINE_H
|
||||||
Reference in New Issue
Block a user