mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Update Json Interface (Enable/Disable components during runtime) (#150)
* Update Hyperion.h * Add files via upload * Update CMakeLists.txt * Update Hyperion.cpp * Update JsonClientConnection.cpp * Update JsonClientConnection.h * Update JsonSchemas.qrc * Add files via upload * Update schema.json * Update JsonConnection.cpp * Update JsonConnection.h * Update hyperion-remote.cpp
This commit is contained in:
committed by
brindosch
parent
f183032270
commit
bfb06966de
@@ -192,6 +192,25 @@ void JsonConnection::clearAll()
|
||||
parseReply(reply);
|
||||
}
|
||||
|
||||
void JsonConnection::setComponentState(const std::string& component, const bool state)
|
||||
{
|
||||
state ? std::cout << "Enable Component " : std::cout << "Disable Component ";
|
||||
std::cout << component << std::endl;
|
||||
|
||||
// create command
|
||||
Json::Value command;
|
||||
command["command"] = "componentstate";
|
||||
Json::Value & parameter = command["componentstate"];
|
||||
parameter["component"] = component;
|
||||
parameter["state"] = state;
|
||||
|
||||
// send command message
|
||||
Json::Value reply = sendMessage(command);
|
||||
|
||||
// parse reply message
|
||||
parseReply(reply);
|
||||
}
|
||||
|
||||
void JsonConnection::setSource(int priority)
|
||||
{
|
||||
// create command
|
||||
|
@@ -82,6 +82,14 @@ public:
|
||||
/// Clear all priority channels
|
||||
///
|
||||
void clearAll();
|
||||
|
||||
///
|
||||
/// Enable/Disable components during runtime
|
||||
///
|
||||
/// @param component The component [SMOOTHING, BLACKBORDER, KODICHECKER, FORWARDER, UDPLISTENER, BOBLIGHT_SERVER, GRABBER]
|
||||
/// @param state The state of the component [true | false]
|
||||
///
|
||||
void setComponentState(const std::string & component, const bool state);
|
||||
|
||||
///
|
||||
/// Set current active priority channel and deactivate auto source switching
|
||||
|
@@ -61,6 +61,8 @@ int main(int argc, char * argv[])
|
||||
SwitchParameter<> & argServerInfo = parameters.add<SwitchParameter<> >('l', "list" , "List server info and active effects with priority and duration");
|
||||
SwitchParameter<> & argClear = parameters.add<SwitchParameter<> >('x', "clear" , "Clear data for the priority channel provided by the -p option");
|
||||
SwitchParameter<> & argClearAll = parameters.add<SwitchParameter<> >(0x0, "clearall" , "Clear data for all active priority channels");
|
||||
StringParameter & argEnableComponent = parameters.add<StringParameter> ('E', "enable" , "Enable the Component with the given name. Available Components are [SMOOTHING, BLACKBORDER, KODICHECKER, FORWARDER, UDPLISTENER, BOBLIGHT_SERVER, GRABBER]");
|
||||
StringParameter & argDisableComponent = parameters.add<StringParameter> ('D', "disable" , "Disable the Component with the given name. Available Components are [SMOOTHING, BLACKBORDER, KODICHECKER, FORWARDER, UDPLISTENER, BOBLIGHT_SERVER, GRABBER]");
|
||||
StringParameter & argId = parameters.add<StringParameter> ('q', "qualifier" , "Identifier(qualifier) of the transform to set");
|
||||
DoubleParameter & argSaturation = parameters.add<DoubleParameter> ('s', "saturation", "!DEPRECATED! Will be removed soon! Set the HSV saturation gain of the leds");
|
||||
DoubleParameter & argValue = parameters.add<DoubleParameter> ('v', "value" , "!DEPRECATED! Will be removed soon! Set the HSV value gain of the leds");
|
||||
@@ -107,7 +109,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(), 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(), argConfigGet.isSet()});
|
||||
if (commandCount != 1)
|
||||
{
|
||||
std::cerr << (commandCount == 0 ? "No command found." : "Multiple commands found.") << " Provide exactly one of the following options:" << std::endl;
|
||||
@@ -117,6 +119,8 @@ 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 << " " << argEnableComponent.usageLine() << std::endl;
|
||||
std::cerr << " " << argDisableComponent.usageLine() << std::endl;
|
||||
std::cerr << " " << argSource.usageLine() << std::endl;
|
||||
std::cerr << " " << argSourceAuto.usageLine() << std::endl;
|
||||
std::cerr << " " << argConfigGet.usageLine() << std::endl;
|
||||
@@ -171,6 +175,14 @@ int main(int argc, char * argv[])
|
||||
{
|
||||
connection.clearAll();
|
||||
}
|
||||
else if (argEnableComponent.isSet())
|
||||
{
|
||||
connection.setComponentState(argEnableComponent.getValue(), true);
|
||||
}
|
||||
else if (argDisableComponent.isSet())
|
||||
{
|
||||
connection.setComponentState(argDisableComponent.getValue(), false);
|
||||
}
|
||||
else if (argSource.isSet())
|
||||
{
|
||||
connection.setSource(argSource.getValue());
|
||||
|
Reference in New Issue
Block a user