Moved effect configurations from the config file to effect directory

Former-commit-id: b8db13f25b93a0007adf613f0310a1cfbb6b8224
This commit is contained in:
johan
2013-12-11 21:58:59 +01:00
parent f1acf5a9e4
commit 0537fdc741
17 changed files with 919 additions and 419 deletions

View File

@@ -5,13 +5,24 @@
// Bootsequence includes
#include <bootsequence/BootSequenceFactory.h>
// Effect engine includes
#include <effectengine/EffectEngine.h>
// Local Bootsequence includes
#include "EffectBootSequence.h"
BootSequence * BootSequenceFactory::createBootSequence(Hyperion * hyperion, const Json::Value & jsonConfig)
{
const std::string script = jsonConfig["script"].asString();
const Json::Value args = jsonConfig.get("args", Json::Value(Json::objectValue));
const std::string path = jsonConfig["path"].asString();
const std::string effectFile = jsonConfig["effect"].asString();
const unsigned duration = jsonConfig["duration_ms"].asUInt();
return new EffectBootSequence(hyperion, script, args, duration);
EffectDefinition effect;
if (EffectEngine::loadEffectDefinition(path, effectFile, effect))
{
return new EffectBootSequence(hyperion, effect, duration);
}
std::cerr << "Boot sequence could not be loaded" << std::endl;
return nullptr;
}

View File

@@ -1,10 +1,9 @@
#include "EffectBootSequence.h"
EffectBootSequence::EffectBootSequence(Hyperion *hyperion, const std::string &script, const Json::Value &args, const unsigned duration_ms) :
EffectBootSequence::EffectBootSequence(Hyperion *hyperion, const EffectDefinition &effect, const unsigned duration_ms) :
BootSequence(),
_hyperion(hyperion),
_script(script),
_args(args),
_effect(effect),
_duration_ms(duration_ms)
{
}
@@ -15,5 +14,5 @@ EffectBootSequence::~EffectBootSequence()
void EffectBootSequence::start()
{
_hyperion->setEffectScript(_script, _args, 0, _duration_ms);
_hyperion->setEffectScript(_effect.script, _effect.args, 0, _duration_ms);
}

View File

@@ -17,9 +17,10 @@ public:
/// duration is the length the effect will run.
///
/// @param[in] hyperion The Hyperion instance
/// @param[in] effect The effect definition
/// @param[in] duration_ms The length of the sequence [ms]
///
EffectBootSequence(Hyperion * hyperion, const std::string & script, const Json::Value & args, const unsigned duration_ms);
EffectBootSequence(Hyperion * hyperion, const EffectDefinition & effect, const unsigned duration_ms);
virtual ~EffectBootSequence();
virtual void start();
@@ -29,10 +30,7 @@ private:
Hyperion * _hyperion;
/// The script to execute
const std::string _script;
/// The arguments of the script
const Json::Value _args;
const EffectDefinition _effect;
/// Duration of the boot sequence
const unsigned _duration_ms;