mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Create Effect configuration files (.json) with JSON RPC (#277)
* Add getEffectSchemas and loadEffectSchema function * Add getEffectSchemas function * add effect schema files to internal resources * Add loadEffectSchema and getEffectSchemas function * add effect schema resources * add getEffectSchemas function * extend handleSchemaGetCommand to get ... ... all available effect schemas add handleCreateEffectCommand function * add handleCreateEffectCommand function * include schema-create-effect.json file * add create-effect schema * Add schema-create-effect.json file * Add createEffect to hyperion-remote * Add createEffect function * add createEffect function * Create fade.schema.json * Add files via upload * Add files via upload * Update police.schema.json * Update EffectEngine.qrc.in * Update CMakeLists.txt
This commit is contained in:
committed by
redPanther
parent
4faa505fa4
commit
fab0c208fe
@@ -148,9 +148,10 @@ void JsonConnection::setEffect(const QString &effectName, const QString & effect
|
||||
}
|
||||
|
||||
effect["args"] = doc.object();
|
||||
command["effect"] = effect;
|
||||
}
|
||||
|
||||
command["effect"] = effect;
|
||||
|
||||
if (duration > 0)
|
||||
{
|
||||
command["duration"] = duration;
|
||||
@@ -163,6 +164,51 @@ void JsonConnection::setEffect(const QString &effectName, const QString & effect
|
||||
parseReply(reply);
|
||||
}
|
||||
|
||||
void JsonConnection::createEffect(const QString &effectName, const QString &effectScript, const QString & effectArgs)
|
||||
{
|
||||
qDebug() << "Create effect " << effectName;
|
||||
|
||||
// create command
|
||||
QJsonObject effect;
|
||||
effect["command"] = QString("create-effect");
|
||||
effect["name"] = effectName;
|
||||
effect["script"] = effectScript;
|
||||
|
||||
if (effectArgs.size() > 0)
|
||||
{
|
||||
QJsonParseError error;
|
||||
QJsonDocument doc = QJsonDocument::fromJson(effectArgs.toUtf8() ,&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,effectArgs.size()); i<count; ++i )
|
||||
{
|
||||
++errorColumn;
|
||||
if(effectArgs.at(i) == '\n' )
|
||||
{
|
||||
errorColumn = 0;
|
||||
++errorLine;
|
||||
}
|
||||
}
|
||||
|
||||
std::stringstream sstream;
|
||||
sstream << "Error in effect arguments: " << error.errorString().toStdString() << " at Line: " << errorLine << ", Column: " << errorColumn;
|
||||
throw std::runtime_error(sstream.str());
|
||||
}
|
||||
|
||||
effect["args"] = doc.object();
|
||||
}
|
||||
|
||||
// send command message
|
||||
QJsonObject reply = sendMessage(effect);
|
||||
|
||||
// parse reply message
|
||||
parseReply(reply);
|
||||
}
|
||||
|
||||
QString JsonConnection::getServerInfo()
|
||||
{
|
||||
qDebug() << "Get server info";
|
||||
|
||||
Reference in New Issue
Block a user