every input sources trackes now its priority and ID to hyperion core

ATM all input sources except inputs via proto are tracked
This commit is contained in:
redpanther 2016-07-15 23:08:55 +02:00
parent 5432aa7d27
commit 505b83f028
12 changed files with 94 additions and 38 deletions

View File

@ -2,6 +2,7 @@
// stl includes
#include <list>
#include <map>
// QT includes
#include <QObject>
@ -46,6 +47,7 @@ class Hyperion : public QObject
public:
/// Type definition of the info structure used by the priority muxer
typedef PriorityMuxer::InputInfo InputInfo;
typedef std::map<std::string,int> PriorityRegister;
///
/// RGB-Color channel enumeration
@ -109,11 +111,24 @@ public:
/// @return The list of active effects
const std::list<ActiveEffectDefinition> &getActiveEffects();
///
/// gets the current json config object
/// @return json config
const Json::Value& getJsonConfig() { return _jsonConfig; };
/// get filename of configfile
/// @return the current config filename
std::string getConfigFileName() { return _configFile; };
/// register a input source to a priority channel
/// @param name uniq name of input source
/// @param priority priority channel
void registerPriority(const std::string name, const int priority);
/// unregister a input source to a priority channel
/// @param name uniq name of input source
void unRegisterPriority(const std::string name);
const PriorityRegister& getPriorityRegister() { return _priorityRegister; }
public slots:
///
/// Writes a single color to all the leds for the given time and priority
@ -307,4 +322,7 @@ private:
/// count of hardware leds
unsigned _hwLedCount;
/// register of input sources and it's prio channel
PriorityRegister _priorityRegister;
};

View File

@ -22,15 +22,15 @@
// project includes
#include "BoblightClientConnection.h"
BoblightClientConnection::BoblightClientConnection(QTcpSocket *socket, const int priority, Hyperion * hyperion)
BoblightClientConnection::BoblightClientConnection(QTcpSocket *socket, const int priority)
: QObject()
, _locale(QLocale::C)
, _socket(socket)
, _imageProcessor(ImageProcessorFactory::getInstance().newImageProcessor())
, _hyperion(hyperion)
, _hyperion(Hyperion::getInstance())
, _receiveBuffer()
, _priority(priority)
, _ledColors(hyperion->getLedCount(), ColorRgb::BLACK)
, _ledColors(Hyperion::getInstance()->getLedCount(), ColorRgb::BLACK)
, _log(Logger::getInstance("BOBLIGHT"))
{
// initalize the locale. Start with the default C-locale

View File

@ -27,7 +27,7 @@ public:
/// @param socket The Socket object for this connection
/// @param hyperion The Hyperion server
///
BoblightClientConnection(QTcpSocket * socket, const int priority, Hyperion * hyperion);
BoblightClientConnection(QTcpSocket * socket, const int priority);
///
/// Destructor

View File

@ -37,6 +37,9 @@ void BoblightServer::start()
_isActive = true;
emit statusChanged(_isActive);
_hyperion->registerPriority("Boblight", _priority);
}
void BoblightServer::stop()
@ -49,6 +52,9 @@ void BoblightServer::stop()
}
_isActive = false;
emit statusChanged(_isActive);
_hyperion->unRegisterPriority("Boblight");
}
@ -64,7 +70,7 @@ void BoblightServer::newConnection()
if (socket != nullptr)
{
Info(_log, "new connection");
BoblightClientConnection * connection = new BoblightClientConnection(socket, _priority, _hyperion);
BoblightClientConnection * connection = new BoblightClientConnection(socket, _priority);
_openConnections.insert(connection);
// register slot for cleaning up after the connection closed

View File

@ -181,6 +181,7 @@ int EffectEngine::runEffectScript(const std::string &script, const Json::Value &
_activeEffects.push_back(effect);
// start the effect
_hyperion->registerPriority("EFFECT: "+script, priority);
effect->start();
return 0;
@ -225,4 +226,5 @@ void EffectEngine::effectFinished(Effect *effect)
// cleanup the effect
effect->deleteLater();
_hyperion->unRegisterPriority("EFFECT: " + effect->getScript());
}

View File

@ -31,6 +31,8 @@ AmlogicWrapper::AmlogicWrapper(const unsigned grabWidth, const unsigned grabHeig
// Connect the QTimer to this
QObject::connect(&_timer, SIGNAL(timeout()), this, SLOT(action()));
_hyperion->registerPriority("Amlogic Grabber", _priority);
}
AmlogicWrapper::~AmlogicWrapper()

View File

@ -31,6 +31,8 @@ DispmanxWrapper::DispmanxWrapper(const unsigned grabWidth, const unsigned grabHe
// Connect the QTimer to this
QObject::connect(&_timer, SIGNAL(timeout()), this, SLOT(action()));
_hyperion->registerPriority("Dispmanx Grabber", _priority);
}
DispmanxWrapper::~DispmanxWrapper()

View File

@ -26,6 +26,8 @@ FramebufferWrapper::FramebufferWrapper(const std::string & device, const unsigne
// Connect the QTimer to this
QObject::connect(&_timer, SIGNAL(timeout()), this, SLOT(action()));
_hyperion->registerPriority("FrameBuffer Grabber", _priority);
}
FramebufferWrapper::~FramebufferWrapper()

View File

@ -26,6 +26,8 @@ OsxWrapper::OsxWrapper(const unsigned display, const unsigned grabWidth, const u
// Connect the QTimer to this
QObject::connect(&_timer, SIGNAL(timeout()), this, SLOT(action()));
_hyperion->registerPriority("OsxFrameGrabber", _priority);
}
OsxWrapper::~OsxWrapper()

View File

@ -15,10 +15,10 @@ V4L2Wrapper::V4L2Wrapper(const std::string &device,
double redSignalThreshold,
double greenSignalThreshold,
double blueSignalThreshold,
int hyperionPriority) :
_timeout_ms(1000),
_priority(hyperionPriority),
_grabber(device,
int hyperionPriority)
: _timeout_ms(1000)
, _priority(hyperionPriority)
, _grabber(device,
input,
videoStandard,
pixelFormat,
@ -26,18 +26,16 @@ V4L2Wrapper::V4L2Wrapper(const std::string &device,
height,
frameDecimation,
pixelDecimation,
pixelDecimation),
_processor(ImageProcessorFactory::getInstance().newImageProcessor()),
_hyperion(Hyperion::getInstance()),
_ledColors(Hyperion::getInstance()->getLedCount(), ColorRgb{0,0,0}),
_timer()
pixelDecimation)
, _processor(ImageProcessorFactory::getInstance().newImageProcessor())
, _hyperion(Hyperion::getInstance())
, _ledColors(Hyperion::getInstance()->getLedCount(), ColorRgb{0,0,0})
, _timer()
{
// set the signal detection threshold of the grabber
_grabber.setSignalThreshold(
redSignalThreshold,
greenSignalThreshold,
blueSignalThreshold,
50);
_grabber.setSignalThreshold( redSignalThreshold, greenSignalThreshold, blueSignalThreshold, 50);
_hyperion->registerPriority("V4L2", _priority);
// register the image type
qRegisterMetaType<Image<ColorRgb>>("Image<ColorRgb>");
@ -55,6 +53,7 @@ V4L2Wrapper::V4L2Wrapper(const std::string &device,
_hyperion, SLOT(setColors(int,std::vector<ColorRgb>,int)),
Qt::QueuedConnection);
// setup the higher prio source checker
// this will disable the v4l2 grabber when a source with hisher priority is active
_timer.setInterval(500);

View File

@ -541,32 +541,32 @@ MessageForwarder * Hyperion::getForwarder()
return _messageForwarder;
}
Hyperion::Hyperion(const Json::Value &jsonConfig, const std::string configFile) :
_ledString(createLedString(jsonConfig["leds"], createColorOrder(jsonConfig["device"]))),
_muxer(_ledString.leds().size()),
_raw2ledTransform(createLedColorsTransform(_ledString.leds().size(), jsonConfig["color"])),
_raw2ledTemperature(createLedColorsTemperature(_ledString.leds().size(), jsonConfig["color"])),
_raw2ledAdjustment(createLedColorsAdjustment(_ledString.leds().size(), jsonConfig["color"])),
_device(LedDeviceFactory::construct(jsonConfig["device"])),
_effectEngine(nullptr),
_messageForwarder(createMessageForwarder(jsonConfig["forwarder"])),
_jsonConfig(jsonConfig),
_configFile(configFile),
_timer(),
_log(Logger::getInstance("Core")),
_hwLedCount(_ledString.leds().size())
Hyperion::Hyperion(const Json::Value &jsonConfig, const std::string configFile)
: _ledString(createLedString(jsonConfig["leds"], createColorOrder(jsonConfig["device"])))
, _muxer(_ledString.leds().size())
, _raw2ledTransform(createLedColorsTransform(_ledString.leds().size(), jsonConfig["color"]))
, _raw2ledTemperature(createLedColorsTemperature(_ledString.leds().size(), jsonConfig["color"]))
, _raw2ledAdjustment(createLedColorsAdjustment(_ledString.leds().size(), jsonConfig["color"]))
, _device(LedDeviceFactory::construct(jsonConfig["device"]))
, _effectEngine(nullptr)
, _messageForwarder(createMessageForwarder(jsonConfig["forwarder"]))
, _jsonConfig(jsonConfig)
, _configFile(configFile)
, _timer()
, _log(Logger::getInstance("Core"))
, _hwLedCount(_ledString.leds().size())
{
if (!_raw2ledAdjustment->verifyAdjustments())
{
throw std::runtime_error("HYPERION ERROR: Color adjustment incorrectly set");
throw std::runtime_error("Color adjustment incorrectly set");
}
if (!_raw2ledTemperature->verifyCorrections())
{
throw std::runtime_error("HYPERION ERROR: Color temperature incorrectly set");
throw std::runtime_error("Color temperature incorrectly set");
}
if (!_raw2ledTransform->verifyTransforms())
{
throw std::runtime_error("HYPERION ERROR: Color transformation incorrectly set");
throw std::runtime_error("Color transformation incorrectly set");
}
// initialize the image processor factory
ImageProcessorFactory::getInstance().init(
@ -614,6 +614,26 @@ unsigned Hyperion::getLedCount() const
return _ledString.leds().size();
}
void Hyperion::registerPriority(const std::string name, const int priority)
{
Info(_log, "Register new input source named '%s' for priority channel '%d'", name.c_str(), priority );
for(auto const &entry : _priorityRegister)
{
WarningIf( ( entry.first != name && entry.second == priority), _log,
"Input source '%s' uses same priority channel (%d) as '%s'.", name.c_str(), priority, entry.first.c_str());
}
_priorityRegister.emplace(name,priority);
}
void Hyperion::unRegisterPriority(const std::string name)
{
Info(_log, "Unregister input source named '%s' from priority register", name.c_str());
_priorityRegister.erase(name);
}
void Hyperion::setColor(int priority, const ColorRgb &color, const int timeout_ms, bool clearEffects)
{
// create led output

View File

@ -29,6 +29,9 @@ UDPListener::UDPListener(const int priority, const int timeout, const std::strin
// Set trigger for incoming connections
connect(_server, SIGNAL(readyRead()), this, SLOT(readPendingDatagrams()));
_hyperion->registerPriority("UDPLISTENER", _priority);
}
UDPListener::~UDPListener()