Added config-schema of Hyperion as resource.

Added constructor to Hyperion using filename.
Added config-filename as commandline parameter for hyperiond.
Added implementation of blackborder detector.
Added test for blackborder detector.
This commit is contained in:
T. van der Zwan
2013-08-21 14:25:27 +00:00
parent 5010b9ce8e
commit 240b118ce9
11 changed files with 327 additions and 16 deletions

View File

@@ -1,8 +1,7 @@
// Syslog include
#include <syslog.h>
// QT includes
#include <QDateTime>
#include <QResource>
// JsonSchema include
#include <utils/jsonschema/JsonFactory.h>
@@ -75,6 +74,33 @@ LedString Hyperion::createLedString(const Json::Value& ledsConfig)
return ledString;
}
Json::Value Hyperion::loadConfig(const std::string& configFile)
{
// read the json schema from the resource
QResource schemaData(":/hyperion.schema.json");
assert(schemaData.isValid());
Json::Reader jsonReader;
Json::Value schemaJson;
if (!jsonReader.parse(reinterpret_cast<const char *>(schemaData.data()), reinterpret_cast<const char *>(schemaData.data()) + schemaData.size(), schemaJson, false))
{
throw std::runtime_error("Schema error: " + jsonReader.getFormattedErrorMessages()) ;
}
JsonSchemaChecker schemaChecker;
schemaChecker.setSchema(schemaJson);
const Json::Value jsonConfig = JsonFactory::readJson(configFile);
schemaChecker.validate(jsonConfig);
return jsonConfig;
}
Hyperion::Hyperion(const std::string& configFile) :
Hyperion(loadConfig(configFile))
{
// empty
}
Hyperion::Hyperion(const Json::Value &jsonConfig) :
mLedString(createLedString(jsonConfig["leds"])),
mRedTransform( createColorTransform(jsonConfig["color"]["red"])),