Make origin in schema-image optional (#610)

* Make origin in schema-image optional

... like in `color` and `effect` schemes.

* use origin if available
This commit is contained in:
Andreas Ganske 2019-08-19 20:25:16 +02:00 committed by brindosch
parent beb9454a1f
commit fe12b36fce
2 changed files with 7 additions and 4 deletions

View File

@ -18,7 +18,9 @@
}, },
"origin": { "origin": {
"type": "string", "type": "string",
"required": true "minLength" : 4,
"maxLength" : 20,
"required": false
}, },
"duration": { "duration": {
"type": "integer", "type": "integer",

View File

@ -210,7 +210,7 @@ void JsonAPI::handleColorCommand(const QJsonObject& message, const QString& comm
// 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);
const QString origin = message["origin"].toString("Empty") + "@"+_peerAddress; const QString origin = message["origin"].toString("JsonRpc") + "@"+_peerAddress;
const QJsonArray & jsonColor = message["color"].toArray(); const QJsonArray & jsonColor = message["color"].toArray();
const ColorRgb color = {uint8_t(jsonColor.at(0).toInt()),uint8_t(jsonColor.at(1).toInt()),uint8_t(jsonColor.at(2).toInt())}; const ColorRgb color = {uint8_t(jsonColor.at(0).toInt()),uint8_t(jsonColor.at(1).toInt()),uint8_t(jsonColor.at(2).toInt())};
@ -228,6 +228,7 @@ void JsonAPI::handleImageCommand(const QJsonObject& message, const QString& comm
// extract parameters // extract parameters
int priority = message["priority"].toInt(); int priority = message["priority"].toInt();
const QString origin = message["origin"].toString("JsonRpc") + "@"+_peerAddress;
int duration = message["duration"].toInt(-1); int duration = message["duration"].toInt(-1);
int width = message["imagewidth"].toInt(); int width = message["imagewidth"].toInt();
int height = message["imageheight"].toInt(); int height = message["imageheight"].toInt();
@ -244,7 +245,7 @@ void JsonAPI::handleImageCommand(const QJsonObject& message, const QString& comm
Image<ColorRgb> image(width, height); Image<ColorRgb> image(width, height);
memcpy(image.memptr(), data.data(), data.size()); memcpy(image.memptr(), data.data(), data.size());
_hyperion->registerInput(priority, hyperion::COMP_IMAGE, "JsonRpc@"+_peerAddress); _hyperion->registerInput(priority, hyperion::COMP_IMAGE, origin);
_hyperion->setInputImage(priority, image, duration); _hyperion->setInputImage(priority, image, duration);
// send reply // send reply
@ -259,7 +260,7 @@ void JsonAPI::handleEffectCommand(const QJsonObject &message, const QString &com
int priority = message["priority"].toInt(); int priority = message["priority"].toInt();
int duration = message["duration"].toInt(-1); int duration = message["duration"].toInt(-1);
QString pythonScript = message["pythonScript"].toString(); QString pythonScript = message["pythonScript"].toString();
QString origin = message["origin"].toString("Empty") + "@"+_peerAddress; QString origin = message["origin"].toString("JsonRpc") + "@"+_peerAddress;
const QJsonObject & effect = message["effect"].toObject(); const QJsonObject & effect = message["effect"].toObject();
const QString & effectName = effect["name"].toString(); const QString & effectName = effect["name"].toString();
const QString & data = message["imageData"].toString("").toUtf8(); const QString & data = message["imageData"].toString("").toUtf8();