This commit is contained in:
brindosch 2017-02-21 12:02:01 +01:00
parent 2a33717103
commit adace4575c
6 changed files with 21 additions and 7 deletions

View File

@ -191,8 +191,10 @@ public slots:
/// @param[in] priority The priority of the written colors
/// @param[in] ledColors The colors to write to the leds
/// @param[in] timeout_ms The time the leds are set to the given colors [ms]
/// @param[in] component The current component
/// @param[in] origin Who set it
///
void setColors(int priority, const std::vector<ColorRgb> &ledColors, const int timeout_ms, bool clearEffects = true, hyperion::Components component=hyperion::COMP_INVALID);
void setColors(int priority, const std::vector<ColorRgb> &ledColors, const int timeout_ms, bool clearEffects = true, hyperion::Components component=hyperion::COMP_INVALID, const QString origin="System");
///
/// Writes the given colors to all leds for the given time and priority

View File

@ -33,7 +33,10 @@ public:
int64_t timeoutTime_ms;
/// The colors for each led of the channel
std::vector<ColorRgb> ledColors;
/// The component
hyperion::Components componentId;
/// Who set it
QString origin;
};
/// The lowest possible priority, which is used when no priority channels are active
@ -90,8 +93,10 @@ public:
/// @param[in] priority The priority of the channel
/// @param[in] ledColors The led colors of the priority channel
/// @param[in] timeoutTime_ms The absolute timeout time of the channel
/// @param[in] component The component of the channel
/// @param[in] origin Who set the channel
///
void setInput(const int priority, const std::vector<ColorRgb>& ledColors, const int64_t timeoutTime_ms=-1, hyperion::Components component=hyperion::COMP_INVALID);
void setInput(const int priority, const std::vector<ColorRgb>& ledColors, const int64_t timeoutTime_ms=-1, hyperion::Components component=hyperion::COMP_INVALID, const QString origin="System");
///
/// Clears the specified priority channel

View File

@ -571,7 +571,7 @@ void Hyperion::setColor(int priority, const ColorRgb &color, const int timeout_m
setColors(priority, ledColors, timeout_ms, clearEffects, hyperion::COMP_COLOR);
}
void Hyperion::setColors(int priority, const std::vector<ColorRgb>& ledColors, const int timeout_ms, bool clearEffects, hyperion::Components component)
void Hyperion::setColors(int priority, const std::vector<ColorRgb>& ledColors, const int timeout_ms, bool clearEffects, hyperion::Components component, const QString origin)
{
// clear effects if this call does not come from an effect
if (clearEffects)
@ -582,11 +582,11 @@ void Hyperion::setColors(int priority, const std::vector<ColorRgb>& ledColors, c
if (timeout_ms > 0)
{
const uint64_t timeoutTime = QDateTime::currentMSecsSinceEpoch() + timeout_ms;
_muxer.setInput(priority, ledColors, timeoutTime, component);
_muxer.setInput(priority, ledColors, timeoutTime, component, origin);
}
else
{
_muxer.setInput(priority, ledColors, -1, component);
_muxer.setInput(priority, ledColors, -1, component, origin);
}
if (! _sourceAutoSelectEnabled || priority == _muxer.getCurrentPriority())

View File

@ -48,13 +48,14 @@ const PriorityMuxer::InputInfo& PriorityMuxer::getInputInfo(const int priority)
return elemIt.value();
}
void PriorityMuxer::setInput(const int priority, const std::vector<ColorRgb>& ledColors, const int64_t timeoutTime_ms, hyperion::Components component)
void PriorityMuxer::setInput(const int priority, const std::vector<ColorRgb>& ledColors, const int64_t timeoutTime_ms, hyperion::Components component, const QString origin)
{
InputInfo& input = _activeInputs[priority];
input.priority = priority;
input.timeoutTime_ms = timeoutTime_ms;
input.ledColors = ledColors;
input.componentId = component;
input.origin = origin;
_currentPriority = std::min(_currentPriority, priority);
}

View File

@ -365,6 +365,7 @@ void JsonClientConnection::handleColorCommand(const QJsonObject& message, const
// extract parameters
int priority = message["priority"].toInt();
int duration = message["duration"].toInt(-1);
QString origin = message["origin"].toString();
std::vector<ColorRgb> colorData(_hyperion->getLedCount());
const QJsonArray & jsonColor = message["color"].toArray();
@ -391,7 +392,7 @@ void JsonClientConnection::handleColorCommand(const QJsonObject& message, const
}
// set output
_hyperion->setColors(priority, colorData, duration, true, hyperion::COMP_COLOR);
_hyperion->setColors(priority, colorData, duration, true, hyperion::COMP_COLOR, origin);
// send reply
sendSuccessReply(command, tan);
@ -598,6 +599,7 @@ void JsonClientConnection::handleServerInfoCommand(const QJsonObject&, const QSt
item["owner"] = QString(hyperion::componentToIdString(priorityInfo.componentId));
item["componentId"] = priorityInfo.componentId;
item["origin"] = priorityInfo.origin;
item["component"] = QString(hyperion::componentToString(priorityInfo.componentId));
item["active"] = true;
item["visible"] = (priority == currentPriority);

View File

@ -20,6 +20,10 @@
"type": "integer",
"required": false
},
"origin": {
"type": "string",
"required": true
},
"color": {
"type": "array",
"required": true,