diff --git a/include/hyperion/Hyperion.h b/include/hyperion/Hyperion.h index 4a41b1fc..03edec7e 100644 --- a/include/hyperion/Hyperion.h +++ b/include/hyperion/Hyperion.h @@ -1,6 +1,8 @@ - #pragma once +// stl includes +#include + // QT includes #include #include @@ -21,6 +23,8 @@ class Hyperion : public QObject { Q_OBJECT public: + typedef PriorityMuxer::InputInfo InputInfo; + enum Color { RED, GREEN, BLUE @@ -49,6 +53,12 @@ public: void clearall(); + double getTransform(Transform transform, Color color) const; + + QList getActivePriorities() const; + + const InputInfo& getPriorityInfo(const int priority) const; + private slots: void update(); diff --git a/libsrc/hyperion/Hyperion.cpp b/libsrc/hyperion/Hyperion.cpp index 60e1c4dd..fc166b47 100644 --- a/libsrc/hyperion/Hyperion.cpp +++ b/libsrc/hyperion/Hyperion.cpp @@ -206,6 +206,53 @@ void Hyperion::clearall() update(); } +double Hyperion::getTransform(Hyperion::Transform transform, Hyperion::Color color) const +{ + // select the transform of the requested color + ColorTransform * t = nullptr; + switch (color) + { + case RED: + t = _redTransform; + break; + case GREEN: + t = _greenTransform; + break; + case BLUE: + t = _blueTransform; + break; + default: + assert(false); + } + + // set transform value + switch (transform) + { + case THRESHOLD: + return t->getThreshold(); + case GAMMA: + return t->getGamma(); + case BLACKLEVEL: + return t->getBlacklevel(); + case WHITELEVEL: + return t->getWhitelevel(); + default: + assert(false); + } + + return 999.0; +} + +QList Hyperion::getActivePriorities() const +{ + return _muxer.getPriorities(); +} + +const Hyperion::InputInfo &Hyperion::getPriorityInfo(const int priority) const +{ + return _muxer.getInputInfo(priority); +} + void Hyperion::update() { // Update the muxer, cleaning obsolete priorities diff --git a/libsrc/jsonserver/JsonClientConnection.cpp b/libsrc/jsonserver/JsonClientConnection.cpp index 1bbcbf97..7eaa8b10 100644 --- a/libsrc/jsonserver/JsonClientConnection.cpp +++ b/libsrc/jsonserver/JsonClientConnection.cpp @@ -9,6 +9,7 @@ // Qt includes #include +#include // hyperion util includes #include "hyperion/ImageProcessorFactory.h" @@ -149,7 +150,46 @@ void JsonClientConnection::handleImageCommand(const Json::Value &message) void JsonClientConnection::handleServerInfoCommand(const Json::Value &message) { - handleNotImplemented(); + // create result + Json::Value result; + result["success"] = true; + Json::Value & info = result["info"]; + + // collect priority information + Json::Value & priorities = info["priorities"]; + uint64_t now = QDateTime::currentMSecsSinceEpoch(); + QList activePriorities = _hyperion->getActivePriorities(); + foreach (int priority, activePriorities) { + const Hyperion::InputInfo & priorityInfo = _hyperion->getPriorityInfo(priority); + Json::Value & item = priorities[priorities.size()]; + item["priority"] = priority; + if (priorityInfo.timeoutTime_ms != -1) + { + item["duration_ms"] = priorityInfo.timeoutTime_ms - now; + } + } + + // collect transform information + Json::Value & transform = info["transform"]; + Json::Value & threshold = transform["threshold"]; + threshold.append(_hyperion->getTransform(Hyperion::THRESHOLD, Hyperion::RED)); + threshold.append(_hyperion->getTransform(Hyperion::THRESHOLD, Hyperion::GREEN)); + threshold.append(_hyperion->getTransform(Hyperion::THRESHOLD, Hyperion::BLUE)); + Json::Value & gamma = transform["gamma"]; + gamma.append(_hyperion->getTransform(Hyperion::GAMMA, Hyperion::RED)); + gamma.append(_hyperion->getTransform(Hyperion::GAMMA, Hyperion::GREEN)); + gamma.append(_hyperion->getTransform(Hyperion::GAMMA, Hyperion::BLUE)); + Json::Value & blacklevel = transform["blacklevel"]; + blacklevel.append(_hyperion->getTransform(Hyperion::BLACKLEVEL, Hyperion::RED)); + blacklevel.append(_hyperion->getTransform(Hyperion::BLACKLEVEL, Hyperion::GREEN)); + blacklevel.append(_hyperion->getTransform(Hyperion::BLACKLEVEL, Hyperion::BLUE)); + Json::Value & whitelevel = transform["whitelevel"]; + whitelevel.append(_hyperion->getTransform(Hyperion::WHITELEVEL, Hyperion::RED)); + whitelevel.append(_hyperion->getTransform(Hyperion::WHITELEVEL, Hyperion::GREEN)); + whitelevel.append(_hyperion->getTransform(Hyperion::WHITELEVEL, Hyperion::BLUE)); + + // send the result + sendMessage(result); } void JsonClientConnection::handleClearCommand(const Json::Value &message)