Effects added to configuration file

Former-commit-id: 2ff4700ee5d5bc3a7dd5a29ecd35c1c9dd189873
This commit is contained in:
johan 2013-11-30 12:42:08 +01:00
parent 554bc30c35
commit ae1bd7d254
5 changed files with 36 additions and 12 deletions

View File

@ -11,7 +11,7 @@ class EffectEngine : public QObject
Q_OBJECT Q_OBJECT
public: public:
EffectEngine(Hyperion * hyperion); EffectEngine(Hyperion * hyperion, const Json::Value & jsonEffectConfig);
virtual ~EffectEngine(); virtual ~EffectEngine();
std::list<std::string> getEffects() const; std::list<std::string> getEffects() const;

View File

@ -1,16 +1,14 @@
// Qt includes
#include <QMetaType>
// Python includes // Python includes
#include <Python.h> #include <Python.h>
// Qt includes
#include <QMetaType>
// effect engine includes // effect engine includes
#include <effectengine/EffectEngine.h> #include <effectengine/EffectEngine.h>
#include "Effect.h" #include "Effect.h"
//static PyThreadState *_mainThreadState = 0; EffectEngine::EffectEngine(Hyperion * hyperion, const Json::Value & jsonEffectConfig) :
EffectEngine::EffectEngine(Hyperion * hyperion) :
_hyperion(hyperion), _hyperion(hyperion),
_availableEffects(), _availableEffects(),
_activeEffects(), _activeEffects(),
@ -23,7 +21,12 @@ EffectEngine::EffectEngine(Hyperion * hyperion) :
connect(_hyperion, SIGNAL(allChannelsCleared()), this, SLOT(allChannelsCleared())); connect(_hyperion, SIGNAL(allChannelsCleared()), this, SLOT(allChannelsCleared()));
// read all effects // read all effects
_availableEffects["test"] = {"test.py", "{\"speed\":0.2}"}; std::vector<std::string> effectNames = jsonEffectConfig.getMemberNames();
for (const std::string & name : effectNames)
{
const Json::Value & info = jsonEffectConfig[name];
_availableEffects[name] = {info["script"].asString(), Json::FastWriter().write(info["args"])};
}
// initialize the python interpreter // initialize the python interpreter
std::cout << "Initializing Python interpreter" << std::endl; std::cout << "Initializing Python interpreter" << std::endl;

View File

@ -270,7 +270,7 @@ Hyperion::Hyperion(const Json::Value &jsonConfig) :
QObject::connect(&_timer, SIGNAL(timeout()), this, SLOT(update())); QObject::connect(&_timer, SIGNAL(timeout()), this, SLOT(update()));
// create the effect engine // create the effect engine
_effectEngine = new EffectEngine(this); _effectEngine = new EffectEngine(this, jsonConfig["effects"]);
// initialize the leds // initialize the leds
update(); update();

View File

@ -200,6 +200,27 @@
"additionalProperties" : false "additionalProperties" : false
} }
}, },
"effects" :
{
"type" : "object",
"required" : false,
"additionalProperties" :
{
"type" : "object",
"required" : false,
"properties" :
{
"script" : {
"type" : "string",
"required" : true
},
"args" : {
"type" : "object",
"required" : false
}
}
}
},
"blackborderdetector" : "blackborderdetector" :
{ {
"type" : "object", "type" : "object",

View File

@ -176,7 +176,7 @@ void JsonClientConnection::handleServerInfoCommand(const Json::Value &)
Json::Value & info = result["info"]; Json::Value & info = result["info"];
// collect priority information // collect priority information
Json::Value & priorities = info["priorities"]; Json::Value & priorities = info["priorities"] = Json::Value(Json::arrayValue);
uint64_t now = QDateTime::currentMSecsSinceEpoch(); uint64_t now = QDateTime::currentMSecsSinceEpoch();
QList<int> activePriorities = _hyperion->getActivePriorities(); QList<int> activePriorities = _hyperion->getActivePriorities();
foreach (int priority, activePriorities) { foreach (int priority, activePriorities) {
@ -190,7 +190,7 @@ void JsonClientConnection::handleServerInfoCommand(const Json::Value &)
} }
// collect transform information // collect transform information
Json::Value & transform = info["transform"]; Json::Value & transform = info["transform"] = Json::Value(Json::objectValue);
transform["saturationGain"] = _hyperion->getTransform(Hyperion::SATURATION_GAIN, Hyperion::INVALID); transform["saturationGain"] = _hyperion->getTransform(Hyperion::SATURATION_GAIN, Hyperion::INVALID);
transform["valueGain"] = _hyperion->getTransform(Hyperion::VALUE_GAIN, Hyperion::INVALID); transform["valueGain"] = _hyperion->getTransform(Hyperion::VALUE_GAIN, Hyperion::INVALID);
Json::Value & threshold = transform["threshold"]; Json::Value & threshold = transform["threshold"];
@ -211,7 +211,7 @@ void JsonClientConnection::handleServerInfoCommand(const Json::Value &)
whitelevel.append(_hyperion->getTransform(Hyperion::WHITELEVEL, Hyperion::BLUE)); whitelevel.append(_hyperion->getTransform(Hyperion::WHITELEVEL, Hyperion::BLUE));
// collect effect info // collect effect info
Json::Value & effects = info["effects"]; Json::Value & effects = info["effects"] = Json::Value(Json::arrayValue);
std::list<std::string> effectNames = _hyperion->getEffects(); std::list<std::string> effectNames = _hyperion->getEffects();
for (const std::string & name : effectNames) for (const std::string & name : effectNames)
{ {