diff --git a/libsrc/hyperion/schemas/hyperion.schema-2.json b/libsrc/hyperion/schemas/hyperion.schema-2.json index 8ea9f066..4b36c785 100644 --- a/libsrc/hyperion/schemas/hyperion.schema-2.json +++ b/libsrc/hyperion/schemas/hyperion.schema-2.json @@ -306,7 +306,7 @@ "type" : "number", "title" : "edt_conf_color_gammaRed_title", "required" : true, - "minimum" : 0.0, + "minimum" : 0.1, "maximum": 100.0, "default" : 1.5, "step" : 0.1, @@ -317,7 +317,7 @@ "type" : "number", "title" : "edt_conf_color_gammaGreen_title", "required" : true, - "minimum" : 0.0, + "minimum" : 0.1, "maximum": 100.0, "default" : 1.5, "step" : 0.1, @@ -328,7 +328,7 @@ "type" : "number", "title" : "edt_conf_color_gammaBlue_title", "required" : true, - "minimum" : 0.0, + "minimum" : 0.1, "maximum": 100.0, "default" : 1.5, "step" : 0.1, diff --git a/libsrc/jsonserver/JsonClientConnection.cpp b/libsrc/jsonserver/JsonClientConnection.cpp index cfd0bcd0..c038aaf9 100644 --- a/libsrc/jsonserver/JsonClientConnection.cpp +++ b/libsrc/jsonserver/JsonClientConnection.cpp @@ -49,6 +49,7 @@ using namespace hyperion; int _connectionCounter = 0; +std::map JsonClientConnection::_componentsPrevState; JsonClientConnection::JsonClientConnection(QTcpSocket *socket) : QObject() @@ -620,13 +621,13 @@ void JsonClientConnection::handleServerInfoCommand(const QJsonObject&, const QSt { item["duration_ms"] = int(priorityInfo.timeoutTime_ms - now); } - - item["owner"] = QString(hyperion::componentToIdString(priorityInfo.componentId)); + + item["owner"] = QString(hyperion::componentToIdString(priorityInfo.componentId)); item["componentId"] = QString(hyperion::componentToIdString(priorityInfo.componentId)); - item["origin"] = priorityInfo.origin; - item["component"] = QString(hyperion::componentToString(priorityInfo.componentId)); - item["active"] = true; - item["visible"] = (priority == currentPriority); + item["origin"] = priorityInfo.origin; + item["component"] = QString(hyperion::componentToString(priorityInfo.componentId)); + item["active"] = true; + item["visible"] = (priority == currentPriority); // remove item from prio register, because we have more valuable information via active priority QList prios = priorityRegister.keys(priority); @@ -687,9 +688,9 @@ void JsonClientConnection::handleServerInfoCommand(const QJsonObject&, const QSt { QJsonObject item; item["priority"] = priorityRegister[key]; - item["active"] = false; - item["visible"] = false; - item["owner"] = key; + item["active"] = false; + item["visible"] = false; + item["owner"] = key; priorities.append(item); } @@ -1147,16 +1148,52 @@ void JsonClientConnection::handleSchemaGetCommand(const QJsonObject& message, co void JsonClientConnection::handleComponentStateCommand(const QJsonObject& message, const QString &command, const int tan) { const QJsonObject & componentState = message["componentstate"].toObject(); - Components component = stringToComponent(componentState["component"].toString("invalid")); - if (component != COMP_INVALID) + QString compStr = componentState["component"].toString("invalid"); + bool compState = componentState["state"].toBool(true); + + if (compStr == "ALL" ) { - _hyperion->setComponentState(component, componentState["state"].toBool(true)); + if (hyperionIsActive() != compState) + { + std::map components = _hyperion->getComponentRegister().getRegister(); + + if (!compState) + { + JsonClientConnection::_componentsPrevState = components; + } + + for(auto comp : components) + { + _hyperion->setComponentState(comp.first, compState ? JsonClientConnection::_componentsPrevState[comp.first] : false); + } + + if (compState) + { + JsonClientConnection::_componentsPrevState.clear(); + } + } + sendSuccessReply(command, tan); + return; + } else { - sendErrorReply("invalid component name", command, tan); + Components component = stringToComponent(compStr); + + if (hyperionIsActive()) + { + if (component != COMP_INVALID) + { + _hyperion->setComponentState(component, compState); + sendSuccessReply(command, tan); + return; + } + sendErrorReply("invalid component name", command, tan); + return; + } + sendErrorReply("can't change component state when hyperion is off", command, tan); } } @@ -1202,7 +1239,7 @@ void JsonClientConnection::handleLoggingCommand(const QJsonObject& message, cons QString subcommand = message["subcommand"].toString(""); _streaming_logging_reply["success"] = true; _streaming_logging_reply["command"] = command; - _streaming_logging_reply["tan"] = tan; + _streaming_logging_reply["tan"] = tan; if (subcommand == "start") { diff --git a/libsrc/jsonserver/JsonClientConnection.h b/libsrc/jsonserver/JsonClientConnection.h index ceb0c478..81b7e72b 100644 --- a/libsrc/jsonserver/JsonClientConnection.h +++ b/libsrc/jsonserver/JsonClientConnection.h @@ -1,5 +1,7 @@ #pragma once +#include + // Qt includes #include #include @@ -317,6 +319,9 @@ private: /// bool checkJson(const QJsonObject & message, const QString &schemaResource, QString & errors, bool ignoreRequired = false); + /// returns if hyperion is on or off + inline bool hyperionIsActive() { return JsonClientConnection::_componentsPrevState.empty(); }; + /// The TCP-Socket that is connected tot the Json-client QTcpSocket * _socket; @@ -358,6 +363,9 @@ private: /// address of client QHostAddress _clientAddress; + /// holds the state before off state + static std::map _componentsPrevState; + // masks for fields in the basic header static uint8_t const BHB0_OPCODE = 0x0F; static uint8_t const BHB0_RSV3 = 0x10; diff --git a/libsrc/jsonserver/schema/schema-componentstate.json b/libsrc/jsonserver/schema/schema-componentstate.json index 0e8db05f..bb62a951 100644 --- a/libsrc/jsonserver/schema/schema-componentstate.json +++ b/libsrc/jsonserver/schema/schema-componentstate.json @@ -21,7 +21,7 @@ "component": { "type" : "string", - "enum" : ["SMOOTHING", "BLACKBORDER", "KODICHECKER", "FORWARDER", "UDPLISTENER", "BOBLIGHTSERVER", "GRABBER", "V4L", "LEDDEVICE"], + "enum" : ["ALL", "SMOOTHING", "BLACKBORDER", "KODICHECKER", "FORWARDER", "UDPLISTENER", "BOBLIGHTSERVER", "GRABBER", "V4L", "LEDDEVICE"], "required": true }, "state": diff --git a/src/hyperion-remote/hyperion-remote.cpp b/src/hyperion-remote/hyperion-remote.cpp index a34c1baf..470d108a 100644 --- a/src/hyperion-remote/hyperion-remote.cpp +++ b/src/hyperion-remote/hyperion-remote.cpp @@ -93,7 +93,8 @@ int main(int argc, char * argv[]) Option & argMapping = parser.add