Update Json Interface (return config file) (#144)

* Add handleConfigGetCommand Function

* Add handleConfigGetCommand Function

* Add schema-configget.json

* Add configget

* Add new JSON file schema-configget.json

* add --configget command to hyperion-remote

* Add getConfigFile function

* Add getConfigFile function
This commit is contained in:
Paulchen-Panther 2016-08-03 22:03:19 +02:00 committed by redPanther
parent 722d4eb357
commit 0e2f0127fd
8 changed files with 79 additions and 3 deletions

View File

@ -258,6 +258,8 @@ void JsonClientConnection::handleMessage(const std::string &messageString)
handleAdjustmentCommand(message); handleAdjustmentCommand(message);
else if (command == "sourceselect") else if (command == "sourceselect")
handleSourceSelectCommand(message); handleSourceSelectCommand(message);
else if (command == "configget")
handleConfigGetCommand(message);
else else
handleNotImplemented(); handleNotImplemented();
} }
@ -801,6 +803,18 @@ void JsonClientConnection::handleSourceSelectCommand(const Json::Value & message
} }
} }
void JsonClientConnection::handleConfigGetCommand(const Json::Value &)
{
// create result
Json::Value result;
result["success"] = true;
Json::Value & config = result["result"];
config = _hyperion->getJsonConfig();
// send the result
sendMessage(result);
}
void JsonClientConnection::handleNotImplemented() void JsonClientConnection::handleNotImplemented()
{ {
sendErrorReply("Command not implemented"); sendErrorReply("Command not implemented");

View File

@ -135,6 +135,12 @@ private:
/// ///
void handleSourceSelectCommand(const Json::Value & message); void handleSourceSelectCommand(const Json::Value & message);
/// Handle an incoming JSON GetConfig message
///
/// @param message the incoming message
///
void handleConfigGetCommand(const Json::Value & message);
/// ///
/// Handle an incoming JSON message of unknown type /// Handle an incoming JSON message of unknown type
/// ///

View File

@ -12,5 +12,6 @@
<file alias="schema-adjustment">schema/schema-adjustment.json</file> <file alias="schema-adjustment">schema/schema-adjustment.json</file>
<file alias="schema-effect">schema/schema-effect.json</file> <file alias="schema-effect">schema/schema-effect.json</file>
<file alias="schema-sourceselect">schema/schema-sourceselect.json</file> <file alias="schema-sourceselect">schema/schema-sourceselect.json</file>
<file alias="schema-configget">schema/schema-configget.json</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -0,0 +1,12 @@
{
"type":"object",
"required":true,
"properties":{
"command": {
"type" : "string",
"required" : true,
"enum" : ["configget"]
}
},
"additionalProperties": false
}

View File

@ -5,7 +5,7 @@
"command": { "command": {
"type" : "string", "type" : "string",
"required" : true, "required" : true,
"enum" : ["color", "image", "effect", "serverinfo", "clear", "clearall", "transform", "correction", "temperature", "adjustment", "sourceselect"] "enum" : ["color", "image", "effect", "serverinfo", "clear", "clearall", "transform", "correction", "temperature", "adjustment", "sourceselect", "configget"]
} }
} }
} }

View File

@ -220,6 +220,32 @@ void JsonConnection::setSourceAutoSelect()
parseReply(reply); parseReply(reply);
} }
QString JsonConnection::getConfigFile()
{
std::cout << "Get configuration file from Hyperion Server" << std::endl;
// create command
Json::Value command;
command["command"] = "configget";
// send command message
Json::Value reply = sendMessage(command);
// parse reply message
if (parseReply(reply))
{
if (!reply.isMember("result") || !reply["result"].isObject())
{
throw std::runtime_error("No configuration file available in result");
}
const Json::Value & config = reply["result"];
return QString(config.toStyledString().c_str());
}
return QString();
}
void JsonConnection::setTransform(std::string * transformId, double * saturation, double * value, double * saturationL, double * luminance, double * luminanceMin, ColorTransformValues *threshold, ColorTransformValues *gamma, ColorTransformValues *blacklevel, ColorTransformValues *whitelevel) void JsonConnection::setTransform(std::string * transformId, double * saturation, double * value, double * saturationL, double * luminance, double * luminanceMin, ColorTransformValues *threshold, ColorTransformValues *gamma, ColorTransformValues *blacklevel, ColorTransformValues *whitelevel)
{ {
std::cout << "Set color transforms" << std::endl; std::cout << "Set color transforms" << std::endl;

View File

@ -84,14 +84,22 @@ public:
void clearAll(); void clearAll();
/// ///
/// Clear the given priority channel /// Set current active priority channel and deactivate auto source switching
/// ///
/// @param priority The priority /// @param priority The priority
/// ///
void setSource(int priority); void setSource(int priority);
///
/// Enables auto source, if disabled prio by manual selecting input source
///
void setSourceAutoSelect(); void setSourceAutoSelect();
///
/// Print the current loaded Hyperion configuration file
///
QString getConfigFile();
/// ///
/// Set the color transform of the leds /// Set the color transform of the leds
/// ///

View File

@ -83,6 +83,7 @@ int main(int argc, char * argv[])
AdjustmentParameter & argBAdjust = parameters.add<AdjustmentParameter>('B', "blueAdjustment", "Set the adjustment of the blue color (requires 3 space seperated values between 0 and 255)"); AdjustmentParameter & argBAdjust = parameters.add<AdjustmentParameter>('B', "blueAdjustment", "Set the adjustment of the blue color (requires 3 space seperated values between 0 and 255)");
IntParameter & argSource = parameters.add<IntParameter> (0x0, "sourceSelect" , "Set current active priority channel and deactivate auto source switching"); IntParameter & argSource = parameters.add<IntParameter> (0x0, "sourceSelect" , "Set current active priority channel and deactivate auto source switching");
SwitchParameter<> & argSourceAuto = parameters.add<SwitchParameter<> >(0x0, "sourceAutoSelect", "Enables auto source, if disabled prio by manual selecting input source"); SwitchParameter<> & argSourceAuto = parameters.add<SwitchParameter<> >(0x0, "sourceAutoSelect", "Enables auto source, if disabled prio by manual selecting input source");
SwitchParameter<> & argConfigGet = parameters.add<SwitchParameter<> >(0x0, "configget" , "Print the current loaded Hyperion configuration file");
// set the default values // set the default values
argAddress.setDefault(defaultServerAddress.toStdString()); argAddress.setDefault(defaultServerAddress.toStdString());
@ -106,7 +107,7 @@ int main(int argc, char * argv[])
bool colorModding = colorTransform || colorAdjust || argCorrection.isSet() || argTemperature.isSet(); bool colorModding = colorTransform || colorAdjust || argCorrection.isSet() || argTemperature.isSet();
// check that exactly one command was given // check that exactly one command was given
int commandCount = count({argColor.isSet(), argImage.isSet(), argEffect.isSet(), argServerInfo.isSet(), argClear.isSet(), argClearAll.isSet(), colorModding, argSource.isSet(), argSourceAuto.isSet()}); int commandCount = count({argColor.isSet(), argImage.isSet(), argEffect.isSet(), argServerInfo.isSet(), argClear.isSet(), argClearAll.isSet(), colorModding, argSource.isSet(), argSourceAuto.isSet(), argConfigGet.isSet()});
if (commandCount != 1) if (commandCount != 1)
{ {
std::cerr << (commandCount == 0 ? "No command found." : "Multiple commands found.") << " Provide exactly one of the following options:" << std::endl; std::cerr << (commandCount == 0 ? "No command found." : "Multiple commands found.") << " Provide exactly one of the following options:" << std::endl;
@ -116,6 +117,9 @@ int main(int argc, char * argv[])
std::cerr << " " << argServerInfo.usageLine() << std::endl; std::cerr << " " << argServerInfo.usageLine() << std::endl;
std::cerr << " " << argClear.usageLine() << std::endl; std::cerr << " " << argClear.usageLine() << std::endl;
std::cerr << " " << argClearAll.usageLine() << std::endl; std::cerr << " " << argClearAll.usageLine() << std::endl;
std::cerr << " " << argSource.usageLine() << std::endl;
std::cerr << " " << argSourceAuto.usageLine() << std::endl;
std::cerr << " " << argConfigGet.usageLine() << std::endl;
std::cerr << "or one or more of the available color modding operations:" << std::endl; std::cerr << "or one or more of the available color modding operations:" << std::endl;
std::cerr << " " << argId.usageLine() << std::endl; std::cerr << " " << argId.usageLine() << std::endl;
std::cerr << " " << argSaturation.usageLine() << std::endl; std::cerr << " " << argSaturation.usageLine() << std::endl;
@ -175,6 +179,11 @@ int main(int argc, char * argv[])
{ {
connection.setSourceAutoSelect(); connection.setSourceAutoSelect();
} }
else if (argConfigGet.isSet())
{
QString info = connection.getConfigFile();
std::cout << "Configuration File:\n" << info.toStdString() << std::endl;
}
else if (colorModding) else if (colorModding)
{ {
if (argCorrection.isSet()) if (argCorrection.isSet())