The WebUI remote page has been rearranged

Set interuption flag to running effects when hyperion emits finished signal
Protobuffer, Flatbuffer and Boblight connection priority check to avoid unwanted program behavior

Signed-off-by: Paulchen-Panther <Paulchen-Panter@protonmail.com>
This commit is contained in:
Paulchen-Panther 2019-08-02 21:12:13 +02:00
parent 2e8014bdbb
commit cacfbada7a
No known key found for this signature in database
GPG Key ID: 84E3B692456B6840
8 changed files with 66 additions and 33 deletions

View File

@ -68,13 +68,6 @@
</div> </div>
</div> </div>
</div> </div>
<div class="col-md-6 col-lg-6 col-xxl-5">
<div class="panel panel-default" >
<div class="panel-heading"><i class="fa fa-wifi fa-fw"></i><span data-i18n="remote_adjustment_label"></span></div>
<div class="panel-body" id="adjust_content">
</div>
</div>
</div>
<div class="col-md-6 col-lg-6 col-xxl-5"> <div class="col-md-6 col-lg-6 col-xxl-5">
<div class="panel panel-default" > <div class="panel panel-default" >
<div class="panel-heading"><i class="fa fa-wifi fa-fw"></i><span data-i18n="remote_videoMode_label"></span></div> <div class="panel-heading"><i class="fa fa-wifi fa-fw"></i><span data-i18n="remote_videoMode_label"></span></div>
@ -83,6 +76,13 @@
</div> </div>
</div> </div>
</div> </div>
<div class="col-md-6 col-lg-6 col-xxl-5">
<div class="panel panel-default" >
<div class="panel-heading"><i class="fa fa-wifi fa-fw"></i><span data-i18n="remote_adjustment_label"></span></div>
<div class="panel-body" id="adjust_content">
</div>
</div>
</div>
</div> </div>
</div> </div>
<script src="/js/content_remote.js" ></script> <script src="/js/content_remote.js" ></script>

View File

@ -44,8 +44,9 @@ BoblightClientConnection::BoblightClientConnection(Hyperion* hyperion, QTcpSocke
BoblightClientConnection::~BoblightClientConnection() BoblightClientConnection::~BoblightClientConnection()
{ {
// clear the current channel // clear the current channel
_hyperion->clear(_priority); if (_priority != 0 && _priority >= 128 && _priority < 254)
_hyperion->clear(_priority);
delete _socket; delete _socket;
} }
@ -79,8 +80,9 @@ void BoblightClientConnection::readData()
void BoblightClientConnection::socketClosed() void BoblightClientConnection::socketClosed()
{ {
// clear the current channel // clear the current channel
_hyperion->clear(_priority); if (_priority != 0 && _priority >= 128 && _priority < 254)
_hyperion->clear(_priority);
emit connectionClosed(this); emit connectionClosed(this);
} }
@ -155,6 +157,9 @@ void BoblightClientConnection::handleMessage(const QString & message)
rgb.green = green; rgb.green = green;
rgb.blue = blue; rgb.blue = blue;
if (_priority == 0 || _priority < 128 || _priority >= 254)
return;
// send current color values to hyperion if this is the last led assuming leds values are send in order of id // send current color values to hyperion if this is the last led assuming leds values are send in order of id
if (ledIndex == _ledColors.size() -1) if (ledIndex == _ledColors.size() -1)
{ {
@ -180,21 +185,35 @@ void BoblightClientConnection::handleMessage(const QString & message)
int prio = messageParts[2].toInt(&rc); int prio = messageParts[2].toInt(&rc);
if (rc && prio != _priority) if (rc && prio != _priority)
{ {
// clear the current channel if (_priority != 0 && _hyperion->getPriorityInfo(_priority).componentId == hyperion::COMP_BOBLIGHTSERVER)
_hyperion->clear(_priority); _hyperion->clear(_priority);
// register new priority if (prio < 128 || prio >= 254)
_hyperion->registerInput(prio, hyperion::COMP_BOBLIGHTSERVER, QString("Boblight@%1").arg(_socket->peerAddress().toString())); {
_priority = 128;
while (_hyperion->getActivePriorities().contains(_priority))
{
_priority += 1;
}
Warning(_log, "The priority %i is not in the priority range between 128 and 253. Priority %i is used instead.", prio, _priority);
}
else
{
// register new priority
_hyperion->registerInput(prio, hyperion::COMP_BOBLIGHTSERVER, QString("Boblight@%1").arg(_socket->peerAddress().toString()));
_priority = prio;
}
_priority = prio;
return; return;
} }
} }
} }
else if (messageParts[0] == "sync") else if (messageParts[0] == "sync")
{ {
// send current color values to hyperion if (_priority != 0 && _priority >= 128 && _priority < 254)
_hyperion->setInput(_priority, _ledColors); _hyperion->setInput(_priority, _ledColors); // send current color values to hyperion
return; return;
} }
} }

View File

@ -168,10 +168,11 @@ int EffectEngine::runEffectScript(const QString &script, const QString &name, co
channelCleared(priority); channelCleared(priority);
// create the effect // create the effect
Effect *effect = new Effect(_hyperion, priority, timeout, script, name, args, imageData); Effect *effect = new Effect(_hyperion, priority, timeout, script, name, args, imageData);
connect(effect, &Effect::setInput, _hyperion, &Hyperion::setInput, Qt::QueuedConnection); connect(effect, &Effect::setInput, _hyperion, &Hyperion::setInput, Qt::QueuedConnection);
connect(effect, &Effect::setInputImage, _hyperion, &Hyperion::setInputImage, Qt::QueuedConnection); connect(effect, &Effect::setInputImage, _hyperion, &Hyperion::setInputImage, Qt::QueuedConnection);
connect(effect, &QThread::finished, this, &EffectEngine::effectFinished); connect(effect, &QThread::finished, this, &EffectEngine::effectFinished);
connect(_hyperion, &Hyperion::finished, effect, &Effect::setInteruptionFlag, Qt::DirectConnection);
_activeEffects.push_back(effect); _activeEffects.push_back(effect);
// start the effect // start the effect

View File

@ -6,9 +6,6 @@
#include <QTimer> #include <QTimer>
#include <QRgb> #include <QRgb>
#include <hyperion/Hyperion.h>
#include <hyperion/HyperionIManager.h>
FlatBufferClient::FlatBufferClient(QTcpSocket* socket, const int &timeout, QObject *parent) FlatBufferClient::FlatBufferClient(QTcpSocket* socket, const int &timeout, QObject *parent)
: QObject(parent) : QObject(parent)
, _log(Logger::getInstance("FLATBUFSERVER")) , _log(Logger::getInstance("FLATBUFSERVER"))
@ -72,7 +69,9 @@ void FlatBufferClient::disconnected()
{ {
Debug(_log, "Socket Closed"); Debug(_log, "Socket Closed");
_socket->deleteLater(); _socket->deleteLater();
emit clearGlobalInput(_priority); if (_priority != 0 && _priority >= 100 && _priority < 200)
emit clearGlobalInput(_priority);
emit clientDisconnected(); emit clientDisconnected();
} }
@ -122,6 +121,13 @@ void FlatBufferClient::registationRequired(const int priority)
void FlatBufferClient::handleRegisterCommand(const hyperionnet::Register *regReq) void FlatBufferClient::handleRegisterCommand(const hyperionnet::Register *regReq)
{ {
if (regReq->priority() < 100 || regReq->priority() >= 200)
{
// Warning(_log, "Register request from client %s contains invalid priority %d. Valid rage is between 100 and 199.", QSTRING_CSTR(_clientAddress), regReq->priority());
sendErrorReply("The priority " + std::to_string(regReq->priority()) + " is not in the priority range between 100 and 199.");
return;
}
_priority = regReq->priority(); _priority = regReq->priority();
emit registerGlobalInput(_priority, hyperion::COMP_FLATBUFSERVER, regReq->origin()->c_str()+_clientAddress); emit registerGlobalInput(_priority, hyperion::COMP_FLATBUFSERVER, regReq->origin()->c_str()+_clientAddress);

View File

@ -12,10 +12,9 @@
class QTcpSocket; class QTcpSocket;
class QTimer; class QTimer;
class Hyperion;
namespace flatbuf { namespace flatbuf {
class HyperionRequest; class HyperionRequest;
} }
/// ///

View File

@ -217,5 +217,8 @@ bool FlatBufferConnection::parseReply(const hyperionnet::Reply *reply)
return true; return true;
} }
else
throw std::runtime_error(reply->error()->str());
return false; return false;
} }

View File

@ -7,12 +7,6 @@
#include <QTimer> #include <QTimer>
#include <QRgb> #include <QRgb>
// Hyperion includes
#include <hyperion/Hyperion.h>
// Hyperion instance manager includes
#include <hyperion/HyperionIManager.h>
// TODO Remove this class if third-party apps have been migrated (eg. Hyperion Android Gabber, Windows Screen grabber etc.) // TODO Remove this class if third-party apps have been migrated (eg. Hyperion Android Gabber, Windows Screen grabber etc.)
ProtoClientConnection::ProtoClientConnection(QTcpSocket* socket, const int &timeout, QObject *parent) ProtoClientConnection::ProtoClientConnection(QTcpSocket* socket, const int &timeout, QObject *parent)
@ -130,6 +124,12 @@ void ProtoClientConnection::handleColorCommand(const proto::ColorRequest &messag
color.green = qGreen(message.rgbcolor()); color.green = qGreen(message.rgbcolor());
color.blue = qBlue(message.rgbcolor()); color.blue = qBlue(message.rgbcolor());
if (priority < 100 || priority >= 200)
{
sendErrorReply("The priority " + std::to_string(priority) + " is not in the priority range between 100 and 199.");
return;
}
// make sure the prio is registered before setColor() // make sure the prio is registered before setColor()
if(priority != _priority) if(priority != _priority)
{ {
@ -154,6 +154,12 @@ void ProtoClientConnection::handleImageCommand(const proto::ImageRequest &messag
int height = message.imageheight(); int height = message.imageheight();
const std::string & imageData = message.imagedata(); const std::string & imageData = message.imagedata();
if (priority < 100 || priority >= 200)
{
sendErrorReply("The priority " + std::to_string(priority) + " is not in the priority range between 100 and 199.");
return;
}
// make sure the prio is registered before setInput() // make sure the prio is registered before setInput()
if(priority != _priority) if(priority != _priority)
{ {

View File

@ -11,10 +11,9 @@
class QTcpSocket; class QTcpSocket;
class QTimer; class QTimer;
class Hyperion;
namespace proto { namespace proto {
class HyperionRequest; class HyperionRequest;
} }
/// ///