mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
global on/off (#424)
* implement global on/off * set gamma minimum to 0.1
This commit is contained in:
parent
a08e951762
commit
c6fa40fa87
@ -306,7 +306,7 @@
|
|||||||
"type" : "number",
|
"type" : "number",
|
||||||
"title" : "edt_conf_color_gammaRed_title",
|
"title" : "edt_conf_color_gammaRed_title",
|
||||||
"required" : true,
|
"required" : true,
|
||||||
"minimum" : 0.0,
|
"minimum" : 0.1,
|
||||||
"maximum": 100.0,
|
"maximum": 100.0,
|
||||||
"default" : 1.5,
|
"default" : 1.5,
|
||||||
"step" : 0.1,
|
"step" : 0.1,
|
||||||
@ -317,7 +317,7 @@
|
|||||||
"type" : "number",
|
"type" : "number",
|
||||||
"title" : "edt_conf_color_gammaGreen_title",
|
"title" : "edt_conf_color_gammaGreen_title",
|
||||||
"required" : true,
|
"required" : true,
|
||||||
"minimum" : 0.0,
|
"minimum" : 0.1,
|
||||||
"maximum": 100.0,
|
"maximum": 100.0,
|
||||||
"default" : 1.5,
|
"default" : 1.5,
|
||||||
"step" : 0.1,
|
"step" : 0.1,
|
||||||
@ -328,7 +328,7 @@
|
|||||||
"type" : "number",
|
"type" : "number",
|
||||||
"title" : "edt_conf_color_gammaBlue_title",
|
"title" : "edt_conf_color_gammaBlue_title",
|
||||||
"required" : true,
|
"required" : true,
|
||||||
"minimum" : 0.0,
|
"minimum" : 0.1,
|
||||||
"maximum": 100.0,
|
"maximum": 100.0,
|
||||||
"default" : 1.5,
|
"default" : 1.5,
|
||||||
"step" : 0.1,
|
"step" : 0.1,
|
||||||
|
@ -49,6 +49,7 @@
|
|||||||
using namespace hyperion;
|
using namespace hyperion;
|
||||||
|
|
||||||
int _connectionCounter = 0;
|
int _connectionCounter = 0;
|
||||||
|
std::map<hyperion::Components, bool> JsonClientConnection::_componentsPrevState;
|
||||||
|
|
||||||
JsonClientConnection::JsonClientConnection(QTcpSocket *socket)
|
JsonClientConnection::JsonClientConnection(QTcpSocket *socket)
|
||||||
: QObject()
|
: QObject()
|
||||||
@ -1147,16 +1148,52 @@ void JsonClientConnection::handleSchemaGetCommand(const QJsonObject& message, co
|
|||||||
void JsonClientConnection::handleComponentStateCommand(const QJsonObject& message, const QString &command, const int tan)
|
void JsonClientConnection::handleComponentStateCommand(const QJsonObject& message, const QString &command, const int tan)
|
||||||
{
|
{
|
||||||
const QJsonObject & componentState = message["componentstate"].toObject();
|
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<hyperion::Components, bool> 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);
|
sendSuccessReply(command, tan);
|
||||||
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Components component = stringToComponent(compStr);
|
||||||
|
|
||||||
|
if (hyperionIsActive())
|
||||||
|
{
|
||||||
|
if (component != COMP_INVALID)
|
||||||
|
{
|
||||||
|
_hyperion->setComponentState(component, compState);
|
||||||
|
sendSuccessReply(command, tan);
|
||||||
|
return;
|
||||||
|
}
|
||||||
sendErrorReply("invalid component name", command, tan);
|
sendErrorReply("invalid component name", command, tan);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sendErrorReply("can't change component state when hyperion is off", command, tan);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QTcpSocket>
|
#include <QTcpSocket>
|
||||||
@ -317,6 +319,9 @@ private:
|
|||||||
///
|
///
|
||||||
bool checkJson(const QJsonObject & message, const QString &schemaResource, QString & errors, bool ignoreRequired = false);
|
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
|
/// The TCP-Socket that is connected tot the Json-client
|
||||||
QTcpSocket * _socket;
|
QTcpSocket * _socket;
|
||||||
|
|
||||||
@ -358,6 +363,9 @@ private:
|
|||||||
/// address of client
|
/// address of client
|
||||||
QHostAddress _clientAddress;
|
QHostAddress _clientAddress;
|
||||||
|
|
||||||
|
/// holds the state before off state
|
||||||
|
static std::map<hyperion::Components, bool> _componentsPrevState;
|
||||||
|
|
||||||
// masks for fields in the basic header
|
// masks for fields in the basic header
|
||||||
static uint8_t const BHB0_OPCODE = 0x0F;
|
static uint8_t const BHB0_OPCODE = 0x0F;
|
||||||
static uint8_t const BHB0_RSV3 = 0x10;
|
static uint8_t const BHB0_RSV3 = 0x10;
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
"component":
|
"component":
|
||||||
{
|
{
|
||||||
"type" : "string",
|
"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
|
"required": true
|
||||||
},
|
},
|
||||||
"state":
|
"state":
|
||||||
|
@ -93,7 +93,8 @@ int main(int argc, char * argv[])
|
|||||||
Option & argMapping = parser.add<Option> ('m', "ledMapping" , "Set the methode for image to led mapping valid values: multicolor_mean, unicolor_mean");
|
Option & argMapping = parser.add<Option> ('m', "ledMapping" , "Set the methode for image to led mapping valid values: multicolor_mean, unicolor_mean");
|
||||||
IntOption & argSource = parser.add<IntOption> (0x0, "sourceSelect" , "Set current active priority channel and deactivate auto source switching");
|
IntOption & argSource = parser.add<IntOption> (0x0, "sourceSelect" , "Set current active priority channel and deactivate auto source switching");
|
||||||
BooleanOption & argSourceAuto = parser.add<BooleanOption>(0x0, "sourceAutoSelect", "Enables auto source, if disabled prio by manual selecting input source");
|
BooleanOption & argSourceAuto = parser.add<BooleanOption>(0x0, "sourceAutoSelect", "Enables auto source, if disabled prio by manual selecting input source");
|
||||||
BooleanOption & argSourceOff = parser.add<BooleanOption>(0x0, "sourceOff", "select no source, this results in leds activly set to black (=off)");
|
BooleanOption & argOff = parser.add<BooleanOption>(0x0, "off", "deactivates hyperion");
|
||||||
|
BooleanOption & argOn = parser.add<BooleanOption>(0x0, "on", "activates hyperion");
|
||||||
BooleanOption & argConfigGet = parser.add<BooleanOption>(0x0, "configGet" , "Print the current loaded Hyperion configuration file");
|
BooleanOption & argConfigGet = parser.add<BooleanOption>(0x0, "configGet" , "Print the current loaded Hyperion configuration file");
|
||||||
BooleanOption & argSchemaGet = parser.add<BooleanOption>(0x0, "schemaGet" , "Print the json schema for Hyperion configuration");
|
BooleanOption & argSchemaGet = parser.add<BooleanOption>(0x0, "schemaGet" , "Print the json schema for Hyperion configuration");
|
||||||
Option & argConfigSet = parser.add<Option> (0x0, "configSet", "Write to the actual loaded configuration file. Should be a Json object string.");
|
Option & argConfigSet = parser.add<Option> (0x0, "configSet", "Write to the actual loaded configuration file. Should be a Json object string.");
|
||||||
@ -115,7 +116,7 @@ int main(int argc, char * argv[])
|
|||||||
// check that exactly one command was given
|
// check that exactly one command was given
|
||||||
int commandCount = count({ parser.isSet(argColor), parser.isSet(argImage), parser.isSet(argEffect), parser.isSet(argCreateEffect), parser.isSet(argDeleteEffect),
|
int commandCount = count({ parser.isSet(argColor), parser.isSet(argImage), parser.isSet(argEffect), parser.isSet(argCreateEffect), parser.isSet(argDeleteEffect),
|
||||||
parser.isSet(argServerInfo), parser.isSet(argSysInfo),parser.isSet(argClear), parser.isSet(argClearAll), parser.isSet(argEnableComponent), parser.isSet(argDisableComponent), colorAdjust,
|
parser.isSet(argServerInfo), parser.isSet(argSysInfo),parser.isSet(argClear), parser.isSet(argClearAll), parser.isSet(argEnableComponent), parser.isSet(argDisableComponent), colorAdjust,
|
||||||
parser.isSet(argSource), parser.isSet(argSourceAuto), parser.isSet(argSourceOff), parser.isSet(argConfigGet), parser.isSet(argSchemaGet), parser.isSet(argConfigSet),
|
parser.isSet(argSource), parser.isSet(argSourceAuto), parser.isSet(argOff), parser.isSet(argOn), parser.isSet(argConfigGet), parser.isSet(argSchemaGet), parser.isSet(argConfigSet),
|
||||||
parser.isSet(argMapping) });
|
parser.isSet(argMapping) });
|
||||||
if (commandCount != 1)
|
if (commandCount != 1)
|
||||||
{
|
{
|
||||||
@ -198,9 +199,13 @@ int main(int argc, char * argv[])
|
|||||||
{
|
{
|
||||||
connection.setComponentState(argDisableComponent.value(parser), false);
|
connection.setComponentState(argDisableComponent.value(parser), false);
|
||||||
}
|
}
|
||||||
else if (parser.isSet(argSourceOff))
|
else if (parser.isSet(argOn))
|
||||||
{
|
{
|
||||||
connection.setSource(std::numeric_limits<uint8_t>::max());
|
connection.setComponentState("ALL", true);
|
||||||
|
}
|
||||||
|
else if (parser.isSet(argOff))
|
||||||
|
{
|
||||||
|
connection.setComponentState("ALL", false);
|
||||||
}
|
}
|
||||||
else if (parser.isSet(argSource))
|
else if (parser.isSet(argSource))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user