Update JsonConnection.cpp

Former-commit-id: 712db0e3d8e525353d62bd7dfc6e2dd708b09b85
This commit is contained in:
AEtHeLsYn 2016-03-21 17:13:46 +01:00
parent 4836bfc863
commit 909112fbfb

View File

@ -264,33 +264,26 @@ void JsonConnection::setTransform(std::string * transformId, double * saturation
parseReply(reply); parseReply(reply);
} }
void JsonConnection::setCorrection(std::string * correctionId, int * red, int * green, int * blue) void JsonConnection::setCorrection(std::string * correctionId, ColorCorrectionValues *correction)
{ {
std::cout << "Set color corrections" << std::endl; std::cout << "Set color corrections" << std::endl;
// create command // create command
Json::Value command; Json::Value command;
command["command"] = "correction"; command["command"] = "correction";
Json::Value & correction = command["correction"]; Json::Value & correct = command["correction"];
if (correctionId != nullptr) if (correctionId != nullptr)
{ {
correction["id"] = *correctionId; correct["id"] = *correctionId;
} }
if (red != nullptr) if (correction != nullptr)
{ {
correction["red"] = *red; Json::Value & v = correction["correctionValues"];
} v.append(correction->valueRed);
v.append(correction->valueGreen);
if (green != nullptr) v.append(correction->valueBlue);
{
correction["green"] = *green;
}
if (blue != nullptr)
{
correction["blue"] = *blue;
} }
// send command message // send command message
@ -300,33 +293,26 @@ void JsonConnection::setCorrection(std::string * correctionId, int * red, int *
parseReply(reply); parseReply(reply);
} }
void JsonConnection::setTemperature(std::string * temperatureId, int * red, int * green, int * blue) void JsonConnection::setTemperature(std::string * temperatureId, ColorCorrectionValues *temperature)
{ {
std::cout << "Set color temperature corrections" << std::endl; std::cout << "Set color temperature corrections" << std::endl;
// create command // create command
Json::Value command; Json::Value command;
command["command"] = "temperature"; command["command"] = "temperature";
Json::Value & temperature = command["temperature"]; Json::Value & temp = command["temperature"];
if (temperatureId != nullptr) if (temperatureId != nullptr)
{ {
temperature["id"] = *temperatureId; temp["id"] = *temperatureId;
} }
if (red != nullptr) if (temperature != nullptr)
{ {
temperature["red"] = *red; Json::Value & v = temp["correctionValues"];
} v.append(temperature->valueRed);
v.append(temperature->valueGreen);
if (green != nullptr) v.append(temperature->valueBlue);
{
temperature["green"] = *green;
}
if (blue != nullptr)
{
temperature["blue"] = *blue;
} }
// send command message // send command message