mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Get server info implemented for jsonserver
This commit is contained in:
parent
cb38baa985
commit
10a566e2ca
@ -1,6 +1,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
// stl includes
|
||||
#include <list>
|
||||
|
||||
// QT includes
|
||||
#include <QObject>
|
||||
#include <QTimer>
|
||||
@ -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<int> getActivePriorities() const;
|
||||
|
||||
const InputInfo& getPriorityInfo(const int priority) const;
|
||||
|
||||
private slots:
|
||||
void update();
|
||||
|
||||
|
@ -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<int> 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
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
// Qt includes
|
||||
#include <QResource>
|
||||
#include <QDateTime>
|
||||
|
||||
// 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<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)
|
||||
|
Loading…
Reference in New Issue
Block a user