This commit is contained in:
brindosch 2017-02-21 14:42:49 +01:00
parent 8a6c1fdab3
commit 50fc89e800
6 changed files with 24 additions and 18 deletions

View File

@ -45,7 +45,7 @@ public:
public slots: public slots:
/// Run the specified effect on the given priority channel and optionally specify a timeout /// 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); return runEffect(effectName, QJsonObject(), priority, timeout);
}; };
@ -68,7 +68,7 @@ private:
bool loadEffectSchema(const QString & path, const QString & effectSchemaFile, EffectSchema &effectSchema); bool loadEffectSchema(const QString & path, const QString & effectSchemaFile, EffectSchema &effectSchema);
/// Run the specified effect on the given priority channel and optionally specify a timeout /// 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: private:
Hyperion * _hyperion; Hyperion * _hyperion;

View File

@ -133,7 +133,8 @@ public:
/// register a input source to a priority channel /// register a input source to a priority channel
/// @param name uniq name of input source /// @param name uniq name of input source
/// @param priority priority channel /// @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 /// unregister a input source to a priority channel
/// @param name uniq name of input source /// @param name uniq name of input source
@ -243,14 +244,14 @@ public slots:
/// @param effectName Name of the effec to run /// @param effectName Name of the effec to run
/// @param priority The priority channel of the effect /// @param priority The priority channel of the effect
/// @param timeout The timeout of the effect (after the timout, the effect will be cleared) /// @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 /// Run the specified effect on the given priority channel and optionally specify a timeout
/// @param effectName Name of the effec to run /// @param effectName Name of the effec to run
/// @param args arguments of the effect script /// @param args arguments of the effect script
/// @param priority The priority channel of the effect /// @param priority The priority channel of the effect
/// @param timeout The timeout of the effect (after the timout, the effect will be cleared) /// @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 /// sets the methode how image is maped to leds
void setLedMappingType(int mappingType); void setLedMappingType(int mappingType);

View File

@ -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); 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 -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 } 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 // clear current effect on the channel
channelCleared(priority); channelCleared(priority);
@ -381,7 +381,7 @@ int EffectEngine::runEffectScript(const QString &script, const QString &name, co
_activeEffects.push_back(effect); _activeEffects.push_back(effect);
// start the effect // start the effect
_hyperion->registerPriority(name.toStdString(), priority); _hyperion->registerPriority(name.toStdString(), priority, origin);
effect->start(); effect->start();
return 0; return 0;

View File

@ -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 ); 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()); "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) void Hyperion::unRegisterPriority(const std::string name)
@ -688,14 +688,14 @@ const std::list<EffectSchema> & Hyperion::getEffectSchemas()
return _effectEngine->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) void Hyperion::setLedMappingType(int mappingType)

View File

@ -438,6 +438,7 @@ void JsonClientConnection::handleEffectCommand(const QJsonObject& message, const
// extract parameters // extract parameters
int priority = message["priority"].toInt(); int priority = message["priority"].toInt();
int duration = message["duration"].toInt(-1); int duration = message["duration"].toInt(-1);
QString origin = message["origin"].toString();
QString pythonScript = message["pythonScript"].toString(""); QString pythonScript = message["pythonScript"].toString("");
const QJsonObject & effect = message["effect"].toObject(); const QJsonObject & effect = message["effect"].toObject();
const QString & effectName = effect["name"].toString(); const QString & effectName = effect["name"].toString();
@ -445,11 +446,11 @@ void JsonClientConnection::handleEffectCommand(const QJsonObject& message, const
// set output // set output
if (effect.contains("args")) if (effect.contains("args"))
{ {
_hyperion->setEffect(effectName, effect["args"].toObject(), priority, duration, pythonScript); _hyperion->setEffect(effectName, effect["args"].toObject(), priority, duration, pythonScript, origin);
} }
else else
{ {
_hyperion->setEffect(effectName, priority, duration); _hyperion->setEffect(effectName, priority, duration, origin);
} }
// send reply // send reply

View File

@ -20,6 +20,10 @@
"type": "integer", "type": "integer",
"required": false "required": false
}, },
"origin": {
"type": "string",
"required": true
},
"effect": { "effect": {
"type": "object", "type": "object",
"required": true, "required": true,