mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Adding the possibility to test new Effects ... (#282)
* Update effects_configurator.html * Update content_effectsconfigurator.js * Update hyperion.js * Update de.json * Add argument QString "pythonScript" to runEffect function * Update Hyperion.h * Update EffectEngine.cpp * Update Hyperion.cpp * Update JsonClientConnection.cpp * Update schema-effect.json
This commit is contained in:
parent
864538f188
commit
08dfec20c5
@ -22,7 +22,7 @@
|
||||
<div id="editor_container" />
|
||||
</div>
|
||||
<div class="panel-footer">
|
||||
<button class="btn btn-warning" id='btn_test' lang="en" data-lang-token="effectsconfigurator_button_testeffect">Test Effect (not implemented)</button>
|
||||
<button class="btn btn-warning" id='btn_test' lang="en" data-lang-token="effectsconfigurator_button_testeffect">Test Effect</button>
|
||||
<button class="btn btn-primary" id='btn_write' lang="en" data-lang-token="effectsconfigurator_button_saveeffect">Save Effect</button>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -48,6 +48,30 @@ $(hyperion).one("cmd-config-getschema", function(event) {
|
||||
|
||||
});
|
||||
|
||||
$('#btn_test').off().on('click',function() {
|
||||
|
||||
effectName = $('#name-input').val();
|
||||
if (effectName == "")
|
||||
{
|
||||
showInfoDialog('error','INVALID NAME FIELD','Effect name is empty! Please fill in a name and try again.')
|
||||
}
|
||||
else
|
||||
{
|
||||
var errors = effects_editor.validate();
|
||||
if(errors.length)
|
||||
{
|
||||
showInfoDialog('error','INVALID VALUES','Please check for red marked inputs and try again.')
|
||||
}
|
||||
else
|
||||
{
|
||||
var args = effects_editor.getEditor('root.args');
|
||||
requestTestEffect(effectName, ":/effects/" + effectPy.slice(1), JSON.stringify(args.getValue()));
|
||||
showInfoDialog('success','SUCCESS!','Your effect has been started!')
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$(document).ready( function() {
|
||||
requestServerConfigSchema();
|
||||
});
|
||||
|
@ -209,3 +209,7 @@ function requestWriteEffect(effectName,effectPy,effectArgs)
|
||||
var cutArgs = effectArgs.slice(1, -1);
|
||||
websocket.send('{"command":"create-effect","name":"'+effectName+'", "script":"'+effectPy+'", '+cutArgs+'}');
|
||||
}
|
||||
|
||||
function requestTestEffect(effectName,effectPy,effectArgs) {
|
||||
websocket.send('{"command":"effect", "tan":'+wsTan+',"effect":{"name":"'+effectName+'", "args":'+effectArgs+'},"priority":1, "pythonScript":"'+effectPy+'"}');
|
||||
}
|
||||
|
@ -86,7 +86,7 @@
|
||||
"effectsconfigurator_label_chooseeff" : "Basis-Effekt auswählen:",
|
||||
"effectsconfigurator_button_saveeffect" : "Effekt speichern",
|
||||
"effectsconfigurator_label_effectname" : "Effektname:",
|
||||
"effectsconfigurator_button_testeffect" : "Effekt testen (nicht implementiert)",
|
||||
"effectsconfigurator_button_testeffect" : "Effekt testen",
|
||||
"support_label_title" : "Unterstütze Hyperion",
|
||||
"support_label_intro" : "Hyperion ist ein kostenloses Open Source Projekt und ein kleines Team arbeitet an seiner Weiterentwicklung. Darum benötigen wir DEINE Unterstützung um den Ball weiter rollen zu lassen und um weiter in bessere Infrastruktur und Weiterentwicklung investieren zu können.",
|
||||
"support_label_spreadtheword" : "Weitersagen!",
|
||||
|
@ -44,7 +44,7 @@ public slots:
|
||||
int runEffect(const QString &effectName, int priority, int timeout = -1);
|
||||
|
||||
/// Run the specified effect on the given priority channel and optionally specify a timeout
|
||||
int runEffect(const QString &effectName, const QJsonObject & args, int priority, int timeout = -1);
|
||||
int runEffect(const QString &effectName, const QJsonObject & args, int priority, int timeout = -1, QString pythonScript = "");
|
||||
|
||||
/// Clear any effect running on the provided channel
|
||||
void channelCleared(int priority);
|
||||
|
@ -256,7 +256,7 @@ public slots:
|
||||
/// @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);
|
||||
int setEffect(const QString & effectName, const QJsonObject & args, int priority, int timeout = -1, QString pythonScript = "");
|
||||
|
||||
public:
|
||||
static Hyperion *_hyperion;
|
||||
|
@ -345,10 +345,12 @@ int EffectEngine::runEffect(const QString &effectName, int priority, int timeout
|
||||
return runEffect(effectName, QJsonObject(), priority, timeout);
|
||||
}
|
||||
|
||||
int EffectEngine::runEffect(const QString &effectName, const QJsonObject &args, int priority, int timeout)
|
||||
int EffectEngine::runEffect(const QString &effectName, const QJsonObject &args, int priority, int timeout, QString pythonScript)
|
||||
{
|
||||
Info( _log, "run effect %s on channel %d", effectName.toUtf8().constData(), priority);
|
||||
|
||||
if (pythonScript == "")
|
||||
{
|
||||
const EffectDefinition * effectDefinition = nullptr;
|
||||
for (const EffectDefinition & e : _availableEffects)
|
||||
{
|
||||
@ -366,6 +368,8 @@ int EffectEngine::runEffect(const QString &effectName, const QJsonObject &args,
|
||||
}
|
||||
|
||||
return runEffectScript(effectDefinition->script, effectName, args.isEmpty() ? effectDefinition->args : args, priority, timeout);
|
||||
} else
|
||||
return runEffectScript(pythonScript, effectName, args, priority, timeout);
|
||||
}
|
||||
|
||||
int EffectEngine::runEffectScript(const QString &script, const QString &name, const QJsonObject &args, int priority, int timeout)
|
||||
|
@ -824,9 +824,9 @@ int Hyperion::setEffect(const QString &effectName, int priority, int timeout)
|
||||
return _effectEngine->runEffect(effectName, priority, timeout);
|
||||
}
|
||||
|
||||
int Hyperion::setEffect(const QString &effectName, const QJsonObject &args, int priority, int timeout)
|
||||
int Hyperion::setEffect(const QString &effectName, const QJsonObject &args, int priority, int timeout, QString pythonScript)
|
||||
{
|
||||
return _effectEngine->runEffect(effectName, args, priority, timeout);
|
||||
return _effectEngine->runEffect(effectName, args, priority, timeout, pythonScript);
|
||||
}
|
||||
|
||||
void Hyperion::update()
|
||||
|
@ -420,13 +420,14 @@ void JsonClientConnection::handleEffectCommand(const QJsonObject& message, const
|
||||
// extract parameters
|
||||
int priority = message["priority"].toInt();
|
||||
int duration = message["duration"].toInt(-1);
|
||||
QString pythonScript = message["pythonScript"].toString("");
|
||||
const QJsonObject & effect = message["effect"].toObject();
|
||||
const QString & effectName = effect["name"].toString();
|
||||
|
||||
// set output
|
||||
if (effect.contains("args"))
|
||||
{
|
||||
_hyperion->setEffect(effectName, effect["args"].toObject(), priority, duration);
|
||||
_hyperion->setEffect(effectName, effect["args"].toObject(), priority, duration, pythonScript);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -32,6 +32,10 @@
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"pythonScript" : {
|
||||
"type" : "string",
|
||||
"required" : false
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
|
Loading…
Reference in New Issue
Block a user