2013-11-26 21:38:24 +01:00
|
|
|
// Python includes
|
|
|
|
#include <Python.h>
|
|
|
|
|
2013-12-11 21:58:59 +01:00
|
|
|
// Stl includes
|
|
|
|
#include <fstream>
|
|
|
|
|
2013-11-30 12:42:08 +01:00
|
|
|
// Qt includes
|
2013-12-11 21:58:59 +01:00
|
|
|
#include <QResource>
|
2013-11-30 12:42:08 +01:00
|
|
|
#include <QMetaType>
|
2013-12-11 21:58:59 +01:00
|
|
|
#include <QFile>
|
|
|
|
#include <QDir>
|
|
|
|
|
|
|
|
// hyperion util includes
|
2016-10-09 22:22:17 +02:00
|
|
|
#include <utils/jsonschema/QJsonSchemaChecker.h>
|
2016-09-03 15:54:33 +02:00
|
|
|
#include <utils/FileUtils.h>
|
2016-10-10 18:29:54 +02:00
|
|
|
#include <utils/Components.h>
|
2013-11-30 12:42:08 +01:00
|
|
|
|
2013-11-26 21:38:24 +01:00
|
|
|
// effect engine includes
|
2013-11-24 16:10:48 +01:00
|
|
|
#include <effectengine/EffectEngine.h>
|
2013-11-26 21:38:24 +01:00
|
|
|
#include "Effect.h"
|
2016-06-12 22:27:24 +02:00
|
|
|
#include "HyperionConfig.h"
|
2013-11-24 16:10:48 +01:00
|
|
|
|
2016-10-09 22:22:17 +02:00
|
|
|
EffectEngine::EffectEngine(Hyperion * hyperion, const QJsonObject & jsonEffectConfig)
|
2016-08-08 00:17:00 +02:00
|
|
|
: _hyperion(hyperion)
|
2016-11-20 18:41:10 +01:00
|
|
|
, _effectConfig(jsonEffectConfig)
|
2016-08-08 00:17:00 +02:00
|
|
|
, _availableEffects()
|
|
|
|
, _activeEffects()
|
|
|
|
, _mainThreadState(nullptr)
|
|
|
|
, _log(Logger::getInstance("EFFECTENGINE"))
|
2013-11-24 16:10:48 +01:00
|
|
|
{
|
2016-09-13 11:51:16 +02:00
|
|
|
Q_INIT_RESOURCE(EffectEngine);
|
2013-11-29 23:22:49 +01:00
|
|
|
qRegisterMetaType<std::vector<ColorRgb>>("std::vector<ColorRgb>");
|
2016-10-10 18:29:54 +02:00
|
|
|
qRegisterMetaType<hyperion::Components>("hyperion::Components");
|
2013-11-29 23:22:49 +01:00
|
|
|
|
2013-11-24 16:10:48 +01:00
|
|
|
// connect the Hyperion channel clear feedback
|
|
|
|
connect(_hyperion, SIGNAL(channelCleared(int)), this, SLOT(channelCleared(int)));
|
|
|
|
connect(_hyperion, SIGNAL(allChannelsCleared()), this, SLOT(allChannelsCleared()));
|
|
|
|
|
|
|
|
// read all effects
|
2016-11-20 18:41:10 +01:00
|
|
|
readEffects();
|
2016-05-24 22:14:45 +02:00
|
|
|
|
2013-11-26 21:38:24 +01:00
|
|
|
// initialize the python interpreter
|
2016-06-23 13:48:49 +02:00
|
|
|
Debug(_log,"Initializing Python interpreter");
|
2014-02-26 18:10:17 +01:00
|
|
|
Effect::registerHyperionExtensionModule();
|
2013-11-26 21:38:24 +01:00
|
|
|
Py_InitializeEx(0);
|
|
|
|
PyEval_InitThreads(); // Create the GIL
|
2013-11-29 23:22:49 +01:00
|
|
|
_mainThreadState = PyEval_SaveThread();
|
2013-11-24 16:10:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
EffectEngine::~EffectEngine()
|
|
|
|
{
|
2013-11-26 21:38:24 +01:00
|
|
|
// clean up the Python interpreter
|
2016-06-23 13:48:49 +02:00
|
|
|
Debug(_log, "Cleaning up Python interpreter");
|
2013-11-29 23:22:49 +01:00
|
|
|
PyEval_RestoreThread(_mainThreadState);
|
|
|
|
Py_Finalize();
|
2013-11-24 16:10:48 +01:00
|
|
|
}
|
|
|
|
|
2016-04-24 17:07:31 +02:00
|
|
|
const std::list<ActiveEffectDefinition> &EffectEngine::getActiveEffects()
|
|
|
|
{
|
|
|
|
_availableActiveEffects.clear();
|
|
|
|
|
|
|
|
for (Effect * effect : _activeEffects)
|
|
|
|
{
|
|
|
|
ActiveEffectDefinition activeEffectDefinition;
|
2016-10-09 22:22:17 +02:00
|
|
|
activeEffectDefinition.script = effect->getScript();
|
|
|
|
activeEffectDefinition.name = effect->getName();
|
2016-04-24 17:07:31 +02:00
|
|
|
activeEffectDefinition.priority = effect->getPriority();
|
|
|
|
activeEffectDefinition.timeout = effect->getTimeout();
|
|
|
|
activeEffectDefinition.args = effect->getArgs();
|
|
|
|
_availableActiveEffects.push_back(activeEffectDefinition);
|
|
|
|
}
|
|
|
|
|
|
|
|
return _availableActiveEffects;
|
|
|
|
}
|
|
|
|
|
2016-09-13 11:51:16 +02:00
|
|
|
bool EffectEngine::loadEffectDefinition(const QString &path, const QString &effectConfigFile, EffectDefinition & effectDefinition)
|
2013-12-11 21:58:59 +01:00
|
|
|
{
|
2016-10-09 22:22:17 +02:00
|
|
|
Logger * log = Logger::getInstance("EFFECTENGINE");
|
|
|
|
|
2016-09-13 11:51:16 +02:00
|
|
|
QString fileName = path + QDir::separator() + effectConfigFile;
|
2016-10-09 22:22:17 +02:00
|
|
|
QJsonParseError error;
|
|
|
|
|
|
|
|
// ---------- Read the effect json config file ----------
|
|
|
|
|
2016-09-13 11:51:16 +02:00
|
|
|
QFile file(fileName);
|
|
|
|
if (!file.open(QIODevice::ReadOnly))
|
2013-12-11 21:58:59 +01:00
|
|
|
{
|
2016-09-13 11:51:16 +02:00
|
|
|
Error( log, "Effect file '%s' could not be loaded", fileName.toUtf8().constData());
|
2013-12-11 21:58:59 +01:00
|
|
|
return false;
|
|
|
|
}
|
2016-10-09 22:22:17 +02:00
|
|
|
|
2016-09-13 11:51:16 +02:00
|
|
|
QByteArray fileContent = file.readAll();
|
2016-10-09 22:22:17 +02:00
|
|
|
QJsonDocument configEffect = QJsonDocument::fromJson(fileContent, &error);
|
2016-09-13 11:51:16 +02:00
|
|
|
|
2016-10-09 22:22:17 +02:00
|
|
|
if (error.error != QJsonParseError::NoError)
|
2013-12-11 21:58:59 +01:00
|
|
|
{
|
2016-10-09 22:22:17 +02:00
|
|
|
// report to the user the failure and their locations in the document.
|
|
|
|
int errorLine(0), errorColumn(0);
|
|
|
|
|
|
|
|
for( int i=0, count=qMin( error.offset,fileContent.size()); i<count; ++i )
|
|
|
|
{
|
|
|
|
++errorColumn;
|
|
|
|
if(fileContent.at(i) == '\n' )
|
|
|
|
{
|
|
|
|
errorColumn = 0;
|
|
|
|
++errorLine;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Error( log, "Error while reading effect: '%s' at Line: '%i' , Column: %i", error.errorString().toUtf8().constData(), errorLine, errorColumn);
|
|
|
|
}
|
|
|
|
|
|
|
|
file.close();
|
|
|
|
|
|
|
|
// ---------- Read the effect json schema file ----------
|
|
|
|
|
|
|
|
Q_INIT_RESOURCE(EffectEngine);
|
|
|
|
QFile schema(":effect-schema");
|
|
|
|
|
|
|
|
if (!schema.open(QIODevice::ReadOnly))
|
|
|
|
{
|
|
|
|
Error( log, "Schema not found: %s", schema.errorString().toUtf8().constData());
|
2013-12-11 21:58:59 +01:00
|
|
|
return false;
|
|
|
|
}
|
2016-10-09 22:22:17 +02:00
|
|
|
|
|
|
|
QByteArray schemaContent = schema.readAll();
|
|
|
|
QJsonDocument configSchema = QJsonDocument::fromJson(schemaContent, &error);
|
|
|
|
|
|
|
|
if (error.error != QJsonParseError::NoError)
|
|
|
|
{
|
|
|
|
// report to the user the failure and their locations in the document.
|
|
|
|
int errorLine(0), errorColumn(0);
|
|
|
|
|
|
|
|
for( int i=0, count=qMin( error.offset,schemaContent.size()); i<count; ++i )
|
|
|
|
{
|
|
|
|
++errorColumn;
|
|
|
|
if(schemaContent.at(i) == '\n' )
|
|
|
|
{
|
|
|
|
errorColumn = 0;
|
|
|
|
++errorLine;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Error( log, "ERROR: Json schema wrong: '%s' at Line: '%i' , Column: %i", error.errorString().toUtf8().constData(), errorLine, errorColumn);
|
|
|
|
}
|
|
|
|
|
|
|
|
schema.close();
|
|
|
|
|
|
|
|
// ---------- validate effect config with effect schema ----------
|
|
|
|
|
|
|
|
QJsonSchemaChecker schemaChecker;
|
|
|
|
schemaChecker.setSchema(configSchema.object());
|
|
|
|
if (!schemaChecker.validate(configEffect.object()))
|
2013-12-11 21:58:59 +01:00
|
|
|
{
|
2017-03-04 22:17:42 +01:00
|
|
|
const QStringList & errors = schemaChecker.getMessages();
|
|
|
|
foreach (auto & error, errors)
|
2016-10-09 22:22:17 +02:00
|
|
|
{
|
2017-03-04 22:17:42 +01:00
|
|
|
Error( log, "Error while checking '%s':%s", QSTRING_CSTR(fileName), QSTRING_CSTR(error));
|
2013-12-11 21:58:59 +01:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-10-09 22:22:17 +02:00
|
|
|
// ---------- setup the definition ----------
|
|
|
|
|
2016-11-18 18:39:21 +01:00
|
|
|
effectDefinition.file = fileName;
|
2016-10-09 22:22:17 +02:00
|
|
|
QJsonObject config = configEffect.object();
|
|
|
|
QString scriptName = config["script"].toString();
|
|
|
|
effectDefinition.name = config["name"].toString();
|
|
|
|
if (scriptName.isEmpty())
|
2016-09-13 11:51:16 +02:00
|
|
|
return false;
|
2016-10-24 23:52:53 +02:00
|
|
|
|
|
|
|
QFile fileInfo(scriptName);
|
2016-09-13 11:51:16 +02:00
|
|
|
|
2016-10-09 22:22:17 +02:00
|
|
|
if (scriptName.mid(0, 1) == ":" )
|
2016-10-24 23:52:53 +02:00
|
|
|
{
|
|
|
|
(!fileInfo.exists())
|
|
|
|
? effectDefinition.script = ":/effects/"+scriptName.mid(1)
|
|
|
|
: effectDefinition.script = scriptName;
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
(!fileInfo.exists())
|
|
|
|
? effectDefinition.script = path + QDir::separator().toLatin1() + scriptName
|
|
|
|
: effectDefinition.script = scriptName;
|
|
|
|
}
|
2016-09-13 11:51:16 +02:00
|
|
|
|
2016-10-09 22:22:17 +02:00
|
|
|
effectDefinition.args = config["args"].toObject();
|
2013-12-11 21:58:59 +01:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-10-24 23:52:53 +02:00
|
|
|
bool EffectEngine::loadEffectSchema(const QString &path, const QString &effectSchemaFile, EffectSchema & effectSchema)
|
|
|
|
{
|
|
|
|
Logger * log = Logger::getInstance("EFFECTENGINE");
|
|
|
|
|
|
|
|
QString fileName = path + "schema/" + QDir::separator() + effectSchemaFile;
|
|
|
|
QJsonParseError error;
|
|
|
|
|
|
|
|
// ---------- Read the effect schema file ----------
|
|
|
|
|
|
|
|
QFile file(fileName);
|
|
|
|
if (!file.open(QIODevice::ReadOnly))
|
|
|
|
{
|
|
|
|
Error( log, "Effect schema '%s' could not be loaded", fileName.toUtf8().constData());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray fileContent = file.readAll();
|
|
|
|
QJsonDocument schemaEffect = QJsonDocument::fromJson(fileContent, &error);
|
|
|
|
|
|
|
|
if (error.error != QJsonParseError::NoError)
|
|
|
|
{
|
|
|
|
// report to the user the failure and their locations in the document.
|
|
|
|
int errorLine(0), errorColumn(0);
|
|
|
|
|
|
|
|
for( int i=0, count=qMin( error.offset,fileContent.size()); i<count; ++i )
|
|
|
|
{
|
|
|
|
++errorColumn;
|
|
|
|
if(fileContent.at(i) == '\n' )
|
|
|
|
{
|
|
|
|
errorColumn = 0;
|
|
|
|
++errorLine;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Error( log, "Error while reading effect schema: '%s' at Line: '%i' , Column: %i", error.errorString().toUtf8().constData(), errorLine, errorColumn);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
file.close();
|
|
|
|
|
|
|
|
// ---------- setup the definition ----------
|
|
|
|
|
|
|
|
QJsonObject tempSchemaEffect = schemaEffect.object();
|
|
|
|
QString scriptName = tempSchemaEffect["script"].toString();
|
|
|
|
effectSchema.schemaFile = fileName;
|
|
|
|
fileName = path + QDir::separator() + scriptName;
|
|
|
|
QFile pyFile(fileName);
|
|
|
|
|
|
|
|
if (scriptName.isEmpty() || !pyFile.open(QIODevice::ReadOnly))
|
|
|
|
{
|
|
|
|
fileName = path + "schema/" + QDir::separator() + effectSchemaFile;
|
|
|
|
Error( log, "Python script '%s' in effect schema '%s' could not be loaded", scriptName.toUtf8().constData(), fileName.toUtf8().constData());
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
pyFile.close();
|
|
|
|
|
|
|
|
if (scriptName.mid(0, 1) == ":" )
|
|
|
|
effectSchema.pyFile = ":/effects/"+scriptName.mid(1);
|
|
|
|
else
|
|
|
|
effectSchema.pyFile = path + QDir::separator().toLatin1() + scriptName;
|
|
|
|
|
|
|
|
effectSchema.pySchema = tempSchemaEffect;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-11-20 18:41:10 +01:00
|
|
|
void EffectEngine::readEffects()
|
2013-12-01 14:09:01 +01:00
|
|
|
{
|
2016-11-20 18:41:10 +01:00
|
|
|
// clear all lists
|
|
|
|
_availableEffects.clear();
|
|
|
|
_effectSchemas.clear();
|
|
|
|
|
|
|
|
// read all effects
|
|
|
|
const QJsonArray & paths = _effectConfig["paths"].toArray();
|
|
|
|
const QJsonArray & disabledEfx = _effectConfig["disable"].toArray();
|
|
|
|
|
|
|
|
QStringList efxPathList;
|
|
|
|
efxPathList << ":/effects/";
|
|
|
|
QStringList disableList;
|
|
|
|
|
|
|
|
for(auto p : paths)
|
|
|
|
{
|
|
|
|
efxPathList << p.toString();
|
|
|
|
}
|
|
|
|
for(auto efx : disabledEfx)
|
|
|
|
{
|
|
|
|
disableList << efx.toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::map<QString, EffectDefinition> availableEffects;
|
|
|
|
foreach (const QString & path, efxPathList )
|
|
|
|
{
|
|
|
|
QDir directory(path);
|
2017-05-29 15:59:11 +02:00
|
|
|
if (!directory.exists())
|
|
|
|
{
|
|
|
|
if(directory.mkpath(path))
|
|
|
|
{
|
|
|
|
Warning(_log, "New Effect path \"%s\" created successfull",path.toUtf8().constData() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Warning(_log, "Failed to create Effect path \"%s\", please check permissions",path.toUtf8().constData() );
|
|
|
|
}
|
|
|
|
}
|
2017-05-29 21:34:47 +02:00
|
|
|
else
|
2016-11-20 18:41:10 +01:00
|
|
|
{
|
|
|
|
int efxCount = 0;
|
|
|
|
QStringList filenames = directory.entryList(QStringList() << "*.json", QDir::Files, QDir::Name | QDir::IgnoreCase);
|
|
|
|
foreach (const QString & filename, filenames)
|
|
|
|
{
|
|
|
|
EffectDefinition def;
|
|
|
|
if (loadEffectDefinition(path, filename, def))
|
|
|
|
{
|
|
|
|
if (availableEffects.find(def.name) != availableEffects.end())
|
|
|
|
{
|
|
|
|
Info(_log, "effect overload effect '%s' is now taken from %s'", def.name.toUtf8().constData(), path.toUtf8().constData() );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( disableList.contains(def.name) )
|
|
|
|
{
|
|
|
|
Info(_log, "effect '%s' not loaded, because it is disabled in hyperion config", def.name.toUtf8().constData());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
availableEffects[def.name] = def;
|
|
|
|
efxCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Info(_log, "%d effects loaded from directory %s", efxCount, path.toUtf8().constData());
|
|
|
|
|
|
|
|
// collect effect schemas
|
|
|
|
efxCount = 0;
|
|
|
|
directory = path + "schema/";
|
|
|
|
QStringList pynames = directory.entryList(QStringList() << "*.json", QDir::Files, QDir::Name | QDir::IgnoreCase);
|
|
|
|
foreach (const QString & pyname, pynames)
|
|
|
|
{
|
|
|
|
EffectSchema pyEffect;
|
|
|
|
if (loadEffectSchema(path, pyname, pyEffect))
|
|
|
|
{
|
|
|
|
_effectSchemas.push_back(pyEffect);
|
|
|
|
efxCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (efxCount > 0)
|
|
|
|
Info(_log, "%d effect schemas loaded from directory %s", efxCount, (path + "schema/").toUtf8().constData());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach(auto item, availableEffects)
|
|
|
|
{
|
|
|
|
_availableEffects.push_back(item.second);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_availableEffects.size() == 0)
|
|
|
|
{
|
|
|
|
Error(_log, "no effects found, check your effect directories");
|
|
|
|
}
|
2013-12-01 14:09:01 +01:00
|
|
|
}
|
|
|
|
|
2017-03-01 15:23:53 +01:00
|
|
|
int EffectEngine::runEffect(const QString &effectName, int priority, int timeout, const QString &origin)
|
|
|
|
{
|
|
|
|
return runEffect(effectName, QJsonObject(), priority, timeout, "", origin);
|
|
|
|
}
|
|
|
|
|
|
|
|
int EffectEngine::runEffect(const QString &effectName, const QJsonObject &args, int priority, int timeout, const QString &pythonScript, const QString &origin)
|
2013-11-24 16:10:48 +01:00
|
|
|
{
|
2016-10-09 22:22:17 +02:00
|
|
|
Info( _log, "run effect %s on channel %d", effectName.toUtf8().constData(), priority);
|
2013-11-26 21:38:24 +01:00
|
|
|
|
2017-03-01 15:23:53 +01:00
|
|
|
if (pythonScript.isEmpty())
|
2013-12-01 14:09:01 +01:00
|
|
|
{
|
2016-10-30 22:59:45 +01:00
|
|
|
const EffectDefinition * effectDefinition = nullptr;
|
|
|
|
for (const EffectDefinition & e : _availableEffects)
|
2013-12-01 14:09:01 +01:00
|
|
|
{
|
2016-10-30 22:59:45 +01:00
|
|
|
if (e.name == effectName)
|
|
|
|
{
|
|
|
|
effectDefinition = &e;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (effectDefinition == nullptr)
|
|
|
|
{
|
|
|
|
// no such effect
|
|
|
|
Error(_log, "effect %s not found", effectName.toUtf8().constData());
|
|
|
|
return -1;
|
2013-12-01 14:09:01 +01:00
|
|
|
}
|
2013-11-30 00:28:04 +01:00
|
|
|
|
2017-03-01 15:23:53 +01:00
|
|
|
return runEffectScript(effectDefinition->script, effectName, (args.isEmpty() ? effectDefinition->args : args), priority, timeout, origin);
|
|
|
|
}
|
|
|
|
return runEffectScript(pythonScript, effectName, args, priority, timeout, origin);
|
2013-12-01 16:35:45 +01:00
|
|
|
}
|
|
|
|
|
2017-03-01 15:23:53 +01:00
|
|
|
int EffectEngine::runEffectScript(const QString &script, const QString &name, const QJsonObject &args, int priority, int timeout, const QString & origin)
|
2013-12-01 16:35:45 +01:00
|
|
|
{
|
2013-11-26 21:38:24 +01:00
|
|
|
// clear current effect on the channel
|
|
|
|
channelCleared(priority);
|
|
|
|
|
|
|
|
// create the effect
|
2017-03-01 15:23:53 +01:00
|
|
|
Effect * effect = new Effect(_mainThreadState, priority, timeout, script, name, args, origin);
|
|
|
|
connect(effect, SIGNAL(setColors(int,std::vector<ColorRgb>,int,bool,hyperion::Components,const QString)), _hyperion, SLOT(setColors(int,std::vector<ColorRgb>,int,bool,hyperion::Components,const QString)), Qt::QueuedConnection);
|
2013-11-26 21:38:24 +01:00
|
|
|
connect(effect, SIGNAL(effectFinished(Effect*)), this, SLOT(effectFinished(Effect*)));
|
|
|
|
_activeEffects.push_back(effect);
|
|
|
|
|
|
|
|
// start the effect
|
2017-03-01 15:23:53 +01:00
|
|
|
_hyperion->registerPriority(name, priority);
|
2013-11-26 21:38:24 +01:00
|
|
|
effect->start();
|
|
|
|
|
2013-11-24 16:10:48 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectEngine::channelCleared(int priority)
|
|
|
|
{
|
2013-11-26 21:38:24 +01:00
|
|
|
for (Effect * effect : _activeEffects)
|
|
|
|
{
|
|
|
|
if (effect->getPriority() == priority)
|
|
|
|
{
|
|
|
|
effect->abort();
|
|
|
|
}
|
|
|
|
}
|
2013-11-24 16:10:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void EffectEngine::allChannelsCleared()
|
|
|
|
{
|
2013-11-26 21:38:24 +01:00
|
|
|
for (Effect * effect : _activeEffects)
|
|
|
|
{
|
|
|
|
effect->abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EffectEngine::effectFinished(Effect *effect)
|
|
|
|
{
|
2013-11-30 15:54:47 +01:00
|
|
|
if (!effect->isAbortRequested())
|
|
|
|
{
|
|
|
|
// effect stopped by itself. Clear the channel
|
|
|
|
_hyperion->clear(effect->getPriority());
|
|
|
|
}
|
|
|
|
|
2016-06-23 13:48:49 +02:00
|
|
|
Info( _log, "effect finished");
|
2013-11-26 21:38:24 +01:00
|
|
|
for (auto effectIt = _activeEffects.begin(); effectIt != _activeEffects.end(); ++effectIt)
|
|
|
|
{
|
|
|
|
if (*effectIt == effect)
|
|
|
|
{
|
|
|
|
_activeEffects.erase(effectIt);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// cleanup the effect
|
|
|
|
effect->deleteLater();
|
2017-03-01 15:23:53 +01:00
|
|
|
_hyperion->unRegisterPriority(effect->getName());
|
2013-11-24 16:10:48 +01:00
|
|
|
}
|