From e4d77660a4526814afae4aa0e4055d9c62c9b83e Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Sun, 13 Mar 2016 11:59:36 +0100 Subject: [PATCH] Bug fixes Former-commit-id: a6783a75edb83988d1737df3d4a7a14c71ec4223 --- libsrc/jsonserver/JsonClientConnection.cpp | 13 ++++-- libsrc/jsonserver/JsonSchemas.qrc | 2 + .../jsonserver/schema/schema-correction.json | 41 +++++++++++++++++++ .../jsonserver/schema/schema-temperature.json | 41 +++++++++++++++++++ .../jsonserver/schema/schema-transform.json | 10 +++++ libsrc/jsonserver/schema/schema.json | 2 +- src/hyperion-remote/JsonConnection.cpp | 2 +- src/hyperion-remote/hyperion-remote.cpp | 20 ++++----- 8 files changed, 115 insertions(+), 16 deletions(-) create mode 100644 libsrc/jsonserver/schema/schema-correction.json create mode 100644 libsrc/jsonserver/schema/schema-temperature.json diff --git a/libsrc/jsonserver/JsonClientConnection.cpp b/libsrc/jsonserver/JsonClientConnection.cpp index 3eea8320..9298a3d2 100644 --- a/libsrc/jsonserver/JsonClientConnection.cpp +++ b/libsrc/jsonserver/JsonClientConnection.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include // project includes @@ -247,6 +248,10 @@ void JsonClientConnection::handleMessage(const std::string &messageString) handleClearallCommand(message); else if (command == "transform") handleTransformCommand(message); + else if (command == "correction") + handleCorrectionCommand(message); + else if (command == "temperature") + handleTemperatureCommand(message); else handleNotImplemented(); } @@ -540,10 +545,10 @@ void JsonClientConnection::handleCorrectionCommand(const Json::Value &message) const Json::Value & correction = message["correction"]; const std::string correctionId = correction.get("id", _hyperion->getCorrectionIds().front()).asString(); - ColorCorrection * colorCorrection = _hyperion->getCorrection(CorrectionId); + ColorCorrection * colorCorrection = _hyperion->getCorrection(correctionId); if (colorCorrection == nullptr) { - //sendErrorReply(std::string("Incorrect transform identifier: ") + transformId); + //sendErrorReply(std::string("Incorrect correction identifier: ") + correctionId); return; } @@ -573,10 +578,10 @@ void JsonClientConnection::handleTemperatureCommand(const Json::Value &message) const Json::Value & temperature = message["temperature"]; const std::string tempId = temperature.get("id", _hyperion->getTemperatureIds().front()).asString(); - ColorCorrection * colorTemperature = _hyperion->getTemperature(TemperatureId); + ColorCorrection * colorTemperature = _hyperion->getTemperature(tempId); if (colorTemperature == nullptr) { - //sendErrorReply(std::string("Incorrect transform identifier: ") + transformId); + //sendErrorReply(std::string("Incorrect temperature identifier: ") + tempId); return; } diff --git a/libsrc/jsonserver/JsonSchemas.qrc b/libsrc/jsonserver/JsonSchemas.qrc index 7736e530..193624ba 100644 --- a/libsrc/jsonserver/JsonSchemas.qrc +++ b/libsrc/jsonserver/JsonSchemas.qrc @@ -7,6 +7,8 @@ schema/schema-clear.json schema/schema-clearall.json schema/schema-transform.json + schema/schema-correction.json + schema/schema-temperature.json schema/schema-effect.json diff --git a/libsrc/jsonserver/schema/schema-correction.json b/libsrc/jsonserver/schema/schema-correction.json new file mode 100644 index 00000000..f156d8fd --- /dev/null +++ b/libsrc/jsonserver/schema/schema-correction.json @@ -0,0 +1,41 @@ +{ + "type":"object", + "required":true, + "properties":{ + "command": { + "type" : "string", + "required" : true, + "enum" : ["correction"] + }, + "correction": { + "type": "object", + "required": true, + "properties": { + "id" : { + "type" : "string", + "required" : false + }, + "red" : { + "type" : "number", + "required" : false, + "minimum": 0.0, + "maximum": 255.0 + }, + "green" : { + "type" : "number", + "required" : false, + "minimum": 0.0, + "maximum": 255.0 + }, + "blue" : { + "type" : "number", + "required" : false, + "minimum": 0.0, + "maximum": 255.0 + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false +} diff --git a/libsrc/jsonserver/schema/schema-temperature.json b/libsrc/jsonserver/schema/schema-temperature.json new file mode 100644 index 00000000..1e2b7058 --- /dev/null +++ b/libsrc/jsonserver/schema/schema-temperature.json @@ -0,0 +1,41 @@ +{ + "type":"object", + "required":true, + "properties":{ + "command": { + "type" : "string", + "required" : true, + "enum" : ["temperature"] + }, + "temperature": { + "type": "object", + "required": true, + "properties": { + "id" : { + "type" : "string", + "required" : false + }, + "red" : { + "type" : "number", + "required" : false, + "minimum": 0.0, + "maximum": 255.0 + }, + "green" : { + "type" : "number", + "required" : false, + "minimum": 0.0, + "maximum": 255.0 + }, + "blue" : { + "type" : "number", + "required" : false, + "minimum": 0.0, + "maximum": 255.0 + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false +} diff --git a/libsrc/jsonserver/schema/schema-transform.json b/libsrc/jsonserver/schema/schema-transform.json index 7b939839..8b194eab 100644 --- a/libsrc/jsonserver/schema/schema-transform.json +++ b/libsrc/jsonserver/schema/schema-transform.json @@ -25,6 +25,16 @@ "required" : false, "minimum" : 0.0 }, + "saturationLGain" : { + "type" : "number", + "required" : false, + "minimum" : 0.0 + }, + "luminanceGain" : { + "type" : "number", + "required" : false, + "minimum" : 0.0 + }, "threshold": { "type": "array", "required": false, diff --git a/libsrc/jsonserver/schema/schema.json b/libsrc/jsonserver/schema/schema.json index e931f7b7..061339d1 100644 --- a/libsrc/jsonserver/schema/schema.json +++ b/libsrc/jsonserver/schema/schema.json @@ -5,7 +5,7 @@ "command": { "type" : "string", "required" : true, - "enum" : ["color", "image", "effect", "serverinfo", "clear", "clearall", "transform"] + "enum" : ["color", "image", "effect", "serverinfo", "clear", "clearall", "transform", "correction", "temperature"] } } } diff --git a/src/hyperion-remote/JsonConnection.cpp b/src/hyperion-remote/JsonConnection.cpp index 7e296af7..150fa63a 100644 --- a/src/hyperion-remote/JsonConnection.cpp +++ b/src/hyperion-remote/JsonConnection.cpp @@ -309,7 +309,7 @@ void JsonConnection::setTemperature(std::string * temperatureId, int * red, int command["command"] = "temperature"; Json::Value & temperature = command["temperature"]; - if (correctionId != nullptr) + if (temperatureId != nullptr) { temperature["id"] = *temperatureId; } diff --git a/src/hyperion-remote/hyperion-remote.cpp b/src/hyperion-remote/hyperion-remote.cpp index e548fbdc..9d02011c 100644 --- a/src/hyperion-remote/hyperion-remote.cpp +++ b/src/hyperion-remote/hyperion-remote.cpp @@ -69,14 +69,14 @@ int main(int argc, char * argv[]) TransformParameter & argWhitelevel = parameters.add('w', "whitelevel", "Set the whitelevel of the leds (requires 3 space seperated values which are normally between 0.0 and 1.0)"); SwitchParameter<> & argPrint = parameters.add >(0x0, "print" , "Print the json input and output messages on stdout"); SwitchParameter<> & argHelp = parameters.add >('h', "help" , "Show this help message and exit"); - StringParameter & argIdC = parameters.add ('cq', "qualifier" , "Identifier(qualifier) of the correction to set"); - IntParameter & argCorrR = parameters.add ('cr', "correctionR" , "Specify the red channel correction factor"); - IntParameter & argCorrG = parameters.add ('cg', "correctionG" , "Specify the green channel correction factor"); - IntParameter & argCorrB = parameters.add ('cb', "correctionB" , "Specify the blue channel correction factor"); - StringParameter & argIdT = parameters.add ('tq', "qualifier" , "Identifier(qualifier) of the temperature to set"); - IntParameter & argTempR = parameters.add ('tr', "tempR" , "Specify the red channel temperature factor"); - IntParameter & argTempG = parameters.add ('tg', "tempG" , "Specify the red channel temperature factor"); - IntParameter & argTempB = parameters.add ('tb', "tempB" , "Specify the red channel temperature factor"); + StringParameter & argIdC = parameters.add ('y', "qualifier" , "Identifier(qualifier) of the correction to set"); + IntParameter & argCorrR = parameters.add ('1', "correctionR" , "Specify the red channel correction factor"); + IntParameter & argCorrG = parameters.add ('2', "correctionG" , "Specify the green channel correction factor"); + IntParameter & argCorrB = parameters.add ('3', "correctionB" , "Specify the blue channel correction factor"); + StringParameter & argIdT = parameters.add ('z', "qualifier" , "Identifier(qualifier) of the temperature to set"); + IntParameter & argTempR = parameters.add ('4', "tempR" , "Specify the red channel temperature factor"); + IntParameter & argTempG = parameters.add ('5', "tempG" , "Specify the red channel temperature factor"); + IntParameter & argTempB = parameters.add ('6', "tempB" , "Specify the red channel temperature factor"); // set the default values argAddress.setDefault(defaultServerAddress.toStdString()); @@ -203,7 +203,7 @@ int main(int argc, char * argv[]) argIdC.isSet() ? &transId : nullptr, argCorrR.isSet() ? &red : nullptr, argCorrG.isSet() ? &green : nullptr, - argCorrB.isSet() ? &blue : nullptr, + argCorrB.isSet() ? &blue : nullptr); } else if (colorTemp) { @@ -219,7 +219,7 @@ int main(int argc, char * argv[]) argIdC.isSet() ? &transId : nullptr, argTempR.isSet() ? &red : nullptr, argTempG.isSet() ? &green : nullptr, - argTempB.isSet() ? &blue : nullptr, + argTempB.isSet() ? &blue : nullptr); } } catch (const std::runtime_error & e)