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 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="panel panel-default" >
<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 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>
<script src="/js/content_remote.js" ></script>

View File

@ -44,8 +44,9 @@ BoblightClientConnection::BoblightClientConnection(Hyperion* hyperion, QTcpSocke
BoblightClientConnection::~BoblightClientConnection()
{
// clear the current channel
_hyperion->clear(_priority);
// clear the current channel
if (_priority != 0 && _priority >= 128 && _priority < 254)
_hyperion->clear(_priority);
delete _socket;
}
@ -79,8 +80,9 @@ void BoblightClientConnection::readData()
void BoblightClientConnection::socketClosed()
{
// clear the current channel
_hyperion->clear(_priority);
// clear the current channel
if (_priority != 0 && _priority >= 128 && _priority < 254)
_hyperion->clear(_priority);
emit connectionClosed(this);
}
@ -155,6 +157,9 @@ void BoblightClientConnection::handleMessage(const QString & message)
rgb.green = green;
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
if (ledIndex == _ledColors.size() -1)
{
@ -180,21 +185,35 @@ void BoblightClientConnection::handleMessage(const QString & message)
int prio = messageParts[2].toInt(&rc);
if (rc && prio != _priority)
{
// clear the current channel
_hyperion->clear(_priority);
if (_priority != 0 && _hyperion->getPriorityInfo(_priority).componentId == hyperion::COMP_BOBLIGHTSERVER)
_hyperion->clear(_priority);
// register new priority
_hyperion->registerInput(prio, hyperion::COMP_BOBLIGHTSERVER, QString("Boblight@%1").arg(_socket->peerAddress().toString()));
if (prio < 128 || prio >= 254)
{
_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;
}
}
}
else if (messageParts[0] == "sync")
{
// send current color values to hyperion
_hyperion->setInput(_priority, _ledColors);
if (_priority != 0 && _priority >= 128 && _priority < 254)
_hyperion->setInput(_priority, _ledColors); // send current color values to hyperion
return;
}
}

View File

@ -168,10 +168,11 @@ int EffectEngine::runEffectScript(const QString &script, const QString &name, co
channelCleared(priority);
// 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::setInputImage, _hyperion, &Hyperion::setInputImage, Qt::QueuedConnection);
connect(effect, &QThread::finished, this, &EffectEngine::effectFinished);
connect(_hyperion, &Hyperion::finished, effect, &Effect::setInteruptionFlag, Qt::DirectConnection);
_activeEffects.push_back(effect);
// start the effect

View File

@ -6,9 +6,6 @@
#include <QTimer>
#include <QRgb>
#include <hyperion/Hyperion.h>
#include <hyperion/HyperionIManager.h>
FlatBufferClient::FlatBufferClient(QTcpSocket* socket, const int &timeout, QObject *parent)
: QObject(parent)
, _log(Logger::getInstance("FLATBUFSERVER"))
@ -72,7 +69,9 @@ void FlatBufferClient::disconnected()
{
Debug(_log, "Socket Closed");
_socket->deleteLater();
emit clearGlobalInput(_priority);
if (_priority != 0 && _priority >= 100 && _priority < 200)
emit clearGlobalInput(_priority);
emit clientDisconnected();
}
@ -122,6 +121,13 @@ void FlatBufferClient::registationRequired(const int priority)
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();
emit registerGlobalInput(_priority, hyperion::COMP_FLATBUFSERVER, regReq->origin()->c_str()+_clientAddress);

View File

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

View File

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

View File

@ -7,12 +7,6 @@
#include <QTimer>
#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.)
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.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()
if(priority != _priority)
{
@ -154,6 +154,12 @@ void ProtoClientConnection::handleImageCommand(const proto::ImageRequest &messag
int height = message.imageheight();
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()
if(priority != _priority)
{

View File

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