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