mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
update
This commit is contained in:
@@ -7,33 +7,10 @@
|
||||
#include <hyperion/Hyperion.h>
|
||||
|
||||
// qt includess
|
||||
#include <QTimer>
|
||||
#include <QJsonObject>
|
||||
#include <QMutex>
|
||||
#include <QString>
|
||||
|
||||
// createEffect helper
|
||||
struct find_schema: std::unary_function<EffectSchema, bool>
|
||||
{
|
||||
QString pyFile;
|
||||
find_schema(QString pyFile):pyFile(pyFile) { }
|
||||
bool operator()(EffectSchema const& schema) const
|
||||
{
|
||||
return schema.pyFile == pyFile;
|
||||
}
|
||||
};
|
||||
|
||||
// deleteEffect helper
|
||||
struct find_effect: std::unary_function<EffectDefinition, bool>
|
||||
{
|
||||
QString effectName;
|
||||
find_effect(QString effectName) :effectName(effectName) { }
|
||||
bool operator()(EffectDefinition const& effectDefinition) const
|
||||
{
|
||||
return effectDefinition.name == effectName;
|
||||
}
|
||||
};
|
||||
|
||||
class JsonCB;
|
||||
|
||||
class JsonAPI : public QObject
|
||||
@@ -59,8 +36,11 @@ public:
|
||||
void handleMessage(const QString & message);
|
||||
|
||||
public slots:
|
||||
/// _timer_ledcolors requests ledcolor updates (if enabled)
|
||||
void streamLedcolorsUpdate();
|
||||
///
|
||||
/// @brief is called whenever the current Hyperion instance pushes new led raw values (if enabled)
|
||||
/// @param ledColors The current ledColors
|
||||
///
|
||||
void streamLedcolorsUpdate(const std::vector<ColorRgb>& ledColors);
|
||||
|
||||
/// push images whenever hyperion emits (if enabled)
|
||||
void setImage(const Image<ColorRgb> & image);
|
||||
@@ -80,11 +60,9 @@ signals:
|
||||
void forwardJsonMessage(QJsonObject);
|
||||
|
||||
private:
|
||||
|
||||
// The JsonCB instance which handles data subscription/notifications
|
||||
JsonCB* _jsonCB;
|
||||
// true if further callbacks are forbidden (http)
|
||||
bool _noListener;
|
||||
|
||||
/// The peer address of the client
|
||||
QString _peerAddress;
|
||||
|
||||
@@ -94,8 +72,8 @@ private:
|
||||
/// Hyperion instance
|
||||
Hyperion* _hyperion;
|
||||
|
||||
/// timer for ledcolors streaming
|
||||
QTimer _timer_ledcolors;
|
||||
// The JsonCB instance which handles data subscription/notifications
|
||||
JsonCB* _jsonCB;
|
||||
|
||||
// streaming buffers
|
||||
QJsonObject _streaming_leds_reply;
|
||||
@@ -108,9 +86,15 @@ private:
|
||||
/// mutex to determine state of image streaming
|
||||
QMutex _image_stream_mutex;
|
||||
|
||||
/// mutex to determine state of image streaming
|
||||
QMutex _led_stream_mutex;
|
||||
|
||||
/// timeout for live video refresh
|
||||
volatile qint64 _image_stream_timeout;
|
||||
|
||||
/// timeout for led color refresh
|
||||
volatile qint64 _led_stream_timeout;
|
||||
|
||||
///
|
||||
/// Handle an incoming JSON Color message
|
||||
///
|
||||
|
@@ -17,30 +17,43 @@
|
||||
#include <effectengine/EffectSchema.h>
|
||||
#include <utils/Logger.h>
|
||||
|
||||
// pre-declarioation
|
||||
// pre-declaration
|
||||
class Effect;
|
||||
class EffectFileHandler;
|
||||
|
||||
class EffectEngine : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
EffectEngine(Hyperion * hyperion, const QJsonObject & jsonEffectConfig);
|
||||
EffectEngine(Hyperion * hyperion);
|
||||
virtual ~EffectEngine();
|
||||
|
||||
void readEffects();
|
||||
|
||||
const std::list<EffectDefinition> & getEffects() const
|
||||
{
|
||||
return _availableEffects;
|
||||
};
|
||||
const std::list<EffectDefinition> & getEffects() const { return _availableEffects; };
|
||||
|
||||
const std::list<ActiveEffectDefinition> & getActiveEffects();
|
||||
|
||||
const std::list<EffectSchema> & getEffectSchemas()
|
||||
{
|
||||
return _effectSchemas;
|
||||
};
|
||||
///
|
||||
/// Get available schemas from EffectFileHandler
|
||||
/// @return all schemas
|
||||
///
|
||||
const std::list<EffectSchema> & getEffectSchemas();
|
||||
|
||||
///
|
||||
/// @brief Save an effect with EffectFileHandler
|
||||
/// @param obj The effect args
|
||||
/// @param[out] resultMsg The feedback message
|
||||
/// @return True on success else false
|
||||
///
|
||||
const bool saveEffect(const QJsonObject& obj, QString& resultMsg);
|
||||
|
||||
///
|
||||
/// @brief Delete an effect by name.
|
||||
/// @param[in] effectName The effect name to delete
|
||||
/// @param[out] resultMsg The message on error
|
||||
/// @return True on success else false
|
||||
///
|
||||
const bool deleteEffect(const QString& effectName, QString& resultMsg);
|
||||
|
||||
///
|
||||
/// @brief Get all init data of the running effects and stop them
|
||||
@@ -72,19 +85,18 @@ public slots:
|
||||
private slots:
|
||||
void effectFinished();
|
||||
|
||||
///
|
||||
/// @brief is called whenever the EffectFileHandler emits updated effect list
|
||||
///
|
||||
void handleUpdatedEffectList();
|
||||
|
||||
private:
|
||||
bool loadEffectDefinition(const QString & path, const QString & effectConfigFile, EffectDefinition &effectDefinition);
|
||||
|
||||
bool loadEffectSchema(const QString & path, const QString & effectSchemaFile, EffectSchema &effectSchema);
|
||||
|
||||
/// Run the specified effect on the given priority channel and optionally specify a timeout
|
||||
int runEffectScript(const QString &script, const QString &name, const QJsonObject & args, int priority, int timeout = -1, const QString & origin="System", unsigned smoothCfg=0);
|
||||
|
||||
private:
|
||||
Hyperion * _hyperion;
|
||||
|
||||
QJsonObject _effectConfig;
|
||||
|
||||
std::list<EffectDefinition> _availableEffects;
|
||||
|
||||
std::list<Effect *> _activeEffects;
|
||||
@@ -93,7 +105,8 @@ private:
|
||||
|
||||
std::list<ActiveEffectDefinition> _cachedActiveEffects;
|
||||
|
||||
std::list<EffectSchema> _effectSchemas;
|
||||
|
||||
Logger * _log;
|
||||
|
||||
// The global effect file handler
|
||||
EffectFileHandler* _effectFileHandler;
|
||||
};
|
||||
|
86
include/effectengine/EffectFileHandler.h
Normal file
86
include/effectengine/EffectFileHandler.h
Normal file
@@ -0,0 +1,86 @@
|
||||
#pragma once
|
||||
|
||||
// util
|
||||
#include <utils/Logger.h>
|
||||
#include <effectengine/EffectDefinition.h>
|
||||
#include <effectengine/EffectSchema.h>
|
||||
#include <utils/settings.h>
|
||||
|
||||
class EffectFileHandler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
friend class HyperionDaemon;
|
||||
EffectFileHandler(const QString& rootPath, const QJsonDocument& effectConfig, QObject* parent = nullptr);
|
||||
|
||||
public:
|
||||
static EffectFileHandler* efhInstance;
|
||||
static EffectFileHandler* getInstance() { return efhInstance; };
|
||||
|
||||
///
|
||||
/// @brief Get all available effects
|
||||
///
|
||||
const std::list<EffectDefinition> & getEffects() const { return _availableEffects; };
|
||||
|
||||
///
|
||||
/// @brief Get all available schemas
|
||||
///
|
||||
const std::list<EffectSchema> & getEffectSchemas() { return _effectSchemas; };
|
||||
|
||||
///
|
||||
/// @brief Save an effect
|
||||
/// @param obj The effect args
|
||||
/// @param[out] resultMsg The feedback message
|
||||
/// @return True on success else false
|
||||
///
|
||||
const bool saveEffect(const QJsonObject& obj, QString& resultMsg);
|
||||
|
||||
///
|
||||
/// @brief Delete an effect by name.
|
||||
/// @param[in] effectName The effect name to delete
|
||||
/// @param[out] resultMsg The message on error
|
||||
/// @return True on success else false
|
||||
///
|
||||
const bool deleteEffect(const QString& effectName, QString& resultMsg);
|
||||
|
||||
public slots:
|
||||
///
|
||||
/// @brief Handle settings update from Hyperion Settingsmanager emit
|
||||
/// @param type settingyType from enum
|
||||
/// @param config configuration object
|
||||
///
|
||||
void handleSettingsUpdate(const settings::type& type, const QJsonDocument& config);
|
||||
|
||||
signals:
|
||||
///
|
||||
/// @brief Emits whenever the data changes for an effect
|
||||
///
|
||||
void effectListChanged();
|
||||
|
||||
private:
|
||||
///
|
||||
/// @brief refresh available schemas and effects
|
||||
///
|
||||
void updateEffects();
|
||||
|
||||
///
|
||||
/// @brief Load the effect definition, called by updateEffects()
|
||||
///
|
||||
bool loadEffectDefinition(const QString & path, const QString & effectConfigFile, EffectDefinition &effectDefinition);
|
||||
|
||||
///
|
||||
/// @brief load effect schemas, called by updateEffects()
|
||||
///
|
||||
bool loadEffectSchema(const QString & path, const QString & effectSchemaFile, EffectSchema &effectSchema);
|
||||
|
||||
private:
|
||||
QJsonObject _effectConfig;
|
||||
Logger* _log;
|
||||
const QString _rootPath;
|
||||
|
||||
// available effects
|
||||
std::list<EffectDefinition> _availableEffects;
|
||||
|
||||
// all schemas
|
||||
std::list<EffectSchema> _effectSchemas;
|
||||
};
|
@@ -54,6 +54,11 @@ private slots:
|
||||
///
|
||||
void setV4lInactive();
|
||||
|
||||
///
|
||||
/// @brief Is called from _systemInactiveTimer to set source after specific time to inactive
|
||||
///
|
||||
void setSystemInactive();
|
||||
|
||||
private:
|
||||
/// Hyperion instance
|
||||
Hyperion* _hyperion;
|
||||
@@ -61,6 +66,7 @@ private:
|
||||
/// Reflect state of System capture and prio
|
||||
bool _systemCaptEnabled;
|
||||
quint8 _systemCaptPrio;
|
||||
QTimer* _systemInactiveTimer;
|
||||
|
||||
/// Reflect state of v4l capture and prio
|
||||
bool _v4lCaptEnabled;
|
||||
|
@@ -163,8 +163,21 @@ public:
|
||||
///
|
||||
const InputInfo getPriorityInfo(const int priority) const;
|
||||
|
||||
/// Reload the list of available effects
|
||||
void reloadEffects();
|
||||
///
|
||||
/// @brief Save an effect
|
||||
/// @param obj The effect args
|
||||
/// @param[out] resultMsg The feedback message
|
||||
/// @return True on success else false
|
||||
///
|
||||
const bool saveEffect(const QJsonObject& obj, QString& resultMsg);
|
||||
|
||||
///
|
||||
/// @brief Delete an effect by name.
|
||||
/// @param[in] effectName The effect name to delete
|
||||
/// @param[out] resultMsg The message on error
|
||||
/// @return True on success else false
|
||||
///
|
||||
const bool deleteEffect(const QString& effectName, QString& resultMsg);
|
||||
|
||||
/// Get the list of available effects
|
||||
/// @return The list of available effects
|
||||
@@ -215,12 +228,6 @@ public:
|
||||
/// @return the state
|
||||
bool sourceAutoSelectEnabled();
|
||||
|
||||
///
|
||||
/// @brief Get the last untransformed/unadjusted led colors
|
||||
/// @return The _rawLedBuffer leds
|
||||
///
|
||||
const std::vector<ColorRgb>& getRawLedBuffer() { return _rawLedBuffer; };
|
||||
|
||||
///
|
||||
/// @brief Enable/Disable components during runtime, called from external API (requests)
|
||||
///
|
||||
@@ -433,6 +440,11 @@ signals:
|
||||
///
|
||||
void v4lImage(const Image<ColorRgb> & image);
|
||||
|
||||
///
|
||||
/// @brief Emits whenever new untransformed ledColos data is available, reflects the current visible device
|
||||
///
|
||||
void rawLedColors(const std::vector<ColorRgb>& ledValues);
|
||||
|
||||
private slots:
|
||||
///
|
||||
/// Updates the priority muxer with the current time and (re)writes the led color with applied
|
||||
@@ -548,8 +560,6 @@ private:
|
||||
|
||||
/// buffer for leds (with adjustment)
|
||||
std::vector<ColorRgb> _ledBuffer;
|
||||
/// buffer for leds (without adjustment)
|
||||
std::vector<ColorRgb> _rawLedBuffer;
|
||||
|
||||
/// Boblight instance
|
||||
BoblightServer* _boblightServer;
|
||||
|
@@ -9,7 +9,7 @@
|
||||
class Hyperion;
|
||||
|
||||
///
|
||||
/// @brief Manage the settings read write from/to database, on settings changed will emit a signal to update components accordingly
|
||||
/// @brief Manage the settings read write from/to config file, on settings changed will emit a signal to update components accordingly
|
||||
///
|
||||
class SettingsManager : public QObject
|
||||
{
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
const bool saveSettings(QJsonObject config, const bool& correct = false);
|
||||
|
||||
///
|
||||
/// @brief get a single setting json from database
|
||||
/// @brief get a single setting json from config
|
||||
/// @param type The settings::type from enum
|
||||
/// @return The requested json data as QJsonDocument
|
||||
///
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
|
||||
signals:
|
||||
///
|
||||
/// @brief Emits whenever a config part changed. Comparison of database and new data to prevent false positive
|
||||
/// @brief Emits whenever a config part changed.
|
||||
/// @param type The settings type from enum
|
||||
/// @param data The data as QJsonDocument
|
||||
///
|
||||
@@ -60,10 +60,13 @@ signals:
|
||||
private:
|
||||
/// Hyperion instance
|
||||
Hyperion* _hyperion;
|
||||
|
||||
/// Logger instance
|
||||
Logger* _log;
|
||||
|
||||
/// the schema
|
||||
static QJsonObject schemaJson;
|
||||
|
||||
/// the current config of this instance
|
||||
QJsonObject _qconfig;
|
||||
};
|
||||
|
Reference in New Issue
Block a user