mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
migrate std::string to qstring + add sysinfo via json (#412)
* std::string -> qstring part 1 * more string migration * more string migration ... * ... * more qstring mogrations add sysinfo via json * remove unneccessary includes * integrate sysinfo into webui
This commit is contained in:
parent
19f8928869
commit
bfb9a08c80
@ -6,11 +6,14 @@ $(document).ready( function() {
|
||||
initWebSocket();
|
||||
|
||||
$(hyperion).on("cmd-serverinfo",function(event){
|
||||
// get sysinfo only once
|
||||
if ( typeof(sysInfo.info) == "undefined" )
|
||||
requestSysInfo();
|
||||
|
||||
serverInfo = event.response;
|
||||
currentVersion = serverInfo.info.hyperion[0].version;
|
||||
$(hyperion).trigger("ready");
|
||||
|
||||
if (serverInfo.info.hyperion[0].config_modified)
|
||||
if (serverInfo.info.hyperion.config_modified)
|
||||
$("#hyperion_reload_notify").fadeIn("fast");
|
||||
else
|
||||
$("#hyperion_reload_notify").fadeOut("fast");
|
||||
@ -22,7 +25,7 @@ $(document).ready( function() {
|
||||
loggingStreamActive = false;
|
||||
}
|
||||
|
||||
if (!serverInfo.info.hyperion[0].config_writeable)
|
||||
if (!serverInfo.info.hyperion.config_writeable)
|
||||
{
|
||||
showInfoDialog('uilock',$.i18n('InfoDialog_nowrite_title'),$.i18n('InfoDialog_nowrite_text'));
|
||||
$('#wrapper').toggle(false);
|
||||
@ -37,6 +40,11 @@ $(document).ready( function() {
|
||||
|
||||
}); // end cmd-serverinfo
|
||||
|
||||
$(hyperion).one("cmd-sysinfo", function(event) {
|
||||
sysInfo = event.response;
|
||||
currentVersion = sysInfo.info.hyperion.version;
|
||||
});
|
||||
|
||||
$(hyperion).one("cmd-config-getschema", function(event) {
|
||||
serverSchema = event.response.result;
|
||||
requestServerConfig();
|
||||
|
@ -3,12 +3,13 @@
|
||||
var webPrio = 1;
|
||||
var webOrigin = "Web Configuration";
|
||||
var showOptHelp;
|
||||
var currentVersion;
|
||||
var currentVersion = "";
|
||||
var latestVersion;
|
||||
var serverInfo = {};
|
||||
var parsedUpdateJSON = {};
|
||||
var serverSchema = {};
|
||||
var serverConfig = {};
|
||||
var sysInfo = {};
|
||||
var schema;
|
||||
var jsonPort = 19444;
|
||||
var websocket = null;
|
||||
@ -76,7 +77,6 @@ function initWebSocket()
|
||||
|
||||
websocket.onopen = function (event) {
|
||||
$(hyperion).trigger({type:"open"});
|
||||
|
||||
$(hyperion).on("cmd-serverinfo", function(event) {
|
||||
watchdog = 0;
|
||||
});
|
||||
@ -171,6 +171,11 @@ function requestServerInfo()
|
||||
sendToHyperion("serverinfo");
|
||||
}
|
||||
|
||||
function requestSysInfo()
|
||||
{
|
||||
sendToHyperion("sysinfo");
|
||||
}
|
||||
|
||||
function requestServerConfigSchema()
|
||||
{
|
||||
sendToHyperion("config","getschema");
|
||||
|
@ -116,7 +116,7 @@ namespace hyperion
|
||||
unsigned _blurRemoveCnt;
|
||||
|
||||
/// The border detection mode
|
||||
const std::string _detectionMode;
|
||||
const QString _detectionMode;
|
||||
|
||||
/// The blackborder detector
|
||||
BlackBorderDetector _detector;
|
||||
|
@ -1,5 +1,4 @@
|
||||
#ifndef HYPERION_OPTION_H
|
||||
#define HYPERION_OPTION_H
|
||||
#pragma once
|
||||
|
||||
#include <QCommandLineOption>
|
||||
#include <QCommandLineParser>
|
||||
@ -13,38 +12,30 @@ class Parser;
|
||||
* regular QCommandLineOption it is _not_ idempotent! */
|
||||
class Option: public QCommandLineOption
|
||||
{
|
||||
protected:
|
||||
QString _error;
|
||||
public:
|
||||
Option(const QString &name,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString::null,
|
||||
const QString &defaultValue = QString()
|
||||
)
|
||||
: QCommandLineOption(name, description, valueName, defaultValue)
|
||||
{}
|
||||
Option(const QStringList &names,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString::null,
|
||||
const QString &defaultValue = QString()
|
||||
)
|
||||
: QCommandLineOption(names, description, valueName, defaultValue)
|
||||
{}
|
||||
Option(const QCommandLineOption &other)
|
||||
: QCommandLineOption(other)
|
||||
{}
|
||||
Option(const QString &name,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString::null,
|
||||
const QString &defaultValue = QString()
|
||||
);
|
||||
|
||||
virtual bool validate(Parser &parser, QString &value);
|
||||
QString name()
|
||||
{ return this->names().last();}
|
||||
QString getError()
|
||||
{ return this->_error; }
|
||||
Option(const QStringList &names,
|
||||
const QString &description = QString(),
|
||||
const QString &valueName = QString::null,
|
||||
const QString &defaultValue = QString()
|
||||
);
|
||||
|
||||
Option(const QCommandLineOption &other);
|
||||
|
||||
virtual bool validate(Parser &parser, QString &value);
|
||||
QString name();
|
||||
QString getError();
|
||||
QString value(Parser &parser);
|
||||
std::string getStdString(Parser &parser);
|
||||
std::wstring getStdWString(Parser &parser);
|
||||
const char* getCString(Parser &parser);
|
||||
const char* getCString(Parser &parser);
|
||||
|
||||
protected:
|
||||
QString _error;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //HYPERION_OPTION_H
|
||||
|
@ -20,7 +20,7 @@ public:
|
||||
/// @param[in] width The width of the captured screenshot
|
||||
/// @param[in] height The heigth of the captured screenshot
|
||||
///
|
||||
FramebufferFrameGrabber(const std::string & device, const unsigned width, const unsigned height);
|
||||
FramebufferFrameGrabber(const QString & device, const unsigned width, const unsigned height);
|
||||
~FramebufferFrameGrabber();
|
||||
|
||||
///
|
||||
@ -47,7 +47,7 @@ private:
|
||||
unsigned char * _fbp;
|
||||
|
||||
/// Framebuffer device e.g. /dev/fb0
|
||||
const std::string _fbDevice;
|
||||
const QString _fbDevice;
|
||||
|
||||
/// With of the captured snapshot [pixels]
|
||||
const unsigned _width;
|
||||
|
@ -28,7 +28,7 @@ public:
|
||||
/// @param[in] grabHeight The height of the grabbed images [pixels]
|
||||
/// @param[in] updateRate_Hz The image grab rate [Hz]
|
||||
///
|
||||
FramebufferWrapper(const std::string & device, const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz, const int priority);
|
||||
FramebufferWrapper(const QString & device, const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz, const int priority);
|
||||
|
||||
///
|
||||
/// Destructor of this framebuffer frame grabber. Releases any claimed resources.
|
||||
|
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
// stl includes
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
@ -29,7 +28,7 @@ class V4L2Grabber : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
V4L2Grabber(const std::string & device,
|
||||
V4L2Grabber(const QString & device,
|
||||
int input,
|
||||
VideoStandard videoStandard, PixelFormat pixelFormat,
|
||||
int width,
|
||||
@ -103,9 +102,9 @@ private:
|
||||
|
||||
int xioctl(int request, void *arg);
|
||||
|
||||
void throw_exception(const std::string &error);
|
||||
void throw_exception(const QString &error);
|
||||
|
||||
void throw_errno_exception(const std::string &error);
|
||||
void throw_errno_exception(const QString &error);
|
||||
|
||||
private:
|
||||
enum io_method {
|
||||
@ -120,8 +119,8 @@ private:
|
||||
};
|
||||
|
||||
private:
|
||||
std::string _deviceName;
|
||||
std::map<std::string,std::string> _v4lDevices;
|
||||
QString _deviceName;
|
||||
std::map<QString,QString> _v4lDevices;
|
||||
int _input;
|
||||
VideoStandard _videoStandard;
|
||||
io_method _ioMethod;
|
||||
|
@ -13,7 +13,7 @@ class V4L2Wrapper : public GrabberWrapper
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
V4L2Wrapper(const std::string & device,
|
||||
V4L2Wrapper(const QString & device,
|
||||
int input,
|
||||
VideoStandard videoStandard,
|
||||
PixelFormat pixelFormat,
|
||||
|
@ -1,8 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
|
||||
/**
|
||||
* Enumeration of the possible video standards the grabber can be set to
|
||||
*/
|
||||
@ -12,10 +9,10 @@ enum VideoStandard {
|
||||
VIDEOSTANDARD_NO_CHANGE
|
||||
};
|
||||
|
||||
inline VideoStandard parseVideoStandard(std::string videoStandard)
|
||||
inline VideoStandard parseVideoStandard(QString videoStandard)
|
||||
{
|
||||
// convert to lower case
|
||||
std::transform(videoStandard.begin(), videoStandard.end(), videoStandard.begin(), ::tolower);
|
||||
videoStandard = videoStandard.toLower();
|
||||
|
||||
if (videoStandard == "pal")
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
// STL includes
|
||||
#include <string>
|
||||
#include <QString>
|
||||
|
||||
// Utils includes
|
||||
#include <utils/RgbChannelAdjustment.h>
|
||||
@ -12,7 +12,7 @@ class ColorAdjustment
|
||||
public:
|
||||
|
||||
/// Unique identifier for this color transform
|
||||
std::string _id;
|
||||
QString _id;
|
||||
|
||||
/// The BLACK (RGB-Channel) adjustment
|
||||
RgbChannelAdjustment _rgbBlackAdjustment;
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QTimer>
|
||||
#include <string>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
|
@ -128,7 +128,7 @@ public:
|
||||
|
||||
/// get filename of configfile
|
||||
/// @return the current config filename
|
||||
std::string getConfigFileName() { return _configFile.toStdString(); };
|
||||
QString getConfigFileName() { return _configFile; };
|
||||
|
||||
/// register a input source to a priority channel
|
||||
/// @param name uniq name of input source
|
||||
@ -210,13 +210,13 @@ public slots:
|
||||
/// Returns the list with unique adjustment identifiers
|
||||
/// @return The list with adjustment identifiers
|
||||
///
|
||||
const std::vector<std::string> & getAdjustmentIds() const;
|
||||
const QStringList & getAdjustmentIds() const;
|
||||
|
||||
///
|
||||
/// Returns the ColorAdjustment with the given identifier
|
||||
/// @return The adjustment with the given identifier (or nullptr if the identifier does not exist)
|
||||
///
|
||||
ColorAdjustment * getAdjustment(const std::string& id);
|
||||
ColorAdjustment * getAdjustment(const QString& id);
|
||||
|
||||
///
|
||||
/// Returns MessageForwarder Object
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
// STL includes
|
||||
#include <ctime>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// Local includes
|
||||
|
@ -25,8 +25,8 @@ public:
|
||||
MessageForwarder();
|
||||
~MessageForwarder();
|
||||
|
||||
void addJsonSlave(std::string slave);
|
||||
void addProtoSlave(std::string slave);
|
||||
void addJsonSlave(QString slave);
|
||||
void addProtoSlave(QString slave);
|
||||
|
||||
bool protoForwardingEnabled();
|
||||
bool jsonForwardingEnabled();
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
// system includes
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
// QT includes
|
||||
#include <QTimer>
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
// STL incldues
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
|
||||
@ -24,7 +23,7 @@
|
||||
class LedDevice;
|
||||
|
||||
typedef LedDevice* ( *LedDeviceCreateFuncType ) ( const QJsonObject& );
|
||||
typedef std::map<std::string,LedDeviceCreateFuncType> LedDeviceRegistry;
|
||||
typedef std::map<QString,LedDeviceCreateFuncType> LedDeviceRegistry;
|
||||
|
||||
///
|
||||
/// Interface (pure virtual base class) for LedDevices.
|
||||
@ -52,10 +51,10 @@ public:
|
||||
///
|
||||
virtual int open();
|
||||
|
||||
static int addToDeviceMap(std::string name, LedDeviceCreateFuncType funcPtr);
|
||||
static int addToDeviceMap(QString name, LedDeviceCreateFuncType funcPtr);
|
||||
static const LedDeviceRegistry& getDeviceMap();
|
||||
static void setActiveDevice(std::string dev);
|
||||
static std::string activeDevice() { return _activeDevice; }
|
||||
static void setActiveDevice(QString dev);
|
||||
static QString activeDevice() { return _activeDevice; }
|
||||
static QJsonObject getLedDeviceSchemas();
|
||||
static void setLedCount(int ledCount);
|
||||
static int getLedCount() { return _ledCount; }
|
||||
@ -78,7 +77,7 @@ protected:
|
||||
|
||||
bool _deviceReady;
|
||||
|
||||
static std::string _activeDevice;
|
||||
static QString _activeDevice;
|
||||
static LedDeviceRegistry _ledDeviceMap;
|
||||
|
||||
static int _ledCount;
|
||||
|
@ -1,9 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
// stl includes
|
||||
#include <string>
|
||||
|
||||
// Qt includes
|
||||
#include <QString>
|
||||
#include <QColor>
|
||||
#include <QImage>
|
||||
#include <QTcpSocket>
|
||||
@ -33,7 +31,7 @@ public:
|
||||
///
|
||||
/// @param address The address of the Hyperion server (for example "192.168.0.32:19444)
|
||||
///
|
||||
ProtoConnection(const std::string & address);
|
||||
ProtoConnection(const QString & address);
|
||||
|
||||
///
|
||||
/// Destructor
|
||||
|
@ -49,7 +49,6 @@ inline std::ostream& operator<<(std::ostream& os, const ColorRgb& color)
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
/// Compare operator to check if a color is 'smaller' than another color
|
||||
inline bool operator<(const ColorRgb & lhs, const ColorRgb & rhs)
|
||||
{
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include <QString>
|
||||
|
||||
// stl includes
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <map>
|
||||
@ -51,9 +50,9 @@ public:
|
||||
} T_LOG_MESSAGE;
|
||||
|
||||
static Logger* getInstance(QString name="", LogLevel minLevel=Logger::INFO);
|
||||
static void deleteInstance(std::string name="");
|
||||
static void setLogLevel(LogLevel level,std::string name="");
|
||||
static LogLevel getLogLevel(std::string name="");
|
||||
static void deleteInstance(QString name="");
|
||||
static void setLogLevel(LogLevel level, QString name="");
|
||||
static LogLevel getLogLevel(QString name="");
|
||||
|
||||
void Message(LogLevel level, const char* sourceFile, const char* func, unsigned int line, const char* fmt, ...);
|
||||
void setMinLevel(LogLevel level) { _minLevel = level; };
|
||||
@ -63,18 +62,18 @@ signals:
|
||||
void newLogMessage(Logger::T_LOG_MESSAGE);
|
||||
|
||||
protected:
|
||||
Logger( std::string name="", LogLevel minLevel=INFO);
|
||||
Logger( QString name="", LogLevel minLevel=INFO);
|
||||
~Logger();
|
||||
|
||||
private:
|
||||
static std::map<std::string,Logger*> *LoggerMap;
|
||||
static std::map<QString,Logger*> *LoggerMap;
|
||||
static LogLevel GLOBAL_MIN_LOG_LEVEL;
|
||||
|
||||
std::string _name;
|
||||
std::string _appname;
|
||||
LogLevel _minLevel;
|
||||
bool _syslogEnabled;
|
||||
unsigned int _loggerId;
|
||||
QString _name;
|
||||
QString _appname;
|
||||
LogLevel _minLevel;
|
||||
bool _syslogEnabled;
|
||||
unsigned _loggerId;
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <QString>
|
||||
|
||||
/**
|
||||
* Enumeration of the possible pixel formats the grabber can be set to
|
||||
@ -16,10 +15,10 @@ enum PixelFormat {
|
||||
PIXELFORMAT_NO_CHANGE
|
||||
};
|
||||
|
||||
inline PixelFormat parsePixelFormat(std::string pixelFormat)
|
||||
inline PixelFormat parsePixelFormat(QString pixelFormat)
|
||||
{
|
||||
// convert to lower case
|
||||
std::transform(pixelFormat.begin(), pixelFormat.end(), pixelFormat.begin(), ::tolower);
|
||||
pixelFormat = pixelFormat.toLower();
|
||||
|
||||
if (pixelFormat == "yuyv")
|
||||
{
|
||||
|
@ -1,4 +1,3 @@
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <time.h>
|
||||
@ -23,16 +22,16 @@ public:
|
||||
Profiler(const char* sourceFile, const char* func, unsigned int line);
|
||||
~Profiler();
|
||||
|
||||
static void TimerStart(const std::string stopWatchName, const char* sourceFile, const char* func, unsigned int line);
|
||||
static void TimerGetTime(const std::string stopWatchName, const char* sourceFile, const char* func, unsigned int line);
|
||||
static void TimerStart(const QString stopWatchName, const char* sourceFile, const char* func, unsigned int line);
|
||||
static void TimerGetTime(const QString stopWatchName, const char* sourceFile, const char* func, unsigned int line);
|
||||
|
||||
private:
|
||||
static void initLogger();
|
||||
|
||||
static Logger* _logger;
|
||||
const char* _file;
|
||||
const char* _func;
|
||||
unsigned int _line;
|
||||
unsigned int _blockId;
|
||||
clock_t _startTime;
|
||||
const char* _file;
|
||||
const char* _func;
|
||||
unsigned int _line;
|
||||
unsigned int _blockId;
|
||||
clock_t _startTime;
|
||||
};
|
||||
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#include <QString>
|
||||
|
||||
#include <utils/ColorRgb.h>
|
||||
#include <utils/ColorRgbw.h>
|
||||
@ -7,7 +8,7 @@ namespace RGBW {
|
||||
|
||||
enum WhiteAlgorithm { INVALID, SUBTRACT_MINIMUM, SUB_MIN_WARM_ADJUST, WHITE_OFF };
|
||||
|
||||
WhiteAlgorithm stringToWhiteAlgorithm(std::string str);
|
||||
WhiteAlgorithm stringToWhiteAlgorithm(QString str);
|
||||
void Rgb_to_Rgbw(ColorRgb input, ColorRgbw * output, const WhiteAlgorithm algorithm);
|
||||
|
||||
};
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
class SysInfo : public QObject
|
||||
{
|
||||
// Q_OBJECT
|
||||
|
||||
public:
|
||||
struct HyperionSysInfo
|
||||
@ -15,26 +14,27 @@ public:
|
||||
QString kernelVersion;
|
||||
QString architecture;
|
||||
QString wordSize;
|
||||
QString productType; // $ID $DISTRIB_ID // single line file containing: // Debian
|
||||
QString productVersion; // $VERSION_ID $DISTRIB_RELEASE // <Vendor_ID release Version_ID> // single line file <Release_ID/sid>
|
||||
QString prettyName; // $PRETTY_NAME $DISTRIB_DESCRIPTION
|
||||
QString productType;
|
||||
QString productVersion;
|
||||
QString prettyName;
|
||||
QString hostName;
|
||||
};
|
||||
|
||||
~SysInfo();
|
||||
static HyperionSysInfo get();
|
||||
|
||||
private:
|
||||
SysInfo();
|
||||
~SysInfo();
|
||||
|
||||
static SysInfo* _instance;
|
||||
|
||||
HyperionSysInfo _sysinfo;
|
||||
|
||||
struct QUnixOSVersion
|
||||
{
|
||||
// from /etc/os-release older /etc/lsb-release // redhat /etc/redhat-release // debian /etc/debian_version
|
||||
QString productType; // $ID $DISTRIB_ID // single line file containing: // Debian
|
||||
QString productVersion; // $VERSION_ID $DISTRIB_RELEASE // <Vendor_ID release Version_ID> // single line file <Release_ID/sid>
|
||||
QString prettyName; // $PRETTY_NAME $DISTRIB_DESCRIPTION
|
||||
QString productType;
|
||||
QString productVersion;
|
||||
QString prettyName;
|
||||
};
|
||||
|
||||
QString machineHostName();
|
||||
|
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <QString>
|
||||
|
||||
/**
|
||||
* Enumeration of the possible modes in which video can be playing (2D, 3D)
|
||||
@ -13,10 +12,10 @@ enum VideoMode
|
||||
VIDEO_3DTAB
|
||||
};
|
||||
|
||||
inline VideoMode parse3DMode(std::string videoMode)
|
||||
inline VideoMode parse3DMode(QString videoMode)
|
||||
{
|
||||
// convert to lower case
|
||||
std::transform(videoMode.begin(), videoMode.end(), videoMode.begin(), ::tolower);
|
||||
videoMode = videoMode.toLower();
|
||||
|
||||
if (videoMode == "3DTAB")
|
||||
{
|
||||
|
@ -1,9 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
|
||||
// JSON-Schema includes
|
||||
#include <utils/jsonschema/QJsonSchemaChecker.h>
|
||||
@ -30,9 +28,10 @@ public:
|
||||
|
||||
bool valid = schemaChecker.validate(configTree);
|
||||
|
||||
for (std::list<std::string>::const_iterator i = schemaChecker.getMessages().begin(); i != schemaChecker.getMessages().end(); ++i)
|
||||
QStringList messages = schemaChecker.getMessages();
|
||||
for (int i = 0; i < messages.size(); ++i)
|
||||
{
|
||||
std::cout << *i << std::endl;
|
||||
std::cout << messages[i].toStdString() << std::endl;
|
||||
}
|
||||
|
||||
if (!valid)
|
||||
@ -52,9 +51,7 @@ public:
|
||||
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
{
|
||||
std::stringstream sstream;
|
||||
sstream << "Configuration file not found: '" << path.toStdString() << "' (" << file.errorString().toStdString() << ")";
|
||||
throw std::runtime_error(sstream.str());
|
||||
throw std::runtime_error(QString("Configuration file not found: '" + path + "' (" + file.errorString() + ")").toStdString());
|
||||
}
|
||||
|
||||
QString config = QString(file.readAll());
|
||||
@ -78,9 +75,9 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
std::stringstream sstream;
|
||||
sstream << "Failed to parse configuration: " << error.errorString().toStdString() << " at Line: " << errorLine << ", Column: " << errorColumn;
|
||||
throw std::runtime_error(sstream.str());
|
||||
throw std::runtime_error (
|
||||
QString("Failed to parse configuration: " + error.errorString() + " at Line: " + QString::number(errorLine) + ", Column: " + QString::number(errorColumn)).toStdString()
|
||||
);
|
||||
}
|
||||
|
||||
return doc.object();
|
||||
@ -93,9 +90,7 @@ public:
|
||||
|
||||
if (!schemaData.open(QIODevice::ReadOnly))
|
||||
{
|
||||
std::stringstream sstream;
|
||||
sstream << "Schema not found: '" << path.toStdString() << "' (" << schemaData.errorString().toStdString() << ")";
|
||||
throw std::runtime_error(sstream.str());
|
||||
throw std::runtime_error(QString("Schema not found: '" + path + "' (" + schemaData.errorString() + ")").toStdString());
|
||||
}
|
||||
|
||||
QByteArray schema = schemaData.readAll();
|
||||
@ -117,9 +112,9 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
std::stringstream sstream;
|
||||
sstream << "ERROR: Json schema wrong: " << error.errorString().toStdString() << " at Line: " << errorLine << ", Column: " << errorColumn;
|
||||
throw std::runtime_error(sstream.str());
|
||||
throw std::runtime_error(QString("ERROR: Json schema wrong: " + error.errorString() + " at Line: " + QString::number(errorLine)
|
||||
+ ", Column: " + QString::number(errorColumn)).toStdString()
|
||||
);
|
||||
}
|
||||
|
||||
return doc.object();
|
||||
|
@ -1,9 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
// stl includes
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonValue>
|
||||
@ -48,7 +44,7 @@ public:
|
||||
///
|
||||
/// @return A list of error messages
|
||||
///
|
||||
const std::list<std::string> & getMessages() const;
|
||||
const QStringList & getMessages() const;
|
||||
|
||||
private:
|
||||
///
|
||||
@ -65,7 +61,7 @@ private:
|
||||
///
|
||||
/// @param[in] message The message to add to the queue
|
||||
///
|
||||
void setMessage(const std::string & message);
|
||||
void setMessage(const QString & message);
|
||||
|
||||
private:
|
||||
// attribute check functions
|
||||
@ -166,9 +162,9 @@ private:
|
||||
/// ignore the required value in json schema
|
||||
bool _ignoreRequired;
|
||||
/// The current location into a json-configuration structure being checked
|
||||
std::list<std::string> _currentPath;
|
||||
QStringList _currentPath;
|
||||
/// The result messages collected during the schema verification
|
||||
std::list<std::string> _messages;
|
||||
QStringList _messages;
|
||||
/// Flag indicating an error occured during validation
|
||||
bool _error;
|
||||
};
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <string>
|
||||
#include <hyperion/Hyperion.h>
|
||||
|
||||
class StaticFileServing;
|
||||
|
@ -14,7 +14,7 @@ BlackBorderProcessor::BlackBorderProcessor(const QJsonObject &blackborderConfig)
|
||||
, _borderSwitchCnt(blackborderConfig["borderFrameCnt"].toInt(50))
|
||||
, _maxInconsistentCnt(blackborderConfig["maxInconsistentCnt"].toInt(10))
|
||||
, _blurRemoveCnt(blackborderConfig["blurRemoveCnt"].toInt(1))
|
||||
, _detectionMode(blackborderConfig["mode"].toString("default").toStdString())
|
||||
, _detectionMode(blackborderConfig["mode"].toString("default"))
|
||||
, _detector(blackborderConfig["threshold"].toDouble(0.01))
|
||||
, _currentBorder({true, -1, -1})
|
||||
, _previousDetectedBorder({true, -1, -1})
|
||||
@ -23,7 +23,7 @@ BlackBorderProcessor::BlackBorderProcessor(const QJsonObject &blackborderConfig)
|
||||
{
|
||||
if (_enabled)
|
||||
{
|
||||
Debug(Logger::getInstance("BLACKBORDER"), "mode: %s", _detectionMode.c_str());
|
||||
Debug(Logger::getInstance("BLACKBORDER"), "mode: %s", QSTRING_CSTR(_detectionMode));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,29 +3,41 @@
|
||||
|
||||
using namespace commandline;
|
||||
|
||||
Option::Option(const QString &name, const QString &description, const QString &valueName, const QString &defaultValue)
|
||||
: QCommandLineOption(name, description, valueName, defaultValue)
|
||||
{}
|
||||
|
||||
Option::Option(const QStringList &names, const QString &description, const QString &valueName, const QString &defaultValue)
|
||||
: QCommandLineOption(names, description, valueName, defaultValue)
|
||||
{}
|
||||
|
||||
|
||||
bool Option::validate(Parser & parser, QString &value)
|
||||
{
|
||||
/* By default everything is accepted */
|
||||
return true;
|
||||
}
|
||||
|
||||
Option::Option(const QCommandLineOption &other)
|
||||
: QCommandLineOption(other)
|
||||
{}
|
||||
|
||||
QString Option::value(Parser &parser)
|
||||
{
|
||||
return parser.value(*this);
|
||||
}
|
||||
|
||||
std::string Option::getStdString(Parser &parser)
|
||||
QString Option::name()
|
||||
{
|
||||
return value(parser).toStdString();
|
||||
return this->names().last();
|
||||
}
|
||||
|
||||
std::wstring Option::getStdWString(Parser &parser)
|
||||
QString Option::getError()
|
||||
{
|
||||
return value(parser).toStdWString();
|
||||
return this->_error;
|
||||
}
|
||||
|
||||
const char* Option::getCString(Parser &parser)
|
||||
{
|
||||
return value(parser).toLocal8Bit().constData();
|
||||
}
|
||||
|
||||
|
@ -152,10 +152,10 @@ bool EffectEngine::loadEffectDefinition(const QString &path, const QString &effe
|
||||
schemaChecker.setSchema(configSchema.object());
|
||||
if (!schemaChecker.validate(configEffect.object()))
|
||||
{
|
||||
const std::list<std::string> & errors = schemaChecker.getMessages();
|
||||
foreach (const std::string & error, errors)
|
||||
const QStringList & errors = schemaChecker.getMessages();
|
||||
foreach (auto & error, errors)
|
||||
{
|
||||
Error( log, "Error while checking '%s':%s", fileName.toUtf8().constData(), error.c_str());
|
||||
Error( log, "Error while checking '%s':%s", QSTRING_CSTR(fileName), QSTRING_CSTR(error));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -69,13 +69,13 @@ void AmlogicGrabber::setVideoMode(const VideoMode videoMode)
|
||||
|
||||
bool AmlogicGrabber::isVideoPlaying()
|
||||
{
|
||||
const std::string videoDevice = "/dev/amvideo";
|
||||
const QString videoDevice = "/dev/amvideo";
|
||||
|
||||
// Open the video device
|
||||
int video_fd = open(videoDevice.c_str(), O_RDONLY);
|
||||
int video_fd = open(QSTRING_CSTR(videoDevice), O_RDONLY);
|
||||
if (video_fd < 0)
|
||||
{
|
||||
Error(_log, "Failed to open video device(%s): %d - %s", videoDevice.c_str(), errno, strerror(errno));
|
||||
Error(_log, "Failed to open video device(%s): %d - %s", QSTRING_CSTR(videoDevice), errno, strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
// Local includes
|
||||
#include <grabber/FramebufferFrameGrabber.h>
|
||||
|
||||
FramebufferFrameGrabber::FramebufferFrameGrabber(const std::string & device, const unsigned width, const unsigned height) :
|
||||
FramebufferFrameGrabber::FramebufferFrameGrabber(const QString & device, const unsigned width, const unsigned height) :
|
||||
_fbfd(0),
|
||||
_fbp(0),
|
||||
_fbDevice(device),
|
||||
@ -25,10 +25,10 @@ FramebufferFrameGrabber::FramebufferFrameGrabber(const std::string & device, con
|
||||
struct fb_var_screeninfo vinfo;
|
||||
|
||||
// Check if the framebuffer device can be opened and display the current resolution
|
||||
_fbfd = open(_fbDevice.c_str(), O_RDONLY);
|
||||
_fbfd = open(QSTRING_CSTR(_fbDevice), O_RDONLY);
|
||||
if (_fbfd == 0)
|
||||
{
|
||||
Error(_log, "Error openning %s", _fbDevice.c_str());
|
||||
Error(_log, "Error openning %s", QSTRING_CSTR(_fbDevice));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -63,7 +63,7 @@ void FramebufferFrameGrabber::grabFrame(Image<ColorRgb> & image)
|
||||
PixelFormat pixelFormat;
|
||||
|
||||
/* Open the framebuffer device */
|
||||
_fbfd = open(_fbDevice.c_str(), O_RDONLY);
|
||||
_fbfd = open(QSTRING_CSTR(_fbDevice), O_RDONLY);
|
||||
|
||||
/* get variable screen information */
|
||||
ioctl (_fbfd, FBIOGET_VSCREENINFO, &vinfo);
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <grabber/FramebufferWrapper.h>
|
||||
#include <grabber/FramebufferFrameGrabber.h>
|
||||
|
||||
FramebufferWrapper::FramebufferWrapper(const std::string & device, const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz, const int priority)
|
||||
FramebufferWrapper::FramebufferWrapper(const QString & device, const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz, const int priority)
|
||||
: GrabberWrapper("FrameBuffer", priority)
|
||||
, _updateInterval_ms(1000/updateRate_Hz)
|
||||
, _timeout_ms(2 * _updateInterval_ms)
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
#define CLEAR(x) memset(&(x), 0, sizeof(x))
|
||||
|
||||
V4L2Grabber::V4L2Grabber(const std::string & device
|
||||
V4L2Grabber::V4L2Grabber(const QString & device
|
||||
, int input
|
||||
, VideoStandard videoStandard
|
||||
, PixelFormat pixelFormat
|
||||
@ -51,7 +51,7 @@ V4L2Grabber::V4L2Grabber(const std::string & device
|
||||
, _noSignalCounter(0)
|
||||
, _streamNotifier(nullptr)
|
||||
, _imageResampler()
|
||||
, _log(Logger::getInstance("V4L2:"+QString::fromStdString(device)))
|
||||
, _log(Logger::getInstance("V4L2:"+device))
|
||||
, _initialized(false)
|
||||
, _deviceAutoDiscoverEnabled(false)
|
||||
, _noSignalDetected(false)
|
||||
@ -74,7 +74,7 @@ V4L2Grabber::~V4L2Grabber()
|
||||
|
||||
void V4L2Grabber::uninit()
|
||||
{
|
||||
Debug(_log,"uninit grabber: %s", _deviceName.c_str());
|
||||
Debug(_log,"uninit grabber: %s", QSTRING_CSTR(_deviceName));
|
||||
// stop if the grabber was not stopped
|
||||
if (_initialized)
|
||||
{
|
||||
@ -91,16 +91,16 @@ bool V4L2Grabber::init()
|
||||
if (! _initialized)
|
||||
{
|
||||
getV4Ldevices();
|
||||
std::string v4lDevices_str;
|
||||
QString v4lDevices_str;
|
||||
|
||||
// show list only once
|
||||
if ( ! QString(_deviceName.c_str()).startsWith("/dev/") )
|
||||
if ( ! QString(QSTRING_CSTR(_deviceName)).startsWith("/dev/") )
|
||||
{
|
||||
for (auto& dev: _v4lDevices)
|
||||
{
|
||||
v4lDevices_str += "\t"+ dev.first + "\t" + dev.second + "\n";
|
||||
}
|
||||
Info(_log, "available V4L2 devices:\n%s", v4lDevices_str.c_str());
|
||||
Info(_log, "available V4L2 devices:\n%s", QSTRING_CSTR(v4lDevices_str));
|
||||
}
|
||||
|
||||
if ( _deviceName == "auto" )
|
||||
@ -113,28 +113,28 @@ bool V4L2Grabber::init()
|
||||
_deviceName = dev.first;
|
||||
if ( init() )
|
||||
{
|
||||
Info(_log, "found usable v4l2 device: %s (%s)",dev.first.c_str(), dev.second.c_str());
|
||||
Info(_log, "found usable v4l2 device: %s (%s)",QSTRING_CSTR(dev.first), QSTRING_CSTR(dev.second));
|
||||
_deviceAutoDiscoverEnabled = false;
|
||||
return _initialized;
|
||||
}
|
||||
}
|
||||
Info( _log, "no usable device found" );
|
||||
}
|
||||
else if ( ! QString(_deviceName.c_str()).startsWith("/dev/") )
|
||||
else if ( ! _deviceName.startsWith("/dev/") )
|
||||
{
|
||||
for (auto& dev: _v4lDevices)
|
||||
{
|
||||
if ( QString(_deviceName.c_str()).toLower() == QString(dev.second.c_str()).toLower() )
|
||||
if ( _deviceName.toLower() == dev.second.toLower() )
|
||||
{
|
||||
_deviceName = dev.first;
|
||||
Info(_log, "found v4l2 device with configured name: %s (%s)", dev.second.c_str(), dev.first.c_str() );
|
||||
Info(_log, "found v4l2 device with configured name: %s (%s)", QSTRING_CSTR(dev.second), QSTRING_CSTR(dev.first) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Info(_log, "%s v4l device: %s", (_deviceAutoDiscoverEnabled? "test" : "configured"),_deviceName.c_str());
|
||||
Info(_log, "%s v4l device: %s", (_deviceAutoDiscoverEnabled? "test" : "configured"), QSTRING_CSTR(_deviceName));
|
||||
}
|
||||
|
||||
bool opened = false;
|
||||
@ -177,7 +177,7 @@ void V4L2Grabber::getV4Ldevices()
|
||||
devName = devName.trimmed();
|
||||
devNameFile.close();
|
||||
}
|
||||
_v4lDevices.emplace("/dev/"+it.fileName().toStdString(), devName.toStdString());
|
||||
_v4lDevices.emplace("/dev/"+it.fileName(), devName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -194,14 +194,12 @@ void V4L2Grabber::set3D(VideoMode mode)
|
||||
|
||||
void V4L2Grabber::setSignalThreshold(double redSignalThreshold, double greenSignalThreshold, double blueSignalThreshold, int noSignalCounterThreshold)
|
||||
{
|
||||
_noSignalThresholdColor.red = uint8_t(255*redSignalThreshold);
|
||||
_noSignalThresholdColor.red = uint8_t(255*redSignalThreshold);
|
||||
_noSignalThresholdColor.green = uint8_t(255*greenSignalThreshold);
|
||||
_noSignalThresholdColor.blue = uint8_t(255*blueSignalThreshold);
|
||||
_noSignalCounterThreshold = std::max(1, noSignalCounterThreshold);
|
||||
_noSignalThresholdColor.blue = uint8_t(255*blueSignalThreshold);
|
||||
_noSignalCounterThreshold = std::max(1, noSignalCounterThreshold);
|
||||
|
||||
std::stringstream ss;
|
||||
ss << _noSignalThresholdColor;
|
||||
Info(_log, "Signal threshold set to: %s", ss.str().c_str() );
|
||||
Info(_log, "Signal threshold set to: {%d, %d, %d}", _noSignalThresholdColor.red, _noSignalThresholdColor.green, _noSignalThresholdColor.blue );
|
||||
}
|
||||
|
||||
void V4L2Grabber::setSignalDetectionOffset(double horizontalMin, double verticalMin, double horizontalMax, double verticalMax)
|
||||
@ -256,7 +254,7 @@ void V4L2Grabber::open_device()
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
if (-1 == stat(_deviceName.c_str(), &st))
|
||||
if (-1 == stat(QSTRING_CSTR(_deviceName), &st))
|
||||
{
|
||||
throw_errno_exception("Cannot identify '" + _deviceName + "'");
|
||||
}
|
||||
@ -266,7 +264,7 @@ void V4L2Grabber::open_device()
|
||||
throw_exception("'" + _deviceName + "' is no device");
|
||||
}
|
||||
|
||||
_fileDescriptor = open(_deviceName.c_str(), O_RDWR /* required */ | O_NONBLOCK, 0);
|
||||
_fileDescriptor = open(QSTRING_CSTR(_deviceName), O_RDWR | O_NONBLOCK, 0);
|
||||
|
||||
if (-1 == _fileDescriptor)
|
||||
{
|
||||
@ -870,14 +868,12 @@ int V4L2Grabber::xioctl(int request, void *arg)
|
||||
return r;
|
||||
}
|
||||
|
||||
void V4L2Grabber::throw_exception(const std::string & error)
|
||||
void V4L2Grabber::throw_exception(const QString & error)
|
||||
{
|
||||
throw std::runtime_error(error);
|
||||
throw std::runtime_error(error.toStdString());
|
||||
}
|
||||
|
||||
void V4L2Grabber::throw_errno_exception(const std::string & error)
|
||||
void V4L2Grabber::throw_errno_exception(const QString & error)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << error << " error code " << errno << ", " << strerror(errno);
|
||||
throw std::runtime_error(oss.str());
|
||||
throw std::runtime_error(QString(error + " error code " + QString::number(errno) + ", " + strerror(errno)).toStdString());
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include <hyperion/ImageProcessorFactory.h>
|
||||
|
||||
V4L2Wrapper::V4L2Wrapper(const std::string &device,
|
||||
V4L2Wrapper::V4L2Wrapper(const QString &device,
|
||||
int input,
|
||||
VideoStandard videoStandard,
|
||||
PixelFormat pixelFormat,
|
||||
@ -16,7 +16,7 @@ V4L2Wrapper::V4L2Wrapper(const std::string &device,
|
||||
double greenSignalThreshold,
|
||||
double blueSignalThreshold,
|
||||
const int priority)
|
||||
: GrabberWrapper("V4L2:"+QString::fromStdString(device), priority, hyperion::COMP_V4L)
|
||||
: GrabberWrapper("V4L2:"+device, priority, hyperion::COMP_V4L)
|
||||
, _timeout_ms(1000)
|
||||
, _grabber(device,
|
||||
input,
|
||||
|
@ -58,7 +58,7 @@ ColorOrder Hyperion::createColorOrder(const QJsonObject &deviceConfig)
|
||||
|
||||
ColorAdjustment * Hyperion::createColorAdjustment(const QJsonObject & adjustmentConfig)
|
||||
{
|
||||
const std::string id = adjustmentConfig["id"].toString("default").toStdString();
|
||||
const QString id = adjustmentConfig["id"].toString("default");
|
||||
|
||||
RgbChannelAdjustment * blackAdjustment = createRgbChannelAdjustment(adjustmentConfig, "black" , 0, 0, 0);
|
||||
RgbChannelAdjustment * whiteAdjustment = createRgbChannelAdjustment(adjustmentConfig, "white" , 255,255,255);
|
||||
@ -117,13 +117,13 @@ MultiColorAdjustment * Hyperion::createLedColorsAdjustment(const unsigned ledCnt
|
||||
{
|
||||
// Special case for indices '*' => all leds
|
||||
adjustment->setAdjustmentForLed(colorAdjustment->_id, 0, ledCnt-1);
|
||||
Info(CORE_LOGGER, "ColorAdjustment '%s' => [0; %d]", colorAdjustment->_id.c_str(), ledCnt-1);
|
||||
Info(CORE_LOGGER, "ColorAdjustment '%s' => [0; %d]", QSTRING_CSTR(colorAdjustment->_id), ledCnt-1);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!overallExp.exactMatch(ledIndicesStr))
|
||||
{
|
||||
Error(CORE_LOGGER, "Given led indices %d not correct format: %s", i, ledIndicesStr.toStdString().c_str());
|
||||
Error(CORE_LOGGER, "Given led indices %d not correct format: %s", i, QSTRING_CSTR(ledIndicesStr));
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -150,7 +150,7 @@ MultiColorAdjustment * Hyperion::createLedColorsAdjustment(const unsigned ledCnt
|
||||
ss << index;
|
||||
}
|
||||
}
|
||||
Info(CORE_LOGGER, "ColorAdjustment '%s' => [%s]", colorAdjustment->_id.c_str(), ss.str().c_str());
|
||||
Info(CORE_LOGGER, "ColorAdjustment '%s' => [%s]", QSTRING_CSTR(colorAdjustment->_id), ss.str().c_str());
|
||||
}
|
||||
|
||||
return adjustment;
|
||||
@ -319,8 +319,7 @@ QSize Hyperion::getLedLayoutGridSize(const QJsonValue& ledsConfig)
|
||||
|
||||
LinearColorSmoothing * Hyperion::createColorSmoothing(const QJsonObject & smoothingConfig, LedDevice* leddevice)
|
||||
{
|
||||
std::string type = smoothingConfig["type"].toString("linear").toStdString();
|
||||
std::transform(type.begin(), type.end(), type.begin(), ::tolower);
|
||||
QString type = smoothingConfig["type"].toString("linear").toLower();
|
||||
LinearColorSmoothing * device = nullptr;
|
||||
type = "linear"; // TODO currently hardcoded type, delete it if we have more types
|
||||
|
||||
@ -337,7 +336,7 @@ LinearColorSmoothing * Hyperion::createColorSmoothing(const QJsonObject & smooth
|
||||
}
|
||||
else
|
||||
{
|
||||
Error(CORE_LOGGER, "Smoothing disabled, because of unknown type '%s'.", type.c_str());
|
||||
Error(CORE_LOGGER, "Smoothing disabled, because of unknown type '%s'.", QSTRING_CSTR(type));
|
||||
}
|
||||
|
||||
device->setEnable(smoothingConfig["enable"].toBool(true));
|
||||
@ -358,7 +357,7 @@ MessageForwarder * Hyperion::createMessageForwarder(const QJsonObject & forwarde
|
||||
for (signed i = 0; i < addr.size(); ++i)
|
||||
{
|
||||
Info(CORE_LOGGER, "Json forward to %s", addr.at(i).toString().toStdString().c_str());
|
||||
forwarder->addJsonSlave(addr[i].toString().toStdString());
|
||||
forwarder->addJsonSlave(addr[i].toString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -368,7 +367,7 @@ MessageForwarder * Hyperion::createMessageForwarder(const QJsonObject & forwarde
|
||||
for (signed i = 0; i < addr.size(); ++i)
|
||||
{
|
||||
Info(CORE_LOGGER, "Proto forward to %s", addr.at(i).toString().toStdString().c_str());
|
||||
forwarder->addProtoSlave(addr[i].toString().toStdString());
|
||||
forwarder->addProtoSlave(addr[i].toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -603,12 +602,12 @@ void Hyperion::setImage(int priority, const Image<ColorRgb> & image, int duratio
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<std::string> & Hyperion::getAdjustmentIds() const
|
||||
const QStringList & Hyperion::getAdjustmentIds() const
|
||||
{
|
||||
return _raw2ledAdjustment->getAdjustmentIds();
|
||||
}
|
||||
|
||||
ColorAdjustment * Hyperion::getAdjustment(const std::string& id)
|
||||
ColorAdjustment * Hyperion::getAdjustment(const QString& id)
|
||||
{
|
||||
return _raw2ledAdjustment->getAdjustment(id);
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
// STL includes
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
|
@ -13,11 +13,11 @@ MessageForwarder::~MessageForwarder()
|
||||
}
|
||||
|
||||
|
||||
void MessageForwarder::addJsonSlave(std::string slave)
|
||||
void MessageForwarder::addJsonSlave(QString slave)
|
||||
{
|
||||
QStringList parts = QString(slave.c_str()).split(":");
|
||||
QStringList parts = slave.split(":");
|
||||
if (parts.size() != 2)
|
||||
throw std::runtime_error(QString("HYPERION (forwarder) ERROR: Wrong address: unable to parse address (%1)").arg(slave.c_str()).toStdString());
|
||||
throw std::runtime_error(QString("HYPERION (forwarder) ERROR: Wrong address: unable to parse address (%1)").arg(slave).toStdString());
|
||||
|
||||
bool ok;
|
||||
quint16 port = parts[1].toUShort(&ok);
|
||||
@ -30,9 +30,9 @@ void MessageForwarder::addJsonSlave(std::string slave)
|
||||
_jsonSlaves << c;
|
||||
}
|
||||
|
||||
void MessageForwarder::addProtoSlave(std::string slave)
|
||||
void MessageForwarder::addProtoSlave(QString slave)
|
||||
{
|
||||
_protoSlaves << QString(slave.c_str());
|
||||
_protoSlaves << slave;
|
||||
}
|
||||
|
||||
QStringList MessageForwarder::getProtoSlaves()
|
||||
|
@ -27,7 +27,7 @@ void MultiColorAdjustment::addAdjustment(ColorAdjustment * adjustment)
|
||||
_adjustment.push_back(adjustment);
|
||||
}
|
||||
|
||||
void MultiColorAdjustment::setAdjustmentForLed(const std::string& id, const unsigned startLed, const unsigned endLed)
|
||||
void MultiColorAdjustment::setAdjustmentForLed(const QString& id, const unsigned startLed, const unsigned endLed)
|
||||
{
|
||||
assert(startLed <= endLed);
|
||||
assert(endLed < _ledAdjustments.size());
|
||||
@ -61,12 +61,12 @@ bool MultiColorAdjustment::verifyAdjustments() const
|
||||
return true;
|
||||
}
|
||||
|
||||
const std::vector<std::string> & MultiColorAdjustment::getAdjustmentIds()
|
||||
const QStringList & MultiColorAdjustment::getAdjustmentIds()
|
||||
{
|
||||
return _adjustmentIds;
|
||||
}
|
||||
|
||||
ColorAdjustment* MultiColorAdjustment::getAdjustment(const std::string& id)
|
||||
ColorAdjustment* MultiColorAdjustment::getAdjustment(const QString& id)
|
||||
{
|
||||
// Iterate through the unique adjustments until we find the one with the given id
|
||||
for (ColorAdjustment* adjustment : _adjustment)
|
||||
|
@ -2,11 +2,11 @@
|
||||
|
||||
// STL includes
|
||||
#include <vector>
|
||||
|
||||
// Utils includes
|
||||
#include <utils/ColorRgb.h>
|
||||
#include <QStringList>
|
||||
#include <QString>
|
||||
|
||||
// Hyperion includes
|
||||
#include <utils/ColorRgb.h>
|
||||
#include <hyperion/ColorAdjustment.h>
|
||||
|
||||
///
|
||||
@ -26,7 +26,7 @@ public:
|
||||
*/
|
||||
void addAdjustment(ColorAdjustment * adjustment);
|
||||
|
||||
void setAdjustmentForLed(const std::string& id, const unsigned startLed, const unsigned endLed);
|
||||
void setAdjustmentForLed(const QString& id, const unsigned startLed, const unsigned endLed);
|
||||
|
||||
bool verifyAdjustments() const;
|
||||
|
||||
@ -36,7 +36,7 @@ public:
|
||||
/// Returns the identifier of all the unique ColorAdjustment
|
||||
///
|
||||
/// @return The list with unique id's of the ColorAdjustment
|
||||
const std::vector<std::string> & getAdjustmentIds();
|
||||
const QStringList & getAdjustmentIds();
|
||||
|
||||
///
|
||||
/// Returns the pointer to the ColorAdjustment with the given id
|
||||
@ -45,7 +45,7 @@ public:
|
||||
///
|
||||
/// @return The ColorAdjustment with the given id (or nullptr if it does not exist)
|
||||
///
|
||||
ColorAdjustment* getAdjustment(const std::string& id);
|
||||
ColorAdjustment* getAdjustment(const QString& id);
|
||||
|
||||
///
|
||||
/// Performs the color adjustment from raw-color to led-color
|
||||
@ -56,7 +56,7 @@ public:
|
||||
|
||||
private:
|
||||
/// List with transform ids
|
||||
std::vector<std::string> _adjustmentIds;
|
||||
QStringList _adjustmentIds;
|
||||
|
||||
/// List with unique ColorTransforms
|
||||
std::vector<ColorAdjustment*> _adjustment;
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include <HyperionConfig.h>
|
||||
#include <utils/jsonschema/QJsonFactory.h>
|
||||
#include <utils/Process.h>
|
||||
#include <utils/SysInfo.h>
|
||||
|
||||
// project includes
|
||||
#include "JsonClientConnection.h"
|
||||
@ -98,13 +99,13 @@ void JsonClientConnection::readData()
|
||||
while(bytes > 0)
|
||||
{
|
||||
// create message string
|
||||
std::string message(_receiveBuffer.data(), bytes);
|
||||
QString message(QByteArray(_receiveBuffer.data(), bytes));
|
||||
|
||||
// remove message data from buffer
|
||||
_receiveBuffer = _receiveBuffer.mid(bytes);
|
||||
|
||||
// handle message
|
||||
handleMessage(QString::fromStdString(message));
|
||||
handleMessage(message);
|
||||
|
||||
// try too look up '\n' again
|
||||
bytes = _receiveBuffer.indexOf('\n') + 1;
|
||||
@ -215,14 +216,14 @@ void JsonClientConnection::doWebSocketHandshake()
|
||||
|
||||
// get the key to prepare an answer
|
||||
int start = _receiveBuffer.indexOf("Sec-WebSocket-Key") + 19;
|
||||
std::string value(_receiveBuffer.mid(start, _receiveBuffer.indexOf("\r\n", start) - start).data());
|
||||
QByteArray value = _receiveBuffer.mid(start, _receiveBuffer.indexOf("\r\n", start) - start);
|
||||
_receiveBuffer.clear();
|
||||
|
||||
// must be always appended
|
||||
value += "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
||||
|
||||
// generate sha1 hash
|
||||
QByteArray hash = QCryptographicHash::hash(value.c_str(), QCryptographicHash::Sha1);
|
||||
QByteArray hash = QCryptographicHash::hash(value, QCryptographicHash::Sha1);
|
||||
|
||||
// prepare an answer
|
||||
std::ostringstream h;
|
||||
@ -292,38 +293,23 @@ void JsonClientConnection::handleMessage(const QString& messageString)
|
||||
|
||||
int tan = message["tan"].toInt(0);
|
||||
// switch over all possible commands and handle them
|
||||
if (command == "color")
|
||||
handleColorCommand(message, command, tan);
|
||||
else if (command == "image")
|
||||
handleImageCommand(message, command, tan);
|
||||
else if (command == "effect")
|
||||
handleEffectCommand(message, command, tan);
|
||||
else if (command == "create-effect")
|
||||
handleCreateEffectCommand(message, command, tan);
|
||||
else if (command == "delete-effect")
|
||||
handleDeleteEffectCommand(message, command, tan);
|
||||
else if (command == "serverinfo")
|
||||
handleServerInfoCommand(message, command, tan);
|
||||
else if (command == "clear")
|
||||
handleClearCommand(message, command, tan);
|
||||
else if (command == "clearall")
|
||||
handleClearallCommand(message, command, tan);
|
||||
else if (command == "adjustment")
|
||||
handleAdjustmentCommand(message, command, tan);
|
||||
else if (command == "sourceselect")
|
||||
handleSourceSelectCommand(message, command, tan);
|
||||
else if (command == "config")
|
||||
handleConfigCommand(message, command, tan);
|
||||
else if (command == "componentstate")
|
||||
handleComponentStateCommand(message, command, tan);
|
||||
else if (command == "ledcolors")
|
||||
handleLedColorsCommand(message, command, tan);
|
||||
else if (command == "logging")
|
||||
handleLoggingCommand(message, command, tan);
|
||||
else if (command == "processing")
|
||||
handleProcessingCommand(message, command, tan);
|
||||
else
|
||||
handleNotImplemented();
|
||||
if (command == "color") handleColorCommand (message, command, tan);
|
||||
else if (command == "image") handleImageCommand (message, command, tan);
|
||||
else if (command == "effect") handleEffectCommand (message, command, tan);
|
||||
else if (command == "create-effect") handleCreateEffectCommand (message, command, tan);
|
||||
else if (command == "delete-effect") handleDeleteEffectCommand (message, command, tan);
|
||||
else if (command == "serverinfo") handleServerInfoCommand (message, command, tan);
|
||||
else if (command == "sysinfo") handleSysInfoCommand (message, command, tan);
|
||||
else if (command == "clear") handleClearCommand (message, command, tan);
|
||||
else if (command == "clearall") handleClearallCommand (message, command, tan);
|
||||
else if (command == "adjustment") handleAdjustmentCommand (message, command, tan);
|
||||
else if (command == "sourceselect") handleSourceSelectCommand (message, command, tan);
|
||||
else if (command == "config") handleConfigCommand (message, command, tan);
|
||||
else if (command == "componentstate") handleComponentStateCommand(message, command, tan);
|
||||
else if (command == "ledcolors") handleLedColorsCommand (message, command, tan);
|
||||
else if (command == "logging") handleLoggingCommand (message, command, tan);
|
||||
else if (command == "processing") handleProcessingCommand (message, command, tan);
|
||||
else handleNotImplemented ();
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
@ -571,6 +557,41 @@ void JsonClientConnection::handleDeleteEffectCommand(const QJsonObject& message,
|
||||
sendErrorReply("Error while parsing json: Message size " + QString(message.size()), command, tan);
|
||||
}
|
||||
|
||||
|
||||
void JsonClientConnection::handleSysInfoCommand(const QJsonObject&, const QString& command, const int tan)
|
||||
{
|
||||
// create result
|
||||
QJsonObject result;
|
||||
QJsonObject info;
|
||||
result["success"] = true;
|
||||
result["command"] = command;
|
||||
result["tan"] = tan;
|
||||
|
||||
SysInfo::HyperionSysInfo data = SysInfo::get();
|
||||
QJsonObject system;
|
||||
system["kernelType" ] = data.kernelType;
|
||||
system["kernelVersion" ] = data.kernelVersion;
|
||||
system["architecture" ] = data.architecture;
|
||||
system["wordSize" ] = data.wordSize;
|
||||
system["productType" ] = data.productType;
|
||||
system["productVersion"] = data.productVersion;
|
||||
system["prettyName" ] = data.prettyName;
|
||||
system["hostName" ] = data.hostName;
|
||||
info["system"] = system;
|
||||
|
||||
QJsonObject hyperion;
|
||||
hyperion["jsonrpc_version" ] = QString(HYPERION_JSON_VERSION);
|
||||
hyperion["version" ] = QString(HYPERION_VERSION);
|
||||
hyperion["build" ] = QString(HYPERION_BUILD_ID);
|
||||
hyperion["time" ] = QString(__DATE__ " " __TIME__);
|
||||
info["hyperion"] = hyperion;
|
||||
|
||||
// send the result
|
||||
result["info" ] = info;
|
||||
sendMessage(result);
|
||||
}
|
||||
|
||||
|
||||
void JsonClientConnection::handleServerInfoCommand(const QJsonObject&, const QString& command, const int tan)
|
||||
{
|
||||
// create result
|
||||
@ -581,9 +602,6 @@ void JsonClientConnection::handleServerInfoCommand(const QJsonObject&, const QSt
|
||||
|
||||
QJsonObject info;
|
||||
|
||||
// add host name for remote clients
|
||||
info["hostname"] = QHostInfo::localHostName();
|
||||
|
||||
// collect priority information
|
||||
QJsonArray priorities;
|
||||
uint64_t now = QDateTime::currentMSecsSinceEpoch();
|
||||
@ -677,17 +695,17 @@ void JsonClientConnection::handleServerInfoCommand(const QJsonObject&, const QSt
|
||||
|
||||
// collect adjustment information
|
||||
QJsonArray adjustmentArray;
|
||||
for (const std::string& adjustmentId : _hyperion->getAdjustmentIds())
|
||||
for (const QString& adjustmentId : _hyperion->getAdjustmentIds())
|
||||
{
|
||||
const ColorAdjustment * colorAdjustment = _hyperion->getAdjustment(adjustmentId);
|
||||
if (colorAdjustment == nullptr)
|
||||
{
|
||||
Error(_log, "Incorrect color adjustment id: %s", adjustmentId.c_str());
|
||||
Error(_log, "Incorrect color adjustment id: %s", QSTRING_CSTR(adjustmentId));
|
||||
continue;
|
||||
}
|
||||
|
||||
QJsonObject adjustment;
|
||||
adjustment["id"] = QString::fromStdString(adjustmentId);
|
||||
adjustment["id"] = adjustmentId;
|
||||
|
||||
QJsonArray blackAdjust;
|
||||
blackAdjust.append(colorAdjustment->_rgbBlackAdjustment.getAdjustmentR());
|
||||
@ -766,11 +784,11 @@ void JsonClientConnection::handleServerInfoCommand(const QJsonObject&, const QSt
|
||||
|
||||
// get available led devices
|
||||
QJsonObject ledDevices;
|
||||
ledDevices["active"] = QString::fromStdString(LedDevice::activeDevice());
|
||||
ledDevices["active"] =LedDevice::activeDevice();
|
||||
QJsonArray availableLedDevices;
|
||||
for (auto dev: LedDevice::getDeviceMap())
|
||||
{
|
||||
availableLedDevices.append(QString::fromStdString(dev.first));
|
||||
availableLedDevices.append(dev.first);
|
||||
}
|
||||
|
||||
ledDevices["available"] = availableLedDevices;
|
||||
@ -805,17 +823,10 @@ void JsonClientConnection::handleServerInfoCommand(const QJsonObject&, const QSt
|
||||
info["components"] = component;
|
||||
info["ledMAppingType"] = ImageProcessor::mappingTypeToStr(_hyperion->getLedMappingType());
|
||||
|
||||
// Add Hyperion Version, build time
|
||||
QJsonArray hyperion;
|
||||
QJsonObject ver;
|
||||
ver["jsonrpc_version"] = QString(HYPERION_JSON_VERSION);
|
||||
ver["version"] = QString(HYPERION_VERSION);
|
||||
ver["build"] = QString(HYPERION_BUILD_ID);
|
||||
ver["time"] = QString(__DATE__ " " __TIME__);
|
||||
ver["config_modified"] = _hyperion->configModified();
|
||||
ver["config_writeable"] = _hyperion->configWriteable();
|
||||
|
||||
hyperion.append(ver);
|
||||
// Add Hyperion
|
||||
QJsonObject hyperion;
|
||||
hyperion["config_modified" ] = _hyperion->configModified();
|
||||
hyperion["config_writeable"] = _hyperion->configWriteable();
|
||||
info["hyperion"] = hyperion;
|
||||
|
||||
// send the result
|
||||
@ -852,8 +863,8 @@ void JsonClientConnection::handleAdjustmentCommand(const QJsonObject& message, c
|
||||
{
|
||||
const QJsonObject & adjustment = message["adjustment"].toObject();
|
||||
|
||||
const QString adjustmentId = adjustment["id"].toString(QString::fromStdString(_hyperion->getAdjustmentIds().front()));
|
||||
ColorAdjustment * colorAdjustment = _hyperion->getAdjustment(adjustmentId.toStdString());
|
||||
const QString adjustmentId = adjustment["id"].toString(_hyperion->getAdjustmentIds().first());
|
||||
ColorAdjustment * colorAdjustment = _hyperion->getAdjustment(adjustmentId);
|
||||
if (colorAdjustment == nullptr)
|
||||
{
|
||||
Warning(_log, "Incorrect adjustment identifier: %s", adjustmentId.toStdString().c_str());
|
||||
@ -1008,7 +1019,7 @@ void JsonClientConnection::handleConfigGetCommand(const QJsonObject& message, co
|
||||
|
||||
try
|
||||
{
|
||||
result["result"] = QJsonFactory::readConfig(QString::fromStdString(_hyperion->getConfigFileName()));
|
||||
result["result"] = QJsonFactory::readConfig(_hyperion->getConfigFileName());
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
@ -1387,9 +1398,7 @@ bool JsonClientConnection::checkJson(const QJsonObject& message, const QString&
|
||||
}
|
||||
}
|
||||
|
||||
std::stringstream sstream;
|
||||
sstream << "Schema error: " << error.errorString().toStdString() << " at Line: " << errorLine << ", Column: " << errorColumn;
|
||||
errorMessage = QString::fromStdString(sstream.str());
|
||||
errorMessage = "Schema error: " + error.errorString() + " at Line: " + QString::number(errorLine) + ", Column: " + QString::number(errorColumn);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1399,15 +1408,13 @@ bool JsonClientConnection::checkJson(const QJsonObject& message, const QString&
|
||||
// check the message
|
||||
if (!schemaChecker.validate(message, ignoreRequired))
|
||||
{
|
||||
const std::list<std::string> & errors = schemaChecker.getMessages();
|
||||
std::stringstream ss;
|
||||
ss << "{";
|
||||
foreach (const std::string & error, errors)
|
||||
const QStringList & errors = schemaChecker.getMessages();
|
||||
errorMessage = "{";
|
||||
foreach (auto & error, errors)
|
||||
{
|
||||
ss << error << " ";
|
||||
errorMessage += error + " ";
|
||||
}
|
||||
ss << "}";
|
||||
errorMessage = QString::fromStdString(ss.str());
|
||||
errorMessage += "}";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
// stl includes
|
||||
#include <string>
|
||||
|
||||
// Qt includes
|
||||
#include <QByteArray>
|
||||
#include <QTcpSocket>
|
||||
#include <QMutex>
|
||||
#include <QHostAddress>
|
||||
#include <QString>
|
||||
|
||||
// Hyperion includes
|
||||
#include <hyperion/Hyperion.h>
|
||||
@ -189,6 +187,13 @@ private:
|
||||
///
|
||||
void handleServerInfoCommand(const QJsonObject & message, const QString &command, const int tan);
|
||||
|
||||
///
|
||||
/// Handle an incoming JSON System info message
|
||||
///
|
||||
/// @param message the incoming message
|
||||
///
|
||||
void handleSysInfoCommand(const QJsonObject & message, const QString &command, const int tan);
|
||||
|
||||
///
|
||||
/// Handle an incoming JSON Clear message
|
||||
///
|
||||
|
@ -4,6 +4,7 @@
|
||||
<file alias="schema-color">schema/schema-color.json</file>
|
||||
<file alias="schema-image">schema/schema-image.json</file>
|
||||
<file alias="schema-serverinfo">schema/schema-serverinfo.json</file>
|
||||
<file alias="schema-sysinfo">schema/schema-sysinfo.json</file>
|
||||
<file alias="schema-clear">schema/schema-clear.json</file>
|
||||
<file alias="schema-clearall">schema/schema-clearall.json</file>
|
||||
<file alias="schema-adjustment">schema/schema-adjustment.json</file>
|
||||
|
15
libsrc/jsonserver/schema/schema-sysinfo.json
Normal file
15
libsrc/jsonserver/schema/schema-sysinfo.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"type":"object",
|
||||
"required":true,
|
||||
"properties":{
|
||||
"command": {
|
||||
"type" : "string",
|
||||
"required" : true,
|
||||
"enum" : ["sysinfo"]
|
||||
},
|
||||
"tan" : {
|
||||
"type" : "integer"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
@ -5,7 +5,7 @@
|
||||
"command": {
|
||||
"type" : "string",
|
||||
"required" : true,
|
||||
"enum" : ["color", "image", "effect", "create-effect", "delete-effect", "serverinfo", "clear", "clearall", "adjustment", "sourceselect", "config", "componentstate", "ledcolors", "logging", "processing"]
|
||||
"enum" : ["color", "image", "effect", "create-effect", "delete-effect", "serverinfo", "clear", "clearall", "adjustment", "sourceselect", "config", "componentstate", "ledcolors", "logging", "processing", "sysinfo"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <QDir>
|
||||
|
||||
LedDeviceRegistry LedDevice::_ledDeviceMap = LedDeviceRegistry();
|
||||
std::string LedDevice::_activeDevice = "";
|
||||
QString LedDevice::_activeDevice = "";
|
||||
int LedDevice::_ledCount = 0;
|
||||
int LedDevice::_ledRGBCount = 0;
|
||||
int LedDevice::_ledRGBWCount= 0;
|
||||
@ -34,7 +34,7 @@ int LedDevice::open()
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LedDevice::addToDeviceMap(std::string name, LedDeviceCreateFuncType funcPtr)
|
||||
int LedDevice::addToDeviceMap(QString name, LedDeviceCreateFuncType funcPtr)
|
||||
{
|
||||
_ledDeviceMap.emplace(name,funcPtr);
|
||||
return 0;
|
||||
@ -45,7 +45,7 @@ const LedDeviceRegistry& LedDevice::getDeviceMap()
|
||||
return _ledDeviceMap;
|
||||
}
|
||||
|
||||
void LedDevice::setActiveDevice(std::string dev)
|
||||
void LedDevice::setActiveDevice(QString dev)
|
||||
{
|
||||
_activeDevice = dev;
|
||||
}
|
||||
@ -74,7 +74,7 @@ QJsonObject LedDevice::getLedDeviceSchemas()
|
||||
|
||||
if (!schemaData.open(QIODevice::ReadOnly))
|
||||
{
|
||||
Error(Logger::getInstance("LedDevice"), "Schema not found: %s", item.toUtf8().constData());
|
||||
Error(Logger::getInstance("LedDevice"), "Schema not found: %s", QSTRING_CSTR(item));
|
||||
throw std::runtime_error("ERROR: Schema not found: " + item.toStdString());
|
||||
}
|
||||
|
||||
@ -97,10 +97,9 @@ QJsonObject LedDevice::getLedDeviceSchemas()
|
||||
}
|
||||
}
|
||||
|
||||
std::stringstream sstream;
|
||||
sstream << error.errorString().toStdString() << " at Line: " << errorLine << ", Column: " << errorColumn;
|
||||
Error(Logger::getInstance("LedDevice"), "LedDevice JSON schema error in %s (%s)", item.toUtf8().constData(), sstream.str().c_str());
|
||||
throw std::runtime_error("ERROR: Json schema wrong: " + sstream.str());
|
||||
QString errorMsg = error.errorString() + " at Line: " + QString::number(errorLine) + ", Column: " + QString::number(errorColumn);
|
||||
Error(Logger::getInstance("LedDevice"), "LedDevice JSON schema error in %s (%s)", QSTRING_CSTR(item), QSTRING_CSTR(errorMsg));
|
||||
throw std::runtime_error("ERROR: Json schema wrong: " + errorMsg.toStdString());
|
||||
}
|
||||
|
||||
schemaJson = doc.object();
|
||||
|
@ -6,13 +6,10 @@
|
||||
#include <QEventLoop>
|
||||
#include <QtNetwork>
|
||||
#include <QNetworkReply>
|
||||
#include <QStringList>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <set>
|
||||
|
||||
AtmoOrbLight::AtmoOrbLight(unsigned int id) {
|
||||
AtmoOrbLight::AtmoOrbLight(unsigned int id)
|
||||
{
|
||||
// Not implemented
|
||||
}
|
||||
|
||||
@ -38,28 +35,20 @@ bool LedDeviceAtmoOrb::init(const QJsonObject &deviceConfig)
|
||||
_multiCastGroupPort = deviceConfig["port"].toInt(49692);
|
||||
_numLeds = deviceConfig["numLeds"].toInt(24);
|
||||
|
||||
const std::string orbId = deviceConfig["orbIds"].toString().toStdString();
|
||||
const QStringList orbIds = deviceConfig["orbIds"].toString().simplified().remove(" ").split(",", QString::SkipEmptyParts);
|
||||
_orbIds.clear();
|
||||
|
||||
// If we find multiple Orb ids separate them and add to list
|
||||
const std::string separator (",");
|
||||
if (orbId.find(separator) != std::string::npos)
|
||||
foreach(auto & id_str, orbIds)
|
||||
{
|
||||
std::stringstream ss(orbId);
|
||||
std::vector<int> output;
|
||||
unsigned int i;
|
||||
while (ss >> i)
|
||||
{
|
||||
_orbIds.push_back(i);
|
||||
if (ss.peek() == ',' || ss.peek() == ' ') ss.ignore();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_orbIds.push_back(atoi(orbId.c_str()));
|
||||
bool ok;
|
||||
int id = id_str.toInt(&ok);
|
||||
if (ok)
|
||||
_orbIds.append(id);
|
||||
else
|
||||
Error(_log, "orb id '%s' is not a number", QSTRING_CSTR(id_str));
|
||||
}
|
||||
|
||||
return true;
|
||||
return _orbIds.size() > 0;
|
||||
}
|
||||
|
||||
LedDevice* LedDeviceAtmoOrb::construct(const QJsonObject &deviceConfig)
|
||||
@ -104,7 +93,7 @@ int LedDeviceAtmoOrb::write(const std::vector <ColorRgb> &ledValues)
|
||||
abs(color.green - lastGreen) >= _skipSmoothingDiff))
|
||||
{
|
||||
// Skip Orb smoothing when using (command type 4)
|
||||
for (unsigned int i = 0; i < _orbIds.size(); i++)
|
||||
for (int i = 0; i < _orbIds.size(); i++)
|
||||
{
|
||||
if (_orbIds[i] == idx)
|
||||
{
|
||||
@ -115,7 +104,7 @@ int LedDeviceAtmoOrb::write(const std::vector <ColorRgb> &ledValues)
|
||||
else
|
||||
{
|
||||
// Send color
|
||||
for (unsigned int i = 0; i < _orbIds.size(); i++)
|
||||
for (int i = 0; i < _orbIds.size(); i++)
|
||||
{
|
||||
if (_orbIds[i] == idx)
|
||||
{
|
||||
|
@ -5,6 +5,8 @@
|
||||
#include <QString>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QHostAddress>
|
||||
#include <QMap>
|
||||
#include <QVector>
|
||||
|
||||
// Leddevice includes
|
||||
#include <leddevice/LedDevice.h>
|
||||
@ -101,7 +103,7 @@ private:
|
||||
QUdpSocket * _udpSocket;
|
||||
|
||||
/// Array of the orb ids.
|
||||
std::vector<unsigned int> _orbIds;
|
||||
QVector<unsigned int> _orbIds;
|
||||
|
||||
///
|
||||
/// Set Orbcolor
|
||||
|
@ -17,14 +17,14 @@ bool LedDeviceDMX::init(const QJsonObject &deviceConfig)
|
||||
{
|
||||
ProviderRs232::init(deviceConfig);
|
||||
|
||||
std::string _dmxString = deviceConfig["dmxdevice"].toString("invalid").toStdString();
|
||||
if (_dmxString == "raw")
|
||||
QString dmxString = deviceConfig["dmxdevice"].toString("invalid");
|
||||
if (dmxString == "raw")
|
||||
{
|
||||
_dmxDeviceType = 0;
|
||||
_dmxStart = 1;
|
||||
_dmxSlotsPerLed = 3;
|
||||
}
|
||||
else if (_dmxString == "McCrypt")
|
||||
else if (dmxString == "McCrypt")
|
||||
{
|
||||
_dmxDeviceType = 1;
|
||||
_dmxStart = 1;
|
||||
@ -32,10 +32,10 @@ bool LedDeviceDMX::init(const QJsonObject &deviceConfig)
|
||||
}
|
||||
else
|
||||
{
|
||||
Error(_log, "unknown dmx device type %s", _dmxString.c_str());
|
||||
Error(_log, "unknown dmx device type %s", QSTRING_CSTR(dmxString));
|
||||
}
|
||||
|
||||
Debug(_log, "_dmxString \"%s\", _dmxDeviceType %d", _dmxString.c_str(), _dmxDeviceType );
|
||||
Debug(_log, "_dmxString \"%s\", _dmxDeviceType %d", QSTRING_CSTR(dmxString), _dmxDeviceType );
|
||||
_rs232Port.setStopBits(QSerialPort::TwoStop);
|
||||
|
||||
_dmxLedCount = std::min(_ledCount, 512/_dmxSlotsPerLed);
|
||||
|
@ -1,7 +1,4 @@
|
||||
// Stl includes
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <exception>
|
||||
#include <map>
|
||||
|
||||
@ -60,13 +57,12 @@ LedDevice * LedDeviceFactory::construct(const QJsonObject & deviceConfig, const
|
||||
QString ss(config.toJson(QJsonDocument::Indented));
|
||||
Info(log, "configuration: %s ", ss.toUtf8().constData());
|
||||
|
||||
std::string type = deviceConfig["type"].toString("UNSPECIFIED").toStdString();
|
||||
std::transform(type.begin(), type.end(), type.begin(), ::tolower);
|
||||
QString type = deviceConfig["type"].toString("UNSPECIFIED").toLower();
|
||||
|
||||
// set amount of led to leddevice
|
||||
LedDevice::setLedCount(ledCount);
|
||||
|
||||
#define REGISTER(className) LedDevice::addToDeviceMap(QString(#className).toLower().toStdString(), LedDevice##className::construct);
|
||||
#define REGISTER(className) LedDevice::addToDeviceMap(QString(#className).toLower(), LedDevice##className::construct);
|
||||
// rs232 devices
|
||||
REGISTER(Adalight);
|
||||
REGISTER(Sedu);
|
||||
@ -126,21 +122,21 @@ LedDevice * LedDeviceFactory::construct(const QJsonObject & deviceConfig, const
|
||||
{
|
||||
device = dev.second(deviceConfig);
|
||||
LedDevice::setActiveDevice(dev.first);
|
||||
Info(log,"LedDevice '%s' configured.", dev.first.c_str());
|
||||
Info(log,"LedDevice '%s' configured.", QSTRING_CSTR(dev.first));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (device == nullptr)
|
||||
{
|
||||
Error(log, "Dummy device used, because configured device '%s' is unknown", type.c_str() );
|
||||
Error(log, "Dummy device used, because configured device '%s' is unknown", QSTRING_CSTR(type) );
|
||||
throw std::runtime_error("unknown device");
|
||||
}
|
||||
}
|
||||
catch(std::exception& e)
|
||||
{
|
||||
|
||||
Error(log, "Dummy device used, because configured device '%s' throws error '%s'", type.c_str(), e.what());
|
||||
Error(log, "Dummy device used, because configured device '%s' throws error '%s'", QSTRING_CSTR(type), e.what());
|
||||
const QJsonObject dummyDeviceConfig;
|
||||
device = LedDeviceFile::construct(QJsonObject());
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ bool LedDeviceFadeCandy::init(const QJsonObject &deviceConfig)
|
||||
return false;
|
||||
}
|
||||
|
||||
_host = deviceConfig["output"].toString("127.0.0.1").toStdString();
|
||||
_host = deviceConfig["output"].toString("127.0.0.1");
|
||||
_port = deviceConfig["port"].toInt(7890);
|
||||
_channel = deviceConfig["channel"].toInt(0);
|
||||
_gamma = deviceConfig["gamma"].toDouble(1.0);
|
||||
@ -74,10 +74,10 @@ bool LedDeviceFadeCandy::isConnected()
|
||||
bool LedDeviceFadeCandy::tryConnect()
|
||||
{
|
||||
if ( _client.state() == QAbstractSocket::UnconnectedState ) {
|
||||
_client.connectToHost( _host.c_str(), _port);
|
||||
_client.connectToHost( _host, _port);
|
||||
if ( _client.waitForConnected(1000) )
|
||||
{
|
||||
Info(_log,"fadecandy/opc: connected to %s:%i on channel %i", _host.c_str(), _port, _channel);
|
||||
Info(_log,"fadecandy/opc: connected to %s:%i on channel %i", QSTRING_CSTR(_host), _port, _channel);
|
||||
if (_setFcConfig)
|
||||
{
|
||||
sendFadeCandyConfiguration();
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
// STL/Qt includes
|
||||
#include <QTcpSocket>
|
||||
#include <QString>
|
||||
|
||||
// Leddevice includes
|
||||
#include <leddevice/LedDevice.h>
|
||||
@ -65,7 +66,7 @@ public:
|
||||
|
||||
private:
|
||||
QTcpSocket _client;
|
||||
std::string _host;
|
||||
QString _host;
|
||||
uint16_t _port;
|
||||
unsigned _channel;
|
||||
QByteArray _opc_data;
|
||||
|
@ -25,8 +25,8 @@ bool LedDeviceFile::init(const QJsonObject &deviceConfig)
|
||||
_refresh_timer_interval = 0;
|
||||
LedDevice::init(deviceConfig);
|
||||
|
||||
std::string fileName = deviceConfig["output"].toString("/dev/null").toStdString();
|
||||
_ofs.open( fileName.c_str() );
|
||||
QString fileName = deviceConfig["output"].toString("/dev/null");
|
||||
_ofs.open( QSTRING_CSTR(fileName) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
// Static constants which define the Hyperion Usbasp device
|
||||
uint16_t LedDeviceHyperionUsbasp::_usbVendorId = 0x16c0;
|
||||
uint16_t LedDeviceHyperionUsbasp::_usbProductId = 0x05dc;
|
||||
std::string LedDeviceHyperionUsbasp::_usbProductDescription = "Hyperion led controller";
|
||||
QString LedDeviceHyperionUsbasp::_usbProductDescription = "Hyperion led controller";
|
||||
|
||||
|
||||
LedDeviceHyperionUsbasp::LedDeviceHyperionUsbasp(const QJsonObject &deviceConfig)
|
||||
@ -41,7 +41,7 @@ bool LedDeviceHyperionUsbasp::init(const QJsonObject &deviceConfig)
|
||||
{
|
||||
LedDevice::init(deviceConfig);
|
||||
|
||||
std::string ledType = deviceConfig["output"].toString("ws2801").toStdString();
|
||||
QString ledType = deviceConfig["output"].toString("ws2801");
|
||||
if (ledType != "ws2801" && ledType != "ws2812")
|
||||
{
|
||||
throw std::runtime_error("HyperionUsbasp: invalid output; must be 'ws2801' or 'ws2812'.");
|
||||
@ -94,7 +94,7 @@ int LedDeviceHyperionUsbasp::open()
|
||||
|
||||
if (_deviceHandle == nullptr)
|
||||
{
|
||||
Error(_log, "No %s has been found", _usbProductDescription.c_str());
|
||||
Error(_log, "No %s has been found", QSTRING_CSTR(_usbProductDescription));
|
||||
}
|
||||
|
||||
return _deviceHandle == nullptr ? -1 : 0;
|
||||
@ -119,18 +119,18 @@ int LedDeviceHyperionUsbasp::testAndOpen(libusb_device * device)
|
||||
int busNumber = libusb_get_bus_number(device);
|
||||
int addressNumber = libusb_get_device_address(device);
|
||||
|
||||
Info(_log, "%s found: bus=%d address=%d", _usbProductDescription.c_str(), busNumber, addressNumber);
|
||||
Info(_log, "%s found: bus=%d address=%d", QSTRING_CSTR(_usbProductDescription), busNumber, addressNumber);
|
||||
|
||||
try
|
||||
{
|
||||
_deviceHandle = openDevice(device);
|
||||
Info(_log, "%s successfully opened", _usbProductDescription.c_str() );
|
||||
Info(_log, "%s successfully opened", QSTRING_CSTR(_usbProductDescription) );
|
||||
return 0;
|
||||
}
|
||||
catch(int e)
|
||||
{
|
||||
_deviceHandle = nullptr;
|
||||
Error(_log, "Unable to open %s. Searching for other device(%d): %s", _usbProductDescription.c_str(), e, libusb_error_name(e));
|
||||
Error(_log, "Unable to open %s. Searching for other device(%d): %s", QSTRING_CSTR(_usbProductDescription), e, libusb_error_name(e));
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,7 +152,7 @@ int LedDeviceHyperionUsbasp::write(const std::vector<ColorRgb> &ledValues)
|
||||
// Disabling interupts for a little while on the device results in a PIPE error. All seems to keep functioning though...
|
||||
if(nbytes < 0 && nbytes != LIBUSB_ERROR_PIPE)
|
||||
{
|
||||
Error(_log, "Error while writing data to %s (%s)", _usbProductDescription.c_str(), libusb_error_name(nbytes));
|
||||
Error(_log, "Error while writing data to %s (%s)", QSTRING_CSTR(_usbProductDescription), libusb_error_name(nbytes));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -195,7 +195,7 @@ libusb_device_handle * LedDeviceHyperionUsbasp::openDevice(libusb_device *device
|
||||
return handle;
|
||||
}
|
||||
|
||||
std::string LedDeviceHyperionUsbasp::getString(libusb_device * device, int stringDescriptorIndex)
|
||||
QString LedDeviceHyperionUsbasp::getString(libusb_device * device, int stringDescriptorIndex)
|
||||
{
|
||||
libusb_device_handle * handle = nullptr;
|
||||
|
||||
@ -214,5 +214,5 @@ std::string LedDeviceHyperionUsbasp::getString(libusb_device * device, int strin
|
||||
}
|
||||
|
||||
libusb_close(handle);
|
||||
return std::string(buffer, error);
|
||||
return QString(QByteArray(buffer, error));
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
// stl includes
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
// libusb include
|
||||
#include <libusb.h>
|
||||
@ -71,7 +70,7 @@ protected:
|
||||
|
||||
static libusb_device_handle * openDevice(libusb_device * device);
|
||||
|
||||
static std::string getString(libusb_device * device, int stringDescriptorIndex);
|
||||
static QString getString(libusb_device * device, int stringDescriptorIndex);
|
||||
|
||||
/// command to write the leds
|
||||
uint8_t _writeLedsCommand;
|
||||
@ -85,5 +84,5 @@ protected:
|
||||
/// Usb device identifiers
|
||||
static uint16_t _usbVendorId;
|
||||
static uint16_t _usbProductId;
|
||||
static std::string _usbProductDescription;
|
||||
static QString _usbProductDescription;
|
||||
};
|
||||
|
@ -32,7 +32,7 @@ enum DATA_VERSION_INDEXES{
|
||||
INDEX_FW_VER_MINOR
|
||||
};
|
||||
|
||||
LedDeviceLightpack::LedDeviceLightpack(const std::string & serialNumber)
|
||||
LedDeviceLightpack::LedDeviceLightpack(const QString & serialNumber)
|
||||
: LedDevice()
|
||||
, _libusbContext(nullptr)
|
||||
, _deviceHandle(nullptr)
|
||||
@ -72,7 +72,7 @@ LedDeviceLightpack::~LedDeviceLightpack()
|
||||
bool LedDeviceLightpack::init(const QJsonObject &deviceConfig)
|
||||
{
|
||||
LedDevice::init(deviceConfig);
|
||||
_serialNumber = deviceConfig["output"].toString("").toStdString();
|
||||
_serialNumber = deviceConfig["output"].toString("");
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -118,20 +118,20 @@ int LedDeviceLightpack::open()
|
||||
|
||||
if (_deviceHandle == nullptr)
|
||||
{
|
||||
if (_serialNumber.empty())
|
||||
if (_serialNumber.isEmpty())
|
||||
{
|
||||
Warning(_log, "No Lightpack device has been found");
|
||||
}
|
||||
else
|
||||
{
|
||||
Error(_log,"No Lightpack device has been found with serial %s", _serialNumber.c_str());
|
||||
Error(_log,"No Lightpack device has been found with serial %s", QSTRING_CSTR(_serialNumber));
|
||||
}
|
||||
}
|
||||
|
||||
return _deviceHandle == nullptr ? -1 : 0;
|
||||
}
|
||||
|
||||
int LedDeviceLightpack::testAndOpen(libusb_device * device, const std::string & requestedSerialNumber)
|
||||
int LedDeviceLightpack::testAndOpen(libusb_device * device, const QString & requestedSerialNumber)
|
||||
{
|
||||
libusb_device_descriptor deviceDescriptor;
|
||||
int error = libusb_get_device_descriptor(device, &deviceDescriptor);
|
||||
@ -151,7 +151,7 @@ int LedDeviceLightpack::testAndOpen(libusb_device * device, const std::string &
|
||||
int addressNumber = libusb_get_device_address(device);
|
||||
|
||||
// get the serial number
|
||||
std::string serialNumber;
|
||||
QString serialNumber;
|
||||
if (deviceDescriptor.iSerialNumber != 0)
|
||||
{
|
||||
try
|
||||
@ -165,10 +165,10 @@ int LedDeviceLightpack::testAndOpen(libusb_device * device, const std::string &
|
||||
}
|
||||
}
|
||||
|
||||
Debug(_log,"Lightpack device found: bus=%d address=%d serial=%s", busNumber, addressNumber, serialNumber.c_str());
|
||||
Debug(_log,"Lightpack device found: bus=%d address=%d serial=%s", busNumber, addressNumber, QSTRING_CSTR(serialNumber));
|
||||
|
||||
// check if this is the device we are looking for
|
||||
if (requestedSerialNumber.empty() || requestedSerialNumber == serialNumber)
|
||||
if (requestedSerialNumber.isEmpty() || requestedSerialNumber == serialNumber)
|
||||
{
|
||||
// This is it!
|
||||
try
|
||||
@ -231,7 +231,7 @@ int LedDeviceLightpack::testAndOpen(libusb_device * device, const std::string &
|
||||
_ledBuffer[0] = CMD_UPDATE_LEDS;
|
||||
|
||||
// return success
|
||||
Debug(_log, "Lightpack device opened: bus=%d address=%d serial=%s version=%s.%s.", _busNumber, _addressNumber, _serialNumber.c_str(), _firmwareVersion.majorVersion, _firmwareVersion.minorVersion );
|
||||
Debug(_log, "Lightpack device opened: bus=%d address=%d serial=%s version=%s.%s.", _busNumber, _addressNumber, QSTRING_CSTR(_serialNumber), _firmwareVersion.majorVersion, _firmwareVersion.minorVersion );
|
||||
return 0;
|
||||
}
|
||||
catch(int e)
|
||||
@ -279,7 +279,7 @@ int LedDeviceLightpack::switchOff()
|
||||
return writeBytes(buf, sizeof(buf)) == sizeof(buf);
|
||||
}
|
||||
|
||||
const std::string &LedDeviceLightpack::getSerialNumber() const
|
||||
const QString &LedDeviceLightpack::getSerialNumber() const
|
||||
{
|
||||
return _serialNumber;
|
||||
}
|
||||
@ -352,7 +352,7 @@ libusb_device_handle * LedDeviceLightpack::openDevice(libusb_device *device)
|
||||
return handle;
|
||||
}
|
||||
|
||||
std::string LedDeviceLightpack::getString(libusb_device * device, int stringDescriptorIndex)
|
||||
QString LedDeviceLightpack::getString(libusb_device * device, int stringDescriptorIndex)
|
||||
{
|
||||
libusb_device_handle * handle = nullptr;
|
||||
|
||||
@ -371,5 +371,5 @@ std::string LedDeviceLightpack::getString(libusb_device * device, int stringDesc
|
||||
}
|
||||
|
||||
libusb_close(handle);
|
||||
return std::string(buffer, error);
|
||||
return QString(QByteArray(buffer, error));
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ public:
|
||||
///
|
||||
/// @param serialNumber serial output device
|
||||
///
|
||||
LedDeviceLightpack(const std::string & serialNumber = "");
|
||||
LedDeviceLightpack(const QString & serialNumber = "");
|
||||
///
|
||||
/// Constructs specific LedDevice
|
||||
///
|
||||
@ -68,7 +68,7 @@ public:
|
||||
virtual int switchOff();
|
||||
|
||||
/// Get the serial of the Lightpack
|
||||
const std::string & getSerialNumber() const;
|
||||
const QString & getSerialNumber() const;
|
||||
|
||||
/// Get the number of leds
|
||||
int getLedCount() const;
|
||||
@ -88,7 +88,7 @@ private:
|
||||
///
|
||||
/// @return Zero on succes else negative
|
||||
///
|
||||
int testAndOpen(libusb_device * device, const std::string & requestedSerialNumber);
|
||||
int testAndOpen(libusb_device * device, const QString & requestedSerialNumber);
|
||||
|
||||
/// write bytes to the device
|
||||
int writeBytes(uint8_t *data, int size);
|
||||
@ -103,7 +103,7 @@ private:
|
||||
};
|
||||
|
||||
static libusb_device_handle * openDevice(libusb_device * device);
|
||||
static std::string getString(libusb_device * device, int stringDescriptorIndex);
|
||||
static QString getString(libusb_device * device, int stringDescriptorIndex);
|
||||
|
||||
/// libusb context
|
||||
libusb_context * _libusbContext;
|
||||
@ -118,7 +118,7 @@ private:
|
||||
int _addressNumber;
|
||||
|
||||
/// device serial number
|
||||
std::string _serialNumber;
|
||||
QString _serialNumber;
|
||||
|
||||
/// firmware version of the device
|
||||
Version _firmwareVersion;
|
||||
|
@ -40,13 +40,13 @@ LedDevice* LedDeviceMultiLightpack::construct(const QJsonObject &deviceConfig)
|
||||
int LedDeviceMultiLightpack::open()
|
||||
{
|
||||
// retrieve a list with Lightpack serials
|
||||
std::list<std::string> serialList = getLightpackSerials();
|
||||
QStringList serialList = getLightpackSerials();
|
||||
|
||||
// sort the list of Lightpacks based on the serial to get a fixed order
|
||||
std::sort(_lightpacks.begin(), _lightpacks.end(), compareLightpacks);
|
||||
|
||||
// open each lightpack device
|
||||
for (const std::string & serial : serialList)
|
||||
foreach (auto serial , serialList)
|
||||
{
|
||||
LedDeviceLightpack * device = new LedDeviceLightpack(serial);
|
||||
int error = device->open();
|
||||
@ -57,7 +57,7 @@ int LedDeviceMultiLightpack::open()
|
||||
}
|
||||
else
|
||||
{
|
||||
Error(_log, "Error while creating Lightpack device with serial %s", serial.c_str());
|
||||
Error(_log, "Error while creating Lightpack device with serial %s", QSTRING_CSTR(serial));
|
||||
delete device;
|
||||
}
|
||||
}
|
||||
@ -109,9 +109,9 @@ int LedDeviceMultiLightpack::switchOff()
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::list<std::string> LedDeviceMultiLightpack::getLightpackSerials()
|
||||
QStringList LedDeviceMultiLightpack::getLightpackSerials()
|
||||
{
|
||||
std::list<std::string> serialList;
|
||||
QStringList serialList;
|
||||
Logger * log = Logger::getInstance("LedDevice");
|
||||
Debug(log, "Getting list of Lightpack serials");
|
||||
|
||||
@ -148,7 +148,7 @@ std::list<std::string> LedDeviceMultiLightpack::getLightpackSerials()
|
||||
Info(log, "Found a lightpack device. Retrieving serial...");
|
||||
|
||||
// get the serial number
|
||||
std::string serialNumber;
|
||||
QString serialNumber;
|
||||
if (deviceDescriptor.iSerialNumber != 0)
|
||||
{
|
||||
try
|
||||
@ -162,8 +162,8 @@ std::list<std::string> LedDeviceMultiLightpack::getLightpackSerials()
|
||||
}
|
||||
}
|
||||
|
||||
Error(log, "Lightpack device found with serial %s", serialNumber.c_str());;
|
||||
serialList.push_back(serialNumber);
|
||||
Error(log, "Lightpack device found with serial %s", QSTRING_CSTR(serialNumber));;
|
||||
serialList.append(serialNumber);
|
||||
}
|
||||
}
|
||||
|
||||
@ -174,7 +174,7 @@ std::list<std::string> LedDeviceMultiLightpack::getLightpackSerials()
|
||||
return serialList;
|
||||
}
|
||||
|
||||
std::string LedDeviceMultiLightpack::getString(libusb_device * device, int stringDescriptorIndex)
|
||||
QString LedDeviceMultiLightpack::getString(libusb_device * device, int stringDescriptorIndex)
|
||||
{
|
||||
libusb_device_handle * handle = nullptr;
|
||||
|
||||
@ -193,5 +193,5 @@ std::string LedDeviceMultiLightpack::getString(libusb_device * device, int strin
|
||||
}
|
||||
|
||||
libusb_close(handle);
|
||||
return std::string(buffer, error);
|
||||
return QString(QByteArray(buffer, error));
|
||||
}
|
||||
|
@ -3,8 +3,8 @@
|
||||
// stl includes
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <QStringList>
|
||||
#include <QString>
|
||||
|
||||
// libusb include
|
||||
#include <libusb.h>
|
||||
@ -56,8 +56,8 @@ private:
|
||||
///
|
||||
virtual int write(const std::vector<ColorRgb>& ledValues);
|
||||
|
||||
static std::list<std::string> getLightpackSerials();
|
||||
static std::string getString(libusb_device * device, int stringDescriptorIndex);
|
||||
static QStringList getLightpackSerials();
|
||||
static QString getString(libusb_device * device, int stringDescriptorIndex);
|
||||
|
||||
/// buffer for led data
|
||||
std::vector<LedDeviceLightpack *> _lightpacks;
|
||||
|
@ -44,7 +44,7 @@ bool LedDevicePiBlaster::init(const QJsonObject &deviceConfig)
|
||||
{
|
||||
LedDevice::init(deviceConfig);
|
||||
|
||||
_deviceName = deviceConfig["output"].toString("/dev/pi-blaster").toStdString();
|
||||
QString _deviceName = deviceConfig["output"].toString("/dev/pi-blaster");
|
||||
QJsonArray gpioMapping = deviceConfig["gpiomap"].toArray();
|
||||
|
||||
if (gpioMapping.isEmpty())
|
||||
@ -82,24 +82,24 @@ int LedDevicePiBlaster::open()
|
||||
if (_fid != nullptr)
|
||||
{
|
||||
// The file pointer is already open
|
||||
Error( _log, "Device (%s) is already open.", _deviceName.c_str() );
|
||||
Error( _log, "Device (%s) is already open.", QSTRING_CSTR(_deviceName) );
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!QFile::exists(_deviceName.c_str()))
|
||||
if (!QFile::exists(_deviceName))
|
||||
{
|
||||
Error( _log, "The device (%s) does not yet exist.", _deviceName.c_str() );
|
||||
Error( _log, "The device (%s) does not yet exist.",QSTRING_CSTR(_deviceName) );
|
||||
return -1;
|
||||
}
|
||||
|
||||
_fid = fopen(_deviceName.c_str(), "w");
|
||||
_fid = fopen(QSTRING_CSTR(_deviceName), "w");
|
||||
if (_fid == nullptr)
|
||||
{
|
||||
Error( _log, "Failed to open device (%s). Error message: %s", _deviceName.c_str(), strerror(errno) );
|
||||
Error( _log, "Failed to open device (%s). Error message: %s", QSTRING_CSTR(_deviceName), strerror(errno) );
|
||||
return -1;
|
||||
}
|
||||
|
||||
Info( _log, "Connected to device(%s)", _deviceName.c_str());
|
||||
Info( _log, "Connected to device(%s)", QSTRING_CSTR(_deviceName));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ private:
|
||||
int write(const std::vector<ColorRgb> &ledValues);
|
||||
|
||||
/// The name of the output device (very likely '/dev/pi-blaster')
|
||||
std::string _deviceName;
|
||||
QString _deviceName;
|
||||
|
||||
int _gpio_to_led[64];
|
||||
char _gpio_to_color[64];
|
||||
|
@ -21,15 +21,15 @@ LedDevice* LedDeviceSk6812SPI::construct(const QJsonObject &deviceConfig)
|
||||
|
||||
bool LedDeviceSk6812SPI::init(const QJsonObject &deviceConfig)
|
||||
{
|
||||
std::string whiteAlgorithm = deviceConfig["white_algorithm"].toString("white_off").toStdString();
|
||||
QString whiteAlgorithm = deviceConfig["white_algorithm"].toString("white_off");
|
||||
_whiteAlgorithm = RGBW::stringToWhiteAlgorithm(whiteAlgorithm);
|
||||
|
||||
if (_whiteAlgorithm == RGBW::INVALID)
|
||||
{
|
||||
Error(_log, "unknown whiteAlgorithm %s", whiteAlgorithm.c_str());
|
||||
Error(_log, "unknown whiteAlgorithm %s", QSTRING_CSTR(whiteAlgorithm));
|
||||
return false;
|
||||
}
|
||||
Debug( _log, "whiteAlgorithm : %s", whiteAlgorithm.c_str());
|
||||
Debug( _log, "whiteAlgorithm : %s", QSTRING_CSTR(whiteAlgorithm));
|
||||
|
||||
_baudRate_Hz = 3000000;
|
||||
if ( !ProviderSpi::init(deviceConfig) )
|
||||
|
@ -35,9 +35,9 @@ bool LedDeviceTinkerforge::init(const QJsonObject &deviceConfig)
|
||||
{
|
||||
LedDevice::init(deviceConfig);
|
||||
|
||||
_host = deviceConfig["output"].toString("127.0.0.1").toStdString();
|
||||
_host = deviceConfig["output"].toString("127.0.0.1");
|
||||
_port = deviceConfig["port"].toInt(4223);
|
||||
_uid = deviceConfig["uid"].toString().toStdString();
|
||||
_uid = deviceConfig["uid"].toString();
|
||||
_interval = deviceConfig["rate"].toInt();
|
||||
|
||||
if ((unsigned)_ledCount > MAX_NUM_LEDS)
|
||||
@ -75,16 +75,16 @@ int LedDeviceTinkerforge::open()
|
||||
_ipConnection = new IPConnection;
|
||||
ipcon_create(_ipConnection);
|
||||
|
||||
int connectionStatus = ipcon_connect(_ipConnection, _host.c_str(), _port);
|
||||
int connectionStatus = ipcon_connect(_ipConnection, QSTRING_CSTR(_host), _port);
|
||||
if (connectionStatus < 0)
|
||||
{
|
||||
Warning(_log, "Attempt to connect to master brick (%s:%d) failed with status %d", _host.c_str(), _port, connectionStatus);
|
||||
Warning(_log, "Attempt to connect to master brick (%s:%d) failed with status %d", QSTRING_CSTR(_host), _port, connectionStatus);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Create the 'LedStrip'
|
||||
_ledStrip = new LEDStrip;
|
||||
led_strip_create(_ledStrip, _uid.c_str(), _ipConnection);
|
||||
led_strip_create(_ledStrip, QSTRING_CSTR(_uid), _ipConnection);
|
||||
|
||||
int frameStatus = led_strip_set_frame_duration(_ledStrip, _interval);
|
||||
if (frameStatus < 0)
|
||||
|
@ -3,6 +3,8 @@
|
||||
// STL includes
|
||||
#include <cstdio>
|
||||
|
||||
#include <QString>
|
||||
|
||||
// Hyperion-Leddevice includes
|
||||
#include <leddevice/LedDevice.h>
|
||||
|
||||
@ -56,13 +58,13 @@ private:
|
||||
int transferLedData(LEDStrip *ledstrip, unsigned int index, unsigned int length, uint8_t *redChannel, uint8_t *greenChannel, uint8_t *blueChannel);
|
||||
|
||||
/// The host of the master brick
|
||||
std::string _host;
|
||||
QString _host;
|
||||
|
||||
/// The port of the master brick
|
||||
uint16_t _port;
|
||||
|
||||
/// The uid of the led strip bricklet
|
||||
std::string _uid;
|
||||
QString _uid;
|
||||
|
||||
/// The interval/rate
|
||||
unsigned _interval;
|
||||
|
@ -16,16 +16,16 @@ bool LedDeviceUdpE131::init(const QJsonObject &deviceConfig)
|
||||
_port = 5568;
|
||||
ProviderUdp::init(deviceConfig);
|
||||
_e131_universe = deviceConfig["universe"].toInt(1);
|
||||
_e131_source_name = deviceConfig["source-name"].toString("hyperion on "+QHostInfo::localHostName()).toStdString();
|
||||
_e131_source_name = deviceConfig["source-name"].toString("hyperion on "+QHostInfo::localHostName());
|
||||
QString _json_cid = deviceConfig["cid"].toString("");
|
||||
|
||||
if (_json_cid.isEmpty())
|
||||
{
|
||||
_e131_cid = QUuid::createUuid();
|
||||
Debug( _log, "e131 no cid found, generated %s", _e131_cid.toString().toStdString().c_str());
|
||||
Debug( _log, "e131 no cid found, generated %s", QSTRING_CSTR(_e131_cid.toString()));
|
||||
} else {
|
||||
_e131_cid = QUuid(_json_cid);
|
||||
Debug( _log, "e131 cid found, using %s", _e131_cid.toString().toStdString().c_str());
|
||||
Debug( _log, "e131 cid found, using %s", QSTRING_CSTR(_e131_cid.toString()));
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -53,7 +53,7 @@ void LedDeviceUdpE131::prepare(const unsigned this_universe, const unsigned this
|
||||
/* Frame Layer */
|
||||
e131_packet.frame_flength = htons(0x7000 | (88+this_dmxChannelCount));
|
||||
e131_packet.frame_vector = htonl(VECTOR_E131_DATA_PACKET);
|
||||
snprintf (e131_packet.source_name, sizeof(e131_packet.source_name), "%s", _e131_source_name.c_str() );
|
||||
snprintf (e131_packet.source_name, sizeof(e131_packet.source_name), "%s", QSTRING_CSTR(_e131_source_name) );
|
||||
e131_packet.priority = 100;
|
||||
e131_packet.reserved = htons(0);
|
||||
e131_packet.options = 0; // Bit 7 = Preview_Data
|
||||
|
@ -133,6 +133,6 @@ private:
|
||||
uint8_t _e131_seq = 0;
|
||||
uint8_t _e131_universe = 1;
|
||||
uint8_t _acn_id[12] = {0x41, 0x53, 0x43, 0x2d, 0x45, 0x31, 0x2e, 0x31, 0x37, 0x00, 0x00, 0x00 };
|
||||
std::string _e131_source_name;
|
||||
QString _e131_source_name;
|
||||
QUuid _e131_cid;
|
||||
};
|
||||
|
@ -20,12 +20,12 @@ bool LedDeviceWS281x::init(const QJsonObject &deviceConfig)
|
||||
{
|
||||
LedDevice::init(deviceConfig);
|
||||
|
||||
std::string whiteAlgorithm = deviceConfig["white_algorithm"].toString("white_off").toStdString();
|
||||
QString whiteAlgorithm = deviceConfig["white_algorithm"].toString("white_off");
|
||||
_whiteAlgorithm = RGBW::stringToWhiteAlgorithm(whiteAlgorithm);
|
||||
Debug( _log, "whiteAlgorithm : %s", whiteAlgorithm.c_str());
|
||||
Debug( _log, "whiteAlgorithm : %s", QSTRING_CSTR(whiteAlgorithm));
|
||||
if (_whiteAlgorithm == RGBW::INVALID)
|
||||
{
|
||||
Error(_log, "unknown whiteAlgorithm %s", whiteAlgorithm.c_str());
|
||||
Error(_log, "unknown whiteAlgorithm %s", QSTRING_CSTR(whiteAlgorithm));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ bool ProviderSpi::init(const QJsonObject &deviceConfig)
|
||||
{
|
||||
LedDevice::init(deviceConfig);
|
||||
|
||||
_deviceName = deviceConfig["output"].toString(QString::fromStdString(_deviceName)).toStdString();
|
||||
_deviceName = deviceConfig["output"].toString(_deviceName);
|
||||
_baudRate_Hz = deviceConfig["rate"].toInt(_baudRate_Hz);
|
||||
_latchTime_ns = deviceConfig["latchtime"].toInt(_latchTime_ns);
|
||||
_spiMode = deviceConfig["spimode"].toInt(_spiMode);
|
||||
@ -51,11 +51,11 @@ int ProviderSpi::open()
|
||||
|
||||
const int bitsPerWord = 8;
|
||||
|
||||
_fid = ::open(_deviceName.c_str(), O_RDWR);
|
||||
_fid = ::open(QSTRING_CSTR(_deviceName), O_RDWR);
|
||||
|
||||
if (_fid < 0)
|
||||
{
|
||||
Error( _log, "Failed to open device (%s). Error message: %s", _deviceName.c_str(), strerror(errno) );
|
||||
Error( _log, "Failed to open device (%s). Error message: %s", QSTRING_CSTR(_deviceName), strerror(errno) );
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ protected:
|
||||
int writeBytes(const unsigned size, const uint8_t *data);
|
||||
|
||||
/// The name of the output device
|
||||
std::string _deviceName;
|
||||
QString _deviceName;
|
||||
|
||||
/// The used baudrate of the output device
|
||||
int _baudRate_Hz;
|
||||
|
@ -7,13 +7,12 @@
|
||||
// protoserver includes
|
||||
#include "protoserver/ProtoConnection.h"
|
||||
|
||||
ProtoConnection::ProtoConnection(const std::string & a) :
|
||||
ProtoConnection::ProtoConnection(const QString & address) :
|
||||
_socket(),
|
||||
_skipReply(false),
|
||||
_prevSocketState(QAbstractSocket::UnconnectedState),
|
||||
_log(Logger::getInstance("PROTOCONNECTION"))
|
||||
{
|
||||
QString address(a.c_str());
|
||||
QStringList parts = address.split(":");
|
||||
if (parts.size() != 2)
|
||||
{
|
||||
|
@ -7,7 +7,7 @@ ProtoConnectionWrapper::ProtoConnectionWrapper(const QString &address,
|
||||
bool skipProtoReply)
|
||||
: _priority(priority)
|
||||
, _duration_ms(duration_ms)
|
||||
, _connection(address.toStdString())
|
||||
, _connection(address)
|
||||
{
|
||||
_connection.setSkipReply(skipProtoReply);
|
||||
connect(&_connection, SIGNAL(setGrabbingMode(GrabbingMode)), this, SIGNAL(setGrabbingMode(GrabbingMode)));
|
||||
|
@ -62,7 +62,7 @@ add_library(hyperion-utils
|
||||
${PROFILER_SOURCE}
|
||||
)
|
||||
|
||||
qt5_use_modules(hyperion-utils Core Gui)
|
||||
qt5_use_modules(hyperion-utils Core Gui Network)
|
||||
|
||||
target_link_libraries(hyperion-utils
|
||||
${QT_LIBRARIES})
|
||||
|
@ -12,43 +12,42 @@ static const int LogLevelSysLog[] = { LOG_DEBUG, LOG_DEBUG, LOG_INFO, LOG_
|
||||
static unsigned int loggerCount = 0;
|
||||
static unsigned int loggerId = 0;
|
||||
|
||||
std::map<std::string,Logger*> *Logger::LoggerMap = nullptr;
|
||||
std::map<QString,Logger*> *Logger::LoggerMap = nullptr;
|
||||
Logger::LogLevel Logger::GLOBAL_MIN_LOG_LEVEL = Logger::UNSET;
|
||||
LoggerManager* LoggerManager::_instance = nullptr;
|
||||
|
||||
Logger* Logger::getInstance(QString name, Logger::LogLevel minLevel)
|
||||
{
|
||||
qRegisterMetaType<Logger::T_LOG_MESSAGE>();
|
||||
std::string loggerName = name.toStdString();
|
||||
Logger* log = nullptr;
|
||||
if (LoggerMap == nullptr)
|
||||
{
|
||||
LoggerMap = new std::map<std::string,Logger*>;
|
||||
LoggerMap = new std::map<QString,Logger*>;
|
||||
}
|
||||
|
||||
if ( LoggerMap->find(loggerName) == LoggerMap->end() )
|
||||
if ( LoggerMap->find(name) == LoggerMap->end() )
|
||||
{
|
||||
log = new Logger(loggerName,minLevel);
|
||||
LoggerMap->insert(std::pair<std::string,Logger*>(loggerName,log)); // compat version, replace it with following line if we have 100% c++11
|
||||
//LoggerMap->emplace(loggerName,log); // not compat with older linux distro's e.g. wheezy
|
||||
log = new Logger(name,minLevel);
|
||||
LoggerMap->insert(std::pair<QString,Logger*>(name,log)); // compat version, replace it with following line if we have 100% c++11
|
||||
//LoggerMap->emplace(name,log); // not compat with older linux distro's e.g. wheezy
|
||||
connect(log, SIGNAL(newLogMessage(Logger::T_LOG_MESSAGE)), LoggerManager::getInstance(), SLOT(handleNewLogMessage(Logger::T_LOG_MESSAGE)));
|
||||
}
|
||||
else
|
||||
{
|
||||
log = LoggerMap->at(loggerName);
|
||||
log = LoggerMap->at(name);
|
||||
}
|
||||
|
||||
return log;
|
||||
}
|
||||
|
||||
void Logger::deleteInstance(std::string name)
|
||||
void Logger::deleteInstance(QString name)
|
||||
{
|
||||
if (LoggerMap == nullptr)
|
||||
return;
|
||||
|
||||
if ( name.empty() )
|
||||
if ( name.isEmpty() )
|
||||
{
|
||||
std::map<std::string,Logger*>::iterator it;
|
||||
std::map<QString,Logger*>::iterator it;
|
||||
for ( it=LoggerMap->begin(); it != LoggerMap->end(); it++)
|
||||
{
|
||||
delete it->second;
|
||||
@ -63,31 +62,31 @@ void Logger::deleteInstance(std::string name)
|
||||
|
||||
}
|
||||
|
||||
void Logger::setLogLevel(LogLevel level,std::string name)
|
||||
void Logger::setLogLevel(LogLevel level,QString name)
|
||||
{
|
||||
if ( name.empty() )
|
||||
if ( name.isEmpty() )
|
||||
{
|
||||
GLOBAL_MIN_LOG_LEVEL = level;
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger* log = Logger::getInstance(QString::fromStdString(name),level);
|
||||
Logger* log = Logger::getInstance(name,level);
|
||||
log->setMinLevel(level);
|
||||
}
|
||||
}
|
||||
|
||||
Logger::LogLevel Logger::getLogLevel(std::string name)
|
||||
Logger::LogLevel Logger::getLogLevel(QString name)
|
||||
{
|
||||
if ( name.empty() )
|
||||
if ( name.isEmpty() )
|
||||
{
|
||||
return GLOBAL_MIN_LOG_LEVEL;
|
||||
}
|
||||
|
||||
Logger* log = Logger::getInstance(QString::fromStdString(name));
|
||||
Logger* log = Logger::getInstance(name);
|
||||
return log->getMinLevel();
|
||||
}
|
||||
|
||||
Logger::Logger ( std::string name, LogLevel minLevel )
|
||||
Logger::Logger ( QString name, LogLevel minLevel )
|
||||
: QObject()
|
||||
, _name(name)
|
||||
, _minLevel(minLevel)
|
||||
@ -99,8 +98,8 @@ Logger::Logger ( std::string name, LogLevel minLevel )
|
||||
#else
|
||||
const char* _appname_char = getprogname();
|
||||
#endif
|
||||
_appname = std::string(_appname_char);
|
||||
std::transform(_appname.begin(), _appname.end(),_appname.begin(), ::toupper);
|
||||
_appname = QString(_appname_char).toLower();
|
||||
|
||||
|
||||
loggerCount++;
|
||||
|
||||
@ -112,7 +111,7 @@ Logger::Logger ( std::string name, LogLevel minLevel )
|
||||
|
||||
Logger::~Logger()
|
||||
{
|
||||
Debug(this, "logger '%s' destroyed", _name.c_str() );
|
||||
Debug(this, "logger '%s' destroyed", QSTRING_CSTR(_name) );
|
||||
loggerCount--;
|
||||
if ( loggerCount == 0 )
|
||||
closelog();
|
||||
@ -134,15 +133,15 @@ void Logger::Message(LogLevel level, const char* sourceFile, const char* func, u
|
||||
|
||||
Logger::T_LOG_MESSAGE logMsg;
|
||||
|
||||
logMsg.appName = QString::fromStdString(_appname);
|
||||
logMsg.loggerName = QString::fromStdString(_name);
|
||||
logMsg.appName = _appname;
|
||||
logMsg.loggerName = _name;
|
||||
logMsg.function = QString(func);
|
||||
logMsg.line = line;
|
||||
logMsg.fileName = FileUtils::getBaseName(sourceFile);
|
||||
time(&(logMsg.utime));
|
||||
logMsg.message = QString(msg);
|
||||
logMsg.level = level;
|
||||
logMsg.levelString = QString::fromStdString(LogLevelStrings[level]);
|
||||
logMsg.levelString = LogLevelStrings[level];
|
||||
|
||||
emit newLogMessage(logMsg);
|
||||
|
||||
@ -152,10 +151,7 @@ void Logger::Message(LogLevel level, const char* sourceFile, const char* func, u
|
||||
location = "<" + logMsg.fileName + ":" + QString::number(line)+":"+ logMsg.function + "()> ";
|
||||
}
|
||||
|
||||
std::cout
|
||||
<< "[" << _appname << " " << _name << "] <"
|
||||
<< LogLevelStrings[level] << "> " << location.toStdString() << msg
|
||||
<< std::endl;
|
||||
std::cout << QString("[" + _appname + " " + _name + "] <" + LogLevelStrings[level] + "> " + location + msg).toStdString() << std::endl;
|
||||
|
||||
if ( _syslogEnabled && level >= Logger::WARNING )
|
||||
syslog (LogLevelSysLog[level], "%s", msg);
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QStringList>
|
||||
#include <string>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <cstdio>
|
||||
@ -41,7 +40,7 @@ void restartHyperion(bool asNewProcess)
|
||||
QByteArray command_exec(QString cmd, QByteArray data)
|
||||
{
|
||||
char buffer[128];
|
||||
std::string result = "";
|
||||
QString result = "";
|
||||
|
||||
std::shared_ptr<FILE> pipe(popen(cmd.toLocal8Bit().constData(), "r"), pclose);
|
||||
if (pipe)
|
||||
@ -52,7 +51,7 @@ QByteArray command_exec(QString cmd, QByteArray data)
|
||||
result += buffer;
|
||||
}
|
||||
}
|
||||
return result.c_str();
|
||||
return QSTRING_CSTR(result);
|
||||
}
|
||||
|
||||
};
|
@ -13,7 +13,7 @@ struct StopWatchItem {
|
||||
};
|
||||
|
||||
static unsigned int blockCounter = 0;
|
||||
static std::map<std::string,StopWatchItem> GlobalProfilerMap;
|
||||
static std::map<QString,StopWatchItem> GlobalProfilerMap;
|
||||
Logger* Profiler::_logger = nullptr;
|
||||
|
||||
double getClockDelta(clock_t start)
|
||||
@ -44,9 +44,9 @@ void Profiler::initLogger()
|
||||
_logger = Logger::getInstance("PROFILER", Logger::DEBUG);
|
||||
}
|
||||
|
||||
void Profiler::TimerStart(const std::string timerName, const char* sourceFile, const char* func, unsigned int line)
|
||||
void Profiler::TimerStart(const QString timerName, const char* sourceFile, const char* func, unsigned int line)
|
||||
{
|
||||
std::pair<std::map<std::string,StopWatchItem>::iterator,bool> ret;
|
||||
std::pair<std::map<QString,StopWatchItem>::iterator,bool> ret;
|
||||
Profiler::initLogger();
|
||||
|
||||
StopWatchItem item = {sourceFile, func, line};
|
||||
@ -56,34 +56,34 @@ void Profiler::TimerStart(const std::string timerName, const char* sourceFile, c
|
||||
{
|
||||
if ( ret.first->second.sourceFile == sourceFile && ret.first->second.func == func && ret.first->second.line == line )
|
||||
{
|
||||
_logger->Message(Logger::DEBUG, sourceFile, func, line, "restart timer '%s'", timerName.c_str() );
|
||||
_logger->Message(Logger::DEBUG, sourceFile, func, line, "restart timer '%s'", QSTRING_CSTR(timerName) );
|
||||
ret.first->second.startTime = clock();
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger->Message(Logger::DEBUG, sourceFile, func, line, "ERROR timer '%s' started in multiple locations. First occurence %s:%d:%s()",
|
||||
timerName.c_str(), FileUtils::getBaseName(ret.first->second.sourceFile).toLocal8Bit().constData(), ret.first->second.line, ret.first->second.func );
|
||||
QSTRING_CSTR(timerName), FileUtils::getBaseName(ret.first->second.sourceFile).toLocal8Bit().constData(), ret.first->second.line, ret.first->second.func );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger->Message(Logger::DEBUG, sourceFile, func, line, "start timer '%s'", timerName.c_str() );
|
||||
_logger->Message(Logger::DEBUG, sourceFile, func, line, "start timer '%s'", QSTRING_CSTR(timerName) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Profiler::TimerGetTime(const std::string timerName, const char* sourceFile, const char* func, unsigned int line)
|
||||
void Profiler::TimerGetTime(const QString timerName, const char* sourceFile, const char* func, unsigned int line)
|
||||
{
|
||||
std::map<std::string,StopWatchItem>::iterator ret = GlobalProfilerMap.find(timerName);
|
||||
std::map<QString,StopWatchItem>::iterator ret = GlobalProfilerMap.find(timerName);
|
||||
Profiler::initLogger();
|
||||
if (ret != GlobalProfilerMap.end())
|
||||
{
|
||||
_logger->Message(Logger::DEBUG, sourceFile, func, line, "timer '%s' started at %s:%d:%s() took %f s execution time until here", timerName.c_str(),
|
||||
_logger->Message(Logger::DEBUG, sourceFile, func, line, "timer '%s' started at %s:%d:%s() took %f s execution time until here", QSTRING_CSTR(timerName),
|
||||
FileUtils::getBaseName(ret->second.sourceFile).toLocal8Bit().constData(), ret->second.line, ret->second.func, getClockDelta(ret->second.startTime) );
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger->Message(Logger::DEBUG, sourceFile, func, line, "ERROR timer '%s' not started", timerName.c_str() );
|
||||
_logger->Message(Logger::DEBUG, sourceFile, func, line, "ERROR timer '%s' not started", QSTRING_CSTR(timerName) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,11 +5,11 @@
|
||||
|
||||
namespace RGBW {
|
||||
|
||||
WhiteAlgorithm stringToWhiteAlgorithm(std::string str)
|
||||
WhiteAlgorithm stringToWhiteAlgorithm(QString str)
|
||||
{
|
||||
if (str == "subtract_minimum") return SUBTRACT_MINIMUM;
|
||||
if (str == "sub_min_warm_adjust") return SUB_MIN_WARM_ADJUST;
|
||||
if (str.empty() || str == "white_off") return WHITE_OFF;
|
||||
if (str.isEmpty() || str == "white_off") return WHITE_OFF;
|
||||
return INVALID;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "utils/SysInfo.h"
|
||||
|
||||
#include <QHostInfo>
|
||||
#include <QSysInfo>
|
||||
#include <iostream>
|
||||
#include <sys/utsname.h>
|
||||
@ -8,7 +9,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
@ -21,22 +21,14 @@ SysInfo::SysInfo()
|
||||
SysInfo::QUnixOSVersion v;
|
||||
findUnixOsVersion(v);
|
||||
|
||||
std::cout
|
||||
<< currentCpuArchitecture().toStdString() << " "
|
||||
<< kernelType().toStdString() << " "
|
||||
<< kernelVersion().toStdString() << " "
|
||||
<< v.productType.toStdString() << " "
|
||||
<< v.productVersion.toStdString() << " "
|
||||
<< v.prettyName.toStdString() << " "
|
||||
<< std::endl;
|
||||
|
||||
_sysinfo.kernelType = kernelType();
|
||||
_sysinfo.kernelVersion = kernelVersion();
|
||||
_sysinfo.architecture = currentCpuArchitecture();
|
||||
_sysinfo.wordSize = QSysInfo::WordSize;
|
||||
_sysinfo.wordSize = QString::number(QSysInfo::WordSize);
|
||||
_sysinfo.productType = v.productType;
|
||||
_sysinfo.productVersion = v.productVersion;
|
||||
_sysinfo.prettyName = v.prettyName;
|
||||
_sysinfo.hostName = QHostInfo::localHostName();
|
||||
}
|
||||
|
||||
SysInfo::~SysInfo()
|
||||
|
@ -1,6 +1,5 @@
|
||||
// stdlib includes
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
#include <math.h>
|
||||
|
||||
@ -33,7 +32,7 @@ bool QJsonSchemaChecker::validate(const QJsonObject & value, bool ignoreRequired
|
||||
_error = false;
|
||||
_messages.clear();
|
||||
_currentPath.clear();
|
||||
_currentPath.push_back("[root]");
|
||||
_currentPath.append("[root]");
|
||||
|
||||
// validate
|
||||
validate(value, _qSchema);
|
||||
@ -116,21 +115,18 @@ void QJsonSchemaChecker::validate(const QJsonValue & value, const QJsonObject &s
|
||||
{
|
||||
// no check function defined for this attribute
|
||||
_error = true;
|
||||
setMessage(std::string("No check function defined for attribute ") + attribute.toStdString());
|
||||
setMessage("No check function defined for attribute " + attribute);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QJsonSchemaChecker::setMessage(const std::string & message)
|
||||
void QJsonSchemaChecker::setMessage(const QString & message)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
std::copy(_currentPath.begin(), _currentPath.end(), std::ostream_iterator<std::string>(oss, ""));
|
||||
oss << ": " << message;
|
||||
_messages.push_back(oss.str());
|
||||
_messages.append(_currentPath.join("") +": "+message);
|
||||
}
|
||||
|
||||
const std::list<std::string> & QJsonSchemaChecker::getMessages() const
|
||||
const QStringList & QJsonSchemaChecker::getMessages() const
|
||||
{
|
||||
return _messages;
|
||||
}
|
||||
@ -166,7 +162,7 @@ void QJsonSchemaChecker::checkType(const QJsonValue & value, const QJsonValue &
|
||||
if (wrongType)
|
||||
{
|
||||
_error = true;
|
||||
setMessage(type.toStdString() + " expected");
|
||||
setMessage(type + " expected");
|
||||
}
|
||||
}
|
||||
|
||||
@ -178,7 +174,7 @@ void QJsonSchemaChecker::checkProperties(const QJsonObject & value, const QJsonO
|
||||
|
||||
const QJsonValue & propertyValue = i.value();
|
||||
|
||||
_currentPath.push_back(std::string(".") + property.toStdString());
|
||||
_currentPath.append("." + property);
|
||||
QJsonObject::const_iterator required = propertyValue.toObject().find("required");
|
||||
|
||||
if (value.contains(property))
|
||||
@ -190,7 +186,7 @@ void QJsonSchemaChecker::checkProperties(const QJsonObject & value, const QJsonO
|
||||
_error = true;
|
||||
setMessage("missing member");
|
||||
}
|
||||
_currentPath.pop_back();
|
||||
_currentPath.removeLast();
|
||||
}
|
||||
}
|
||||
|
||||
@ -202,7 +198,7 @@ void QJsonSchemaChecker::checkAdditionalProperties(const QJsonObject & value, co
|
||||
if (std::find(ignoredProperties.begin(), ignoredProperties.end(), property) == ignoredProperties.end())
|
||||
{
|
||||
// property has no property definition. check against the definition for additional properties
|
||||
_currentPath.push_back(std::string(".") + property.toStdString());
|
||||
_currentPath.append("." + property);
|
||||
if (schema.isBool())
|
||||
{
|
||||
if (schema.toBool() == false)
|
||||
@ -215,7 +211,7 @@ void QJsonSchemaChecker::checkAdditionalProperties(const QJsonObject & value, co
|
||||
{
|
||||
validate(value[property].toObject(), schema.toObject());
|
||||
}
|
||||
_currentPath.pop_back();
|
||||
_currentPath.removeLast();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -233,9 +229,7 @@ void QJsonSchemaChecker::checkMinimum(const QJsonValue & value, const QJsonValue
|
||||
if (value.toDouble() < schema.toDouble())
|
||||
{
|
||||
_error = true;
|
||||
std::ostringstream oss;
|
||||
oss << "value is too small (minimum=" << schema.toDouble() << ")";
|
||||
setMessage(oss.str());
|
||||
setMessage("value is too small (minimum=" + schema.toString() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
@ -252,9 +246,7 @@ void QJsonSchemaChecker::checkMaximum(const QJsonValue & value, const QJsonValue
|
||||
if (value.toDouble() > schema.toDouble())
|
||||
{
|
||||
_error = true;
|
||||
std::ostringstream oss;
|
||||
oss << "value is too large (maximum=" << schema.toDouble() << ")";
|
||||
setMessage(oss.str());
|
||||
setMessage("value is too large (maximum=" + schema.toString() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
@ -272,11 +264,9 @@ void QJsonSchemaChecker::checkItems(const QJsonValue & value, const QJsonObject
|
||||
for(int i = 0; i < jArray.size(); ++i)
|
||||
{
|
||||
// validate each item
|
||||
std::ostringstream oss;
|
||||
oss << "[" << i << "]";
|
||||
_currentPath.push_back(oss.str());
|
||||
_currentPath.append("[" + QString::number(i) + "]");
|
||||
validate(jArray[i], schema);
|
||||
_currentPath.pop_back();
|
||||
_currentPath.removeLast();
|
||||
}
|
||||
}
|
||||
|
||||
@ -296,9 +286,7 @@ void QJsonSchemaChecker::checkMinItems(const QJsonValue & value, const QJsonValu
|
||||
if (static_cast<int>(jArray.size()) < minimum)
|
||||
{
|
||||
_error = true;
|
||||
std::ostringstream oss;
|
||||
oss << "array is too small (minimum=" << minimum << ")";
|
||||
setMessage(oss.str());
|
||||
setMessage("array is too large (minimum=" + QString::number(minimum) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
@ -318,9 +306,7 @@ void QJsonSchemaChecker::checkMaxItems(const QJsonValue & value, const QJsonValu
|
||||
if (static_cast<int>(jArray.size()) > maximum)
|
||||
{
|
||||
_error = true;
|
||||
std::ostringstream oss;
|
||||
oss << "array is too large (maximum=" << maximum << ")";
|
||||
setMessage(oss.str());
|
||||
setMessage("array is too large (maximum=" + QString::number(maximum) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
@ -371,10 +357,7 @@ void QJsonSchemaChecker::checkEnum(const QJsonValue & value, const QJsonValue &
|
||||
|
||||
// nothing found
|
||||
_error = true;
|
||||
std::ostringstream oss;
|
||||
oss << "Unknown enum value (allowed values are: " << schema.toString().toStdString();
|
||||
QJsonDocument doc(schema.toArray());
|
||||
QString strJson(doc.toJson(QJsonDocument::Compact));
|
||||
oss << strJson.toStdString() << ")";
|
||||
setMessage(oss.str());
|
||||
setMessage("Unknown enum value (allowed values are: " + schema.toString() + strJson+ ")");
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ void CgiHandler::cmd_cfg_get()
|
||||
{
|
||||
if ( _args.at(0) == "cfg_get" )
|
||||
{
|
||||
QFile file ( _hyperion->getConfigFileName().c_str() );
|
||||
QFile file ( _hyperion->getConfigFileName() );
|
||||
if (file.exists ())
|
||||
{
|
||||
if (file.open (QFile::ReadOnly)) {
|
||||
@ -110,17 +110,18 @@ void CgiHandler::cmd_cfg_set()
|
||||
schemaChecker.setSchema(schemaJson);
|
||||
if ( schemaChecker.validate(hyperionConfigJsonObj) )
|
||||
{
|
||||
QJsonFactory::writeJson(QString::fromStdString(_hyperion->getConfigFileName()), hyperionConfigJsonObj);
|
||||
QJsonFactory::writeJson(_hyperion->getConfigFileName(), hyperionConfigJsonObj);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string errorMsg = "ERROR: Json validation failed: \n";
|
||||
for (std::list<std::string>::const_iterator i = schemaChecker.getMessages().begin(); i != schemaChecker.getMessages().end(); ++i)
|
||||
QString errorMsg = "ERROR: Json validation failed: \n";
|
||||
QStringList schemaErrors = schemaChecker.getMessages();
|
||||
foreach (auto & schemaError, schemaErrors)
|
||||
{
|
||||
Error(_log, "config write validation: %s", (*i).c_str());
|
||||
errorMsg += *i + "\n";
|
||||
Error(_log, "config write validation: %s", QSTRING_CSTR(schemaError));
|
||||
errorMsg += schemaError + "\n";
|
||||
}
|
||||
throw std::runtime_error(errorMsg.c_str());
|
||||
throw std::runtime_error(errorMsg.toStdString());
|
||||
}
|
||||
}
|
||||
catch(const std::runtime_error& validate_error)
|
||||
|
@ -45,11 +45,11 @@ void StaticFileServing::onServerStarted (quint16 port)
|
||||
{
|
||||
Info(_log, "started on port %d name \"%s\"", port ,_server->getServerName().toStdString().c_str());
|
||||
|
||||
const std::string mDNSDescr = (_server->getServerName().toStdString() + "@" + QHostInfo::localHostName().toStdString());
|
||||
const QString mDNSDescr = _server->getServerName() + "@" + QHostInfo::localHostName();
|
||||
|
||||
BonjourServiceRegister *bonjourRegister_http = new BonjourServiceRegister();
|
||||
bonjourRegister_http->registerService(
|
||||
BonjourRecord(mDNSDescr.c_str(), "_hyperiond-http._tcp", QString()),
|
||||
BonjourRecord(mDNSDescr, "_hyperiond-http._tcp", QString()),
|
||||
port
|
||||
);
|
||||
Debug(_log, "Web Config mDNS responder started");
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Hyperion-AmLogic includes
|
||||
#include "FramebufferWrapper.h"
|
||||
|
||||
FramebufferWrapper::FramebufferWrapper(const std::string & device, const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz) :
|
||||
FramebufferWrapper::FramebufferWrapper(const QString & device, const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz) :
|
||||
_timer(this),
|
||||
_grabber(device,grabWidth, grabHeight)
|
||||
{
|
||||
|
@ -9,7 +9,7 @@ class FramebufferWrapper : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
FramebufferWrapper(const std::string & device, const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz);
|
||||
FramebufferWrapper(const QString & device, const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz);
|
||||
|
||||
const Image<ColorRgb> & getScreenshot();
|
||||
|
||||
|
@ -46,7 +46,7 @@ int main(int argc, char ** argv)
|
||||
parser.showHelp(0);
|
||||
}
|
||||
|
||||
FramebufferWrapper fbWrapper(argDevice.getStdString(parser), argWidth.getInt(parser), argHeight.getInt(parser), 1000 / argFps.getInt(parser));
|
||||
FramebufferWrapper fbWrapper(argDevice.value(parser), argWidth.getInt(parser), argHeight.getInt(parser), 1000 / argFps.getInt(parser));
|
||||
|
||||
if (parser.isSet(argScreenshot))
|
||||
{
|
||||
|
@ -256,6 +256,33 @@ QString JsonConnection::getServerInfo()
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString JsonConnection::getSysInfo()
|
||||
{
|
||||
qDebug() << "Get system info";
|
||||
|
||||
// create command
|
||||
QJsonObject command;
|
||||
command["command"] = QString("sysinfo");
|
||||
|
||||
// send command message
|
||||
QJsonObject reply = sendMessage(command);
|
||||
|
||||
// parse reply message
|
||||
if (parseReply(reply))
|
||||
{
|
||||
if (!reply.contains("info") || !reply["info"].isObject())
|
||||
{
|
||||
throw std::runtime_error("No info available in result");
|
||||
}
|
||||
|
||||
QJsonDocument doc(reply["info"].toObject());
|
||||
QString info(doc.toJson(QJsonDocument::Indented));
|
||||
return info;
|
||||
}
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
void JsonConnection::clear(int priority)
|
||||
{
|
||||
qDebug() << "Clear priority channel " << priority;
|
||||
|
@ -1,8 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
// stl includes
|
||||
#include <string>
|
||||
|
||||
// Qt includes
|
||||
#include <QColor>
|
||||
#include <QImage>
|
||||
@ -79,6 +76,13 @@ public:
|
||||
///
|
||||
QString getServerInfo();
|
||||
|
||||
///
|
||||
/// Retrieve system info
|
||||
///
|
||||
/// @return String with the sys info
|
||||
///
|
||||
QString getSysInfo();
|
||||
|
||||
///
|
||||
/// Clear the given priority channel
|
||||
///
|
||||
|
@ -67,6 +67,7 @@ int main(int argc, char * argv[])
|
||||
Option & argCreateEffect= parser.add<Option> (0x0, "createEffect","Write a new Json Effect configuration file.\nFirst parameter = Effect name.\nSecond parameter = Effect file (--effectFile).\nLast parameter = Effect arguments (--effectArgs.)", "");
|
||||
Option & argDeleteEffect= parser.add<Option> (0x0, "deleteEffect","Delete a custom created Json Effect configuration file.");
|
||||
BooleanOption & argServerInfo = parser.add<BooleanOption>('l', "list" , "List server info and active effects with priority and duration");
|
||||
BooleanOption & argSysInfo = parser.add<BooleanOption>('s', "sysinfo" , "show system info");
|
||||
BooleanOption & argClear = parser.add<BooleanOption>('x', "clear" , "Clear data for the priority channel provided by the -p option");
|
||||
BooleanOption & argClearAll = parser.add<BooleanOption>(0x0, "clearall" , "Clear data for all active priority channels");
|
||||
Option & argEnableComponent = parser.add<Option> ('E', "enable" , "Enable the Component with the given name. Available Components are [SMOOTHING, BLACKBORDER, KODICHECKER, FORWARDER, UDPLISTENER, BOBLIGHT_SERVER, GRABBER, V4L]");
|
||||
@ -110,7 +111,7 @@ int main(int argc, char * argv[])
|
||||
|
||||
// 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),
|
||||
parser.isSet(argServerInfo), 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(argMapping) });
|
||||
if (commandCount != 1)
|
||||
@ -122,6 +123,7 @@ int main(int argc, char * argv[])
|
||||
showHelp(argCreateEffect);
|
||||
showHelp(argDeleteEffect);
|
||||
showHelp(argServerInfo);
|
||||
showHelp(argSysInfo);
|
||||
showHelp(argClear);
|
||||
showHelp(argClearAll);
|
||||
showHelp(argEnableComponent);
|
||||
@ -171,8 +173,11 @@ int main(int argc, char * argv[])
|
||||
}
|
||||
else if (parser.isSet(argServerInfo))
|
||||
{
|
||||
QString info = connection.getServerInfo();
|
||||
std::cout << "Server info:\n" << info.toStdString() << std::endl;
|
||||
std::cout << "Server info:\n" << connection.getServerInfo().toStdString() << std::endl;
|
||||
}
|
||||
else if (parser.isSet(argSysInfo))
|
||||
{
|
||||
std::cout << "System info:\n" << connection.getSysInfo().toStdString() << std::endl;
|
||||
}
|
||||
else if (parser.isSet(argClear))
|
||||
{
|
||||
|
@ -109,7 +109,7 @@ int main(int argc, char** argv)
|
||||
|
||||
// initialize the grabber
|
||||
V4L2Grabber grabber(
|
||||
argDevice.getStdString(parser),
|
||||
argDevice.value(parser),
|
||||
argInput.getInt(parser),
|
||||
argVideoStandard.switchValue(parser),
|
||||
argPixelFormat.switchValue(parser),
|
||||
|
@ -158,9 +158,10 @@ int HyperionDaemon::tryLoadConfig(const QString & configFile, const int schemaVe
|
||||
_qconfig = QJsonFactory::readConfig(configFile);
|
||||
if (!schemaChecker.validate(_qconfig))
|
||||
{
|
||||
for (std::list<std::string>::const_iterator i = schemaChecker.getMessages().begin(); i != schemaChecker.getMessages().end(); ++i)
|
||||
QStringList schemaErrors = schemaChecker.getMessages();
|
||||
foreach (auto & schemaError, schemaErrors)
|
||||
{
|
||||
std::cout << *i << std::endl;
|
||||
std::cout << schemaError.toStdString() << std::endl;
|
||||
}
|
||||
|
||||
throw std::runtime_error("ERROR: Json validation failed");
|
||||
@ -536,7 +537,7 @@ void HyperionDaemon::createGrabberFramebuffer(const QJsonObject & grabberConfig)
|
||||
#ifdef ENABLE_FB
|
||||
// Construct and start the framebuffer grabber if the configuration is present
|
||||
_fbGrabber = new FramebufferWrapper(
|
||||
grabberConfig["device"].toString("/dev/fb0").toStdString(),
|
||||
grabberConfig["device"].toString("/dev/fb0"),
|
||||
_grabber_width, _grabber_height, _grabber_frequency, _grabber_priority);
|
||||
|
||||
QObject::connect(_kodiVideoChecker, SIGNAL(grabbingMode(GrabbingMode)), _fbGrabber, SLOT(setGrabbingMode(GrabbingMode)));
|
||||
@ -593,10 +594,10 @@ void HyperionDaemon::createGrabberV4L2()
|
||||
}
|
||||
#ifdef ENABLE_V4L2
|
||||
V4L2Wrapper* grabber = new V4L2Wrapper(
|
||||
grabberConfig["device"].toString("auto").toStdString(),
|
||||
grabberConfig["device"].toString("auto"),
|
||||
grabberConfig["input"].toInt(0),
|
||||
parseVideoStandard(grabberConfig["standard"].toString("no-change").toStdString()),
|
||||
parsePixelFormat(grabberConfig["pixelFormat"].toString("no-change").toStdString()),
|
||||
parseVideoStandard(grabberConfig["standard"].toString("no-change")),
|
||||
parsePixelFormat(grabberConfig["pixelFormat"].toString("no-change")),
|
||||
grabberConfig["width"].toInt(-1),
|
||||
grabberConfig["height"].toInt(-1),
|
||||
grabberConfig["frameDecimation"].toInt(2),
|
||||
@ -605,7 +606,7 @@ void HyperionDaemon::createGrabberV4L2()
|
||||
grabberConfig["greenSignalThreshold"].toDouble(0.0),
|
||||
grabberConfig["blueSignalThreshold"].toDouble(0.0),
|
||||
grabberConfig["priority"].toInt(890));
|
||||
grabber->set3D(parse3DMode(grabberConfig["mode"].toString("2D").toStdString()));
|
||||
grabber->set3D(parse3DMode(grabberConfig["mode"].toString("2D")));
|
||||
grabber->setCropping(
|
||||
grabberConfig["cropLeft"].toInt(0),
|
||||
grabberConfig["cropRight"].toInt(0),
|
||||
|
@ -43,9 +43,10 @@ bool loadConfig(const QString & configFile)
|
||||
|
||||
if (!schemaChecker.validate(jsonConfig))
|
||||
{
|
||||
for (std::list<std::string>::const_iterator i = schemaChecker.getMessages().begin(); i != schemaChecker.getMessages().end(); ++i)
|
||||
QStringList schemaErrors = schemaChecker.getMessages();
|
||||
foreach (auto & schemaError, schemaErrors)
|
||||
{
|
||||
std::cout << *i << std::endl;
|
||||
std::cout << "config write validation: " << schemaError.toStdString() << std::endl;
|
||||
}
|
||||
|
||||
std::cout << "FAILED" << std::endl;
|
||||
|
Loading…
Reference in New Issue
Block a user