From adace4575cd37b5afcc83ea54aec76ff4d9464c3 Mon Sep 17 00:00:00 2001 From: brindosch Date: Tue, 21 Feb 2017 12:02:01 +0100 Subject: [PATCH] update --- include/hyperion/Hyperion.h | 4 +++- include/hyperion/PriorityMuxer.h | 7 ++++++- libsrc/hyperion/Hyperion.cpp | 6 +++--- libsrc/hyperion/PriorityMuxer.cpp | 3 ++- libsrc/jsonserver/JsonClientConnection.cpp | 4 +++- libsrc/jsonserver/schema/schema-color.json | 4 ++++ 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/include/hyperion/Hyperion.h b/include/hyperion/Hyperion.h index 230514b3..fb492e79 100644 --- a/include/hyperion/Hyperion.h +++ b/include/hyperion/Hyperion.h @@ -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 &ledColors, const int timeout_ms, bool clearEffects = true, hyperion::Components component=hyperion::COMP_INVALID); + void setColors(int priority, const std::vector &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 diff --git a/include/hyperion/PriorityMuxer.h b/include/hyperion/PriorityMuxer.h index b3d47b8f..cd908f0e 100644 --- a/include/hyperion/PriorityMuxer.h +++ b/include/hyperion/PriorityMuxer.h @@ -33,7 +33,10 @@ public: int64_t timeoutTime_ms; /// The colors for each led of the channel std::vector 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& ledColors, const int64_t timeoutTime_ms=-1, hyperion::Components component=hyperion::COMP_INVALID); + void setInput(const int priority, const std::vector& ledColors, const int64_t timeoutTime_ms=-1, hyperion::Components component=hyperion::COMP_INVALID, const QString origin="System"); /// /// Clears the specified priority channel diff --git a/libsrc/hyperion/Hyperion.cpp b/libsrc/hyperion/Hyperion.cpp index cdc327af..6fc65b6a 100644 --- a/libsrc/hyperion/Hyperion.cpp +++ b/libsrc/hyperion/Hyperion.cpp @@ -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& ledColors, const int timeout_ms, bool clearEffects, hyperion::Components component) +void Hyperion::setColors(int priority, const std::vector& 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& 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()) diff --git a/libsrc/hyperion/PriorityMuxer.cpp b/libsrc/hyperion/PriorityMuxer.cpp index 707109f4..7aef7ae9 100644 --- a/libsrc/hyperion/PriorityMuxer.cpp +++ b/libsrc/hyperion/PriorityMuxer.cpp @@ -48,13 +48,14 @@ const PriorityMuxer::InputInfo& PriorityMuxer::getInputInfo(const int priority) return elemIt.value(); } -void PriorityMuxer::setInput(const int priority, const std::vector& ledColors, const int64_t timeoutTime_ms, hyperion::Components component) +void PriorityMuxer::setInput(const int priority, const std::vector& 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); } diff --git a/libsrc/jsonserver/JsonClientConnection.cpp b/libsrc/jsonserver/JsonClientConnection.cpp index 6fa626ae..3a2b9503 100644 --- a/libsrc/jsonserver/JsonClientConnection.cpp +++ b/libsrc/jsonserver/JsonClientConnection.cpp @@ -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 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); diff --git a/libsrc/jsonserver/schema/schema-color.json b/libsrc/jsonserver/schema/schema-color.json index 02ab77da..fcbd606a 100644 --- a/libsrc/jsonserver/schema/schema-color.json +++ b/libsrc/jsonserver/schema/schema-color.json @@ -20,6 +20,10 @@ "type": "integer", "required": false }, + "origin": { + "type": "string", + "required": true + }, "color": { "type": "array", "required": true,