mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
JSON RPC Writer (configSet) (#175)
* Remove "endOfJson" Value Deprecated value from Hypercon * Remove "endOfJson" Value Deprecated value from Hypercon * Add writeJson function to JsonFactory * ability to ignore required value in schema file * Remove "endOfJson" Value * Add handleConfigSetCommand function * Add handleConfigSetCommand function * Update JsonSchemas.qrc * Update schema.json * Update JsonSchemaChecker.cpp * Add configSet command to Hyperion-remote * Add setConfigFile function * Add setConfigFile function * Add schema-configset.json
This commit is contained in:
committed by
redPanther
parent
97181fa83c
commit
68fd395670
@@ -265,6 +265,29 @@ QString JsonConnection::getConfigFile()
|
||||
return QString();
|
||||
}
|
||||
|
||||
void JsonConnection::setConfigFile(const std::string &jsonString, bool create)
|
||||
{
|
||||
// create command
|
||||
Json::Value command;
|
||||
command["command"] = "configset";
|
||||
command["create"] = create;
|
||||
Json::Value & config = command["configset"];
|
||||
if (jsonString.size() > 0)
|
||||
{
|
||||
Json::Reader reader;
|
||||
if (!reader.parse(jsonString, config, false))
|
||||
{
|
||||
throw std::runtime_error("Error in configset arguments: " + reader.getFormattedErrorMessages());
|
||||
}
|
||||
}
|
||||
|
||||
// send command message
|
||||
Json::Value reply = sendMessage(command);
|
||||
|
||||
// parse reply message
|
||||
parseReply(reply);
|
||||
}
|
||||
|
||||
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;
|
||||
|
@@ -108,6 +108,14 @@ public:
|
||||
///
|
||||
QString getConfigFile();
|
||||
|
||||
///
|
||||
/// Write JSON Value(s) to the actual loaded configuration file
|
||||
///
|
||||
/// @param jsonString The JSON String(s) to write
|
||||
/// @param create Specifies whether the nonexistent json string to be created
|
||||
///
|
||||
void setConfigFile(const std::string & jsonString, bool create);
|
||||
|
||||
///
|
||||
/// Set the color transform of the leds
|
||||
///
|
||||
|
@@ -87,7 +87,9 @@ int main(int argc, char * argv[])
|
||||
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<> & argSourceOff = parameters.add<SwitchParameter<> >(0x0, "sourceOff", "select no source, this results in leds activly set to black (=off)");
|
||||
SwitchParameter<> & argConfigGet = parameters.add<SwitchParameter<> >(0x0, "configget" , "Print the current loaded Hyperion configuration file");
|
||||
SwitchParameter<> & argConfigGet = parameters.add<SwitchParameter<> >(0x0, "configGet" , "Print the current loaded Hyperion configuration file");
|
||||
StringParameter & argConfigSet = parameters.add<StringParameter>('W', "configSet", "Write to the actual loaded configuration file. Should be a Json object string.");
|
||||
SwitchParameter<> & argCreate = parameters.add<SwitchParameter<> >(0x0, "createkeys", "Create non exist Json Entry(s) in the actual loaded configuration file. Argument to use in combination with configSet.");
|
||||
|
||||
// set the default values
|
||||
argAddress.setDefault(defaultServerAddress.toStdString());
|
||||
@@ -111,7 +113,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(), argEnableComponent.isSet(), argDisableComponent.isSet(), colorModding, argSource.isSet(), argSourceAuto.isSet(), argSourceOff.isSet(), argConfigGet.isSet()});
|
||||
int commandCount = count({argColor.isSet(), argImage.isSet(), argEffect.isSet(), argServerInfo.isSet(), argClear.isSet(), argClearAll.isSet(), argEnableComponent.isSet(), argDisableComponent.isSet(), colorModding, argSource.isSet(), argSourceAuto.isSet(), argSourceOff.isSet(), argConfigGet.isSet(), argConfigSet.isSet()});
|
||||
if (commandCount != 1)
|
||||
{
|
||||
std::cerr << (commandCount == 0 ? "No command found." : "Multiple commands found.") << " Provide exactly one of the following options:" << std::endl;
|
||||
@@ -126,6 +128,7 @@ int main(int argc, char * argv[])
|
||||
std::cerr << " " << argSource.usageLine() << std::endl;
|
||||
std::cerr << " " << argSourceAuto.usageLine() << std::endl;
|
||||
std::cerr << " " << argConfigGet.usageLine() << std::endl;
|
||||
std::cerr << " " << argConfigSet.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;
|
||||
@@ -202,6 +205,10 @@ int main(int argc, char * argv[])
|
||||
QString info = connection.getConfigFile();
|
||||
std::cout << "Configuration File:\n" << info.toStdString() << std::endl;
|
||||
}
|
||||
else if (argConfigSet.isSet())
|
||||
{
|
||||
connection.setConfigFile(argConfigSet.getValue(), argCreate.isSet());
|
||||
}
|
||||
else if (colorModding)
|
||||
{
|
||||
if (argCorrection.isSet())
|
||||
|
Reference in New Issue
Block a user