Details coming soon.

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

View File

@@ -0,0 +1,71 @@
#pragma once
#include <utils/Logger.h>
#include <hyperion/Hyperion.h>
#include <utils/settings.h>
///
/// @brief Handle the background Effect settings, reacts on runtime to settings changes
///
class BGEffectHandler : public QObject
{
Q_OBJECT
public:
BGEffectHandler(Hyperion* hyperion)
: QObject(hyperion)
, _hyperion(hyperion)
{
// listen for config changes
connect(_hyperion, &Hyperion::settingsChanged, this, &BGEffectHandler::handleSettingsUpdate);
// init
handleSettingsUpdate(settings::BGEFFECT, _hyperion->getSetting(settings::BGEFFECT));
};
private slots:
///
/// @brief Handle settings update from Hyperion Settingsmanager emit or this constructor
/// @param type settingyType from enum
/// @param config configuration object
///
void handleSettingsUpdate(const settings::type& type, const QJsonDocument& config)
{
if(type == settings::BGEFFECT)
{
const QJsonObject& BGEffectConfig = config.object();
#define BGCONFIG_ARRAY bgColorConfig.toArray()
// clear bg prioritiy
_hyperion->clear(254);
// initial background effect/color
if (BGEffectConfig["enable"].toBool(true))
{
const QString bgTypeConfig = BGEffectConfig["type"].toString("effect");
const QString bgEffectConfig = BGEffectConfig["effect"].toString("Warm mood blobs");
const QJsonValue bgColorConfig = BGEffectConfig["color"];
if (bgTypeConfig.contains("color"))
{
ColorRgb bg_color = {
(uint8_t)BGCONFIG_ARRAY.at(0).toInt(0),
(uint8_t)BGCONFIG_ARRAY.at(1).toInt(0),
(uint8_t)BGCONFIG_ARRAY.at(2).toInt(0)
};
_hyperion->setColor(254, bg_color);
Info(Logger::getInstance("HYPERION"),"Inital background color set (%d %d %d)",bg_color.red,bg_color.green,bg_color.blue);
}
else
{
int result = _hyperion->setEffect(bgEffectConfig, 254);
Info(Logger::getInstance("HYPERION"),"Inital background effect '%s' %s", QSTRING_CSTR(bgEffectConfig), ((result == 0) ? "started" : "failed"));
}
}
#undef BGCONFIG_ARRAY
}
};
private:
/// Hyperion instance pointer
Hyperion* _hyperion;
};

View File

@@ -0,0 +1,62 @@
#pragma once
#include <utils/Logger.h>
#include <utils/settings.h>
#include <utils/Components.h>
#include <utils/Image.h>
class Hyperion;
///
/// @brief Capture Control class which is a interface to the HyperionDaemon native capture classes.
/// It controls the instance based enable/disable of capture feeds and PriorityMuxer registrations
///
class CaptureCont : public QObject
{
Q_OBJECT
public:
CaptureCont(Hyperion* hyperion);
~CaptureCont();
void setSystemCaptureEnable(const bool& enable);
void setV4LCaptureEnable(const bool& enable);
private slots:
///
/// @brief Handle component state change of V4L and SystemCapture
/// @param component The component from enum
/// @param enable The new state
///
void componentStateChanged(const hyperion::Components component, bool enable);
///
/// @brief Handle settings update from Hyperion Settingsmanager emit or this constructor
/// @param type settingyType from enum
/// @param config configuration object
///
void handleSettingsUpdate(const settings::type& type, const QJsonDocument& config);
///
/// @brief forward system image
/// @param image The image
///
void handleSystemImage(const Image<ColorRgb>& image);
///
/// @brief forward v4l image
/// @param image The image
///
void handleV4lImage(const Image<ColorRgb> & image);
private:
/// Hyperion instance
Hyperion* _hyperion;
/// Reflect state of System capture and prio
bool _systemCaptEnabled;
quint8 _systemCaptPrio;
/// Reflect state of v4l capture and prio
bool _v4lCaptEnabled;
quint8 _v4lCaptPrio;
};

View File

@@ -1,6 +1,6 @@
#pragma once
#include <utils/Components.h>
#include <utils/Components.h>
#include <utils/Logger.h>
// STL includes
@@ -8,21 +8,61 @@
#include <QObject>
class Hyperion;
///
/// @brief The component register reflects and manages the current state of all components and Hyperion as a whole
/// It emits also real component state changes (triggert from the specific component), which can be used for listening APIs (Network Clients/Plugins)
///
class ComponentRegister : public QObject
{
Q_OBJECT
public:
ComponentRegister();
ComponentRegister(Hyperion* hyperion);
~ComponentRegister();
///
/// @brief Enable or disable Hyperion (all components)
/// @param state The new state of Hyperion
///
/// @return Returns true on success, false when Hyperion is already at the requested state
///
bool setHyperionEnable(const bool& state);
///
/// @brief Check if a component is currently enabled
/// @param comp The component from enum
/// @return True if component is running else false
///
bool isComponentEnabled(const hyperion::Components& comp) const;
/// contains all components and their state
std::map<hyperion::Components, bool> getRegister() { return _componentStates; };
signals:
///
/// @brief Emits whenever a component changed (really) the state
/// @param comp The component
/// @param state The new state of the component
///
void updatedComponentState(const hyperion::Components comp, const bool state);
public slots:
///
/// @brief is called whenever a component change a state, DO NOT CALL FROM API (use hyperion->setComponentState() instead)
/// @param comp The component
/// @param state The new state of the component
///
void componentStateChanged(const hyperion::Components comp, const bool activated);
private:
std::map<hyperion::Components, bool> _componentStates;
/// Hyperion instance
Hyperion * _hyperion;
/// Logger instance
Logger * _log;
/// current state of all components
std::map<hyperion::Components, bool> _componentStates;
/// on hyperion off we save the previous states of all components
std::map<hyperion::Components, bool> _prevComponentStates;
};

View File

@@ -6,10 +6,14 @@
#include <utils/ColorRgb.h>
#include <utils/Image.h>
#include <utils/VideoMode.h>
#include <grabber/VideoStandard.h>
#include <utils/ImageResampler.h>
#include <utils/Logger.h>
///
/// @brief The Grabber class is responsible to apply image resizes (with or without ImageResampler)
/// Overwrite the videoMode with setVideoMode()
/// Overwrite setCropping()
class Grabber : public QObject
{
Q_OBJECT
@@ -24,14 +28,71 @@ public:
///
virtual void setVideoMode(VideoMode mode);
///
/// @brief Apply new crop values, on errors reject the values
///
virtual void setCropping(unsigned cropLeft, unsigned cropRight, unsigned cropTop, unsigned cropBottom);
/// gets resulting height of image
///
/// @brief Apply new width/height values, on errors (collide with cropping) reject the values
///
virtual void setWidthHeight(int width, int height);
///
/// @brief Apply new pixelDecimation (used from x11)
///
virtual void setPixelDecimation(int pixelDecimation) {};
///
/// @brief Apply new signalThreshold (used from v4l)
///
virtual void setSignalThreshold(
double redSignalThreshold,
double greenSignalThreshold,
double blueSignalThreshold,
int noSignalCounterThreshold = 50) {};
///
/// @brief Apply new SignalDetectionOffset (used from v4l)
///
virtual void setSignalDetectionOffset(
double verticalMin,
double horizontalMin,
double verticalMax,
double horizontalMax) {};
///
/// @brief Apply SignalDetectionEnable (used from v4l)
///
virtual void setSignalDetectionEnable(bool enable) {};
///
/// @brief Apply input and videoStanded (used from v4l)
///
virtual void setInputVideoStandard(int input, VideoStandard videoStandard) {};
///
/// @brief Apply display index (used from x11)
///
virtual void setDisplayIndex(int index) {};
///
/// @brief Apply path for device (used from framebuffer)
///
virtual void setDevicePath(const QString& path) {};
///
/// @brief get current resulting height of image (after crop)
///
virtual const int getImageWidth() { return _width; };
/// gets resulting width of image
///
/// @brief get current resulting width of image (after crop)
///
virtual const int getImageHeight() { return _height; };
///
/// @brief Prevent the real capture implementation from capturing if disabled
///
void setEnabled(bool enable);
protected:

View File

@@ -1,27 +1,29 @@
#pragma once
#include <QObject>
#include <QTimer>
#include <QString>
#include <QStringList>
#include <utils/Logger.h>
#include <utils/Components.h>
#include <hyperion/Hyperion.h>
#include <hyperion/ImageProcessor.h>
#include <utils/Image.h>
#include <utils/ColorRgb.h>
#include <utils/VideoMode.h>
#include <utils/settings.h>
class ImageProcessor;
class Grabber;
class DispmanxFrameGrabber;
class QTimer;
///
/// This class will be inherted by FramebufferWrapper and others which contains the real capture interface
///
class GrabberWrapper : public QObject
{
Q_OBJECT
public:
GrabberWrapper(QString grabberName, Grabber * ggrabber, unsigned width, unsigned height, const unsigned updateRate_Hz, const int priority, hyperion::Components grabberComponentId=hyperion::COMP_GRABBER);
GrabberWrapper(QString grabberName, Grabber * ggrabber, unsigned width, unsigned height, const unsigned updateRate_Hz);
virtual ~GrabberWrapper();
@@ -35,8 +37,6 @@ public:
///
virtual void stop();
void setImageProcessorEnabled(bool enable);
static QStringList availableGrabbers();
public:
@@ -45,18 +45,15 @@ public:
{
unsigned w = grabber.getImageWidth();
unsigned h = grabber.getImageHeight();
if (_imageProcessorEnabled && ( _image.width() != w || _image.height() != h))
if ( _image.width() != w || _image.height() != h)
{
_processor->setSize(w, h);
_image.resize(w, h);
}
int ret = grabber.grabFrame(_image);
if (ret >= 0)
{
emit emitImage(_priority, _image, _timeout_ms);
_processor->process(_image, _ledColors);
setColors(_ledColors, _timeout_ms);
emit systemImage(_image);
return true;
}
return false;
@@ -64,46 +61,51 @@ public:
public slots:
void componentStateChanged(const hyperion::Components component, bool enable);
///
/// virtual method, should perform single frame grab and computes the led-colors
///
virtual void action() = 0;
void actionWrapper();
///
/// Set the video mode (2D/3D)
/// @param[in] mode The new video mode
///
virtual void setVideoMode(const VideoMode videoMode);
virtual void setVideoMode(const VideoMode& videoMode);
///
/// Set the crop values
/// @param cropLeft Left pixel crop
/// @param cropRight Right pixel crop
/// @param cropTop Top pixel crop
/// @param cropBottom Bottom pixel crop
///
virtual void setCropping(unsigned cropLeft, unsigned cropRight, unsigned cropTop, unsigned cropBottom);
///
/// @brief Handle settings update from HyperionDaemon Settingsmanager emit
/// @param type settingyType from enum
/// @param config configuration object
///
virtual void handleSettingsUpdate(const settings::type& type, const QJsonDocument& config);
signals:
void emitImage(int priority, const Image<ColorRgb> & image, const int timeout_ms);
///
/// @brief Emit the final processed image
///
void systemImage(const Image<ColorRgb>& image);
protected:
void setColors(const std::vector<ColorRgb> &ledColors, const int timeout_ms);
QString _grabberName;
/// Pointer to Hyperion for writing led values
Hyperion * _hyperion;
/// The priority of the led colors
const int _priority;
/// The timer for generating events with the specified update rate
QTimer _timer;
QTimer* _timer;
/// The update rate [Hz]
const int _updateInterval_ms;
/// The timeout of the led colors [ms]
const int _timeout_ms;
/// The calced update rate [ms]
int _updateInterval_ms;
/// The Logger instance
Logger * _log;
@@ -111,18 +113,8 @@ protected:
// forwarding enabled
bool _forward;
/// The processor for transforming images to led colors
ImageProcessor * _processor;
hyperion::Components _grabberComponentId;
Grabber *_ggrabber;
/// The image used for grabbing frames
Image<ColorRgb> _image;
/// The list with computed led colors
std::vector<ColorRgb> _ledColors;
bool _imageProcessorEnabled;
};

View File

@@ -8,12 +8,10 @@
#include <QObject>
#include <QString>
#include <QStringList>
#include <QTimer>
#include <QSize>
#include <QJsonObject>
#include <QJsonValue>
#include <QJsonArray>
#include <QTimer>
#include <QFileSystemWatcher>
// hyperion-utils includes
@@ -27,7 +25,6 @@
#include <hyperion/LedString.h>
#include <hyperion/PriorityMuxer.h>
#include <hyperion/ColorAdjustment.h>
#include <hyperion/MessageForwarder.h>
#include <hyperion/ComponentRegister.h>
// Effect engine includes
@@ -35,17 +32,23 @@
#include <effectengine/ActiveEffectDefinition.h>
#include <effectengine/EffectSchema.h>
// bonjour includes
#include <bonjour/bonjourservicebrowser.h>
#include <bonjour/bonjourserviceresolver.h>
// settings utils
#include <utils/settings.h>
// Forward class declaration
class QTimer;
class HyperionDaemon;
class ImageProcessor;
class MessageForwarder;
class LedDevice;
class LinearColorSmoothing;
class RgbTransform;
class EffectEngine;
class RgbChannelAdjustment;
class MultiColorAdjustment;
class ColorAdjustment;
class SettingsManager;
class BGEffectHandler;
class CaptureCont;
///
/// The main class of Hyperion. This gives other 'users' access to the attached LedDevice through
@@ -57,8 +60,6 @@ class Hyperion : public QObject
public:
/// Type definition of the info structure used by the priority muxer
typedef PriorityMuxer::InputInfo InputInfo;
typedef QMap<QString,int> PriorityRegister;
typedef QMap<QString,BonjourRecord> BonjourRegister;
///
/// RGB-Color channel enumeration
///
@@ -79,23 +80,54 @@ public:
///
/// @brief creates a new Hyperion instance, usually called from the Hyperion Daemon
/// @param[in] qjsonConfig The configuration file
/// @param[in] daemon The Hyperion daemon parent
/// @param[in] instance The instance id
/// @param[in] rootPath Root path of all hyperion userdata
/// @return Hyperion instance pointer
///
static Hyperion* initInstance(const QJsonObject& qjsonConfig, const QString configFile, const QString rootPath);
static Hyperion* initInstance(HyperionDaemon* daemon, const quint8& instance, const QString configFile, const QString rootPath);
///
/// @brief Get a pointer of this Hyperion instance
/// @return Hyperion instance pointer
/// @return Hyperion instance pointer
///
static Hyperion* getInstance();
///
/// @brief Get a pointer to the effect engine
/// @return EffectEngine instance pointer
///
EffectEngine* getEffectEngineInstance() { return _effectEngine; };
///
/// @brief Get a pointer to the priorityMuxer instance
/// @return PriorityMuxer instance pointer
///
PriorityMuxer* getMuxerInstance() { return &_muxer; };
///
/// @brief Get a setting by settings::type from SettingsManager
/// @param type The settingsType from enum
/// @return Data Document
///
QJsonDocument getSetting(const settings::type& type);
///
/// @brief Save a complete json config
/// @param config The entire config object
/// @param correct If true will correct json against schema before save
/// @return True on success else false
///
bool saveSettings(QJsonObject config, const bool& correct = false);
///
/// Returns the number of attached leds
///
unsigned getLedCount() const;
///
/// @brief Return the size of led grid
///
QSize getLedGridSize() const { return _ledGridSize; };
///
@@ -124,11 +156,9 @@ public:
///
/// @param[in] priority The priority channel
///
/// @return The information of the given
/// @return The information of the given, a not found priority will return lowest priority as fallback
///
/// @throw std::runtime_error when the priority channel does not exist
///
const InputInfo& getPriorityInfo(const int priority) const;
const InputInfo getPriorityInfo(const int priority) const;
/// Reload the list of available effects
void reloadEffects();
@@ -145,27 +175,29 @@ public:
/// @return The list of available effect schema files
const std::list<EffectSchema> &getEffectSchemas();
/// gets the current json config object
/// gets the current json config object from SettingsManager
/// @return json config
const QJsonObject& getQJsonConfig() { return _qjsonConfig; };
const QJsonObject& getQJsonConfig();
/// get path+filename of configfile
/// @return the current config path+filename
QString getConfigFilePath() { return _configFile; };
/// get filename of configfile
/// @return the current config filename
QString getConfigFileName() { return _configFile; };
QString getConfigFileName() const;
/// register a input source to a priority channel
/// @param name uniq name of input source
/// @param origin External setter
/// @param priority priority channel
void registerPriority(const QString &name, const int priority);
///
/// @brief Register a new input by priority, the priority is not active (timeout -100 isn't muxer recognized) until you start to update the data with setInput()
/// A repeated call to update the base data of a known priority won't overwrite their current timeout
/// @param[in] priority The priority of the channel
/// @param[in] component The component of the channel
/// @param[in] origin Who set the channel (CustomString@IP)
/// @param[in] owner Speicifc owner string, might be empty
/// @param[in] smooth_cfg The smooth id to use
///
void registerInput(const int priority, const hyperion::Components& component, const QString& origin = "System", const QString& owner = "", unsigned smooth_cfg = 0);
/// unregister a input source to a priority channel
/// @param name uniq name of input source
void unRegisterPriority(const QString &name);
/// gets current priority register
/// @return the priority register
const PriorityRegister& getPriorityRegister() { return _priorityRegister; }
/// enable/disable automatic/priorized source selection
/// @param enabled the state
@@ -178,12 +210,18 @@ public:
/// gets current state of automatic/priorized source selection
/// @return the state
bool sourceAutoSelectEnabled() { return _sourceAutoSelectEnabled; };
bool sourceAutoSelectEnabled();
///
/// Enable/Disable components during runtime
/// @brief Get the last untransformed/unadjusted led colors
/// @return The _rawLedBuffer leds
///
/// @param component The component [SMOOTHING, BLACKBORDER, FORWARDER, UDPLISTENER, BOBLIGHT_SERVER, GRABBER]
const std::vector<ColorRgb>& getRawLedBuffer() { return _rawLedBuffer; };
///
/// @brief Enable/Disable components during runtime, called from external API (requests)
///
/// @param component The component from enum
/// @param state The state of the component [true | false]
///
void setComponentState(const hyperion::Components component, const bool state);
@@ -195,54 +233,63 @@ public:
bool configWriteable() { return _configWrite; };
/// gets the methode how image is maped to leds
int getLedMappingType() { return _ledMAppingType; };
/// get the configuration
QJsonObject getConfig() { return _qjsonConfig; };
const int & getLedMappingType();
/// get the root path for all hyperion user data files
QString getRootPath() { return _rootPath; };
const QString &getRootPath() { return _rootPath; };
/// unique id per instance
QString id;
/// get unique id per instance
const QString &getId(){ return _id; };
/// set unique id
void setId(QString id){ _id = id; };
int getLatchTime() const;
/// forward smoothing config
unsigned addSmoothingConfig(int settlingTime_ms, double ledUpdateFrequency_hz=25.0, unsigned updateDelay=0);
VideoMode getCurrentVideoMode() { return _videoMode; };
const VideoMode & getCurrentVideoMode();
///
/// @brief Get the current active led device
/// @return The device nam
/// e
const QString & getActiveDevice();
public slots:
///
/// @brief Update the current color of a priority (prev registered with registerInput())
/// DO NOT use this together with setInputImage() at the same time!
/// @param priority The priority to update
/// @param ledColors The colors
/// @param timeout_ms The new timeout (defaults to -1 endless)
/// @param clearEffect Should be true when NOT called from an effect
/// @return True on success, false when priority is not found
///
const bool setInput(const int priority, const std::vector<ColorRgb>& ledColors, const int timeout_ms = -1, const bool& clearEffect = true);
///
/// @brief Update the current image of a priority (prev registered with registerInput())
/// DO NOT use this together with setInput() at the same time!
/// @param priority The priority to update
/// @param image The new image
/// @param timeout_ms The new timeout (defaults to -1 endless)
/// @param clearEffect Should be true when NOT called from an effect
/// @return True on success, false when priority is not found
///
const bool setInputImage(const int priority, const Image<ColorRgb>& image, int64_t timeout_ms = -1, const bool& clearEffect = true);
///
/// Writes a single color to all the leds for the given time and priority
/// Registers comp color or provided type against muxer
/// Should be never used to update leds continuous
///
/// @param[in] priority The priority of the written color
/// @param[in] ledColor The color to write to the leds
/// @param[in] origin The setter
/// @param[in] timeout_ms The time the leds are set to the given color [ms]
///
void setColor(int priority, const ColorRgb &ledColor, const int timeout_ms, bool clearEffects = true);
///
/// Writes the given colors to all leds for the given time and priority
///
/// @param[in] priority The priority of the written colors
/// @param[in] ledColors The colors to write to the leds
/// @param[in] timeout_ms The time the leds are set to the given colors [ms]
/// @param[in] component The current component
/// @param[in] origin Who set it
/// @param[in] smoothCfg smoothing config id
///
void setColors(int priority, const std::vector<ColorRgb> &ledColors, const int timeout_ms, bool clearEffects = true, hyperion::Components component=hyperion::COMP_INVALID, const QString origin="System", unsigned smoothCfg=SMOOTHING_MODE_DEFAULT);
///
/// Writes the given colors to all leds for the given time and priority
///
/// @param[in] priority The priority of the written colors
/// @param[in] ledColors The colors to write to the leds
/// @param[in] timeout_ms The time the leds are set to the given colors [ms]
///
void setImage(int priority, const Image<ColorRgb> & image, int duration_ms);
void setColor(int priority, const ColorRgb &ledColor, const int timeout_ms = -1, const QString& origin = "System" ,bool clearEffects = true);
///
/// Returns the list with unique adjustment identifiers
@@ -270,8 +317,9 @@ public slots:
/// lower priority channel (or off if no more channels are set)
///
/// @param[in] priority The priority channel
/// @return True on success else false (not found)
///
void clear(int priority);
const bool clear(int priority);
///
/// Clears all priority channels. This will switch the leds off until a new priority is written.
@@ -292,44 +340,18 @@ public slots:
int setEffect(const QString & effectName, const QJsonObject & args, int priority,
int timeout = -1, const QString & pythonScript = "", const QString & origin="System");
/// sets the methode how image is maped to leds
void setLedMappingType(int mappingType);
///
Hyperion::BonjourRegister getHyperionSessions();
/// Slot which is called, when state of hyperion has been changed
void hyperionStateChanged();
/// sets the methode how image is maped to leds at ImageProcessor
void setLedMappingType(const int& mappingType);
///
/// Set the video mode (2D/3D)
/// @param[in] mode The new video mode
///
void setVideoMode(VideoMode mode);
void setVideoMode(const VideoMode& mode);
public:
static Hyperion *_hyperion;
static ColorOrder createColorOrder(const QJsonObject & deviceConfig);
/**
* Construct the 'led-string' with the integration area definition per led and the color
* ordering of the RGB channels
* @param ledsConfig The configuration of the led areas
* @param deviceOrder The default RGB channel ordering
* @return The constructed ledstring
*/
static LedString createLedString(const QJsonValue & ledsConfig, const ColorOrder deviceOrder);
static LedString createLedStringClone(const QJsonValue & ledsConfig, const ColorOrder deviceOrder);
static MultiColorAdjustment * createLedColorsAdjustment(const unsigned ledCnt, const QJsonObject & colorAdjustmentConfig);
static ColorAdjustment * createColorAdjustment(const QJsonObject & adjustmentConfig);
static RgbTransform * createRgbTransform(const QJsonObject& colorConfig);
static RgbChannelAdjustment * createRgbChannelAdjustment(const QJsonObject & colorConfig, const QString channelName, const int defaultR, const int defaultG, const int defaultB);
static LinearColorSmoothing * createColorSmoothing(const QJsonObject & smoothingConfig, LedDevice* leddevice);
static MessageForwarder * createMessageForwarder(const QJsonObject & forwarderConfig);
static QSize getLedLayoutGridSize(const QJsonValue& ledsConfig);
signals:
/// Signal which is emitted when a priority channel is actively cleared
/// This signal will not be emitted when a priority channel time out
@@ -339,25 +361,67 @@ signals:
/// This signal will not be emitted when a priority channel time out
void allChannelsCleared();
///
/// @brief Emits whenever a user request a component state change, it's up the component to listen
/// and update the component state at the componentRegister
/// @param component The component from enum
/// @param enabled The new state of the component
///
void componentStateChanged(const hyperion::Components component, bool enabled);
void imageToLedsMappingChanged(int mappingType);
void emitImage(int priority, const Image<ColorRgb> & image, const int timeout_ms);
///
/// @brief Emits whenever the imageToLedsMapping has changed
/// @param mappingType The new mapping type
///
void imageToLedsMappingChanged(const int& mappingType);
///
/// @brief Emits whenever the visible priority delivers a image which is applied in update()
/// priorities with ledColors won't emit this signal
/// @param image The current image
///
void currentImage(const Image<ColorRgb> & image);
void closing();
/// Signal which is emitted, when a new json message should be forwarded
void forwardJsonMessage(QJsonObject);
/// Signal which is emitted, after the hyperionStateChanged has been processed with a emit count blocker (250ms interval)
void sendServerInfo();
/// Signal emitted when a 3D movie is detected
void videoMode(VideoMode mode);
///
/// @brief Is emitted from clients who request a videoMode change
///
void videoMode(const VideoMode& mode);
///
/// @brief Emits whenever new untransformed ledColos data is available, reflects the current visible device
/// @brief A new videoMode was requested (called from Daemon!)
///
void rawLedColors(const std::vector<ColorRgb>& ledValues);
void newVideoMode(const VideoMode& mode);
///
/// @brief Emits whenever a config part changed. SIGNAL PIPE helper for SettingsManager -> HyperionDaemon
/// @param type The settings type from enum
/// @param data The data as QJsonDocument
///
void settingsChanged(const settings::type& type, const QJsonDocument& data);
///
/// @brief Emits whenever the adjustments have been updated
///
void adjustmentChanged();
///
/// @brief Signal pipe from EffectEngine to external, emits when effect list has been updated
///
void effectListUpdated();
///
/// @brief systemImage from the parent HyperionDaemon SystemCapture
///
void systemImage(const Image<ColorRgb>& image);
///
/// @brief v4lImage from the parent HyperionDaemon V4lCapture
///
void v4lImage(const Image<ColorRgb> & image);
private slots:
///
@@ -366,13 +430,23 @@ private slots:
///
void update();
void currentBonjourRecordsChanged(const QList<BonjourRecord> &list);
void bonjourRecordResolved(const QHostInfo &hostInfo, int port);
void bonjourResolve();
/// check for configWriteable and modified changes, called by _fsWatcher or fallback _cTimer
void checkConfigState(QString cfile = NULL);
///
/// @brief Apply ComponentRegister emits for COMP_ALL. Enables/Disables core timers
/// @param comp The component
/// @param state The new state of the component
///
void updatedComponentState(const hyperion::Components comp, const bool state);
///
/// @brief Apply settings updates for LEDS and COLOR
/// @param type The type from enum
/// @param config The configuration
///
void handleSettingsUpdate(const settings::type& type, const QJsonDocument& config);
private:
///
@@ -380,7 +454,16 @@ private:
///
/// @param[in] qjsonConfig The Json configuration
///
Hyperion(const QJsonObject& qjsonConfig, const QString configFile, const QString rootPath);
Hyperion(HyperionDaemon* daemon, const quint8& instance, const QString configFile, const QString rootPath);
/// The parent Hyperion Daemon
HyperionDaemon* _daemon;
/// Settings manager of this instance
SettingsManager* _settingsManager;
/// Register that holds component states
ComponentRegister _componentRegister;
/// The specifiation of the led frame construction and picture integration
LedString _ledString;
@@ -388,6 +471,9 @@ private:
/// specifiation of cloned leds
LedString _ledStringClone;
/// Image Processor
ImageProcessor* _imageProcessor;
std::vector<ColorOrder> _ledStringColorOrder;
/// The priority muxer
@@ -408,21 +494,14 @@ private:
// proto and json Message forwarder
MessageForwarder * _messageForwarder;
// json configuration
const QJsonObject& _qjsonConfig;
/// the name of config file
QString _configFile;
/// root path for all hyperion user data files
QString _rootPath;
/// The timer for handling priority channel timeouts
QTimer _timer;
QTimer _timerBonjourResolver;
/// buffer for leds (with adjustment)
std::vector<ColorRgb> _ledBuffer;
/// unique id per instance
QString _id;
/// Logger instance
Logger * _log;
@@ -430,32 +509,16 @@ private:
/// count of hardware leds
unsigned _hwLedCount;
ComponentRegister _componentRegister;
/// register of input sources and it's prio channel
PriorityRegister _priorityRegister;
/// flag indicates state for autoselection of input source
bool _sourceAutoSelectEnabled;
/// holds the current priority channel that is manualy selected
int _currentSourcePriority;
QByteArray _configHash;
QSize _ledGridSize;
int _ledMAppingType;
/// Store the previous compID for smarter update()
hyperion::Components _prevCompId;
BonjourServiceBrowser _bonjourBrowser;
BonjourServiceResolver _bonjourResolver;
BonjourRegister _hyperionSessions;
QString _bonjourCurrentServiceToResolve;
/// Observe filesystem changes (_configFile), if failed use Timer
QFileSystemWatcher _fsWatcher;
QTimer _cTimer;
QTimer* _cTimer;
/// holds the prev states of configWriteable and modified
bool _prevConfigMod = false;
@@ -465,9 +528,16 @@ private:
bool _configMod = false;
bool _configWrite = true;
/// timers to handle severinfo blocking
QTimer _fsi_timer;
QTimer _fsi_blockTimer;
/// Background effect instance, kept active to react on setting changes
BGEffectHandler* _BGEffectHandler;
/// Capture control for Daemon native capture
CaptureCont* _captureCont;
VideoMode _videoMode;
// lock Hyperion::update() for exec
bool _lockUpdate = false;
/// buffer for leds (with adjustment)
std::vector<ColorRgb> _ledBuffer;
/// buffer for leds (without adjustment)
std::vector<ColorRgb> _rawLedBuffer;
};

View File

@@ -6,14 +6,18 @@
#include <utils/Image.h>
// Hyperion includes
#include <hyperion/ImageProcessorFactory.h>
#include <hyperion/LedString.h>
#include <hyperion/ImageToLedsMap.h>
#include <utils/Logger.h>
// settings
#include <utils/settings.h>
// Black border includes
#include <blackborder/BlackBorderProcessor.h>
class Hyperion;
///
/// The ImageProcessor translates an RGB-image to RGB-values for the leds. The processing is
/// performed in two steps. First the average color per led-region is computed. Second a
@@ -24,14 +28,16 @@ class ImageProcessor : public QObject
Q_OBJECT
public:
///
/// Constructs an image-processor for translating an image to led-color values based on the
/// given led-string specification
/// @param[in] ledString LedString data
/// @param[in] hyperion Hyperion instance pointer
///
ImageProcessor(const LedString& ledString, Hyperion* hyperion);
~ImageProcessor();
///
/// Returns the number of attached leds
///
unsigned getLedCount() const;
///
/// Specifies the width and height of 'incomming' images. This will resize the buffer-image to
/// match the given size.
@@ -42,20 +48,39 @@ public:
///
void setSize(const unsigned width, const unsigned height);
///
/// @brief Update the led string (eg on settings change)
///
void setLedString(const LedString& ledString);
/// Returns starte of black border detector
bool blackBorderDetectorEnabled();
/// Returns starte of black border detector
int ledMappingType();
/// Returns the current _userMappingType, this may not be the current applied type!
const int & getUserLedMappingType() { return _userMappingType; };
/// Returns the current _mappingType
const int & ledMappingType() { return _mappingType; };
static int mappingTypeToInt(QString mappingType);
static QString mappingTypeToStr(int mappingType);
public slots:
/// Enable or disable the black border detector
void enableBlackBorderDetector(bool enable);
///
/// @brief Set the Hyperion::update() requestes led mapping type. This type is used in favour of type set with setLedMappingType.
/// If you don't want to force a mapType set this to -1 (user choice will be set)
/// @param mapType The new mapping type
///
void setHardLedMappingType(int mapType);
/// Enable or disable the black border detector
public slots:
/// Enable or disable the black border detector based on component
void setBlackbarDetectDisable(bool enable);
///
/// @brief Set the user requested led mapping.
/// The type set with setHardLedMappingType() will be used in favour to respect comp specific settings
/// @param mapType The new mapping type
///
void setLedMappingType(int mapType);
public:
@@ -101,7 +126,7 @@ public:
}
else
{
Warning(_log, "ImageProcessor::process called without image size 0");
Warning(_log, "ImageProcessor::process called with image size 0");
}
// return the computed colors
@@ -134,7 +159,7 @@ public:
}
else
{
Warning(_log, "ImageProcessor::process called without image size 0");
Warning(_log, "Called with image size 0");
}
}
@@ -150,18 +175,6 @@ public:
bool getScanParameters(size_t led, double & hscanBegin, double & hscanEnd, double & vscanBegin, double & vscanEnd) const;
private:
/// Friend declaration of the factory for creating ImageProcessor's
friend class ImageProcessorFactory;
///
/// Constructs an image-processor for translating an image to led-color values based on the
/// given led-string specification
///
/// @param[in] ledString The led-string specification
/// @param[in] blackborderThreshold The threshold which the blackborder detector should use
///
ImageProcessor(const LedString &ledString, const QJsonObject &blackborderConfig);
///
/// Performs black-border detection (if enabled) on the given image
///
@@ -172,7 +185,7 @@ private:
{
if (!_borderProcessor->enabled() && ( _imageToLeds->horizontalBorder()!=0 || _imageToLeds->verticalBorder()!=0 ))
{
Debug(Logger::getInstance("BLACKBORDER"), "disabled, reset border");
Debug(_log, "Reset border");
_borderProcessor->process(image);
delete _imageToLeds;
_imageToLeds = new hyperion::ImageToLedsMap(image.width(), image.height(), 0, 0, _ledString.leds());
@@ -180,8 +193,6 @@ private:
if(_borderProcessor->enabled() && _borderProcessor->process(image))
{
//Debug(Logger::getInstance("BLACKBORDER"), "BORDER SWITCH REQUIRED!!");
const hyperion::BlackBorder border = _borderProcessor->getCurrentBorder();
// Clean up the old mapping
@@ -203,10 +214,13 @@ private:
}
}
private slots:
void handleSettingsUpdate(const settings::type& type, const QJsonDocument& config);
private:
Logger * _log;
/// The Led-string specification
const LedString _ledString;
LedString _ledString;
/// The processor for black border detection
hyperion::BlackBorderProcessor * _borderProcessor;
@@ -216,4 +230,11 @@ private:
/// Type of image 2 led mapping
int _mappingType;
/// Type of last requested user type
int _userMappingType;
/// Type of last requested hard type
int _hardMappingType;
/// Hyperion instance pointer
Hyperion* _hyperion;
};

View File

@@ -1,53 +0,0 @@
#pragma once
// STL includes
#include <memory>
// QT includes
#include <QJsonObject>
#include <hyperion/LedString.h>
// Forward class declaration
class ImageProcessor;
///
/// The ImageProcessor is a singleton factor for creating ImageProcessors that translate images to
/// led color values.
///
class ImageProcessorFactory
{
public:
///
/// Returns the 'singleton' instance (creates the singleton if it does not exist)
///
/// @return The singleton instance of the ImageProcessorFactory
///
static ImageProcessorFactory& getInstance();
public:
///
/// Initialises this factory with the given led-configuration
///
/// @param[in] ledString The led configuration
/// @param[in] blackborderConfig Contains the blackborder configuration
///
void init(const LedString& ledString, const QJsonObject &blackborderConfig, int mappingType);
///
/// Creates a new ImageProcessor. The onwership of the processor is transferred to the caller.
///
/// @return The newly created ImageProcessor
///
ImageProcessor* newImageProcessor() const;
private:
/// The Led-string specification
LedString _ledString;
/// Reference to the blackborder json configuration values
QJsonObject _blackborderConfig;
// image 2 led mapping type
int _mappingType;
};

View File

@@ -7,6 +7,7 @@
// hyperion-utils includes
#include <utils/Image.h>
#include <utils/Logger.h>
// hyperion includes
#include <hyperion/LedString.h>
@@ -58,7 +59,7 @@ namespace hyperion
const unsigned horizontalBorder() const { return _horizontalBorder; };
const unsigned verticalBorder() const { return _verticalBorder; };
///
/// Determines the mean-color for each led using the mapping the image given
/// at construction.
@@ -86,7 +87,12 @@ namespace hyperion
void getMeanLedColor(const Image<Pixel_T> & image, std::vector<ColorRgb> & ledColors) const
{
// Sanity check for the number of leds
assert(_colorsMap.size() == ledColors.size());
//assert(_colorsMap.size() == ledColors.size());
if(_colorsMap.size() != ledColors.size())
{
Debug(Logger::getInstance("HYPERION"), "ImageToLedsMap: colorsMap.size != ledColors.size -> %d != %d", _colorsMap.size(), ledColors.size());
return;
}
// Iterate each led and compute the mean
auto led = ledColors.begin();
@@ -96,7 +102,7 @@ namespace hyperion
*led = color;
}
}
///
/// Determines the mean-color for each led using the mapping the image given
/// at construction.
@@ -124,7 +130,13 @@ namespace hyperion
void getUniLedColor(const Image<Pixel_T> & image, std::vector<ColorRgb> & ledColors) const
{
// Sanity check for the number of leds
assert(_colorsMap.size() == ledColors.size());
// assert(_colorsMap.size() == ledColors.size());
if(_colorsMap.size() != ledColors.size())
{
Debug(Logger::getInstance("HYPERION"), "ImageToLedsMap: colorsMap.size != ledColors.size -> %d != %d", _colorsMap.size(), ledColors.size());
return;
}
// calculate uni color
const ColorRgb color = calcMeanColor(image);
@@ -136,11 +148,11 @@ namespace hyperion
const unsigned _width;
/// The height of the indexed image
const unsigned _height;
const unsigned _horizontalBorder;
const unsigned _verticalBorder;
/// The absolute indices into the image for each led
std::vector<std::vector<unsigned>> _colorsMap;

View File

@@ -10,31 +10,45 @@
#include <QList>
#include <QStringList>
#include <QHostAddress>
#include <QJsonObject>
#include <QJsonArray>
#include <QJsonDocument>
// Utils includes
#include <utils/ColorRgb.h>
class MessageForwarder
#include <utils/settings.h>
#include <utils/Logger.h>
class Hyperion;
class MessageForwarder : public QObject
{
Q_OBJECT
public:
struct JsonSlaveAddress {
QHostAddress addr;
quint16 port;
};
MessageForwarder();
MessageForwarder(Hyperion* hyperion, const QJsonDocument & config);
~MessageForwarder();
void addJsonSlave(QString slave);
void addProtoSlave(QString slave);
bool protoForwardingEnabled();
bool jsonForwardingEnabled();
bool forwardingEnabled() { return jsonForwardingEnabled() || protoForwardingEnabled(); };
QStringList getProtoSlaves();
QList<MessageForwarder::JsonSlaveAddress> getJsonSlaves();
QStringList getProtoSlaves() const { return _protoSlaves; };
QStringList getJsonSlaves() const { return _jsonSlaves; };
private slots:
///
/// @brief Handle settings update from Hyperion Settingsmanager emit or this constructor
/// @param type settingyType from enum
/// @param config configuration object
///
void handleSettingsUpdate(const settings::type& type, const QJsonDocument& config);
private:
QStringList _protoSlaves;
QList<MessageForwarder::JsonSlaveAddress> _jsonSlaves;
Hyperion* _hyperion;
Logger* _log;
QStringList _protoSlaves;
QStringList _jsonSlaves;
};

View File

@@ -0,0 +1,69 @@
#pragma once
// STL includes
#include <vector>
#include <QStringList>
#include <QString>
// Hyperion includes
#include <utils/ColorRgb.h>
#include <hyperion/ColorAdjustment.h>
///
/// The LedColorTransform is responsible for performing color transformation from 'raw' colors
/// received as input to colors mapped to match the color-properties of the leds.
///
class MultiColorAdjustment
{
public:
MultiColorAdjustment(const unsigned ledCnt);
~MultiColorAdjustment();
/**
* Adds a new ColorAdjustment to this MultiColorTransform
*
* @param adjustment The new ColorAdjustment (ownership is transfered)
*/
void addAdjustment(ColorAdjustment * adjustment);
void setAdjustmentForLed(const QString& id, const unsigned startLed, unsigned endLed);
bool verifyAdjustments() const;
void setBacklightEnabled(bool enable);
///
/// Returns the identifier of all the unique ColorAdjustment
///
/// @return The list with unique id's of the ColorAdjustment
const QStringList & getAdjustmentIds();
///
/// Returns the pointer to the ColorAdjustment with the given id
///
/// @param id The identifier of the ColorAdjustment
///
/// @return The ColorAdjustment with the given id (or nullptr if it does not exist)
///
ColorAdjustment* getAdjustment(const QString& id);
///
/// Performs the color adjustment from raw-color to led-color
///
/// @param ledColors The list with raw colors
///
void applyAdjustment(std::vector<ColorRgb>& ledColors);
private:
/// List with transform ids
QStringList _adjustmentIds;
/// List with unique ColorTransforms
std::vector<ColorAdjustment*> _adjustment;
/// List with a pointer to the ColorAdjustment for each individual led
std::vector<ColorAdjustment*> _ledAdjustments;
// logger instance
Logger * _log;
};

View File

@@ -7,23 +7,25 @@
// QT includes
#include <QMap>
#include <QObject>
#include <QTimer>
#include <QMap>
#include <QVector>
// Utils includes
#include <utils/ColorRgb.h>
#include <utils/Image.h>
#include <utils/Components.h>
// global defines
#define SMOOTHING_MODE_DEFAULT 0
#define SMOOTHING_MODE_PAUSE 1
class QTimer;
class Logger;
///
/// The PriorityMuxer handles the priority channels. Led values input is written to the priority map
/// The PriorityMuxer handles the priority channels. Led values input/ images are written to the priority map
/// and the muxer keeps track of all active priorities. The current priority can be queried and per
/// priority the led colors.
/// priority the led colors. Handles also manual/auto selection mode, provides a lot of signals to hook into priority related events
///
class PriorityMuxer : public QObject
{
@@ -36,17 +38,20 @@ public:
{
/// The priority of this channel
int priority;
/// The absolute timeout of the channel
int64_t timeoutTime_ms;
/// The colors for each led of the channel
std::vector<ColorRgb> ledColors;
/// The raw Image (size should be preprocessed!)
Image<ColorRgb> image;
/// The component
hyperion::Components componentId;
/// Who set it
QString origin;
/// id fo smoothing config
/// id of smoothing config
unsigned smooth_cfg;
/// specific owner description
QString owner;
};
/// The lowest possible priority, which is used when no priority channels are active
@@ -65,6 +70,38 @@ public:
///
~PriorityMuxer();
///
/// @brief Start/Stop the PriorityMuxer update timer; On disabled no priority and timeout updates will be performend
/// @param enable The new state
///
void setEnable(const bool& enable);
/// @brief Enable or disable auto source selection
/// @param enable True if it should be enabled else false
/// @param update True to update _currentPriority - INTERNAL usage.
/// @return True if changed has been applied, false if the state is unchanged
///
bool setSourceAutoSelectEnabled(const bool& enabel, const bool& update = true);
///
/// @brief Get the state of source auto selection
/// @return True if enabled, else false
///
bool isSourceAutoSelectEnabled() const { return _sourceAutoSelectEnabled; };
///
/// @brief Overwrite current lowest piority with manual selection; On success disables aito selection
/// @param priority The
/// @return True on success, false if priority not found
///
bool setPriority(const uint8_t priority);
///
/// @brief Update all ledColos with min length of >= 1 to fit the new led length
/// @param[in] ledCount The count of leds
///
void updateLedColorsLength(const int& ledCount);
///
/// Returns the current priority
///
@@ -87,69 +124,134 @@ public:
QList<int> getPriorities() const;
///
/// Returns the information of a specified priority channel
/// Returns the information of a specified priority channel.
/// If a priority is no longer available the _lowestPriorityInfo (255) is returned
///
/// @param priority The priority channel
///
/// @return The information for the specified priority channel
///
/// @throws std::runtime_error if the priority channel does not exist
///
const InputInfo& getInputInfo(const int priority) const;
const InputInfo getInputInfo(const int priority) const;
///
/// Sets/Updates the data for a priority channel
/// @brief Register a new input by priority, the priority is not active (timeout -100 isn't muxer recognized) until you start to update the data with setInput()
/// A repeated call to update the base data of a known priority won't overwrite their current timeout
/// @param[in] priority The priority of the channel
/// @param[in] component The component of the channel
/// @param[in] origin Who set the channel (CustomString@IP)
/// @param[in] owner Speicifc owner string, might be empty
/// @param[in] smooth_cfg The smooth id to use
///
/// @param[in] priority The priority of the channel
/// @param[in] ledColors The led colors of the priority channel
/// @param[in] timeoutTime_ms The absolute timeout time of the channel
/// @param[in] component The component of the channel
/// @param[in] origin Who set the channel
///
void setInput(const int priority, const std::vector<ColorRgb>& ledColors, const int64_t timeoutTime_ms=-1, hyperion::Components component=hyperion::COMP_INVALID, const QString origin="System", unsigned smooth_cfg=SMOOTHING_MODE_DEFAULT);
void registerInput(const int priority, const hyperion::Components& component, const QString& origin = "System", const QString& owner = "", unsigned smooth_cfg = SMOOTHING_MODE_DEFAULT);
///
/// Clears the specified priority channel
/// @brief Update the current color of a priority (prev registered with registerInput())
/// @param priority The priority to update
/// @param ledColors The colors
/// @param timeout_ms The new timeout (defaults to -1 endless)
/// @return True on success, false when priority is not found
///
const bool setInput(const int priority, const std::vector<ColorRgb>& ledColors, int64_t timeout_ms = -1);
///
/// @brief Update the current image of a priority (prev registered with registerInput())
/// @param priority The priority to update
/// @param image The new image
/// @param timeout_ms The new timeout (defaults to -1 endless)
/// @return True on success, false when priority is not found
///
const bool setInputImage(const int priority, const Image<ColorRgb>& image, int64_t timeout_ms = -1);
///
/// Clears the specified priority channel and update _currentPriority on success
///
/// @param[in] priority The priority of the channel to clear
/// @return True if priority has been cleared else false (not found)
///
void clearInput(const int priority);
const bool clearInput(const uint8_t priority);
///
/// Clears all priority channels
///
void clearAll(bool forceClearAll=false);
signals:
///
/// @brief Signal which emits when a effect or color with timeout > -1 is running, once per second
///
void timeRunner();
///
/// @brief A priority has been added (registerInput()) or deleted, method clear or timeout clear
/// @param priority The priority which has changed
/// @param state If true it was added else it was removed!
///
void priorityChanged(const quint8& priority, const bool& state);
///
/// @brief Emits whenever the visible priority has changed
/// @param priority The new visible prioritiy
///
void visiblePriorityChanged(const quint8& priority);
///
/// @brief Emits whenever a priority changes active state
/// @param priority The priority who changed the active state
/// @param state The new state, state true = active else false
///
void activeStateChanged(const quint8& priority, const bool& state);
///
/// @brief Emits whenever the auto selection state has been changed
/// @param state The new state of auto selection; True enabled else false
///
void autoSelectChanged(const bool& state);
///
/// @brief Emits whenever something changes which influences the priorities listing
/// Emits also in 1s interval when a COLOR or EFFECT is running with a timeout > -1
///
void prioritiesChanged(void);
///
/// internal used signal to resolve treading issues with timer
///
void signalTimeTrigger();
private slots:
///
/// Slot which is called to adapt to 1s interval for signal timeRunner() / prioritiesChanged()
///
void timeTrigger();
///
/// Updates the current time. Channels with a configured time out will be checked and cleared if
/// required.
///
/// @param[in] now The current time
///
void setCurrentTime(const int64_t& now);
signals:
///
/// Signal which is called, when a effect or color with timeout is running, once per second
///
void timerunner();
private slots:
///
/// Slots which is called to adapt to 1s interval for signal timerunner()
///
void emitReq();
void setCurrentTime(void);
private:
/// Logger instance
Logger* _log;
/// The current priority (lowest value in _activeInputs)
int _currentPriority;
/// The manual select priority set with setPriority
int _manualSelectedPriority;
/// The mapping from priority channel to led-information
QMap<int, InputInfo> _activeInputs;
/// The information of the lowest priority channel
InputInfo _lowestPriorityInfo;
QTimer _timer;
QTimer _blockTimer;
// Reflect the state of auto select
bool _sourceAutoSelectEnabled;
// Timer to update Muxer times independent
QTimer* _updateTimer;
QTimer* _timer;
QTimer* _blockTimer;
};

View File

@@ -0,0 +1,72 @@
#pragma once
#include <utils/Logger.h>
#include <utils/settings.h>
// qt incl
#include <QJsonObject>
class SettingsTable;
class Hyperion;
///
/// @brief Manage the settings read write from/to database, on settings changed will emit a signal to update components accordingly
///
class SettingsManager : public QObject
{
Q_OBJECT
public:
///
/// @brief Construct a settings manager and assign a hyperion instance
/// @params hyperion The parent hyperion instance
/// @params instance Instance number of Hyperion
///
SettingsManager(Hyperion* hyperion, const quint8& instance, const QString& configFile);
///
/// @brief Construct a settings manager for HyperionDaemon
///
SettingsManager(const quint8& instance, const QString& configFile);
~SettingsManager();
///
/// @brief Save a complete json config
/// @param config The entire config object
/// @param correct If true will correct json against schema before save
/// @return True on success else false
///
const bool saveSettings(QJsonObject config, const bool& correct = false);
///
/// @brief get a single setting json from database
/// @param type The settings::type from enum
/// @return The requested json data as QJsonDocument
///
const QJsonDocument getSetting(const settings::type& type);
///
/// @brief get the full settings object of this instance (with global settings)
/// @return The requested json
///
const QJsonObject & getSettings() { return _qconfig; };
signals:
///
/// @brief Emits whenever a config part changed. Comparison of database and new data to prevent false positive
/// @param type The settings type from enum
/// @param data The data as QJsonDocument
///
void settingsChanged(const settings::type& type, const QJsonDocument& data);
private:
/// Hyperion instance
Hyperion* _hyperion;
/// Logger instance
Logger* _log;
/// instance of database table interface
SettingsTable* _sTable;
/// the schema
static QJsonObject schemaJson;
/// the current config of this instance
QJsonObject _qconfig;
};