Details coming soon.

This commit is contained in:
Paulchen-Panther
2018-12-27 23:11:32 +01:00
parent e3be03ea73
commit d762aa2f3e
186 changed files with 6156 additions and 5444 deletions

View File

@@ -9,11 +9,8 @@ if ( NOT ENABLE_PROFILER )
LIST ( REMOVE_ITEM Utils_SOURCES ${CURRENT_HEADER_DIR}/Profiler.h ${CURRENT_SOURCE_DIR}/Profiler.cpp )
endif()
set(Utils_RESOURCES ${CURRENT_SOURCE_DIR}/JSONRPC_schemas.qrc )
add_library(hyperion-utils
${Utils_SOURCES}
${Utils_RESOURCES}
)
target_link_libraries(hyperion-utils

View File

@@ -1,6 +1,7 @@
#include <utils/FileUtils.h>
// qt incl
#include <QDir>
#include <QFileInfo>
#include <QDebug>
@@ -21,6 +22,17 @@ namespace FileUtils {
return fi.path();
}
bool removeDir(const QString& path, Logger* log)
{
//QDir dir(path);
if(!QDir(path).removeRecursively())
{
Error(log, "Failed to remove directory: %s", QSTRING_CSTR(path));
return false;
}
return true;
}
bool fileExists(const QString& path, Logger* log, bool ignError)
{
QFile file(path);
@@ -71,17 +83,18 @@ namespace FileUtils {
return true;
}
bool removeFile(const QString& path, Logger* log)
bool removeFile(const QString& path, Logger* log, bool ignError)
{
QFile file(path);
if(!file.remove())
{
resolveFileError(file,log);
if(!ignError)
resolveFileError(file,log);
return false;
}
return true;
}
QString convertPath(const QString path)
{
QString p = path;

View File

@@ -1,154 +0,0 @@
{
"type":"object",
"required":true,
"properties":{
"command": {
"type" : "string",
"required" : true,
"enum" : ["adjustment"]
},
"tan" : {
"type" : "integer"
},
"adjustment": {
"type": "object",
"required": true,
"properties": {
"id" : {
"type" : "string",
"required" : false
},
"red": {
"type": "array",
"required": false,
"items" : {
"type": "integer",
"minimum": 0,
"maximum": 255
},
"minItems": 3,
"maxItems": 3
},
"green": {
"type": "array",
"required": false,
"items" : {
"type": "integer",
"minimum": 0,
"maximum": 255
},
"minItems": 3,
"maxItems": 3
},
"blue": {
"type": "array",
"required": false,
"items" : {
"type": "integer",
"minimum": 0,
"maximum": 255
},
"minItems": 3,
"maxItems": 3
},
"yellow": {
"type": "array",
"required": false,
"items" : {
"type": "integer",
"minimum": 0,
"maximum": 255
},
"minItems": 3,
"maxItems": 3
},
"magenta": {
"type": "array",
"required": false,
"items" : {
"type": "integer",
"minimum": 0,
"maximum": 255
},
"minItems": 3,
"maxItems": 3
},
"cyan": {
"type": "array",
"required": false,
"items" : {
"type": "integer",
"minimum": 0,
"maximum": 255
},
"minItems": 3,
"maxItems": 3
},
"black": {
"type": "array",
"required": false,
"items" : {
"type": "integer",
"minimum": 0,
"maximum": 255
},
"minItems": 3,
"maxItems": 3
},
"white": {
"type": "array",
"required": false,
"items" : {
"type": "integer",
"minimum": 0,
"maximum": 255
},
"minItems": 3,
"maxItems": 3
},
"gammaRed": {
"type" : "number",
"required" : false,
"minimum" : 0.1,
"maximum" : 5.0
},
"gammaGreen": {
"type" : "number",
"required" : false,
"minimum" : 0.1,
"maximum" : 5.0
},
"gammaBlue": {
"type" : "number",
"required" : false,
"minimum" : 0.1,
"maximum" : 5.0
},
"backlightThreshold" : {
"type" : "integer",
"required" : false,
"minimum" : 0,
"maximum" : 100
},
"backlightColored" : {
"type" : "boolean",
"required" : false
},
"brightness" : {
"type" : "integer",
"required" : false,
"minimum" : 0,
"maximum" : 100
},
"brightnessCompensation" : {
"type" : "integer",
"required" : false,
"minimum" : 0,
"maximum" : 100
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}

View File

@@ -1,21 +0,0 @@
{
"type":"object",
"required":true,
"properties":{
"command": {
"type" : "string",
"required" : true,
"enum" : ["clear"]
},
"tan" : {
"type" : "integer"
},
"priority": {
"type": "integer",
"minimum" : 1,
"maximum" : 253,
"required": true
}
},
"additionalProperties": false
}

View File

@@ -1,15 +0,0 @@
{
"type":"object",
"required":true,
"properties":{
"command": {
"type" : "string",
"required" : true,
"enum" : ["clearall"]
},
"tan" : {
"type" : "integer"
}
},
"additionalProperties": false
}

View File

@@ -1,39 +0,0 @@
{
"type":"object",
"required":true,
"properties":{
"command": {
"type" : "string",
"required" : true,
"enum" : ["color"]
},
"tan" : {
"type" : "integer"
},
"priority": {
"type": "integer",
"minimum" : 1,
"maximum" : 253,
"required": true
},
"duration": {
"type": "integer",
"required": false
},
"origin": {
"type": "string",
"minLength" : 4,
"maxLength" : 20,
"required": true
},
"color": {
"type": "array",
"required": true,
"items" :{
"type" : "integer"
},
"minItems": 3
}
},
"additionalProperties": false
}

View File

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

View File

@@ -1,23 +0,0 @@
{
"type":"object",
"required":true,
"properties":{
"command": {
"type" : "string",
"required" : true,
"enum" : ["config"]
},
"subcommand": {
"type" : "string",
"required" : true,
"enum" : ["setconfig","getconfig","getschema","reload"]
},
"tan" : {
"type" : "integer"
},
"config": {
"type" : "object"
}
},
"additionalProperties": false
}

View File

@@ -1,30 +0,0 @@
{
"type":"object",
"required":true,
"properties":{
"command": {
"type" : "string",
"required" : true,
"enum" : ["create-effect"]
},
"tan" : {
"type" : "integer"
},
"name" :
{
"type" : "string",
"required" : true
},
"script" :
{
"type" : "string",
"required" : true
},
"args" :
{
"type" : "object",
"required" : true
}
},
"additionalProperties": false
}

View File

@@ -1,21 +0,0 @@
{
"type":"object",
"required":true,
"properties":{
"command": {
"type" : "string",
"required" : true,
"enum" : ["delete-effect"]
},
"tan" : {
"type" : "integer"
},
"name" :
{
"type" : "string",
"required" : true
}
},
"additionalProperties": false
}

View File

@@ -1,50 +0,0 @@
{
"type":"object",
"required":true,
"properties":{
"command": {
"type" : "string",
"required" : true,
"enum" : ["effect"]
},
"tan" : {
"type" : "integer"
},
"priority": {
"type": "integer",
"minimum" : 1,
"maximum" : 253,
"required": true
},
"duration": {
"type": "integer",
"required": false
},
"origin": {
"type": "string",
"minLength" : 4,
"maxLength" : 20,
"required": true
},
"effect": {
"type": "object",
"required": true,
"properties" :{
"name" : {
"type" : "string",
"required" : true
},
"args" : {
"type" : "object",
"required" : false
}
},
"additionalProperties": false
},
"pythonScript" : {
"type" : "string",
"required" : false
}
},
"additionalProperties": false
}

View File

@@ -1,43 +0,0 @@
{
"type":"object",
"required":true,
"properties":{
"command": {
"type" : "string",
"required" : true,
"enum" : ["image"]
},
"tan" : {
"type" : "integer"
},
"priority": {
"type": "integer",
"minimum" : 1,
"maximum" : 253,
"required": true
},
"origin": {
"type": "string",
"required": true
},
"duration": {
"type": "integer",
"required": false
},
"imagewidth": {
"type" : "integer",
"required": true,
"minimum": 0
},
"imageheight": {
"type" : "integer",
"required": true,
"minimum": 0
},
"imagedata": {
"type": "string",
"required": true
}
},
"additionalProperties": false
}

View File

@@ -1,27 +0,0 @@
{
"type":"object",
"required":true,
"properties":{
"command": {
"type" : "string",
"required" : true,
"enum" : ["ledcolors"]
},
"tan" : {
"type" : "integer"
},
"subcommand": {
"type" : "string",
"required" : true,
"enum" : ["ledstream-stop","ledstream-start","testled","imagestream-start","imagestream-stop"]
},
"oneshot": {
"type" : "bool"
},
"interval": {
"type" : "integer"
}
},
"additionalProperties": false
}

View File

@@ -1,28 +0,0 @@
{
"type":"object",
"required":true,
"properties":{
"command": {
"type" : "string",
"required" : true,
"enum" : ["logging"]
},
"tan" : {
"type" : "integer"
},
"subcommand": {
"type" : "string",
"required" : true,
"enum" : ["stop","start","update"]
},
"oneshot": {
"type" : "bool"
},
"interval": {
"type" : "integer"
}
},
"additionalProperties": false
}

View File

@@ -1,19 +0,0 @@
{
"type":"object",
"required":true,
"properties":{
"command": {
"type" : "string",
"required" : true,
"enum" : ["processing"]
},
"tan" : {
"type" : "integer"
},
"mappingType": {
"type" : "string",
"enum" : ["multicolor_mean", "unicolor_mean"]
}
},
"additionalProperties": false
}

View File

@@ -1,15 +0,0 @@
{
"type":"object",
"required":true,
"properties":{
"command": {
"type" : "string",
"required" : true,
"enum" : ["serverinfo"]
},
"tan" : {
"type" : "integer"
}
},
"additionalProperties": false
}

View File

@@ -1,23 +0,0 @@
{
"type":"object",
"required":false,
"properties":{
"command": {
"type" : "string",
"required" : true,
"enum" : ["sourceselect"]
},
"tan" : {
"type" : "integer"
},
"priority": {
"type": "integer",
"minimum" : 0,
"maximum" : 255
},
"auto": {
"type": "boolean"
}
},
"additionalProperties": false
}

View File

@@ -1,15 +0,0 @@
{
"type":"object",
"required":true,
"properties":{
"command": {
"type" : "string",
"required" : true,
"enum" : ["sysinfo"]
},
"tan" : {
"type" : "integer"
}
},
"additionalProperties": false
}

View File

@@ -1,19 +0,0 @@
{
"type":"object",
"required":true,
"properties":{
"command": {
"type" : "string",
"required" : true,
"enum" : ["videomode"]
},
"tan" : {
"type" : "integer"
},
"videoMode": {
"type" : "string",
"enum" : ["2D", "3DSBS", "3DTAB"]
}
},
"additionalProperties": false
}

View File

@@ -1,11 +0,0 @@
{
"type":"object",
"required":true,
"properties":{
"command": {
"type" : "string",
"required" : true,
"enum" : ["color", "image", "effect", "create-effect", "delete-effect", "serverinfo", "clear", "clearall", "adjustment", "sourceselect", "config", "componentstate", "ledcolors", "logging", "processing", "sysinfo", "videomode"]
}
}
}

View File

@@ -1,22 +0,0 @@
<RCC>
<qresource prefix="/">
<file alias="schema">JSONRPC_schema/schema.json</file>
<file alias="schema-color">JSONRPC_schema/schema-color.json</file>
<file alias="schema-image">JSONRPC_schema/schema-image.json</file>
<file alias="schema-serverinfo">JSONRPC_schema/schema-serverinfo.json</file>
<file alias="schema-sysinfo">JSONRPC_schema/schema-sysinfo.json</file>
<file alias="schema-clear">JSONRPC_schema/schema-clear.json</file>
<file alias="schema-clearall">JSONRPC_schema/schema-clearall.json</file>
<file alias="schema-adjustment">JSONRPC_schema/schema-adjustment.json</file>
<file alias="schema-effect">JSONRPC_schema/schema-effect.json</file>
<file alias="schema-create-effect">JSONRPC_schema/schema-create-effect.json</file>
<file alias="schema-delete-effect">JSONRPC_schema/schema-delete-effect.json</file>
<file alias="schema-sourceselect">JSONRPC_schema/schema-sourceselect.json</file>
<file alias="schema-config">JSONRPC_schema/schema-config.json</file>
<file alias="schema-componentstate">JSONRPC_schema/schema-componentstate.json</file>
<file alias="schema-ledcolors">JSONRPC_schema/schema-ledcolors.json</file>
<file alias="schema-logging">JSONRPC_schema/schema-logging.json</file>
<file alias="schema-processing">JSONRPC_schema/schema-processing.json</file>
<file alias="schema-videomode">JSONRPC_schema/schema-videomode.json</file>
</qresource>
</RCC>

File diff suppressed because it is too large Load Diff

View File

@@ -9,8 +9,6 @@
#include <QJsonObject>
#include <QJsonParseError>
#include <QDebug>
namespace JsonUtils {
bool readFile(const QString& path, QJsonObject& obj, Logger* log, bool ignError)
@@ -38,13 +36,33 @@ namespace JsonUtils {
}
bool parse(const QString& path, const QString& data, QJsonObject& obj, Logger* log)
{
QJsonDocument doc;
if(!parse(path, data, doc, log))
return false;
obj = doc.object();
return true;
}
bool parse(const QString& path, const QString& data, QJsonArray& arr, Logger* log)
{
QJsonDocument doc;
if(!parse(path, data, doc, log))
return false;
arr = doc.array();
return true;
}
bool parse(const QString& path, const QString& data, QJsonDocument& doc, Logger* log)
{
//remove Comments in data
QString cleanData = data;
cleanData.remove(QRegularExpression("([^:]?\\/\\/.*)"));
//cleanData .remove(QRegularExpression("([^:]?\\/\\/.*)"));
QJsonParseError error;
QJsonDocument doc = QJsonDocument::fromJson(cleanData.toUtf8(), &error);
doc = QJsonDocument::fromJson(cleanData.toUtf8(), &error);
if (error.error != QJsonParseError::NoError)
{
@@ -63,7 +81,6 @@ namespace JsonUtils {
Error(log,"Failed to parse json data from %s: Error: %s at Line: %i, Column: %i", QSTRING_CSTR(path), QSTRING_CSTR(error.errorString()), errorLine, errorColumn);
return false;
}
obj = doc.object();
return true;
}
@@ -74,6 +91,14 @@ namespace JsonUtils {
if(!readFile(schemaPath, schema, log))
return false;
if(!validate(file, json, schema, log))
return false;
return true;
}
bool validate(const QString& file, const QJsonObject& json, const QJsonObject& schema, Logger* log)
{
QJsonSchemaChecker schemaChecker;
schemaChecker.setSchema(schema);
if (!schemaChecker.validate(json).first)
@@ -120,7 +145,7 @@ namespace JsonUtils {
obj.insert(attribute, resolveRefs(attributeValue.toObject(), obj, log));
else
{
qDebug() <<"ADD ATTR:VALUE"<<attribute<<attributeValue;
//qDebug() <<"ADD ATTR:VALUE"<<attribute<<attributeValue;
obj.insert(attribute, attributeValue);
}
}

View File

@@ -11,7 +11,7 @@
#include <stdexcept>
namespace Process {
void restartHyperion(bool asNewProcess)
{
Logger* log = Logger::getInstance("Process");
@@ -19,8 +19,8 @@ void restartHyperion(bool asNewProcess)
<< " *******************************************" << std::endl
<< " * hyperion will restart now *" << std::endl
<< " *******************************************" << std::endl << std::endl;
QStringList qargs = QCoreApplication::arguments();
int size = qargs.size();
char *args[size+1];
@@ -43,7 +43,7 @@ QByteArray command_exec(QString cmd, QByteArray data)
QString result = "";
std::shared_ptr<FILE> pipe(popen(cmd.toLocal8Bit().constData(), "r"), pclose);
if (pipe)
if (pipe)
{
while (!feof(pipe.get()))
{
@@ -54,4 +54,4 @@ QByteArray command_exec(QString cmd, QByteArray data)
return QSTRING_CSTR(result);
}
};
};

View File

@@ -21,7 +21,7 @@ RgbChannelAdjustment::~RgbChannelAdjustment()
void RgbChannelAdjustment::resetInitialized()
{
Debug(_log, "initialize mapping with %d,%d,%d", _adjust[RED], _adjust[GREEN], _adjust[BLUE]);
//Debug(_log, "initialize mapping with %d,%d,%d", _adjust[RED], _adjust[GREEN], _adjust[BLUE]);
memset(_initialized, false, sizeof(_initialized));
}

View File

@@ -144,8 +144,8 @@ void RgbTransform::transform(uint8_t & red, uint8_t & green, uint8_t & blue)
{
// apply gamma
red = _mappingR[red];
green = _mappingG[green];
blue = _mappingB[blue];
green = _mappingR[green];
blue = _mappingR[blue];
// apply brightnesss
int rgbSum = red+green+blue;

View File

@@ -23,7 +23,7 @@ Stats::Stats()
{
if (!(interface.flags() & QNetworkInterface::IsLoopBack))
{
_hyperion->id = QString(QCryptographicHash::hash(interface.hardwareAddress().toLocal8Bit().append(_hyperion->getConfigFileName().toLocal8Bit()),QCryptographicHash::Sha1).toHex());
_hyperion->setId(QString(QCryptographicHash::hash(interface.hardwareAddress().toLocal8Bit().append(_hyperion->getConfigFileName().toLocal8Bit()),QCryptographicHash::Sha1).toHex()));
_hash = QString(QCryptographicHash::hash(interface.hardwareAddress().toLocal8Bit(),QCryptographicHash::Sha1).toHex());
break;
}
@@ -34,12 +34,12 @@ Stats::Stats()
{
Warning(_log, "No interface found, abort");
// fallback id
_hyperion->id = QString(QCryptographicHash::hash(_hyperion->getConfigFileName().toLocal8Bit(),QCryptographicHash::Sha1).toHex());
_hyperion->setId(QString(QCryptographicHash::hash(_hyperion->getConfigFileName().toLocal8Bit(),QCryptographicHash::Sha1).toHex()));
return;
}
// prepare content
QJsonObject config = _hyperion->getConfig();
QJsonObject config = _hyperion->getQJsonConfig();
SysInfo::HyperionSysInfo data = SysInfo::get();
QJsonObject system;
@@ -49,8 +49,8 @@ Stats::Stats()
system["pVersion" ] = data.productVersion;
system["pName" ] = data.prettyName;
system["version" ] = QString(HYPERION_VERSION);
system["device" ] = LedDevice::activeDevice();
system["id" ] = _hyperion->id;
system["device" ] = Hyperion::getInstance()->getActiveDevice();
system["id" ] = _hyperion->getId();
system["hw_id" ] = _hash;
system["ledCount" ] = QString::number(Hyperion::getInstance()->getLedCount());
system["comp_sm" ] = config["smoothing"].toObject().take("enable");
@@ -100,7 +100,7 @@ void Stats::sendHTTP()
void Stats::sendHTTPp()
{
_req.setUrl(QUrl("https://api.hyperion-project.org/api/stats/"+_hyperion->id));
_req.setUrl(QUrl("https://api.hyperion-project.org/api/stats/"+_hyperion->getId()));
_mgr.put(_req,_ba);
}
@@ -122,7 +122,7 @@ bool Stats::trigger(bool set)
{
QString path = _hyperion->getRootPath()+"/misc/";
QDir dir;
QFile file(path + _hyperion->id);
QFile file(path + _hyperion->getId());
if(set && file.open(QIODevice::ReadWrite) )
{