added name property in Effect class to make it possible to get the name of the active effect in the 'serverinfo' JSON command results
This commit is contained in:
parent
1d125d8df8
commit
4c3cc8d318
|
@ -8,6 +8,7 @@
|
|||
|
||||
struct ActiveEffectDefinition
|
||||
{
|
||||
std::string name;
|
||||
std::string script;
|
||||
int priority;
|
||||
int timeout;
|
||||
|
|
|
@ -49,7 +49,7 @@ private slots:
|
|||
|
||||
private:
|
||||
/// Run the specified effect on the given priority channel and optionally specify a timeout
|
||||
int runEffectScript(const std::string &script, const Json::Value & args, int priority, int timeout = -1);
|
||||
int runEffectScript(const std::string & name, const std::string &script, const Json::Value & args, int priority, int timeout = -1);
|
||||
|
||||
private:
|
||||
Hyperion * _hyperion;
|
||||
|
|
|
@ -49,9 +49,10 @@ void Effect::registerHyperionExtensionModule()
|
|||
PyImport_AppendInittab("hyperion", &PyInit_hyperion);
|
||||
}
|
||||
|
||||
Effect::Effect(PyThreadState * mainThreadState, int priority, int timeout, const std::string & script, const Json::Value & args) :
|
||||
Effect::Effect(PyThreadState * mainThreadState, const std::string & name, int priority, int timeout, const std::string & script, const Json::Value & args) :
|
||||
QThread(),
|
||||
_mainThreadState(mainThreadState),
|
||||
_name(name),
|
||||
_priority(priority),
|
||||
_timeout(timeout),
|
||||
_script(script),
|
||||
|
|
|
@ -14,11 +14,13 @@ class Effect : public QThread
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Effect(PyThreadState * mainThreadState, int priority, int timeout, const std::string & script, const Json::Value & args = Json::Value());
|
||||
Effect(PyThreadState * mainThreadState, const std::string & name, int priority, int timeout, const std::string & script, const Json::Value & args = Json::Value());
|
||||
virtual ~Effect();
|
||||
|
||||
virtual void run();
|
||||
|
||||
std::string getName() const { return _name; }
|
||||
|
||||
int getPriority() const;
|
||||
|
||||
std::string getScript() const { return _script; }
|
||||
|
@ -63,6 +65,8 @@ private:
|
|||
private:
|
||||
PyThreadState * _mainThreadState;
|
||||
|
||||
const std::string _name;
|
||||
|
||||
const int _priority;
|
||||
|
||||
const int _timeout;
|
||||
|
|
|
@ -86,6 +86,7 @@ const std::list<ActiveEffectDefinition> &EffectEngine::getActiveEffects()
|
|||
for (Effect * effect : _activeEffects)
|
||||
{
|
||||
ActiveEffectDefinition activeEffectDefinition;
|
||||
activeEffectDefinition.name = effect->getName();
|
||||
activeEffectDefinition.script = effect->getScript();
|
||||
activeEffectDefinition.priority = effect->getPriority();
|
||||
activeEffectDefinition.timeout = effect->getTimeout();
|
||||
|
@ -174,16 +175,16 @@ int EffectEngine::runEffect(const std::string &effectName, const Json::Value &ar
|
|||
return -1;
|
||||
}
|
||||
|
||||
return runEffectScript(effectDefinition->script, args.isNull() ? effectDefinition->args : args, priority, timeout);
|
||||
return runEffectScript(effectName, effectDefinition->script, args.isNull() ? effectDefinition->args : args, priority, timeout);
|
||||
}
|
||||
|
||||
int EffectEngine::runEffectScript(const std::string &script, const Json::Value &args, int priority, int timeout)
|
||||
int EffectEngine::runEffectScript(const std::string & name, const std::string &script, const Json::Value &args, int priority, int timeout)
|
||||
{
|
||||
// clear current effect on the channel
|
||||
channelCleared(priority);
|
||||
|
||||
// create the effect
|
||||
Effect * effect = new Effect(_mainThreadState, priority, timeout, script, args);
|
||||
Effect * effect = new Effect(_mainThreadState, name, priority, timeout, script, args);
|
||||
connect(effect, SIGNAL(setColors(int,std::vector<ColorRgb>,int,bool)), _hyperion, SLOT(setColors(int,std::vector<ColorRgb>,int,bool)), Qt::QueuedConnection);
|
||||
connect(effect, SIGNAL(effectFinished(Effect*)), this, SLOT(effectFinished(Effect*)));
|
||||
_activeEffects.push_back(effect);
|
||||
|
|
|
@ -524,6 +524,7 @@ void JsonClientConnection::handleServerInfoCommand(const Json::Value &)
|
|||
for (const ActiveEffectDefinition & activeEffectDefinition : activeEffectsDefinitions)
|
||||
{
|
||||
Json::Value activeEffect;
|
||||
activeEffect["name"] = activeEffectDefinition.name;
|
||||
activeEffect["script"] = activeEffectDefinition.script;
|
||||
activeEffect["priority"] = activeEffectDefinition.priority;
|
||||
activeEffect["timeout"] = activeEffectDefinition.timeout;
|
||||
|
|
Loading…
Reference in New Issue