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

@@ -220,6 +220,32 @@ void JsonConnection::setSourceAutoSelect()
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)
{
std::cout << "Set color transforms" << std::endl;

View File

@@ -84,13 +84,21 @@ public:
void clearAll();
///
/// Clear the given priority channel
/// Set current active priority channel and deactivate auto source switching
///
/// @param priority The priority
///
void setSource(int priority);
///
/// Enables auto source, if disabled prio by manual selecting input source
///
void setSourceAutoSelect();
///
/// Print the current loaded Hyperion configuration file
///
QString getConfigFile();
///
/// 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)");
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<> & argConfigGet = parameters.add<SwitchParameter<> >(0x0, "configget" , "Print the current loaded Hyperion configuration file");
// set the default values
argAddress.setDefault(defaultServerAddress.toStdString());
@@ -106,7 +107,7 @@ int main(int argc, char * argv[])
bool colorModding = colorTransform || colorAdjust || argCorrection.isSet() || argTemperature.isSet();
// 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)
{
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 << " " << argClear.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 << " " << argId.usageLine() << std::endl;
std::cerr << " " << argSaturation.usageLine() << std::endl;
@@ -175,6 +179,11 @@ int main(int argc, char * argv[])
{
connection.setSourceAutoSelect();
}
else if (argConfigGet.isSet())
{
QString info = connection.getConfigFile();
std::cout << "Configuration File:\n" << info.toStdString() << std::endl;
}
else if (colorModding)
{
if (argCorrection.isSet())