2013-11-24 16:10:48 +01:00
|
|
|
#pragma once
|
|
|
|
|
2013-12-01 14:09:01 +01:00
|
|
|
// Qt includes
|
|
|
|
#include <QObject>
|
2016-09-13 11:51:16 +02:00
|
|
|
#include <QString>
|
2016-10-09 22:22:17 +02:00
|
|
|
#include <QJsonObject>
|
|
|
|
#include <QJsonValue>
|
|
|
|
#include <QJsonDocument>
|
|
|
|
#include <QJsonArray>
|
2013-11-30 17:41:38 +01:00
|
|
|
|
|
|
|
// Hyperion includes
|
2013-11-24 16:10:48 +01:00
|
|
|
#include <hyperion/Hyperion.h>
|
|
|
|
|
2013-12-01 14:09:01 +01:00
|
|
|
// Effect engine includes
|
|
|
|
#include <effectengine/EffectDefinition.h>
|
2016-04-24 17:07:31 +02:00
|
|
|
#include <effectengine/ActiveEffectDefinition.h>
|
2016-06-23 13:48:49 +02:00
|
|
|
#include <utils/Logger.h>
|
2013-12-01 14:09:01 +01:00
|
|
|
|
2013-11-26 21:38:24 +01:00
|
|
|
// pre-declarioation
|
|
|
|
class Effect;
|
2013-11-29 23:22:49 +01:00
|
|
|
typedef struct _ts PyThreadState;
|
2013-11-26 21:38:24 +01:00
|
|
|
|
2013-11-24 16:10:48 +01:00
|
|
|
class EffectEngine : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2016-10-09 22:22:17 +02:00
|
|
|
EffectEngine(Hyperion * hyperion, const QJsonObject & jsonEffectConfig);
|
2013-11-24 16:10:48 +01:00
|
|
|
virtual ~EffectEngine();
|
|
|
|
|
2013-12-01 14:09:01 +01:00
|
|
|
const std::list<EffectDefinition> & getEffects() const;
|
2016-04-24 17:07:31 +02:00
|
|
|
|
|
|
|
const std::list<ActiveEffectDefinition> & getActiveEffects();
|
2013-11-24 16:10:48 +01:00
|
|
|
|
2016-09-13 11:51:16 +02:00
|
|
|
static bool loadEffectDefinition(const QString & path, const QString & effectConfigFile, EffectDefinition &effectDefinition);
|
2013-12-11 21:58:59 +01:00
|
|
|
|
2013-11-24 16:10:48 +01:00
|
|
|
public slots:
|
|
|
|
/// Run the specified effect on the given priority channel and optionally specify a timeout
|
2016-10-09 22:22:17 +02:00
|
|
|
int runEffect(const QString &effectName, int priority, int timeout = -1);
|
2013-11-24 16:10:48 +01:00
|
|
|
|
2013-12-01 14:09:01 +01:00
|
|
|
/// Run the specified effect on the given priority channel and optionally specify a timeout
|
2016-10-09 22:22:17 +02:00
|
|
|
int runEffect(const QString &effectName, const QJsonObject & args, int priority, int timeout = -1);
|
2013-12-01 14:09:01 +01:00
|
|
|
|
2013-11-24 16:10:48 +01:00
|
|
|
/// Clear any effect running on the provided channel
|
|
|
|
void channelCleared(int priority);
|
|
|
|
|
|
|
|
/// Clear all effects
|
|
|
|
void allChannelsCleared();
|
|
|
|
|
2013-11-26 21:38:24 +01:00
|
|
|
private slots:
|
|
|
|
void effectFinished(Effect * effect);
|
|
|
|
|
2013-12-13 22:41:24 +01:00
|
|
|
private:
|
|
|
|
/// Run the specified effect on the given priority channel and optionally specify a timeout
|
2016-10-09 22:22:17 +02:00
|
|
|
int runEffectScript(const QString &script, const QString &name, const QJsonObject & args, int priority, int timeout = -1);
|
2013-12-13 22:41:24 +01:00
|
|
|
|
2013-11-24 16:10:48 +01:00
|
|
|
private:
|
|
|
|
Hyperion * _hyperion;
|
|
|
|
|
2013-12-01 14:09:01 +01:00
|
|
|
std::list<EffectDefinition> _availableEffects;
|
2013-11-26 21:38:24 +01:00
|
|
|
|
|
|
|
std::list<Effect *> _activeEffects;
|
2016-06-23 13:48:49 +02:00
|
|
|
|
2016-04-24 17:07:31 +02:00
|
|
|
std::list<ActiveEffectDefinition> _availableActiveEffects;
|
2013-11-29 23:22:49 +01:00
|
|
|
|
2016-06-23 13:48:49 +02:00
|
|
|
PyThreadState * _mainThreadState;
|
|
|
|
|
|
|
|
Logger * _log;
|
2013-11-24 16:10:48 +01:00
|
|
|
};
|