Added config file settings for XBMCVideoChecker

This commit is contained in:
johan 2013-08-24 11:51:52 +02:00
parent 026937d5e1
commit 213545afe7
7 changed files with 537 additions and 508 deletions

View File

@ -2,297 +2,302 @@
// Generation script: ./WriteConfig // Generation script: ./WriteConfig
{ {
"device" : "device" :
{ {
"name" : "MyPi", "name" : "MyPi",
"type" : "ws2801", "type" : "ws2801",
"output" : "/dev/spidev0.0", "output" : "/dev/spidev0.0",
"interval" : 20000, "interval" : 20000,
"rate" : 48000 "rate" : 48000
}, },
"color" : "color" :
{ {
"hsv" : { "hsv" : {
"saturationGain" : 1.0, "saturationGain" : 1.0,
"valueGain" : 1.0 "valueGain" : 1.0
}, },
"red" : "red" :
{ {
"threshold" : 0.0, "threshold" : 0.0,
"gamma" : 1.0, "gamma" : 1.0,
"blacklevel" : 0.0, "blacklevel" : 0.0,
"whitelevel" : 1.0 "whitelevel" : 1.0
}, },
"green" : "green" :
{ {
"threshold" : 0.0, "threshold" : 0.0,
"gamma" : 1.0, "gamma" : 1.0,
"blacklevel" : 0.0, "blacklevel" : 0.0,
"whitelevel" : 1.0 "whitelevel" : 1.0
}, },
"blue" : "blue" :
{ {
"threshold" : 0.0, "threshold" : 0.0,
"gamma" : 1.0, "gamma" : 1.0,
"blacklevel" : 0.0, "blacklevel" : 0.0,
"whitelevel" : 1.0 "whitelevel" : 1.0
} }
}, },
"leds" : "leds" :
[ [
{ {
"index" : 0, "index" : 0,
"hscan" : { "minimum" : 47.0588, "maximum" : 52.9412 }, "hscan" : { "minimum" : 47.0588, "maximum" : 52.9412 },
"vscan" : { "minimum" : 0, "maximum" : 10 } "vscan" : { "minimum" : 0, "maximum" : 10 }
}, },
{ {
"index" : 1, "index" : 1,
"hscan" : { "minimum" : 41.1765, "maximum" : 47.0588 }, "hscan" : { "minimum" : 41.1765, "maximum" : 47.0588 },
"vscan" : { "minimum" : 0, "maximum" : 10 } "vscan" : { "minimum" : 0, "maximum" : 10 }
}, },
{ {
"index" : 2, "index" : 2,
"hscan" : { "minimum" : 35.2941, "maximum" : 41.1765 }, "hscan" : { "minimum" : 35.2941, "maximum" : 41.1765 },
"vscan" : { "minimum" : 0, "maximum" : 10 } "vscan" : { "minimum" : 0, "maximum" : 10 }
}, },
{ {
"index" : 3, "index" : 3,
"hscan" : { "minimum" : 29.4118, "maximum" : 35.2941 }, "hscan" : { "minimum" : 29.4118, "maximum" : 35.2941 },
"vscan" : { "minimum" : 0, "maximum" : 10 } "vscan" : { "minimum" : 0, "maximum" : 10 }
}, },
{ {
"index" : 4, "index" : 4,
"hscan" : { "minimum" : 23.5294, "maximum" : 29.4118 }, "hscan" : { "minimum" : 23.5294, "maximum" : 29.4118 },
"vscan" : { "minimum" : 0, "maximum" : 10 } "vscan" : { "minimum" : 0, "maximum" : 10 }
}, },
{ {
"index" : 5, "index" : 5,
"hscan" : { "minimum" : 17.6471, "maximum" : 23.5294 }, "hscan" : { "minimum" : 17.6471, "maximum" : 23.5294 },
"vscan" : { "minimum" : 0, "maximum" : 10 } "vscan" : { "minimum" : 0, "maximum" : 10 }
}, },
{ {
"index" : 6, "index" : 6,
"hscan" : { "minimum" : 11.7647, "maximum" : 17.6471 }, "hscan" : { "minimum" : 11.7647, "maximum" : 17.6471 },
"vscan" : { "minimum" : 0, "maximum" : 10 } "vscan" : { "minimum" : 0, "maximum" : 10 }
}, },
{ {
"index" : 7, "index" : 7,
"hscan" : { "minimum" : 5.88235, "maximum" : 11.7647 }, "hscan" : { "minimum" : 5.88235, "maximum" : 11.7647 },
"vscan" : { "minimum" : 0, "maximum" : 10 } "vscan" : { "minimum" : 0, "maximum" : 10 }
}, },
// TOP-LEFT Corner // TOP-LEFT Corner
{ {
"index" : 8, "index" : 8,
"hscan" : { "minimum" : 0, "maximum" : 5.88235 }, "hscan" : { "minimum" : 0, "maximum" : 5.88235 },
"vscan" : { "minimum" : 0, "maximum" : 10 } "vscan" : { "minimum" : 0, "maximum" : 10 }
}, },
{ {
"index" : 9, "index" : 9,
"hscan" : { "minimum" : 0, "maximum" : 10 }, "hscan" : { "minimum" : 0, "maximum" : 10 },
"vscan" : { "minimum" : 10, "maximum" : 20 } "vscan" : { "minimum" : 10, "maximum" : 20 }
}, },
{ {
"index" : 10, "index" : 10,
"hscan" : { "minimum" : 0, "maximum" : 10 }, "hscan" : { "minimum" : 0, "maximum" : 10 },
"vscan" : { "minimum" : 20, "maximum" : 30 } "vscan" : { "minimum" : 20, "maximum" : 30 }
}, },
{ {
"index" : 11, "index" : 11,
"hscan" : { "minimum" : 0, "maximum" : 10 }, "hscan" : { "minimum" : 0, "maximum" : 10 },
"vscan" : { "minimum" : 30, "maximum" : 40 } "vscan" : { "minimum" : 30, "maximum" : 40 }
}, },
{ {
"index" : 12, "index" : 12,
"hscan" : { "minimum" : 0, "maximum" : 10 }, "hscan" : { "minimum" : 0, "maximum" : 10 },
"vscan" : { "minimum" : 40, "maximum" : 50 } "vscan" : { "minimum" : 40, "maximum" : 50 }
}, },
{ {
"index" : 13, "index" : 13,
"hscan" : { "minimum" : 0, "maximum" : 10 }, "hscan" : { "minimum" : 0, "maximum" : 10 },
"vscan" : { "minimum" : 50, "maximum" : 60 } "vscan" : { "minimum" : 50, "maximum" : 60 }
}, },
{ {
"index" : 14, "index" : 14,
"hscan" : { "minimum" : 0, "maximum" : 10 }, "hscan" : { "minimum" : 0, "maximum" : 10 },
"vscan" : { "minimum" : 60, "maximum" : 70 } "vscan" : { "minimum" : 60, "maximum" : 70 }
}, },
{ {
"index" : 15, "index" : 15,
"hscan" : { "minimum" : 0, "maximum" : 10 }, "hscan" : { "minimum" : 0, "maximum" : 10 },
"vscan" : { "minimum" : 70, "maximum" : 80 } "vscan" : { "minimum" : 70, "maximum" : 80 }
}, },
{ {
"index" : 16, "index" : 16,
"hscan" : { "minimum" : 0, "maximum" : 10 }, "hscan" : { "minimum" : 0, "maximum" : 10 },
"vscan" : { "minimum" : 80, "maximum" : 90 } "vscan" : { "minimum" : 80, "maximum" : 90 }
}, },
// BOTTOM-LEFT Corner // BOTTOM-LEFT Corner
{ {
"index" : 17, "index" : 17,
"hscan" : { "minimum" : 0, "maximum" : 5.88235 }, "hscan" : { "minimum" : 0, "maximum" : 5.88235 },
"vscan" : { "minimum" : 90, "maximum" : 100 } "vscan" : { "minimum" : 90, "maximum" : 100 }
}, },
{ {
"index" : 18, "index" : 18,
"hscan" : { "minimum" : 5.88235, "maximum" : 11.7647 }, "hscan" : { "minimum" : 5.88235, "maximum" : 11.7647 },
"vscan" : { "minimum" : 90, "maximum" : 100 } "vscan" : { "minimum" : 90, "maximum" : 100 }
}, },
{ {
"index" : 19, "index" : 19,
"hscan" : { "minimum" : 11.7647, "maximum" : 17.6471 }, "hscan" : { "minimum" : 11.7647, "maximum" : 17.6471 },
"vscan" : { "minimum" : 90, "maximum" : 100 } "vscan" : { "minimum" : 90, "maximum" : 100 }
}, },
{ {
"index" : 20, "index" : 20,
"hscan" : { "minimum" : 17.6471, "maximum" : 23.5294 }, "hscan" : { "minimum" : 17.6471, "maximum" : 23.5294 },
"vscan" : { "minimum" : 90, "maximum" : 100 } "vscan" : { "minimum" : 90, "maximum" : 100 }
}, },
{ {
"index" : 21, "index" : 21,
"hscan" : { "minimum" : 23.5294, "maximum" : 29.4118 }, "hscan" : { "minimum" : 23.5294, "maximum" : 29.4118 },
"vscan" : { "minimum" : 90, "maximum" : 100 } "vscan" : { "minimum" : 90, "maximum" : 100 }
}, },
{ {
"index" : 22, "index" : 22,
"hscan" : { "minimum" : 29.4118, "maximum" : 35.2941 }, "hscan" : { "minimum" : 29.4118, "maximum" : 35.2941 },
"vscan" : { "minimum" : 90, "maximum" : 100 } "vscan" : { "minimum" : 90, "maximum" : 100 }
}, },
{ {
"index" : 23, "index" : 23,
"hscan" : { "minimum" : 35.2941, "maximum" : 41.1765 }, "hscan" : { "minimum" : 35.2941, "maximum" : 41.1765 },
"vscan" : { "minimum" : 90, "maximum" : 100 } "vscan" : { "minimum" : 90, "maximum" : 100 }
}, },
{ {
"index" : 24, "index" : 24,
"hscan" : { "minimum" : 41.1765, "maximum" : 47.0588 }, "hscan" : { "minimum" : 41.1765, "maximum" : 47.0588 },
"vscan" : { "minimum" : 90, "maximum" : 100 } "vscan" : { "minimum" : 90, "maximum" : 100 }
}, },
{ {
"index" : 25, "index" : 25,
"hscan" : { "minimum" : 47.0588, "maximum" : 52.9412 }, "hscan" : { "minimum" : 47.0588, "maximum" : 52.9412 },
"vscan" : { "minimum" : 90, "maximum" : 100 } "vscan" : { "minimum" : 90, "maximum" : 100 }
}, },
{ {
"index" : 26, "index" : 26,
"hscan" : { "minimum" : 52.9412, "maximum" : 58.8235 }, "hscan" : { "minimum" : 52.9412, "maximum" : 58.8235 },
"vscan" : { "minimum" : 90, "maximum" : 100 } "vscan" : { "minimum" : 90, "maximum" : 100 }
}, },
{ {
"index" : 27, "index" : 27,
"hscan" : { "minimum" : 58.8235, "maximum" : 64.7059 }, "hscan" : { "minimum" : 58.8235, "maximum" : 64.7059 },
"vscan" : { "minimum" : 90, "maximum" : 100 } "vscan" : { "minimum" : 90, "maximum" : 100 }
}, },
{ {
"index" : 28, "index" : 28,
"hscan" : { "minimum" : 64.7059, "maximum" : 70.5882 }, "hscan" : { "minimum" : 64.7059, "maximum" : 70.5882 },
"vscan" : { "minimum" : 90, "maximum" : 100 } "vscan" : { "minimum" : 90, "maximum" : 100 }
}, },
{ {
"index" : 29, "index" : 29,
"hscan" : { "minimum" : 70.5882, "maximum" : 76.4706 }, "hscan" : { "minimum" : 70.5882, "maximum" : 76.4706 },
"vscan" : { "minimum" : 90, "maximum" : 100 } "vscan" : { "minimum" : 90, "maximum" : 100 }
}, },
{ {
"index" : 30, "index" : 30,
"hscan" : { "minimum" : 76.4706, "maximum" : 82.3529 }, "hscan" : { "minimum" : 76.4706, "maximum" : 82.3529 },
"vscan" : { "minimum" : 90, "maximum" : 100 } "vscan" : { "minimum" : 90, "maximum" : 100 }
}, },
{ {
"index" : 31, "index" : 31,
"hscan" : { "minimum" : 82.3529, "maximum" : 88.2353 }, "hscan" : { "minimum" : 82.3529, "maximum" : 88.2353 },
"vscan" : { "minimum" : 90, "maximum" : 100 } "vscan" : { "minimum" : 90, "maximum" : 100 }
}, },
{ {
"index" : 32, "index" : 32,
"hscan" : { "minimum" : 88.2353, "maximum" : 94.1176 }, "hscan" : { "minimum" : 88.2353, "maximum" : 94.1176 },
"vscan" : { "minimum" : 90, "maximum" : 100 } "vscan" : { "minimum" : 90, "maximum" : 100 }
}, },
// BOTTOM-RIGHT Corner // BOTTOM-RIGHT Corner
{ {
"index" : 33, "index" : 33,
"hscan" : { "minimum" : 94.1176, "maximum" : 100 }, "hscan" : { "minimum" : 94.1176, "maximum" : 100 },
"vscan" : { "minimum" : 90, "maximum" : 100 } "vscan" : { "minimum" : 90, "maximum" : 100 }
}, },
{ {
"index" : 34, "index" : 34,
"hscan" : { "minimum" : 90, "maximum" : 100 }, "hscan" : { "minimum" : 90, "maximum" : 100 },
"vscan" : { "minimum" : 80, "maximum" : 90 } "vscan" : { "minimum" : 80, "maximum" : 90 }
}, },
{ {
"index" : 35, "index" : 35,
"hscan" : { "minimum" : 90, "maximum" : 100 }, "hscan" : { "minimum" : 90, "maximum" : 100 },
"vscan" : { "minimum" : 70, "maximum" : 80 } "vscan" : { "minimum" : 70, "maximum" : 80 }
}, },
{ {
"index" : 36, "index" : 36,
"hscan" : { "minimum" : 90, "maximum" : 100 }, "hscan" : { "minimum" : 90, "maximum" : 100 },
"vscan" : { "minimum" : 60, "maximum" : 70 } "vscan" : { "minimum" : 60, "maximum" : 70 }
}, },
{ {
"index" : 37, "index" : 37,
"hscan" : { "minimum" : 90, "maximum" : 100 }, "hscan" : { "minimum" : 90, "maximum" : 100 },
"vscan" : { "minimum" : 50, "maximum" : 60 } "vscan" : { "minimum" : 50, "maximum" : 60 }
}, },
{ {
"index" : 38, "index" : 38,
"hscan" : { "minimum" : 90, "maximum" : 100 }, "hscan" : { "minimum" : 90, "maximum" : 100 },
"vscan" : { "minimum" : 40, "maximum" : 50 } "vscan" : { "minimum" : 40, "maximum" : 50 }
}, },
{ {
"index" : 39, "index" : 39,
"hscan" : { "minimum" : 90, "maximum" : 100 }, "hscan" : { "minimum" : 90, "maximum" : 100 },
"vscan" : { "minimum" : 30, "maximum" : 40 } "vscan" : { "minimum" : 30, "maximum" : 40 }
}, },
{ {
"index" : 40, "index" : 40,
"hscan" : { "minimum" : 90, "maximum" : 100 }, "hscan" : { "minimum" : 90, "maximum" : 100 },
"vscan" : { "minimum" : 20, "maximum" : 30 } "vscan" : { "minimum" : 20, "maximum" : 30 }
}, },
{ {
"index" : 41, "index" : 41,
"hscan" : { "minimum" : 90, "maximum" : 100 }, "hscan" : { "minimum" : 90, "maximum" : 100 },
"vscan" : { "minimum" : 10, "maximum" : 20 } "vscan" : { "minimum" : 10, "maximum" : 20 }
}, },
// TOP-RIGHT Corner // TOP-RIGHT Corner
{ {
"index" : 42, "index" : 42,
"hscan" : { "minimum" : 94.1176, "maximum" : 100 }, "hscan" : { "minimum" : 94.1176, "maximum" : 100 },
"vscan" : { "minimum" : 0, "maximum" : 10 } "vscan" : { "minimum" : 0, "maximum" : 10 }
}, },
{ {
"index" : 43, "index" : 43,
"hscan" : { "minimum" : 88.2353, "maximum" : 94.1176 }, "hscan" : { "minimum" : 88.2353, "maximum" : 94.1176 },
"vscan" : { "minimum" : 0, "maximum" : 10 } "vscan" : { "minimum" : 0, "maximum" : 10 }
}, },
{ {
"index" : 44, "index" : 44,
"hscan" : { "minimum" : 82.3529, "maximum" : 88.2353 }, "hscan" : { "minimum" : 82.3529, "maximum" : 88.2353 },
"vscan" : { "minimum" : 0, "maximum" : 10 } "vscan" : { "minimum" : 0, "maximum" : 10 }
}, },
{ {
"index" : 45, "index" : 45,
"hscan" : { "minimum" : 76.4706, "maximum" : 82.3529 }, "hscan" : { "minimum" : 76.4706, "maximum" : 82.3529 },
"vscan" : { "minimum" : 0, "maximum" : 10 } "vscan" : { "minimum" : 0, "maximum" : 10 }
}, },
{ {
"index" : 46, "index" : 46,
"hscan" : { "minimum" : 70.5882, "maximum" : 76.4706 }, "hscan" : { "minimum" : 70.5882, "maximum" : 76.4706 },
"vscan" : { "minimum" : 0, "maximum" : 10 } "vscan" : { "minimum" : 0, "maximum" : 10 }
}, },
{ {
"index" : 47, "index" : 47,
"hscan" : { "minimum" : 64.7059, "maximum" : 70.5882 }, "hscan" : { "minimum" : 64.7059, "maximum" : 70.5882 },
"vscan" : { "minimum" : 0, "maximum" : 10 } "vscan" : { "minimum" : 0, "maximum" : 10 }
}, },
{ {
"index" : 48, "index" : 48,
"hscan" : { "minimum" : 58.8235, "maximum" : 64.7059 }, "hscan" : { "minimum" : 58.8235, "maximum" : 64.7059 },
"vscan" : { "minimum" : 0, "maximum" : 10 } "vscan" : { "minimum" : 0, "maximum" : 10 }
}, },
{ {
"index" : 49, "index" : 49,
"hscan" : { "minimum" : 52.9412, "maximum" : 58.8235 }, "hscan" : { "minimum" : 52.9412, "maximum" : 58.8235 },
"vscan" : { "minimum" : 0, "maximum" : 10 } "vscan" : { "minimum" : 0, "maximum" : 10 }
} }
] ],
"xbmcVideoChecker" : {
"enable" : true,
"xbmcAddress" : "127.0.0.1",
"xbmcTcpPort" : 9090
}
} }

View File

@ -35,11 +35,6 @@ public:
SATURATION_GAIN, VALUE_GAIN, THRESHOLD, GAMMA, BLACKLEVEL, WHITELEVEL SATURATION_GAIN, VALUE_GAIN, THRESHOLD, GAMMA, BLACKLEVEL, WHITELEVEL
}; };
static LedString createLedString(const Json::Value& ledsConfig);
static Json::Value loadConfig(const std::string& configFile);
Hyperion(const std::string& configFile);
Hyperion(const Json::Value& jsonConfig); Hyperion(const Json::Value& jsonConfig);
~Hyperion(); ~Hyperion();
@ -62,6 +57,11 @@ public:
const InputInfo& getPriorityInfo(const int priority) const; const InputInfo& getPriorityInfo(const int priority) const;
static LedDevice* constructDevice(const Json::Value & deviceConfig);
static LedString createLedString(const Json::Value & ledsConfig);
static HsvTransform * createHsvTransform(const Json::Value & hsvConfig);
static ColorTransform* createColorTransform(const Json::Value & colorConfig);
private slots: private slots:
void update(); void update();

View File

@ -23,7 +23,7 @@ class XBMCVideoChecker : public QObject
Q_OBJECT Q_OBJECT
public: public:
XBMCVideoChecker(QString address, uint16_t port, uint64_t interval, Hyperion * hyperion, int priority); XBMCVideoChecker(const std::string & address, uint16_t port, uint64_t interval, Hyperion * hyperion, int priority);
void start(); void start();

View File

@ -1,7 +1,6 @@
// QT includes // QT includes
#include <QDateTime> #include <QDateTime>
#include <QResource>
// JsonSchema include // JsonSchema include
#include <utils/jsonschema/JsonFactory.h> #include <utils/jsonschema/JsonFactory.h>
@ -17,7 +16,7 @@
#include <utils/ColorTransform.h> #include <utils/ColorTransform.h>
#include <utils/HsvTransform.h> #include <utils/HsvTransform.h>
LedDevice* constructDevice(const Json::Value& deviceConfig) LedDevice* Hyperion::constructDevice(const Json::Value& deviceConfig)
{ {
std::cout << "Device configuration: " << deviceConfig << std::endl; std::cout << "Device configuration: " << deviceConfig << std::endl;
LedDevice* device = nullptr; LedDevice* device = nullptr;
@ -44,12 +43,12 @@ LedDevice* constructDevice(const Json::Value& deviceConfig)
return device; return device;
} }
HsvTransform * createHsvTransform(const Json::Value & hsvConfig) HsvTransform * Hyperion::createHsvTransform(const Json::Value & hsvConfig)
{ {
return new HsvTransform(hsvConfig["saturationGain"].asDouble(), hsvConfig["valueGain"].asDouble()); return new HsvTransform(hsvConfig["saturationGain"].asDouble(), hsvConfig["valueGain"].asDouble());
} }
ColorTransform* createColorTransform(const Json::Value& colorConfig) ColorTransform* Hyperion::createColorTransform(const Json::Value& colorConfig)
{ {
const double threshold = colorConfig["threshold"].asDouble(); const double threshold = colorConfig["threshold"].asDouble();
const double gamma = colorConfig["gamma"].asDouble(); const double gamma = colorConfig["gamma"].asDouble();
@ -79,36 +78,6 @@ LedString Hyperion::createLedString(const Json::Value& ledsConfig)
return ledString; return ledString;
} }
Json::Value Hyperion::loadConfig(const std::string& configFile)
{
// make sure the resources are loaded (they may be left out after static linking)
Q_INIT_RESOURCE(resource);
// read the json schema from the resource
QResource schemaData(":/hyperion-schema");
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) : Hyperion::Hyperion(const Json::Value &jsonConfig) :
_ledString(createLedString(jsonConfig["leds"])), _ledString(createLedString(jsonConfig["leds"])),
_muxer(_ledString.leds().size()), _muxer(_ledString.leds().size()),

View File

@ -1,169 +1,190 @@
{ {
"type":"object", "type":"object",
"required":true, "required":true,
"properties":{ "properties":{
"device": { "device": {
"type":"object", "type":"object",
"required":true, "required":true,
"properties":{ "properties":{
"name": { "name": {
"type":"string", "type":"string",
"required":true "required":true
}, },
"type": { "type": {
"type":"string", "type":"string",
"required":true "required":true
}, },
"output": { "output": {
"type":"string", "type":"string",
"required":true "required":true
}, },
"interval": { "interval": {
"type":"integer", "type":"integer",
"required":true "required":true
}, },
"rate": { "rate": {
"type":"integer", "type":"integer",
"required":true "required":true
} }
}, },
"additionalProperties": false "additionalProperties": false
}, },
"color": { "color": {
"type":"object", "type":"object",
"required":true, "required":true,
"properties": { "properties": {
"hsv" : { "hsv" : {
"type" : "object", "type" : "object",
"required" : true, "required" : true,
"properties" : { "properties" : {
"saturationGain" : { "saturationGain" : {
"type" : "number", "type" : "number",
"required" : true, "required" : true,
"minimum" : 0.0 "minimum" : 0.0
}, },
"valueGain" : { "valueGain" : {
"type" : "number", "type" : "number",
"required" : true, "required" : true,
"minimum" : 0.0 "minimum" : 0.0
} }
}, },
"additionalProperties" : false "additionalProperties" : false
}, },
"red": { "red": {
"type":"object", "type":"object",
"required":true, "required":true,
"properties":{ "properties":{
"gamma": { "gamma": {
"type":"number", "type":"number",
"required":true "required":true
}, },
"blacklevel": { "blacklevel": {
"type":"number", "type":"number",
"required":true "required":true
}, },
"whitelevel": { "whitelevel": {
"type":"number", "type":"number",
"required":true "required":true
}, },
"threshold": { "threshold": {
"type":"number", "type":"number",
"required":true, "required":true,
"minimum" : 0.0, "minimum" : 0.0,
"maximum" : 1.0 "maximum" : 1.0
} }
} }
}, },
"green": { "green": {
"type":"object", "type":"object",
"required":true, "required":true,
"properties":{ "properties":{
"gamma": { "gamma": {
"type":"number", "type":"number",
"required":true "required":true
}, },
"blacklevel": { "blacklevel": {
"type":"number", "type":"number",
"required":true "required":true
}, },
"whitelevel": { "whitelevel": {
"type":"number", "type":"number",
"required":true "required":true
}, },
"threshold": { "threshold": {
"type":"number", "type":"number",
"required":true, "required":true,
"minimum" : 0.0, "minimum" : 0.0,
"maximum" : 1.0 "maximum" : 1.0
} }
} }
}, },
"blue": { "blue": {
"type":"object", "type":"object",
"required":true, "required":true,
"properties":{ "properties":{
"gamma": { "gamma": {
"type":"number", "type":"number",
"required":true "required":true
}, },
"whitelevel": { "whitelevel": {
"type":"number", "type":"number",
"required":true "required":true
}, },
"blacklevel": { "blacklevel": {
"type":"number", "type":"number",
"required":true "required":true
}, },
"threshold": { "threshold": {
"type":"number", "type":"number",
"required":true, "required":true,
"minimum" : 0.0, "minimum" : 0.0,
"maximum" : 1.0 "maximum" : 1.0
} }
} }
} }
} }
}, },
"leds": { "leds": {
"type":"array", "type":"array",
"required":true, "required":true,
"items": { "items": {
"type":"object", "type":"object",
"properties": { "properties": {
"index": { "index": {
"type":"integer", "type":"integer",
"required":true "required":true
}, },
"hscan": { "hscan": {
"type":"object", "type":"object",
"required":true, "required":true,
"properties": { "properties": {
"minimum": { "minimum": {
"type":"number", "type":"number",
"required":true "required":true
}, },
"maximum": { "maximum": {
"type":"number", "type":"number",
"required":true "required":true
} }
} }
}, },
"vscan": { "vscan": {
"type":"object", "type":"object",
"required":true, "required":true,
"properties": { "properties": {
"minimum": { "minimum": {
"type":"number", "type":"number",
"required":true "required":true
}, },
"maximum": { "maximum": {
"type":"number", "type":"number",
"required":true "required":true
} }
} }
} }
} }
} }
} },
} "xbmcVideoChecker" :
{
"type" : "object",
"required" : true,
"properties" : {
"enable" : {
"type" : "boolean",
"required" : true
},
"xbmcAddress" : {
"type" : "string",
"required" : true
},
"xbmcTcpPort" : {
"type" : "integer",
"required" : true
}
},
"additionalProperties" : false
}
},
"additionalProperties" : false
} }

View File

@ -3,9 +3,9 @@
#include <xbmcvideochecker/XBMCVideoChecker.h> #include <xbmcvideochecker/XBMCVideoChecker.h>
XBMCVideoChecker::XBMCVideoChecker(QString address, uint16_t port, uint64_t interval_ms, Hyperion * hyperion, int priority) : XBMCVideoChecker::XBMCVideoChecker(const std::string & address, uint16_t port, uint64_t interval_ms, Hyperion * hyperion, int priority) :
QObject(), QObject(),
_address(address), _address(QString::fromStdString(address)),
_port(port), _port(port),
_request("{\"jsonrpc\":\"2.0\",\"method\":\"Player.GetActivePlayers\",\"id\":1}"), _request("{\"jsonrpc\":\"2.0\",\"method\":\"Player.GetActivePlayers\",\"id\":1}"),
_timer(), _timer(),
@ -48,7 +48,7 @@ void XBMCVideoChecker::sendRequest()
void XBMCVideoChecker::receiveReply() void XBMCVideoChecker::receiveReply()
{ {
// expect that the reply is received as a single message. Probaly oke considering the size of the expected reply // expect that the reply is received as a single message. Probably oke considering the size of the expected reply
QString reply(_socket.readAll()); QString reply(_socket.readAll());
if (reply.contains("playerid")) if (reply.contains("playerid"))

View File

@ -4,6 +4,7 @@
// QT includes // QT includes
#include <QCoreApplication> #include <QCoreApplication>
#include <QResource>
// Json-Schema includes // Json-Schema includes
#include <utils/jsonschema/JsonFactory.h> #include <utils/jsonschema/JsonFactory.h>
@ -26,6 +27,30 @@ void signal_handler(const int signum)
QCoreApplication::quit(); QCoreApplication::quit();
} }
Json::Value loadConfig(const std::string & configFile)
{
// make sure the resources are loaded (they may be left out after static linking)
Q_INIT_RESOURCE(resource);
// read the json schema from the resource
QResource schemaData(":/hyperion-schema");
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;
}
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
// Initialising QCoreApplication // Initialising QCoreApplication
@ -44,15 +69,21 @@ int main(int argc, char** argv)
const std::string configFile = argv[1]; const std::string configFile = argv[1];
std::cout << "Selected configuration file: " << configFile.c_str() << std::endl; std::cout << "Selected configuration file: " << configFile.c_str() << std::endl;
const Json::Value config = loadConfig(configFile);
Hyperion hyperion(configFile); Hyperion hyperion(config);
std::cout << "Hyperion created and initialised" << std::endl; std::cout << "Hyperion created and initialised" << std::endl;
RainbowBootSequence bootSequence(&hyperion); RainbowBootSequence bootSequence(&hyperion);
bootSequence.start(); bootSequence.start();
XBMCVideoChecker xbmcVideoChecker("127.0.0.1", 9090, 1000, &hyperion, 999); const Json::Value & videoCheckerConfig = config["xbmcVideoChecker"];
xbmcVideoChecker.start(); XBMCVideoChecker xbmcVideoChecker(videoCheckerConfig["xbmcAddress"].asString(), videoCheckerConfig["xbmcTcpPort"].asUInt(), 1000, &hyperion, 999);
if (videoCheckerConfig["enable"].asBool())
{
xbmcVideoChecker.start();
std::cout << "XBMC video checker created and started" << std::endl;
}
DispmanxWrapper dispmanx(64, 64, 10, &hyperion); DispmanxWrapper dispmanx(64, 64, 10, &hyperion);
dispmanx.start(); dispmanx.start();
@ -61,11 +92,14 @@ int main(int argc, char** argv)
JsonServer jsonServer(&hyperion); JsonServer jsonServer(&hyperion);
std::cout << "Json server created and started on port " << jsonServer.getPort() << std::endl; std::cout << "Json server created and started on port " << jsonServer.getPort() << std::endl;
app.exec(); // run the application
std::cout << "Application closed" << std::endl; int rc = app.exec();
std::cout << "Application closed" << std::endl;
// Stop the frame grabber // Stop the frame grabber
dispmanx.stop(); dispmanx.stop();
// Clear all colors (switchting off all leds) // Clear all colors (switchting off all leds)
hyperion.clearall(); hyperion.clearall();
return rc;
} }