diff --git a/include/effectengine/EffectEngine.h b/include/effectengine/EffectEngine.h index 6fcf3808..ab42fb05 100644 --- a/include/effectengine/EffectEngine.h +++ b/include/effectengine/EffectEngine.h @@ -45,7 +45,7 @@ public: public slots: /// Run the specified effect on the given priority channel and optionally specify a timeout - int runEffect(const QString &effectName, int priority, int timeout = -1) + int runEffect(const QString &effectName, int priority, int timeout = -1, const QString origin="System") { return runEffect(effectName, QJsonObject(), priority, timeout); }; @@ -68,7 +68,7 @@ private: bool loadEffectSchema(const QString & path, const QString & effectSchemaFile, EffectSchema &effectSchema); /// Run the specified effect on the given priority channel and optionally specify a timeout - int runEffectScript(const QString &script, const QString &name, const QJsonObject & args, int priority, int timeout = -1); + int runEffectScript(const QString &script, const QString &name, const QJsonObject & args, int priority, int timeout = -1, const QString origin="System"); private: Hyperion * _hyperion; diff --git a/include/hyperion/Hyperion.h b/include/hyperion/Hyperion.h index fb492e79..5d2630ec 100644 --- a/include/hyperion/Hyperion.h +++ b/include/hyperion/Hyperion.h @@ -133,7 +133,8 @@ public: /// register a input source to a priority channel /// @param name uniq name of input source /// @param priority priority channel - void registerPriority(const std::string name, const int priority); + /// @param origin External setter + void registerPriority(const std::string name, const int priority, const QString origin="System"); /// unregister a input source to a priority channel /// @param name uniq name of input source @@ -243,14 +244,14 @@ public slots: /// @param effectName Name of the effec to run /// @param priority The priority channel of the effect /// @param timeout The timeout of the effect (after the timout, the effect will be cleared) - int setEffect(const QString & effectName, int priority, int timeout = -1); + int setEffect(const QString & effectName, int priority, int timeout = -1, const QString origin="System"); /// Run the specified effect on the given priority channel and optionally specify a timeout /// @param effectName Name of the effec to run /// @param args arguments of the effect script /// @param priority The priority channel of the effect /// @param timeout The timeout of the effect (after the timout, the effect will be cleared) - int setEffect(const QString & effectName, const QJsonObject & args, int priority, int timeout = -1, QString pythonScript = ""); + int setEffect(const QString & effectName, const QJsonObject & args, int priority, int timeout = -1, QString pythonScript = "", const QString origin="System"); /// sets the methode how image is maped to leds void setLedMappingType(int mappingType); diff --git a/libsrc/effectengine/EffectEngine.cpp b/libsrc/effectengine/EffectEngine.cpp index dd148a61..4d4d065d 100644 --- a/libsrc/effectengine/EffectEngine.cpp +++ b/libsrc/effectengine/EffectEngine.cpp @@ -342,7 +342,7 @@ void EffectEngine::readEffects() } } -int EffectEngine::runEffect(const QString &effectName, const QJsonObject &args, int priority, int timeout, QString pythonScript) +int EffectEngine::runEffect(const QString &effectName, const QJsonObject &args, int priority, int timeout, QString pythonScript, const QString origin) { Info( _log, "run effect %s on channel %d", effectName.toUtf8().constData(), priority); @@ -364,12 +364,12 @@ int EffectEngine::runEffect(const QString &effectName, const QJsonObject &args, return -1; } - return runEffectScript(effectDefinition->script, effectName, args.isEmpty() ? effectDefinition->args : args, priority, timeout); + return runEffectScript(effectDefinition->script, effectName, args.isEmpty() ? effectDefinition->args : args, priority, timeout, origin); } else - return runEffectScript(pythonScript, effectName, args, priority, timeout); + return runEffectScript(pythonScript, effectName, args, priority, timeout, origin); } -int EffectEngine::runEffectScript(const QString &script, const QString &name, const QJsonObject &args, int priority, int timeout) +int EffectEngine::runEffectScript(const QString &script, const QString &name, const QJsonObject &args, int priority, int timeout, const QString origin) { // clear current effect on the channel channelCleared(priority); @@ -381,7 +381,7 @@ int EffectEngine::runEffectScript(const QString &script, const QString &name, co _activeEffects.push_back(effect); // start the effect - _hyperion->registerPriority(name.toStdString(), priority); + _hyperion->registerPriority(name.toStdString(), priority, origin); effect->start(); return 0; diff --git a/libsrc/hyperion/Hyperion.cpp b/libsrc/hyperion/Hyperion.cpp index 6fc65b6a..6ea3c251 100644 --- a/libsrc/hyperion/Hyperion.cpp +++ b/libsrc/hyperion/Hyperion.cpp @@ -504,7 +504,7 @@ bool Hyperion::configWriteable() } -void Hyperion::registerPriority(const std::string name, const int priority) +void Hyperion::registerPriority(const std::string name, const int priority, const QString origin) { Info(_log, "Register new input source named '%s' for priority channel '%d'", name.c_str(), priority ); @@ -514,7 +514,7 @@ void Hyperion::registerPriority(const std::string name, const int priority) "Input source '%s' uses same priority channel (%d) as '%s'.", name.c_str(), priority, entry.first.c_str()); } - _priorityRegister.emplace(name,priority); + _priorityRegister.emplace(name,priority,origin); } void Hyperion::unRegisterPriority(const std::string name) @@ -688,14 +688,14 @@ const std::list & Hyperion::getEffectSchemas() return _effectEngine->getEffectSchemas(); } -int Hyperion::setEffect(const QString &effectName, int priority, int timeout) +int Hyperion::setEffect(const QString &effectName, int priority, int timeout, const QString origin) { - return _effectEngine->runEffect(effectName, priority, timeout); + return _effectEngine->runEffect(effectName, priority, timeout, origin); } -int Hyperion::setEffect(const QString &effectName, const QJsonObject &args, int priority, int timeout, QString pythonScript) +int Hyperion::setEffect(const QString &effectName, const QJsonObject &args, int priority, int timeout, QString pythonScript, const QString origin) { - return _effectEngine->runEffect(effectName, args, priority, timeout, pythonScript); + return _effectEngine->runEffect(effectName, args, priority, timeout, pythonScript, origin); } void Hyperion::setLedMappingType(int mappingType) diff --git a/libsrc/jsonserver/JsonClientConnection.cpp b/libsrc/jsonserver/JsonClientConnection.cpp index 3a2b9503..1a821c5e 100644 --- a/libsrc/jsonserver/JsonClientConnection.cpp +++ b/libsrc/jsonserver/JsonClientConnection.cpp @@ -438,6 +438,7 @@ void JsonClientConnection::handleEffectCommand(const QJsonObject& message, const // extract parameters int priority = message["priority"].toInt(); int duration = message["duration"].toInt(-1); + QString origin = message["origin"].toString(); QString pythonScript = message["pythonScript"].toString(""); const QJsonObject & effect = message["effect"].toObject(); const QString & effectName = effect["name"].toString(); @@ -445,11 +446,11 @@ void JsonClientConnection::handleEffectCommand(const QJsonObject& message, const // set output if (effect.contains("args")) { - _hyperion->setEffect(effectName, effect["args"].toObject(), priority, duration, pythonScript); + _hyperion->setEffect(effectName, effect["args"].toObject(), priority, duration, pythonScript, origin); } else { - _hyperion->setEffect(effectName, priority, duration); + _hyperion->setEffect(effectName, priority, duration, origin); } // send reply diff --git a/libsrc/jsonserver/schema/schema-effect.json b/libsrc/jsonserver/schema/schema-effect.json index 0db56d22..dd203238 100644 --- a/libsrc/jsonserver/schema/schema-effect.json +++ b/libsrc/jsonserver/schema/schema-effect.json @@ -20,6 +20,10 @@ "type": "integer", "required": false }, + "origin": { + "type": "string", + "required": true + }, "effect": { "type": "object", "required": true,