Proto- and Flatbuffer now share their input to all instances

Signed-off-by: Paulchen-Panther <Paulchen-Panter@protonmail.com>
This commit is contained in:
Paulchen-Panther
2019-07-29 19:09:26 +02:00
parent f5d0fe34a8
commit ce2f0a17d5
16 changed files with 208 additions and 76 deletions

View File

@@ -17,6 +17,7 @@
// utils
#include <utils/hyperion.h>
#include <utils/GlobalSignals.h>
// Leddevice includes
#include <leddevice/LedDeviceWrapper.h>
@@ -133,6 +134,13 @@ void Hyperion::start()
// create the Daemon capture interface
_captureCont = new CaptureCont(this);
// forwards global signals to the corresponding slots
connect(GlobalSignals::getInstance(), &GlobalSignals::registerGlobalInput, this, &Hyperion::registerInput);
connect(GlobalSignals::getInstance(), &GlobalSignals::clearGlobalInput, this, &Hyperion::clear);
connect(GlobalSignals::getInstance(), &GlobalSignals::clearAllGlobalInput, this, &Hyperion::clearall);
connect(GlobalSignals::getInstance(), &GlobalSignals::setGlobalColor, this, &Hyperion::setColor);
connect(GlobalSignals::getInstance(), &GlobalSignals::setGlobalImage, this, &Hyperion::setInputImage);
// if there is no startup / background eff and no sending capture interface we probably want to push once BLACK (as PrioMuxer won't emit a prioritiy change)
update();
@@ -325,6 +333,12 @@ bool Hyperion::setInput(const int priority, const std::vector<ColorRgb>& ledColo
bool Hyperion::setInputImage(const int priority, const Image<ColorRgb>& image, int64_t timeout_ms, const bool& clearEffect)
{
if (!_muxer.hasPriority(priority))
{
emit GlobalSignals::getInstance()->globalRegRequired(priority);
return false;
}
if(_muxer.setInputImage(priority, image, timeout_ms))
{
// clear effect if this call does not come from an effect
@@ -345,7 +359,7 @@ bool Hyperion::setInputInactive(const quint8& priority)
return _muxer.setInputInactive(priority);
}
void Hyperion::setColor(int priority, const ColorRgb &color, const int timeout_ms, const QString& origin, bool clearEffects)
void Hyperion::setColor(const int priority, const ColorRgb &color, const int timeout_ms, const QString& origin, bool clearEffects)
{
// clear effect if this call does not come from an effect
if(clearEffects)
@@ -379,7 +393,7 @@ void Hyperion::adjustmentsUpdated()
update();
}
bool Hyperion::clear(int priority)
bool Hyperion::clear(const int priority)
{
// send clear signal to the effect engine
// (outside the check so the effect gets cleared even when the effect is not sending colors)

View File

@@ -69,17 +69,17 @@ bool HyperionIManager::startInstance(const quint8& inst, const bool& block)
// setup thread management
connect(hyperionThread, &QThread::started, hyperion, &Hyperion::start);
connect(hyperionThread, &QThread::finished, hyperionThread, &QObject::deleteLater);
connect(hyperion, &Hyperion::started, HyperionIManager::getInstance(), &HyperionIManager::handleStarted);
connect(hyperion, &Hyperion::finished, HyperionIManager::getInstance(), &HyperionIManager::handleFinished);
connect(hyperion, &Hyperion::started, this, &HyperionIManager::handleStarted);
connect(hyperion, &Hyperion::finished, this, &HyperionIManager::handleFinished);
connect(hyperion, &Hyperion::finished, hyperionThread, &QThread::quit, Qt::DirectConnection);
// setup further connections
// from Hyperion
connect(hyperion, &Hyperion::settingsChanged, HyperionIManager::getInstance(), &HyperionIManager::settingsChanged);
connect(hyperion, &Hyperion::videoMode, HyperionIManager::getInstance(), &HyperionIManager::requestVideoMode);
connect(hyperion, &Hyperion::componentStateChanged, HyperionIManager::getInstance(), &HyperionIManager::componentStateChanged);
connect(hyperion, &Hyperion::settingsChanged, this, &HyperionIManager::settingsChanged);
connect(hyperion, &Hyperion::videoMode, this, &HyperionIManager::requestVideoMode);
connect(hyperion, &Hyperion::componentStateChanged, this, &HyperionIManager::componentStateChanged);
// to Hyperion
connect(HyperionIManager::getInstance(), &HyperionIManager::newVideoMode, hyperion, &Hyperion::newVideoMode);
connect(this, &HyperionIManager::newVideoMode, hyperion, &Hyperion::newVideoMode);
// add to queue and start
_startQueue << inst;
@@ -103,7 +103,7 @@ bool HyperionIManager::startInstance(const quint8& inst, const bool& block)
return false;
}
bool HyperionIManager::stopInstance(const quint8& inst, const bool& block)
bool HyperionIManager::stopInstance(const quint8& inst)
{
// inst 0 can't be stopped
if(!isInstAllowed(inst))
@@ -121,10 +121,6 @@ bool HyperionIManager::stopInstance(const quint8& inst, const bool& block)
// update db
_instanceTable->setEnable(inst, false);
if(block)
{
hyperion->thread()->wait(10000);
}
return true;
}
Debug(_log,"Can't stop Hyperion instance index '%d' with name '%s' it's not running'", inst, QSTRING_CSTR(_instanceTable->getNamebyIndex(inst)));
@@ -157,8 +153,7 @@ bool HyperionIManager::deleteInstance(const quint8& inst)
return false;
// stop it if required as blocking and wait
if (stopInstance(inst, true))
;
stopInstance(inst);
if(_instanceTable->deleteInstance(inst))
{

View File

@@ -280,7 +280,6 @@ void PriorityMuxer::setCurrentTime(void)
{
const int64_t now = QDateTime::currentMSecsSinceEpoch();
int newPriority;
_activeInputs.contains(140) ? newPriority = 140 : newPriority = PriorityMuxer::LOWEST_PRIORITY;
_activeInputs.contains(0) ? newPriority = 0 : newPriority = PriorityMuxer::LOWEST_PRIORITY;
for (auto infoIt = _activeInputs.begin(); infoIt != _activeInputs.end();)