mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
sourceOff feature + small json refactoring (#151)
* add --sourceOff to hyperion-remote - this will select "off" source and set all leds to black refactor new json stuff make schema checker not so strict, do not require values that have defaults (not finished yet) initialEffect config: effect is always an array, regardless if it is a color or an effect name * make off source visible in active priority list * transform initialeffect to qjson (except part of effect-args, this needs effectengine transformed to qjson) * remove unneeded comment * add web ui for source selection. call http://hyperion_host:8099/select/index.html current example needed json server on port 19444
This commit is contained in:
parent
6b04c1571c
commit
817dabae8c
98
assets/webconfig/select/index.html
Normal file
98
assets/webconfig/select/index.html
Normal file
@ -0,0 +1,98 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<title>Hyperion web control</title>
|
||||
|
||||
<!-- bootstrap -->
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
|
||||
|
||||
<!-- Optional theme -->
|
||||
<!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous"> -->
|
||||
<link href="starter-template.css" rel="stylesheet">
|
||||
|
||||
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<nav class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<!-- <span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>-->
|
||||
</button>
|
||||
<a class="navbar-brand" href="#">Hyperion</a>
|
||||
</div>
|
||||
<div id="navbar" class="collapse navbar-collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li class="active"><a href="#">Source Selection</a></li>
|
||||
<!-- <li><a href="#about">About</a></li> -->
|
||||
</ul>
|
||||
</div><!--/.nav-collapse -->
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
<div class="starter-template">
|
||||
<div id="inputs"></div>
|
||||
</div>
|
||||
</div><!-- /.container -->
|
||||
|
||||
|
||||
<!-- ====================================================================== -->
|
||||
<script>
|
||||
var webSocket = new WebSocket('ws://'+document.location.hostname+':19444');
|
||||
var serverInfo;
|
||||
|
||||
function setSource( prio )
|
||||
{
|
||||
if ( prio == "auto" )
|
||||
webSocket.send('{"command":"sourceselect", "auto" : true}');
|
||||
else
|
||||
webSocket.send('{"command":"sourceselect", "priority" : '+prio+'}');
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
function updateButtons()
|
||||
{
|
||||
webSocket.send('{"command":"serverinfo"}');
|
||||
}
|
||||
|
||||
webSocket.onerror = function(event) {
|
||||
alert(event.data);
|
||||
};
|
||||
|
||||
webSocket.onopen = function(event) {
|
||||
updateButtons();
|
||||
setInterval(function() {updateButtons();}, 3000);
|
||||
};
|
||||
|
||||
webSocket.onmessage = function(event) {
|
||||
serverInfo = JSON.parse( event.data );
|
||||
var data = "";
|
||||
var i;
|
||||
for(i = 0; i < serverInfo.info.priorities.length; i++) {
|
||||
var owner = serverInfo.info.priorities[i].owner;
|
||||
var active = serverInfo.info.priorities[i].active;
|
||||
var visible = serverInfo.info.priorities[i].visible;
|
||||
var priority = serverInfo.info.priorities[i].priority;
|
||||
var btn_type = "default";
|
||||
if (active) btn_type = "warning";
|
||||
if (visible) btn_type = "success";
|
||||
|
||||
data += '<button id="srcBtn'+i+'" type="button" class="btn btn-lg btn-'+btn_type+'" style="margin:10px;min-width:200px" title="prio '+priority+'" onclick="setSource('+priority+');">'+owner+'</button><br/>';
|
||||
}
|
||||
data += '<button id="srcBtn'+i+'" type="button" class="btn btn-lg btn-info" style="margin:10px;min-width:200px" onclick="setSource(\'auto\');">auto select</button><br/>';
|
||||
$('#inputs').html(data);
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
8
assets/webconfig/select/starter-template.css
Normal file
8
assets/webconfig/select/starter-template.css
Normal file
@ -0,0 +1,8 @@
|
||||
body {
|
||||
padding-top: 50px;
|
||||
}
|
||||
.starter-template {
|
||||
padding: 40px 15px;
|
||||
text-align: center;
|
||||
}
|
||||
|
@ -268,18 +268,18 @@
|
||||
},
|
||||
|
||||
/// Initial Effect sets a "booteffect" or "color" (foreground-effect) and optional set a "effect" or "color" during inactive grabbers and network receivers (background-effect)
|
||||
/// * background-effect : 2 options: set a effect (example: "Rainbow swirl fast") or set a color (RGB) (example: [255,134,0])
|
||||
/// * background-effect : 2 options: set a effect (example: ["Rainbow swirl fast"]) or set a color (RGB) (example: [255,134,0])
|
||||
/// * background-effect-args : Set optional effect arguments (Have a look at the select effect to get the possible values), define it only when needed
|
||||
/// * foreground-effect : 2 options: set a effect (example: "Rainbow swirl fast") or set a color (RGB) (example: [255,134,0])
|
||||
/// * foreground-effect : 2 options: set a effect (example: ["Rainbow swirl fast"]) or set a color (RGB) (example: [255,134,0])
|
||||
/// * foreground-effect-args : Set optional effect arguments (Have a look at the select effect to get the possible values), define it only when needed
|
||||
/// * foreground-duration_ms : The duration of the selected foreground-effect or color (0=endless)
|
||||
/// HINT: "foreground-effect" starts always with priority 0, so it blocks all remotes and grabbers if the loop is endless
|
||||
/// HINT: Set a empty value if you want to disable a component (example: "")
|
||||
"initialEffect" :
|
||||
{
|
||||
"background-effect" : "Full color mood blobs",
|
||||
"background-effect" : ["Full color mood blobs"],
|
||||
//"background-effect-args" : {},
|
||||
"foreground-effect" : "Rainbow swirl fast",
|
||||
"foreground-effect" : ["Rainbow swirl fast"],
|
||||
//"foreground-effect-args" : {},
|
||||
"foreground-duration_ms" : 3000
|
||||
},
|
||||
|
@ -150,8 +150,8 @@
|
||||
|
||||
"initialEffect" :
|
||||
{
|
||||
"background-effect" : "Full color mood blobs",
|
||||
"foreground-effect" : "Rainbow swirl fast",
|
||||
"background-effect" : ["Full color mood blobs"],
|
||||
"foreground-effect" : ["Rainbow swirl fast"],
|
||||
"foreground-duration_ms" : 3000
|
||||
},
|
||||
|
||||
|
@ -34,6 +34,9 @@ public:
|
||||
std::vector<ColorRgb> ledColors;
|
||||
};
|
||||
|
||||
/// The lowest possible priority, which is used when no priority channels are active
|
||||
const static int LOWEST_PRIORITY = std::numeric_limits<int>::max();
|
||||
|
||||
///
|
||||
/// Constructs the PriorityMuxer for the given number of leds (used to switch to black when
|
||||
/// there are no priority channels
|
||||
@ -118,6 +121,4 @@ private:
|
||||
/// The information of the lowest priority channel
|
||||
InputInfo _lowestPriorityInfo;
|
||||
|
||||
/// The lowest possible priority, which is used when no priority channels are active
|
||||
const static int LOWEST_PRIORITY = std::numeric_limits<int>::max();
|
||||
};
|
||||
|
@ -557,6 +557,8 @@ Hyperion::Hyperion(const Json::Value &jsonConfig, const std::string configFile)
|
||||
, _hwLedCount(_ledString.leds().size())
|
||||
, _sourceAutoSelectEnabled(true)
|
||||
{
|
||||
registerPriority("Off", PriorityMuxer::LOWEST_PRIORITY);
|
||||
|
||||
if (!_raw2ledAdjustment->verifyAdjustments())
|
||||
{
|
||||
throw std::runtime_error("Color adjustment incorrectly set");
|
||||
@ -679,14 +681,15 @@ void Hyperion::setComponentState(const Components component, const bool state)
|
||||
break;
|
||||
case KODICHECKER:
|
||||
{
|
||||
KODIVideoChecker* _kodiVideoChecker = KODIVideoChecker::getInstance();
|
||||
if (_kodiVideoChecker != nullptr)
|
||||
state ? _kodiVideoChecker->start() : _kodiVideoChecker->stop();
|
||||
KODIVideoChecker* kodiVideoChecker = KODIVideoChecker::getInstance();
|
||||
if (kodiVideoChecker != nullptr)
|
||||
state ? kodiVideoChecker->start() : kodiVideoChecker->stop();
|
||||
else
|
||||
Debug(_log, "Can't get instance from: '%s'", componentToString(component));
|
||||
break;
|
||||
}
|
||||
case FORWARDER:
|
||||
//_messageForwarder
|
||||
break;
|
||||
case UDPLISTENER:
|
||||
break;
|
||||
|
@ -14,6 +14,8 @@ PriorityMuxer::PriorityMuxer(int ledCount)
|
||||
_lowestPriorityInfo.priority = LOWEST_PRIORITY;
|
||||
_lowestPriorityInfo.timeoutTime_ms = -1;
|
||||
_lowestPriorityInfo.ledColors = std::vector<ColorRgb>(ledCount, {0, 0, 0});
|
||||
|
||||
_activeInputs[_currentPriority] = _lowestPriorityInfo;
|
||||
}
|
||||
|
||||
PriorityMuxer::~PriorityMuxer()
|
||||
@ -33,21 +35,15 @@ QList<int> PriorityMuxer::getPriorities() const
|
||||
|
||||
bool PriorityMuxer::hasPriority(const int priority) const
|
||||
{
|
||||
return _activeInputs.contains(priority);
|
||||
return (priority == LOWEST_PRIORITY) ? true : _activeInputs.contains(priority);
|
||||
}
|
||||
|
||||
const PriorityMuxer::InputInfo& PriorityMuxer::getInputInfo(const int priority) const
|
||||
{
|
||||
if (priority == LOWEST_PRIORITY)
|
||||
{
|
||||
return _lowestPriorityInfo;
|
||||
}
|
||||
|
||||
auto elemIt = _activeInputs.find(priority);
|
||||
if (elemIt == _activeInputs.end())
|
||||
{
|
||||
std::cout << "error " << priority << std::endl;
|
||||
throw std::runtime_error("HYPERION (prioritymux) ERROR: no such priority");
|
||||
throw std::runtime_error("HYPERION (prioritymuxer) ERROR: no such priority");
|
||||
}
|
||||
return elemIt.value();
|
||||
}
|
||||
@ -63,15 +59,11 @@ void PriorityMuxer::setInput(const int priority, const std::vector<ColorRgb>& le
|
||||
}
|
||||
|
||||
void PriorityMuxer::clearInput(const int priority)
|
||||
{
|
||||
if (priority < LOWEST_PRIORITY)
|
||||
{
|
||||
_activeInputs.remove(priority);
|
||||
if (_currentPriority == priority)
|
||||
{
|
||||
if (_activeInputs.empty())
|
||||
{
|
||||
_currentPriority = LOWEST_PRIORITY;
|
||||
}
|
||||
else
|
||||
{
|
||||
QList<int> keys = _activeInputs.keys();
|
||||
_currentPriority = *std::min_element(keys.begin(), keys.end());
|
||||
@ -83,6 +75,7 @@ void PriorityMuxer::clearAll()
|
||||
{
|
||||
_activeInputs.clear();
|
||||
_currentPriority = LOWEST_PRIORITY;
|
||||
_activeInputs[_currentPriority] = _lowestPriorityInfo;
|
||||
}
|
||||
|
||||
void PriorityMuxer::setCurrentTime(const int64_t& now)
|
||||
|
@ -6,13 +6,11 @@
|
||||
"logger" :
|
||||
{
|
||||
"type" : "object",
|
||||
"required" : true,
|
||||
"properties" :
|
||||
{
|
||||
"level" :
|
||||
{
|
||||
"type" : "string",
|
||||
"required" : true
|
||||
"enum" : ["silent", "warn", "verbose", "debug"]
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
@ -50,7 +48,7 @@
|
||||
"required" : false
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
"additionalProperties" : true
|
||||
},
|
||||
"color" :
|
||||
{
|
||||
@ -364,44 +362,37 @@
|
||||
"smoothing":
|
||||
{
|
||||
"type" : "object",
|
||||
"required" : true,
|
||||
"properties" :
|
||||
{
|
||||
"enable" :
|
||||
{
|
||||
"type" : "boolean",
|
||||
"required" : true
|
||||
"type" : "boolean"
|
||||
},
|
||||
"type" :
|
||||
{
|
||||
"enum" : ["none", "linear"],
|
||||
"required" : true
|
||||
"enum" : ["linear"]
|
||||
},
|
||||
"time_ms" :
|
||||
{
|
||||
"type" : "integer",
|
||||
"required" : false,
|
||||
"minimum" : 25,
|
||||
"maximum": 600
|
||||
},
|
||||
"updateFrequency" :
|
||||
{
|
||||
"type" : "number",
|
||||
"required" : false,
|
||||
"minimum" : 1.000,
|
||||
"maximum": 100.000
|
||||
},
|
||||
"updateDelay" :
|
||||
{
|
||||
"type" : "integer",
|
||||
"required" : false,
|
||||
"minimum" : 0,
|
||||
"maximum": 2048
|
||||
},
|
||||
"continuousOutput" :
|
||||
{
|
||||
"type" : "boolean",
|
||||
"required" : false
|
||||
"type" : "boolean"
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
@ -503,88 +494,120 @@
|
||||
"framegrabber" :
|
||||
{
|
||||
"type" : "object",
|
||||
"required" : false,
|
||||
"properties" :
|
||||
{
|
||||
"enable" :
|
||||
{
|
||||
"type" : "boolean",
|
||||
"required" : true
|
||||
"type" : "boolean"
|
||||
},
|
||||
"type" :
|
||||
{
|
||||
"type" : "string",
|
||||
"required" : true
|
||||
"type" : "string"
|
||||
},
|
||||
"width" :
|
||||
{
|
||||
"type" : "integer",
|
||||
"required" : false
|
||||
"type" : "integer"
|
||||
},
|
||||
"height" :
|
||||
{
|
||||
"type" : "integer",
|
||||
"required" : false
|
||||
"type" : "integer"
|
||||
},
|
||||
"frequency_Hz" :
|
||||
{
|
||||
"type" : "integer",
|
||||
"required" : true
|
||||
"minimum" : 0
|
||||
},
|
||||
"priority" :
|
||||
{
|
||||
"type" : "integer"
|
||||
},
|
||||
"cropLeft" :
|
||||
{
|
||||
"type" : "integer",
|
||||
"required" : true
|
||||
"minimum" : 0
|
||||
},
|
||||
"cropRight" :
|
||||
{
|
||||
"type" : "integer",
|
||||
"minimum" : 0
|
||||
},
|
||||
"cropTop" :
|
||||
{
|
||||
"type" : "integer",
|
||||
"minimum" : 0
|
||||
},
|
||||
"cropBottom" :
|
||||
{
|
||||
"type" : "integer",
|
||||
"minimum" : 0
|
||||
},
|
||||
"useXGetImage" :
|
||||
{
|
||||
"type" : "boolean"
|
||||
},
|
||||
"horizontalPixelDecimation" :
|
||||
{
|
||||
"type" : "integer",
|
||||
"minimum" : 0
|
||||
},
|
||||
"verticalPixelDecimation" :
|
||||
{
|
||||
"type" : "integer",
|
||||
"minimum" : 0
|
||||
},
|
||||
"device" :
|
||||
{
|
||||
"type" : "string"
|
||||
},
|
||||
"display" :
|
||||
{
|
||||
"type" : "integer",
|
||||
"minimum" : 0
|
||||
}
|
||||
},
|
||||
"additionalProperties" : true
|
||||
"additionalProperties" : false
|
||||
},
|
||||
"blackborderdetector" :
|
||||
{
|
||||
"type" : "object",
|
||||
"required" : true,
|
||||
"properties" :
|
||||
{
|
||||
"enable" :
|
||||
{
|
||||
"type" : "boolean",
|
||||
"required" : true
|
||||
"type" : "boolean"
|
||||
},
|
||||
"threshold" :
|
||||
{
|
||||
"type" : "number",
|
||||
"required" : true,
|
||||
"minimum" : 0.0,
|
||||
"maximum" : 1.0
|
||||
},
|
||||
"unknownFrameCnt" :
|
||||
{
|
||||
"type" : "number",
|
||||
"required" : false,
|
||||
"minimum" : 0
|
||||
},
|
||||
"borderFrameCnt" :
|
||||
{
|
||||
"type" : "number",
|
||||
"required" : false,
|
||||
"minimum" : 0
|
||||
},
|
||||
"maxInconsistentCnt" :
|
||||
{
|
||||
"type" : "number",
|
||||
"required" : false,
|
||||
"minimum" : 0
|
||||
},
|
||||
"blurRemoveCnt" :
|
||||
{
|
||||
"type" : "number",
|
||||
"required" : false,
|
||||
"minimum" : 0
|
||||
},
|
||||
"mode" :
|
||||
{
|
||||
"type" : "string",
|
||||
"required" : true
|
||||
"type" :
|
||||
{
|
||||
"enum" : ["default", "classic", "osd"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
@ -592,58 +615,47 @@
|
||||
"kodiVideoChecker" :
|
||||
{
|
||||
"type" : "object",
|
||||
"required" : true,
|
||||
"properties" :
|
||||
{
|
||||
"enable" :
|
||||
{
|
||||
"type" : "boolean",
|
||||
"required" : true
|
||||
"type" : "boolean"
|
||||
},
|
||||
"kodiAddress" :
|
||||
{
|
||||
"type" : "string",
|
||||
"required" : true
|
||||
"type" : "string"
|
||||
},
|
||||
"kodiTcpPort" :
|
||||
{
|
||||
"type" : "integer",
|
||||
"required" : true
|
||||
"type" : "integer"
|
||||
},
|
||||
"grabVideo" :
|
||||
{
|
||||
"type" : "boolean",
|
||||
"required" : true
|
||||
"type" : "boolean"
|
||||
},
|
||||
"grabPictures" :
|
||||
{
|
||||
"type" : "boolean",
|
||||
"required" : true
|
||||
"type" : "boolean"
|
||||
},
|
||||
"grabAudio" :
|
||||
{
|
||||
"type" : "boolean",
|
||||
"required" : true
|
||||
"type" : "boolean"
|
||||
},
|
||||
"grabMenu" :
|
||||
{
|
||||
"type" : "boolean",
|
||||
"required" : true
|
||||
"type" : "boolean"
|
||||
},
|
||||
"grabPause" :
|
||||
{
|
||||
"type" : "boolean",
|
||||
"required" : true
|
||||
"type" : "boolean"
|
||||
},
|
||||
"grabScreensaver" :
|
||||
{
|
||||
"type" : "boolean",
|
||||
"required" : true
|
||||
"type" : "boolean"
|
||||
},
|
||||
"enable3DDetection" :
|
||||
{
|
||||
"type" : "boolean",
|
||||
"required" : true
|
||||
"type" : "boolean"
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
@ -651,33 +663,27 @@
|
||||
"initialEffect" :
|
||||
{
|
||||
"type" : "object",
|
||||
"required" : false,
|
||||
"properties" :
|
||||
{
|
||||
"background-effect" :
|
||||
{
|
||||
"type" : "string",
|
||||
"required" : false
|
||||
"type" : "array"
|
||||
},
|
||||
"background-effect-args" :
|
||||
{
|
||||
"type" : "object",
|
||||
"required" : false
|
||||
"type" : "object"
|
||||
},
|
||||
"foreground-effect" :
|
||||
{
|
||||
"type" : "string",
|
||||
"required" : false
|
||||
"type" : "array"
|
||||
},
|
||||
"foreground-effect-args" :
|
||||
{
|
||||
"type" : "object",
|
||||
"required" : false
|
||||
"type" : "object"
|
||||
},
|
||||
"foreground-duration_ms" :
|
||||
{
|
||||
"type" : "integer",
|
||||
"required" : false
|
||||
"type" : "integer"
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
@ -741,13 +747,11 @@
|
||||
"boblightServer" :
|
||||
{
|
||||
"type" : "object",
|
||||
"required" : true,
|
||||
"properties" :
|
||||
{
|
||||
"enable" :
|
||||
{
|
||||
"type" : "boolean",
|
||||
"required" : true
|
||||
"type" : "boolean"
|
||||
},
|
||||
"port" :
|
||||
{
|
||||
@ -758,8 +762,7 @@
|
||||
},
|
||||
"priority" :
|
||||
{
|
||||
"type" : "integer",
|
||||
"required" : true
|
||||
"type" : "integer"
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
@ -767,13 +770,11 @@
|
||||
"udpListener" :
|
||||
{
|
||||
"type" : "object",
|
||||
"required" : true,
|
||||
"properties" :
|
||||
{
|
||||
"enable" :
|
||||
{
|
||||
"type" : "boolean",
|
||||
"required" : true
|
||||
"type" : "boolean"
|
||||
},
|
||||
"address" :
|
||||
{
|
||||
@ -783,24 +784,20 @@
|
||||
"port" :
|
||||
{
|
||||
"type" : "integer",
|
||||
"required" : true,
|
||||
"minimum" : 0,
|
||||
"maximum" : 65535
|
||||
},
|
||||
"priority" :
|
||||
{
|
||||
"type" : "integer",
|
||||
"required" : true
|
||||
"type" : "integer"
|
||||
},
|
||||
"timeout" :
|
||||
{
|
||||
"type" : "integer",
|
||||
"required" : true
|
||||
"type" : "integer"
|
||||
},
|
||||
"shared" :
|
||||
{
|
||||
"type" : "boolean",
|
||||
"required" : true
|
||||
"type" : "boolean"
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
@ -832,13 +829,11 @@
|
||||
"effects" :
|
||||
{
|
||||
"type" : "object",
|
||||
"required" : false,
|
||||
"properties" :
|
||||
{
|
||||
"paths" :
|
||||
{
|
||||
"type" : "array",
|
||||
"required" : false
|
||||
"type" : "array"
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
@ -906,8 +901,7 @@
|
||||
},
|
||||
"endOfJson" :
|
||||
{
|
||||
"type" : "string",
|
||||
"required" : false
|
||||
"type" : "string"
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <QDateTime>
|
||||
#include <QCryptographicHash>
|
||||
#include <QHostInfo>
|
||||
#include <QString>
|
||||
|
||||
// hyperion util includes
|
||||
#include <hyperion/ImageProcessorFactory.h>
|
||||
@ -820,7 +821,7 @@ void JsonClientConnection::handleConfigGetCommand(const Json::Value &)
|
||||
void JsonClientConnection::handleComponentStateCommand(const Json::Value& message)
|
||||
{
|
||||
const Json::Value & componentState = message["componentstate"];
|
||||
std::string component = componentState.get("component", "").asString();
|
||||
QString component = QString::fromStdString(componentState.get("component", "").asString()).toUpper();
|
||||
|
||||
if (component == "SMOOTHING")
|
||||
_hyperion->setComponentState((Components)0, componentState.get("state", true).asBool());
|
||||
|
@ -1,6 +1,7 @@
|
||||
// stl includes
|
||||
#include <clocale>
|
||||
#include <initializer_list>
|
||||
#include <limits>
|
||||
|
||||
// Qt includes
|
||||
#include <QCoreApplication>
|
||||
@ -85,6 +86,7 @@ int main(int argc, char * argv[])
|
||||
AdjustmentParameter & argBAdjust = parameters.add<AdjustmentParameter>('B', "blueAdjustment", "Set the adjustment of the blue color (requires 3 space seperated values between 0 and 255)");
|
||||
IntParameter & argSource = parameters.add<IntParameter> (0x0, "sourceSelect" , "Set current active priority channel and deactivate auto source switching");
|
||||
SwitchParameter<> & argSourceAuto = parameters.add<SwitchParameter<> >(0x0, "sourceAutoSelect", "Enables auto source, if disabled prio by manual selecting input source");
|
||||
SwitchParameter<> & argSourceOff = parameters.add<SwitchParameter<> >(0x0, "sourceOff", "select no source, this results in leds activly set to black (=off)");
|
||||
SwitchParameter<> & argConfigGet = parameters.add<SwitchParameter<> >(0x0, "configget" , "Print the current loaded Hyperion configuration file");
|
||||
|
||||
// set the default values
|
||||
@ -109,7 +111,7 @@ int main(int argc, char * argv[])
|
||||
bool colorModding = colorTransform || colorAdjust || argCorrection.isSet() || argTemperature.isSet();
|
||||
|
||||
// check that exactly one command was given
|
||||
int commandCount = count({argColor.isSet(), argImage.isSet(), argEffect.isSet(), argServerInfo.isSet(), argClear.isSet(), argClearAll.isSet(), argEnableComponent.isSet(), argDisableComponent.isSet(), colorModding, argSource.isSet(), argSourceAuto.isSet(), argConfigGet.isSet()});
|
||||
int commandCount = count({argColor.isSet(), argImage.isSet(), argEffect.isSet(), argServerInfo.isSet(), argClear.isSet(), argClearAll.isSet(), argEnableComponent.isSet(), argDisableComponent.isSet(), colorModding, argSource.isSet(), argSourceAuto.isSet(), argSourceOff.isSet(), argConfigGet.isSet()});
|
||||
if (commandCount != 1)
|
||||
{
|
||||
std::cerr << (commandCount == 0 ? "No command found." : "Multiple commands found.") << " Provide exactly one of the following options:" << std::endl;
|
||||
@ -183,6 +185,10 @@ int main(int argc, char * argv[])
|
||||
{
|
||||
connection.setComponentState(argDisableComponent.getValue(), false);
|
||||
}
|
||||
else if (argSourceOff.isSet())
|
||||
{
|
||||
connection.setSource(std::numeric_limits<int>::max());
|
||||
}
|
||||
else if (argSource.isSet())
|
||||
{
|
||||
connection.setSource(argSource.getValue());
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <utils/jsonschema/QJsonFactory.h>
|
||||
|
||||
#include <hyperion/Hyperion.h>
|
||||
#include <hyperion/PriorityMuxer.h>
|
||||
#include <effectengine/EffectEngine.h>
|
||||
#include <bonjour/bonjourserviceregister.h>
|
||||
#include <bonjour/bonjourrecord.h>
|
||||
@ -32,7 +33,7 @@
|
||||
#include "hyperiond.h"
|
||||
|
||||
|
||||
HyperionDaemon::HyperionDaemon(std::string configFile, QObject *parent)
|
||||
HyperionDaemon::HyperionDaemon(QString configFile, QObject *parent)
|
||||
: QObject(parent)
|
||||
, _log(Logger::getInstance("MAIN"))
|
||||
, _kodiVideoChecker(nullptr)
|
||||
@ -48,10 +49,9 @@ HyperionDaemon::HyperionDaemon(std::string configFile, QObject *parent)
|
||||
, _osxGrabber(nullptr)
|
||||
, _hyperion(nullptr)
|
||||
{
|
||||
loadConfig(configFile); // DEPRECATED | Remove this only when the conversion have been completed from JsonCpp to QTJson
|
||||
loadConfig(QString::fromStdString(configFile));
|
||||
loadConfig(configFile);
|
||||
|
||||
_hyperion = Hyperion::initInstance(_config, configFile);
|
||||
_hyperion = Hyperion::initInstance(_config, configFile.toStdString());
|
||||
|
||||
if (Logger::getLogLevel() == Logger::WARNING)
|
||||
{
|
||||
@ -72,7 +72,7 @@ HyperionDaemon::HyperionDaemon(std::string configFile, QObject *parent)
|
||||
WarningIf(_qconfig.contains("logger"), Logger::getInstance("LOGGER"), "Logger settings overriden by command line argument");
|
||||
}
|
||||
|
||||
Info(_log, "Hyperion started and initialised");
|
||||
Info(_log, "Hyperion initialised");
|
||||
}
|
||||
|
||||
HyperionDaemon::~HyperionDaemon()
|
||||
@ -106,35 +106,14 @@ void HyperionDaemon::run()
|
||||
#if !defined(ENABLE_DISPMANX) && !defined(ENABLE_OSX) && !defined(ENABLE_FB) && !defined(ENABLE_X11) && !defined(ENABLE_AMLOGIC)
|
||||
WarningIf(_qconfig.contains("framegrabber"), _log, "No grabber can be instantiated, because all grabbers have been left out from the build");
|
||||
#endif
|
||||
Info(_log, "Hyperion started");
|
||||
|
||||
}
|
||||
|
||||
void HyperionDaemon::loadConfig(const std::string & configFile) // DEPRECATED | Remove this only when the conversion have been completed from JsonCpp to QTJson
|
||||
{
|
||||
Info(_log, "Selected configuration file: %s", configFile.c_str() );
|
||||
// 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("ERROR: Json schema wrong: " + jsonReader.getFormattedErrorMessages()) ;
|
||||
}
|
||||
JsonSchemaChecker schemaChecker;
|
||||
schemaChecker.setSchema(schemaJson);
|
||||
|
||||
_config = JsonFactory::readJson(configFile);
|
||||
schemaChecker.validate(_config);
|
||||
}
|
||||
|
||||
void HyperionDaemon::loadConfig(const QString & configFile)
|
||||
{
|
||||
// Info(_log, "Selected configuration file: %s", configFile.toStdString().c_str()); // uncommend this line only if JsonCpp is removed. Otherwise appears this line twice in the debug output
|
||||
Info(_log, "Selected configuration file: %s", configFile.toUtf8().constData());
|
||||
|
||||
// make sure the resources are loaded (they may be left out after static linking)
|
||||
Q_INIT_RESOURCE(resource);
|
||||
@ -176,6 +155,7 @@ void HyperionDaemon::loadConfig(const QString & configFile)
|
||||
QJsonSchemaChecker schemaChecker;
|
||||
schemaChecker.setSchema(schemaJson.object());
|
||||
|
||||
_config = JsonFactory::readJson(configFile.toStdString()); // DEPRECATED | Remove this only when the conversion have been completed from JsonCpp to QTJson
|
||||
_qconfig = QJsonFactory::readJson(configFile);
|
||||
if (!schemaChecker.validate(_qconfig))
|
||||
{
|
||||
@ -190,68 +170,76 @@ void HyperionDaemon::loadConfig(const QString & configFile)
|
||||
|
||||
void HyperionDaemon::startInitialEffect()
|
||||
{
|
||||
#define FGCONFIG_ARRAY fgEffectConfig.toArray()
|
||||
#define BGCONFIG_ARRAY bgEffectConfig.toArray()
|
||||
|
||||
Hyperion *hyperion = Hyperion::getInstance();
|
||||
|
||||
// create boot sequence if the configuration is present
|
||||
if (_config.isMember("initialEffect"))
|
||||
{
|
||||
const Json::Value effectConfig = _config["initialEffect"];
|
||||
const int HIGHEST_PRIORITY = 0;
|
||||
const QJsonObject & effectConfig = _qconfig["initialEffect"].toObject();
|
||||
const int FG_PRIORITY = 0;
|
||||
const int DURATION_INFINITY = 0;
|
||||
const int LOWEST_PRIORITY = std::numeric_limits<int>::max()-1;
|
||||
const int BG_PRIORITY = PriorityMuxer::LOWEST_PRIORITY -1;
|
||||
|
||||
// clear the leds
|
||||
hyperion->setColor(HIGHEST_PRIORITY, ColorRgb::BLACK, DURATION_INFINITY, false);
|
||||
hyperion->setColor(FG_PRIORITY, ColorRgb::BLACK, DURATION_INFINITY, false);
|
||||
|
||||
// initial foreground effect/color
|
||||
const Json::Value fgEffectConfig = effectConfig["foreground-effect"];
|
||||
const QJsonValue fgEffectConfig = effectConfig["foreground-effect"];
|
||||
int default_fg_duration_ms = 3000;
|
||||
int fg_duration_ms = effectConfig.get("foreground-effect-duration_ms",default_fg_duration_ms).asUInt();
|
||||
int fg_duration_ms = effectConfig["foreground-effect-duration_ms"].toInt(default_fg_duration_ms);
|
||||
if (fg_duration_ms == DURATION_INFINITY)
|
||||
{
|
||||
fg_duration_ms = default_fg_duration_ms;
|
||||
Warning(_log, "foreground effect duration 'infinity' is forbidden, set to default value %d ms",default_fg_duration_ms);
|
||||
}
|
||||
if ( ! fgEffectConfig.isNull() && fgEffectConfig.isArray() && fgEffectConfig.size() == 3 )
|
||||
if ( ! fgEffectConfig.isNull() && fgEffectConfig.isArray() && FGCONFIG_ARRAY.size() == 3 )
|
||||
{
|
||||
ColorRgb fg_color = {
|
||||
(uint8_t)fgEffectConfig[0].asUInt(),
|
||||
(uint8_t)fgEffectConfig[1].asUInt(),
|
||||
(uint8_t)fgEffectConfig[2].asUInt()
|
||||
(uint8_t)FGCONFIG_ARRAY.at(0).toInt(0),
|
||||
(uint8_t)FGCONFIG_ARRAY.at(1).toInt(0),
|
||||
(uint8_t)FGCONFIG_ARRAY.at(2).toInt(0)
|
||||
};
|
||||
hyperion->setColor(HIGHEST_PRIORITY, fg_color, fg_duration_ms, false);
|
||||
hyperion->setColor(FG_PRIORITY, fg_color, fg_duration_ms, false);
|
||||
Info(_log,"Inital foreground color set (%d %d %d)",fg_color.red,fg_color.green,fg_color.blue);
|
||||
}
|
||||
else if (! fgEffectConfig.isNull() && fgEffectConfig.isString())
|
||||
else if (! fgEffectConfig.isNull() && fgEffectConfig.isArray() && FGCONFIG_ARRAY.size() == 1 && FGCONFIG_ARRAY.at(0).isString())
|
||||
{
|
||||
const std::string bgEffectName = fgEffectConfig.asString();
|
||||
int result = effectConfig.isMember("foreground-effect-args")
|
||||
? hyperion->setEffect(bgEffectName, effectConfig["foreground-effect-args"], HIGHEST_PRIORITY, fg_duration_ms)
|
||||
: hyperion->setEffect(bgEffectName, HIGHEST_PRIORITY, fg_duration_ms);
|
||||
Info(_log,"Inital foreground effect '%s' %s", bgEffectName.c_str(), ((result == 0) ? "started" : "failed"));
|
||||
const std::string fgEffectName = FGCONFIG_ARRAY.at(0).toString().toStdString();
|
||||
int result = effectConfig.contains("foreground-effect-args")
|
||||
// ? hyperion->setEffect(fgEffectName, effectConfig["foreground-effect-args"], FG_PRIORITY, fg_duration_ms)
|
||||
? hyperion->setEffect(fgEffectName, _config["initialEffect"]["foreground-effect-args"], FG_PRIORITY, fg_duration_ms)
|
||||
: hyperion->setEffect(fgEffectName, FG_PRIORITY, fg_duration_ms);
|
||||
Info(_log,"Inital foreground effect '%s' %s", fgEffectName.c_str(), ((result == 0) ? "started" : "failed"));
|
||||
}
|
||||
|
||||
// initial background effect/color
|
||||
const Json::Value bgEffectConfig = effectConfig["background-effect"];
|
||||
if ( ! bgEffectConfig.isNull() && bgEffectConfig.isArray() && bgEffectConfig.size() == 3 )
|
||||
const QJsonValue bgEffectConfig = effectConfig["background-effect"];
|
||||
if ( ! bgEffectConfig.isNull() && bgEffectConfig.isArray() && BGCONFIG_ARRAY.size() == 3 )
|
||||
{
|
||||
ColorRgb bg_color = {
|
||||
(uint8_t)bgEffectConfig[0].asUInt(),
|
||||
(uint8_t)bgEffectConfig[1].asUInt(),
|
||||
(uint8_t)bgEffectConfig[2].asUInt()
|
||||
(uint8_t)BGCONFIG_ARRAY.at(0).toInt(0),
|
||||
(uint8_t)BGCONFIG_ARRAY.at(1).toInt(0),
|
||||
(uint8_t)BGCONFIG_ARRAY.at(2).toInt(0)
|
||||
};
|
||||
hyperion->setColor(LOWEST_PRIORITY, bg_color, DURATION_INFINITY, false);
|
||||
hyperion->setColor(BG_PRIORITY, bg_color, DURATION_INFINITY, false);
|
||||
Info(_log,"Inital background color set (%d %d %d)",bg_color.red,bg_color.green,bg_color.blue);
|
||||
}
|
||||
else if (! bgEffectConfig.isNull() && bgEffectConfig.isString())
|
||||
else if (! bgEffectConfig.isNull() && bgEffectConfig.isArray() && BGCONFIG_ARRAY.size() == 1 && BGCONFIG_ARRAY.at(0).isString())
|
||||
{
|
||||
const std::string bgEffectName = bgEffectConfig.asString();
|
||||
int result = effectConfig.isMember("background-effect-args")
|
||||
? hyperion->setEffect(bgEffectName, effectConfig["background-effect-args"], LOWEST_PRIORITY, DURATION_INFINITY)
|
||||
: hyperion->setEffect(bgEffectName, LOWEST_PRIORITY, DURATION_INFINITY);
|
||||
const std::string bgEffectName = BGCONFIG_ARRAY.at(0).toString().toStdString();
|
||||
int result = effectConfig.contains("background-effect-args")
|
||||
// ? hyperion->setEffect(bgEffectName, effectConfig["background-effect-args"], BG_PRIORITY, fg_duration_ms)
|
||||
? hyperion->setEffect(bgEffectName, _config["initialEffect"]["background-effect-args"], BG_PRIORITY, DURATION_INFINITY)
|
||||
: hyperion->setEffect(bgEffectName, BG_PRIORITY, DURATION_INFINITY);
|
||||
Info(_log,"Inital background effect '%s' %s", bgEffectName.c_str(), ((result == 0) ? "started" : "failed"));
|
||||
}
|
||||
}
|
||||
|
||||
#undef FGCONFIG_ARRAY
|
||||
#undef BGCONFIG_ARRAY
|
||||
}
|
||||
|
||||
|
||||
|
@ -51,10 +51,9 @@
|
||||
class HyperionDaemon : public QObject
|
||||
{
|
||||
public:
|
||||
HyperionDaemon(std::string configFile, QObject *parent=nullptr);
|
||||
HyperionDaemon(QString configFile, QObject *parent=nullptr);
|
||||
~HyperionDaemon();
|
||||
|
||||
void loadConfig(const std::string & configFile); // DEPRECATED | Remove this only when the conversion have been completed from JsonCpp to QTJson
|
||||
void loadConfig(const QString & configFile);
|
||||
void run();
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <QCoreApplication>
|
||||
#include <QLocale>
|
||||
#include <QFile>
|
||||
#include <QString>
|
||||
|
||||
#include "HyperionConfig.h"
|
||||
|
||||
@ -143,7 +144,7 @@ int main(int argc, char** argv)
|
||||
HyperionDaemon* hyperiond = nullptr;
|
||||
try
|
||||
{
|
||||
hyperiond = new HyperionDaemon(configFiles[argvId], &app);
|
||||
hyperiond = new HyperionDaemon(QString::fromStdString(configFiles[argvId]), &app);
|
||||
hyperiond->run();
|
||||
}
|
||||
catch (std::exception& e)
|
||||
|
Loading…
Reference in New Issue
Block a user