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:
Paulchen-Panther
2016-08-04 13:10:53 +02:00
committed by brindosch
parent f183032270
commit bfb06966de
12 changed files with 179 additions and 2 deletions

View File

@@ -54,6 +54,7 @@ add_library(hyperion
)
target_link_libraries(hyperion
kodivideochecker
blackborder
hyperion-utils
leddevice

View File

@@ -669,6 +669,33 @@ bool Hyperion::setCurrentSourcePriority(int priority )
return priorityValid;
}
void Hyperion::setComponentState(const Components component, const bool state)
{
switch(component)
{
case SMOOTHING:
break;
case BLACKBORDER:
break;
case KODICHECKER:
{
KODIVideoChecker* _kodiVideoChecker = KODIVideoChecker::getInstance();
if (_kodiVideoChecker != nullptr)
state ? _kodiVideoChecker->start() : _kodiVideoChecker->stop();
else
Debug(_log, "Can't get instance from: '%s'", componentToString(component));
break;
}
case FORWARDER:
break;
case UDPLISTENER:
break;
case BOBLIGHTSERVER:
break;
case GRABBER:
break;
}
}
void Hyperion::setColor(int priority, const ColorRgb &color, const int timeout_ms, bool clearEffects)
{

View File

@@ -260,6 +260,8 @@ void JsonClientConnection::handleMessage(const std::string &messageString)
handleSourceSelectCommand(message);
else if (command == "configget")
handleConfigGetCommand(message);
else if (command == "componentstate")
handleComponentStateCommand(message);
else
handleNotImplemented();
}
@@ -815,6 +817,29 @@ void JsonClientConnection::handleConfigGetCommand(const Json::Value &)
sendMessage(result);
}
void JsonClientConnection::handleComponentStateCommand(const Json::Value& message)
{
const Json::Value & componentState = message["componentstate"];
std::string component = componentState.get("component", "").asString();
if (component == "SMOOTHING")
_hyperion->setComponentState((Components)0, componentState.get("state", true).asBool());
else if (component == "BLACKBORDER")
_hyperion->setComponentState((Components)1, componentState.get("state", true).asBool());
else if (component == "KODICHECKER")
_hyperion->setComponentState((Components)2, componentState.get("state", true).asBool());
else if (component == "FORWARDER")
_hyperion->setComponentState((Components)3, componentState.get("state", true).asBool());
else if (component == "UDPLISTENER")
_hyperion->setComponentState((Components)4, componentState.get("state", true).asBool());
else if (component == "BOBLIGHTSERVER")
_hyperion->setComponentState((Components)5, componentState.get("state", true).asBool());
else if (component == "GRABBER")
_hyperion->setComponentState((Components)6, componentState.get("state", true).asBool());
sendSuccessReply();
}
void JsonClientConnection::handleNotImplemented()
{
sendErrorReply("Command not implemented");

View File

@@ -16,6 +16,7 @@
// util includes
#include <utils/jsonschema/JsonSchemaChecker.h>
#include <utils/Logger.h>
#include <utils/Components.h>
class ImageProcessor;
@@ -140,6 +141,13 @@ private:
/// @param message the incoming message
///
void handleConfigGetCommand(const Json::Value & message);
///
/// Handle an incoming JSON Component State message
///
/// @param message the incoming message
///
void handleComponentStateCommand(const Json::Value & message);
///
/// Handle an incoming JSON message of unknown type

View File

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

View File

@@ -0,0 +1,33 @@
{
"type":"object",
"required":true,
"properties":
{
"command":
{
"type" : "string",
"required" : true,
"enum" : ["componentstate"]
},
"componentstate":
{
"type": "object",
"required": true,
"properties":
{
"component":
{
"enum" : ["SMOOTHING", "BLACKBORDER", "KODICHECKER", "FORWARDER", "UDPLISTENER", "BOBLIGHTSERVER", "GRABBER"],
"required": true
},
"state":
{
"type": "bool",
"required": true
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}

View File

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