Get server info implemented for jsonserver

This commit is contained in:
johan 2013-08-19 20:33:36 +02:00
parent cb38baa985
commit 10a566e2ca
3 changed files with 99 additions and 2 deletions

View File

@ -1,6 +1,8 @@
#pragma once #pragma once
// stl includes
#include <list>
// QT includes // QT includes
#include <QObject> #include <QObject>
#include <QTimer> #include <QTimer>
@ -21,6 +23,8 @@ class Hyperion : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
typedef PriorityMuxer::InputInfo InputInfo;
enum Color enum Color
{ {
RED, GREEN, BLUE RED, GREEN, BLUE
@ -49,6 +53,12 @@ public:
void clearall(); void clearall();
double getTransform(Transform transform, Color color) const;
QList<int> getActivePriorities() const;
const InputInfo& getPriorityInfo(const int priority) const;
private slots: private slots:
void update(); void update();

View File

@ -206,6 +206,53 @@ void Hyperion::clearall()
update(); 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<int> Hyperion::getActivePriorities() const
{
return _muxer.getPriorities();
}
const Hyperion::InputInfo &Hyperion::getPriorityInfo(const int priority) const
{
return _muxer.getInputInfo(priority);
}
void Hyperion::update() void Hyperion::update()
{ {
// Update the muxer, cleaning obsolete priorities // Update the muxer, cleaning obsolete priorities

View File

@ -9,6 +9,7 @@
// Qt includes // Qt includes
#include <QResource> #include <QResource>
#include <QDateTime>
// hyperion util includes // hyperion util includes
#include "hyperion/ImageProcessorFactory.h" #include "hyperion/ImageProcessorFactory.h"
@ -149,7 +150,46 @@ void JsonClientConnection::handleImageCommand(const Json::Value &message)
void JsonClientConnection::handleServerInfoCommand(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<int> 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) void JsonClientConnection::handleClearCommand(const Json::Value &message)