2013-10-16 18:13:31 +02:00
|
|
|
// stl includes
|
|
|
|
#include <cctype>
|
|
|
|
#include <algorithm>
|
2013-08-25 18:20:19 +02:00
|
|
|
|
|
|
|
// Bootsequence includes
|
|
|
|
#include <bootsequence/BootSequenceFactory.h>
|
|
|
|
|
|
|
|
// Local Bootsequence includes
|
|
|
|
#include "RainbowBootSequence.h"
|
2013-09-12 20:42:16 +02:00
|
|
|
#include "KittBootSequence.h"
|
2013-08-25 18:20:19 +02:00
|
|
|
|
|
|
|
BootSequence * BootSequenceFactory::createBootSequence(Hyperion * hyperion, const Json::Value & jsonConfig)
|
|
|
|
{
|
2013-10-16 18:13:31 +02:00
|
|
|
std::string type = jsonConfig["type"].asString();
|
2013-10-16 18:51:08 +02:00
|
|
|
std::transform(type.begin(), type.end(), type.begin(), ::tolower);
|
2013-08-25 18:20:19 +02:00
|
|
|
|
|
|
|
if (type == "none")
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
else if (type == "rainbow")
|
|
|
|
{
|
2013-10-16 22:53:27 +02:00
|
|
|
std::cout << "SELECTED BOOT SEQUENCE: " << "RAINBOW" << std::endl;
|
2013-08-25 18:20:19 +02:00
|
|
|
const unsigned duration_ms = jsonConfig["duration_ms"].asUInt();
|
|
|
|
return new RainbowBootSequence(hyperion, duration_ms);
|
|
|
|
}
|
2013-10-16 18:13:31 +02:00
|
|
|
else if (type == "knightrider" || type == "knight rider")
|
2013-08-25 18:20:19 +02:00
|
|
|
{
|
2013-10-16 22:53:27 +02:00
|
|
|
std::cout << "SELECTED BOOT SEQUENCE: " << "KITT" << std::endl;
|
2013-09-12 20:42:16 +02:00
|
|
|
const unsigned duration_ms = jsonConfig["duration_ms"].asUInt();
|
|
|
|
return new KittBootSequence(hyperion, duration_ms);
|
2013-08-25 18:20:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::cerr << "Unknown boot-sequence selected; boot-sequence disabled." << std::endl;
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|