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

View File

@ -23,7 +23,7 @@ class XBMCVideoChecker : public QObject
Q_OBJECT
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();

View File

@ -1,7 +1,6 @@
// QT includes
#include <QDateTime>
#include <QResource>
// JsonSchema include
#include <utils/jsonschema/JsonFactory.h>
@ -17,7 +16,7 @@
#include <utils/ColorTransform.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;
LedDevice* device = nullptr;
@ -44,12 +43,12 @@ LedDevice* constructDevice(const Json::Value& deviceConfig)
return device;
}
HsvTransform * createHsvTransform(const Json::Value & hsvConfig)
HsvTransform * Hyperion::createHsvTransform(const Json::Value & hsvConfig)
{
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 gamma = colorConfig["gamma"].asDouble();
@ -79,36 +78,6 @@ LedString Hyperion::createLedString(const Json::Value& ledsConfig)
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) :
_ledString(createLedString(jsonConfig["leds"])),
_muxer(_ledString.leds().size()),

View File

@ -1,169 +1,190 @@
{
"type":"object",
"required":true,
"properties":{
"device": {
"type":"object",
"required":true,
"properties":{
"name": {
"type":"string",
"required":true
},
"type": {
"type":"string",
"required":true
},
"output": {
"type":"string",
"required":true
},
"interval": {
"type":"integer",
"required":true
},
"rate": {
"type":"integer",
"required":true
}
},
"additionalProperties": false
},
"color": {
"type":"object",
"required":true,
"properties": {
"hsv" : {
"type" : "object",
"required" : true,
"properties" : {
"saturationGain" : {
"type" : "number",
"required" : true,
"minimum" : 0.0
},
"valueGain" : {
"type" : "number",
"required" : true,
"minimum" : 0.0
}
},
"additionalProperties" : false
},
"red": {
"type":"object",
"required":true,
"properties":{
"gamma": {
"type":"number",
"required":true
},
"blacklevel": {
"type":"number",
"required":true
},
"whitelevel": {
"type":"number",
"required":true
},
"threshold": {
"type":"number",
"required":true,
"minimum" : 0.0,
"maximum" : 1.0
}
}
},
"green": {
"type":"object",
"required":true,
"properties":{
"gamma": {
"type":"number",
"required":true
},
"blacklevel": {
"type":"number",
"required":true
},
"whitelevel": {
"type":"number",
"required":true
},
"threshold": {
"type":"number",
"required":true,
"minimum" : 0.0,
"maximum" : 1.0
}
}
},
"blue": {
"type":"object",
"required":true,
"properties":{
"gamma": {
"type":"number",
"required":true
},
"whitelevel": {
"type":"number",
"required":true
},
"blacklevel": {
"type":"number",
"required":true
},
"threshold": {
"type":"number",
"required":true,
"minimum" : 0.0,
"maximum" : 1.0
}
}
}
}
},
"leds": {
"type":"array",
"required":true,
"items": {
"type":"object",
"properties": {
"index": {
"type":"integer",
"required":true
},
"hscan": {
"type":"object",
"required":true,
"properties": {
"minimum": {
"type":"number",
"required":true
},
"maximum": {
"type":"number",
"required":true
}
}
},
"vscan": {
"type":"object",
"required":true,
"properties": {
"minimum": {
"type":"number",
"required":true
},
"maximum": {
"type":"number",
"required":true
}
}
}
}
}
}
}
"type":"object",
"required":true,
"properties":{
"device": {
"type":"object",
"required":true,
"properties":{
"name": {
"type":"string",
"required":true
},
"type": {
"type":"string",
"required":true
},
"output": {
"type":"string",
"required":true
},
"interval": {
"type":"integer",
"required":true
},
"rate": {
"type":"integer",
"required":true
}
},
"additionalProperties": false
},
"color": {
"type":"object",
"required":true,
"properties": {
"hsv" : {
"type" : "object",
"required" : true,
"properties" : {
"saturationGain" : {
"type" : "number",
"required" : true,
"minimum" : 0.0
},
"valueGain" : {
"type" : "number",
"required" : true,
"minimum" : 0.0
}
},
"additionalProperties" : false
},
"red": {
"type":"object",
"required":true,
"properties":{
"gamma": {
"type":"number",
"required":true
},
"blacklevel": {
"type":"number",
"required":true
},
"whitelevel": {
"type":"number",
"required":true
},
"threshold": {
"type":"number",
"required":true,
"minimum" : 0.0,
"maximum" : 1.0
}
}
},
"green": {
"type":"object",
"required":true,
"properties":{
"gamma": {
"type":"number",
"required":true
},
"blacklevel": {
"type":"number",
"required":true
},
"whitelevel": {
"type":"number",
"required":true
},
"threshold": {
"type":"number",
"required":true,
"minimum" : 0.0,
"maximum" : 1.0
}
}
},
"blue": {
"type":"object",
"required":true,
"properties":{
"gamma": {
"type":"number",
"required":true
},
"whitelevel": {
"type":"number",
"required":true
},
"blacklevel": {
"type":"number",
"required":true
},
"threshold": {
"type":"number",
"required":true,
"minimum" : 0.0,
"maximum" : 1.0
}
}
}
}
},
"leds": {
"type":"array",
"required":true,
"items": {
"type":"object",
"properties": {
"index": {
"type":"integer",
"required":true
},
"hscan": {
"type":"object",
"required":true,
"properties": {
"minimum": {
"type":"number",
"required":true
},
"maximum": {
"type":"number",
"required":true
}
}
},
"vscan": {
"type":"object",
"required":true,
"properties": {
"minimum": {
"type":"number",
"required":true
},
"maximum": {
"type":"number",
"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>
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(),
_address(address),
_address(QString::fromStdString(address)),
_port(port),
_request("{\"jsonrpc\":\"2.0\",\"method\":\"Player.GetActivePlayers\",\"id\":1}"),
_timer(),
@ -48,7 +48,7 @@ void XBMCVideoChecker::sendRequest()
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());
if (reply.contains("playerid"))

View File

@ -4,6 +4,7 @@
// QT includes
#include <QCoreApplication>
#include <QResource>
// Json-Schema includes
#include <utils/jsonschema/JsonFactory.h>
@ -26,6 +27,30 @@ void signal_handler(const int signum)
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)
{
// Initialising QCoreApplication
@ -44,15 +69,21 @@ int main(int argc, char** argv)
const std::string configFile = argv[1];
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;
RainbowBootSequence bootSequence(&hyperion);
bootSequence.start();
XBMCVideoChecker xbmcVideoChecker("127.0.0.1", 9090, 1000, &hyperion, 999);
xbmcVideoChecker.start();
const Json::Value & videoCheckerConfig = config["xbmcVideoChecker"];
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);
dispmanx.start();
@ -61,11 +92,14 @@ int main(int argc, char** argv)
JsonServer jsonServer(&hyperion);
std::cout << "Json server created and started on port " << jsonServer.getPort() << std::endl;
app.exec();
std::cout << "Application closed" << std::endl;
// run the application
int rc = app.exec();
std::cout << "Application closed" << std::endl;
// Stop the frame grabber
dispmanx.stop();
// Clear all colors (switchting off all leds)
hyperion.clearall();
return rc;
}