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:
Paulchen Panther 2016-10-30 22:59:45 +01:00 committed by brindosch
parent 864538f188
commit 08dfec20c5
10 changed files with 59 additions and 22 deletions

View File

@ -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>

View File

@ -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();
});

View File

@ -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+'"}');
}

View File

@ -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!",

View File

@ -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);

View File

@ -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;

View File

@ -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)

View File

@ -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()

View File

@ -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
{

View File

@ -32,6 +32,10 @@
}
},
"additionalProperties": false
},
"pythonScript" : {
"type" : "string",
"required" : false
}
},
"additionalProperties": false