mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Proto- and Flatbuffer now share their input to all instances
Signed-off-by: Paulchen-Panther <Paulchen-Panter@protonmail.com>
This commit is contained in:
parent
f5d0fe34a8
commit
ce2f0a17d5
@ -178,10 +178,10 @@
|
||||
"conf_colors_smoothing_intro": "Glätte den Farbverlauf und Helligkeitsänderungen um nicht von schnellen Übergängen abgelenkt zu werden.",
|
||||
"conf_colors_blackborder_intro": "Ignoriere schwarze Balken, jeder Modus nutzt einen anderen Algorithmus um diese zu erkennen. Erhöhe die Schwelle, sollte es nicht funktionieren.",
|
||||
"conf_network_net_intro" : "Einstellungen zum Netzwerk die für alle Netzwerk-Dienste gelten",
|
||||
"conf_network_json_intro": "Der JSON-RPC-Port dieser Hyperion-Instanz, wird genutzt zur Fernsteuerung.",
|
||||
"conf_network_json_intro": "Der JSON-RPC-Port aller Hyperion-Instanzen, wird genutzt zur Fernsteuerung.",
|
||||
"conf_network_bobl_intro": "Boblight Empfänger",
|
||||
"conf_network_fbs_intro": "Google Flatbuffers Empfänger. Wird genutzt für schnellen Bildempfang.",
|
||||
"conf_network_proto_intro": "Der PROTO-Port dieser Hyperion-Instanz, wird genutzt für \"Bildstreams\" (HyperionScreenCap, Kodi Addon, ...)",
|
||||
"conf_network_proto_intro": "Der PROTO-Port aller Hyperion-Instanzen, wird genutzt für \"Bildstreams\" (HyperionScreenCap, Kodi Addon, Android Hyperion Grabber, ...)",
|
||||
"conf_network_forw_intro": "Leite alles an eine zweite Hyperion Instanz weiter, diese kann dann mit einer anderen LED Steuerung genutzt werden",
|
||||
"conf_logging_label_intro": "Überprüfe die Meldungen im Prokotoll um zu erfahren was Hyperion gerade beschäftigt. Je nach eingestellter Protokoll-Stufe siehst du mehr oder weniger Informationen.",
|
||||
"conf_logging_btn_pbupload": "Bericht für Supportanfrage hochladen",
|
||||
|
@ -185,10 +185,10 @@
|
||||
"conf_colors_smoothing_intro" : "Smoothing flattens color/brightness changes to reduce annoying distraction.",
|
||||
"conf_colors_blackborder_intro" : "Skip black bars wherever they are. Each mode use another detection algorithm which is tuned for special situations. Higher the threshold if it doesn't work for you.",
|
||||
"conf_network_net_intro" : "Network related settings which are applied to all network services.",
|
||||
"conf_network_json_intro" : "The JSON-RPC-Port of this Hyperion instance, used for remote control.",
|
||||
"conf_network_json_intro" : "The JSON-RPC-Port of all Hyperion instances, used for remote control.",
|
||||
"conf_network_bobl_intro" : "Receiver for Boblight",
|
||||
"conf_network_fbs_intro" : "Google Flatbuffers Receiver. Used for fast image transmission.",
|
||||
"conf_network_proto_intro" : "The PROTO-Port of this Hyperion instance, used for picture streams (HyperionScreenCap, Kodi Addon, ...)",
|
||||
"conf_network_proto_intro" : "The PROTO-Port of all Hyperion instances, used for picture streams (HyperionScreenCap, Kodi Addon, Android Hyperion Grabber, ...)",
|
||||
"conf_network_forw_intro" : "Forward all input to a second Hyperion instance which could be driven with another led controller",
|
||||
"conf_logging_label_intro" : "Area to check log messages, depending on loglevel setting you see more or less information.",
|
||||
"conf_logging_btn_pbupload" : "Upload report for support request",
|
||||
|
@ -90,10 +90,9 @@ $(document).ready(function() {
|
||||
{
|
||||
$('.sstbody').html("");
|
||||
var prios = window.serverInfo.priorities;
|
||||
var i;
|
||||
var clearAll = false;
|
||||
|
||||
for(i = 0; i < prios.length; i++)
|
||||
for(var i = 0; i < prios.length; i++)
|
||||
{
|
||||
var origin = prios[i].origin ? prios[i].origin : "System";
|
||||
origin = origin.split("@");
|
||||
@ -339,22 +338,22 @@ $(document).ready(function() {
|
||||
$(window.hyperion).on("components-updated",updateComponents);
|
||||
|
||||
$(window.hyperion).on("cmd-priorities-update", function(event){
|
||||
window.serverInfo.priorities = event.response.data.priorities
|
||||
window.serverInfo.priorities_autoselect = event.response.data.priorities_autoselect
|
||||
updateInputSelect()
|
||||
window.serverInfo.priorities = event.response.data.priorities;
|
||||
window.serverInfo.priorities_autoselect = event.response.data.priorities_autoselect;
|
||||
updateInputSelect();
|
||||
});
|
||||
$(window.hyperion).on("cmd-imageToLedMapping-update", function(event){
|
||||
window.serverInfo.imageToLedMappingType = event.response.data.imageToLedMappingType
|
||||
updateLedMapping()
|
||||
window.serverInfo.imageToLedMappingType = event.response.data.imageToLedMappingType;
|
||||
updateLedMapping();
|
||||
});
|
||||
|
||||
$(window.hyperion).on("cmd-videomode-update", function(event){
|
||||
window.serverInfo.videomode = event.response.data.videomode
|
||||
updateVideoMode()
|
||||
window.serverInfo.videomode = event.response.data.videomode;
|
||||
updateVideoMode();
|
||||
});
|
||||
|
||||
$(window.hyperion).on("cmd-effects-update", function(event){
|
||||
window.serverInfo.effects = event.response.data.effects
|
||||
window.serverInfo.effects = event.response.data.effects;
|
||||
updateEffectlist();
|
||||
});
|
||||
|
||||
|
@ -183,18 +183,6 @@ public:
|
||||
/// @return json config
|
||||
const QJsonObject& getQJsonConfig();
|
||||
|
||||
///
|
||||
/// @brief Register a new input by priority, the priority is not active (timeout -100 isn't muxer recognized) until you start to update the data with setInput()
|
||||
/// A repeated call to update the base data of a known priority won't overwrite their current timeout
|
||||
/// @param[in] priority The priority of the channel
|
||||
/// @param[in] component The component of the channel
|
||||
/// @param[in] origin Who set the channel (CustomString@IP)
|
||||
/// @param[in] owner Specific owner string, might be empty
|
||||
/// @param[in] smooth_cfg The smooth id to use
|
||||
///
|
||||
void registerInput(const int priority, const hyperion::Components& component, const QString& origin = "System", const QString& owner = "", unsigned smooth_cfg = 0);
|
||||
|
||||
|
||||
/// enable/disable automatic/priorized source selection
|
||||
/// @param enabled the state
|
||||
void setSourceAutoSelectEnabled(bool enabled);
|
||||
@ -242,6 +230,17 @@ public:
|
||||
const QString & getActiveDevice();
|
||||
|
||||
public slots:
|
||||
///
|
||||
/// @brief Register a new input by priority, the priority is not active (timeout -100 isn't muxer recognized) until you start to update the data with setInput()
|
||||
/// A repeated call to update the base data of a known priority won't overwrite their current timeout
|
||||
/// @param[in] priority The priority of the channel
|
||||
/// @param[in] component The component of the channel
|
||||
/// @param[in] origin Who set the channel (CustomString@IP)
|
||||
/// @param[in] owner Specific owner string, might be empty
|
||||
/// @param[in] smooth_cfg The smooth id to use
|
||||
///
|
||||
void registerInput(const int priority, const hyperion::Components& component, const QString& origin = "System", const QString& owner = "", unsigned smooth_cfg = 0);
|
||||
|
||||
///
|
||||
/// @brief Update the current color of a priority (prev registered with registerInput())
|
||||
/// DO NOT use this together with setInputImage() at the same time!
|
||||
@ -262,7 +261,7 @@ public slots:
|
||||
/// @param clearEffect Should be true when NOT called from an effect
|
||||
/// @return True on success, false when priority is not found
|
||||
///
|
||||
bool setInputImage(const int priority, const Image<ColorRgb>& image, int64_t timeout_ms = -1, const bool& clearEffect = true);
|
||||
bool setInputImage(const int priority, const Image<ColorRgb>& image, const int64_t timeout_ms = -1, const bool& clearEffect = true);
|
||||
|
||||
///
|
||||
/// Writes a single color to all the leds for the given time and priority
|
||||
@ -271,10 +270,11 @@ public slots:
|
||||
///
|
||||
/// @param[in] priority The priority of the written color
|
||||
/// @param[in] ledColor The color to write to the leds
|
||||
/// @param[in] origin The setter
|
||||
/// @param[in] timeout_ms The time the leds are set to the given color [ms]
|
||||
/// @param[in] origin The setter
|
||||
/// @param clearEffect Should be true when NOT called from an effect
|
||||
///
|
||||
void setColor(int priority, const ColorRgb &ledColor, const int timeout_ms = -1, const QString& origin = "System" ,bool clearEffects = true);
|
||||
void setColor(const int priority, const ColorRgb &ledColor, const int timeout_ms = -1, const QString& origin = "System" ,bool clearEffects = true);
|
||||
|
||||
///
|
||||
/// @brief Set the given priority to inactive
|
||||
@ -305,7 +305,7 @@ public slots:
|
||||
/// @param[in] priority The priority channel
|
||||
/// @return True on success else false (not found)
|
||||
///
|
||||
bool clear(int priority);
|
||||
bool clear(const int priority);
|
||||
|
||||
///
|
||||
/// @brief Clears all priority channels. This will switch the leds off until a new priority is written.
|
||||
|
@ -62,10 +62,9 @@ public:
|
||||
///
|
||||
/// @brief Stop a Hyperion instance
|
||||
/// @param instance Instance index
|
||||
/// @param block If true return when thread has been started
|
||||
/// @return Return true on success, false if not found in db
|
||||
///
|
||||
bool stopInstance(const quint8& inst, const bool& block = false);
|
||||
bool stopInstance(const quint8& inst);
|
||||
|
||||
///
|
||||
/// @brief Create a new Hyperion instance entry in db
|
||||
|
@ -3,6 +3,7 @@
|
||||
// util
|
||||
#include <utils/Image.h>
|
||||
#include <utils/ColorRgb.h>
|
||||
#include <utils/Components.h>
|
||||
|
||||
// qt
|
||||
#include <QObject>
|
||||
@ -27,6 +28,10 @@ public:
|
||||
void operator=(GlobalSignals const&) = delete;
|
||||
|
||||
signals:
|
||||
///////////////////////////////////////
|
||||
///////////// TO HYPERION /////////////
|
||||
///////////////////////////////////////
|
||||
|
||||
///
|
||||
/// @brief PIPE SystemCapture images from GrabberWrapper to Hyperion class
|
||||
/// @param name The name of the platform capture that is currently active
|
||||
@ -39,5 +44,56 @@ signals:
|
||||
/// @param name The name of the v4l capture (path) that is currently active
|
||||
/// @param image The prepared image
|
||||
///
|
||||
void setV4lImage(const QString& name, const Image<ColorRgb> & image);
|
||||
void setV4lImage(const QString& name, const Image<ColorRgb>& image);
|
||||
|
||||
///
|
||||
/// @brief PIPE the register command for a new global input over HyperionDaemon to Hyperion class
|
||||
/// @param[in] priority The priority of the channel
|
||||
/// @param[in] component The component of the channel
|
||||
/// @param[in] origin Who set the channel (CustomString@IP)
|
||||
/// @param[in] owner Specific owner string, might be empty
|
||||
/// @param[in] smooth_cfg The smooth id to use
|
||||
///
|
||||
void registerGlobalInput(const int priority, const hyperion::Components& component, const QString& origin = "External", const QString& owner = "", unsigned smooth_cfg = 0);
|
||||
|
||||
///
|
||||
/// @brief PIPE the clear command for the global priority channel over HyperionDaemon to Hyperion class
|
||||
/// @param[in] priority The priority channel
|
||||
///
|
||||
void clearGlobalInput(int priority);
|
||||
|
||||
///
|
||||
/// @brief PIPE the clearAll command over HyperionDaemon to Hyperion class
|
||||
///
|
||||
void clearAllGlobalInput(bool forceClearAll=false);
|
||||
|
||||
///
|
||||
/// @brief PIPE external images over HyperionDaemon to Hyperion class
|
||||
/// @param[in] priority The priority of the channel
|
||||
/// @param image The prepared image
|
||||
/// @param[in] timeout_ms The timeout in milliseconds
|
||||
/// @param clearEffect Should be true when NOT called from an effect
|
||||
///
|
||||
void setGlobalImage(const int priority, const Image<ColorRgb>& image, const int timeout_ms, const bool& clearEffect = true);
|
||||
|
||||
///
|
||||
/// @brief PIPE external color message over HyperionDaemon to Hyperion class
|
||||
/// @param[in] priority The priority of the channel
|
||||
/// @param image The prepared color
|
||||
/// @param[in] timeout_ms The timeout in milliseconds
|
||||
/// @param[in] origin The setter
|
||||
/// @param clearEffect Should be true when NOT called from an effect
|
||||
///
|
||||
void setGlobalColor(const int priority, const ColorRgb &ledColor, const int timeout_ms, const QString& origin = "External" ,bool clearEffects = true);
|
||||
|
||||
///////////////////////////////////////
|
||||
//////////// FROM HYPERION ////////////
|
||||
///////////////////////////////////////
|
||||
|
||||
///
|
||||
/// @brief PIPE a registration request from the Hyperion class to the priority channel
|
||||
/// @param[in] priority The priority channel
|
||||
///
|
||||
void globalRegRequired(int priority);
|
||||
|
||||
};
|
||||
|
@ -17,7 +17,6 @@ FlatBufferClient::FlatBufferClient(QTcpSocket* socket, const int &timeout, QObje
|
||||
, _timeoutTimer(new QTimer(this))
|
||||
, _timeout(timeout * 1000)
|
||||
, _priority()
|
||||
, _hyperion(HyperionIManager::getInstance()->getHyperionInstance())
|
||||
{
|
||||
// timer setup
|
||||
_timeoutTimer->setSingleShot(true);
|
||||
@ -72,8 +71,8 @@ void FlatBufferClient::forceClose()
|
||||
void FlatBufferClient::disconnected()
|
||||
{
|
||||
Debug(_log, "Socket Closed");
|
||||
_socket->deleteLater();
|
||||
_hyperion->clear(_priority);
|
||||
_socket->deleteLater();
|
||||
emit clearGlobalInput(_priority);
|
||||
emit clientDisconnected();
|
||||
}
|
||||
|
||||
@ -103,16 +102,28 @@ void FlatBufferClient::handleColorCommand(const hyperionnet::Color *colorReq)
|
||||
color.blue = qBlue(rgbData);
|
||||
|
||||
// set output
|
||||
_hyperion->setColor(_priority, color, colorReq->duration());
|
||||
emit setGlobalInputColor(_priority, color, colorReq->duration());
|
||||
|
||||
// send reply
|
||||
sendSuccessReply();
|
||||
}
|
||||
|
||||
void FlatBufferClient::registationRequired(const int priority)
|
||||
{
|
||||
if (_priority == priority)
|
||||
{
|
||||
auto reply = hyperionnet::CreateReplyDirect(_builder, nullptr, -1, -1);
|
||||
_builder.Finish(reply);
|
||||
|
||||
// send reply
|
||||
sendMessage();
|
||||
}
|
||||
}
|
||||
|
||||
void FlatBufferClient::handleRegisterCommand(const hyperionnet::Register *regReq)
|
||||
{
|
||||
_priority = regReq->priority();
|
||||
_hyperion->registerInput(_priority, hyperion::COMP_FLATBUFSERVER, regReq->origin()->c_str()+_clientAddress);
|
||||
emit registerGlobalInput(_priority, hyperion::COMP_FLATBUFSERVER, regReq->origin()->c_str()+_clientAddress);
|
||||
|
||||
auto reply = hyperionnet::CreateReplyDirect(_builder, nullptr, -1, (_priority ? _priority : -1));
|
||||
_builder.Finish(reply);
|
||||
@ -142,7 +153,7 @@ void FlatBufferClient::handleImageCommand(const hyperionnet::Image *image)
|
||||
|
||||
Image<ColorRgb> imageDest(width, height);
|
||||
memmove(imageDest.memptr(), imageData->data(), imageData->size());
|
||||
_hyperion->setInputImage(_priority, imageDest, duration);
|
||||
emit setGlobalInputImage(_priority, imageDest, duration);
|
||||
}
|
||||
|
||||
// send reply
|
||||
@ -156,7 +167,7 @@ void FlatBufferClient::handleClearCommand(const hyperionnet::Clear *clear)
|
||||
const int priority = clear->priority();
|
||||
|
||||
if (priority == -1) {
|
||||
_hyperion->clearall();
|
||||
emit clearAllGlobalInput();
|
||||
}
|
||||
else {
|
||||
// Check if we are clearing ourselves.
|
||||
@ -164,7 +175,7 @@ void FlatBufferClient::handleClearCommand(const hyperionnet::Clear *clear)
|
||||
_priority = -1;
|
||||
}
|
||||
|
||||
_hyperion->clear(priority);
|
||||
emit clearGlobalInput(priority);
|
||||
}
|
||||
|
||||
sendSuccessReply();
|
||||
|
@ -37,12 +37,27 @@ signals:
|
||||
///
|
||||
/// @brief forward register data to HyperionDaemon
|
||||
///
|
||||
void registerGlobalInput(const int priority, const hyperion::Components& component, const QString& origin = "System", const QString& owner = "", unsigned smooth_cfg = 0);
|
||||
void registerGlobalInput(const int priority, const hyperion::Components& component, const QString& origin = "FlatBuffer", const QString& owner = "", unsigned smooth_cfg = 0);
|
||||
|
||||
///
|
||||
/// @brief Forward clear command to HyperionDaemon
|
||||
///
|
||||
void clearGlobalInput(const int priority);
|
||||
|
||||
///
|
||||
/// @brief Forward clearAll command to HyperionDaemon
|
||||
///
|
||||
void clearAllGlobalInput(bool forceClearAll=false);
|
||||
|
||||
///
|
||||
/// @brief forward prepared image to HyperionDaemon
|
||||
///
|
||||
const bool setGlobalInputImage(const int priority, const Image<ColorRgb>& image, const int timeout_ms = -1);
|
||||
const bool setGlobalInputImage(const int priority, const Image<ColorRgb>& image, const int timeout_ms, const bool& clearEffect = false);
|
||||
|
||||
///
|
||||
/// @brief Forward requested color
|
||||
///
|
||||
void setGlobalInputColor(const int priority, const ColorRgb &ledColor, const int timeout_ms, const QString& origin = "FlatBuffer" ,bool clearEffects = true);
|
||||
|
||||
///
|
||||
/// @brief Emits whenever the client disconnected
|
||||
@ -50,6 +65,11 @@ signals:
|
||||
void clientDisconnected();
|
||||
|
||||
public slots:
|
||||
///
|
||||
/// @brief Requests a registration from the client
|
||||
///
|
||||
void registationRequired(const int priority);
|
||||
|
||||
///
|
||||
/// @brief close the socket and call disconnected()
|
||||
///
|
||||
@ -125,7 +145,6 @@ private:
|
||||
QTimer *_timeoutTimer;
|
||||
int _timeout;
|
||||
int _priority;
|
||||
Hyperion* _hyperion;
|
||||
|
||||
QByteArray _receiveBuffer;
|
||||
|
||||
|
@ -210,7 +210,7 @@ bool FlatBufferConnection::parseReply(const hyperionnet::Reply *reply)
|
||||
}
|
||||
|
||||
// We got a registered reply.
|
||||
if (registered != -1 && registered != _priority)
|
||||
if (registered == -1 || registered != _priority)
|
||||
_registered = false;
|
||||
else
|
||||
_registered = true;
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
// util
|
||||
#include <utils/NetOrigin.h>
|
||||
#include <utils/GlobalSignals.h>
|
||||
|
||||
// qt
|
||||
#include <QJsonObject>
|
||||
@ -68,6 +69,12 @@ void FlatBufferServer::newConnection()
|
||||
FlatBufferClient *client = new FlatBufferClient(socket, _timeout, this);
|
||||
// internal
|
||||
connect(client, &FlatBufferClient::clientDisconnected, this, &FlatBufferServer::clientDisconnected);
|
||||
connect(client, &FlatBufferClient::registerGlobalInput, GlobalSignals::getInstance(), &GlobalSignals::registerGlobalInput);
|
||||
connect(client, &FlatBufferClient::clearGlobalInput, GlobalSignals::getInstance(), &GlobalSignals::clearGlobalInput);
|
||||
connect(client, &FlatBufferClient::clearAllGlobalInput, GlobalSignals::getInstance(), &GlobalSignals::clearAllGlobalInput);
|
||||
connect(client, &FlatBufferClient::setGlobalInputImage, GlobalSignals::getInstance(), &GlobalSignals::setGlobalImage);
|
||||
connect(client, &FlatBufferClient::setGlobalInputColor, GlobalSignals::getInstance(), &GlobalSignals::setGlobalColor);
|
||||
connect(GlobalSignals::getInstance(), &GlobalSignals::globalRegRequired, client, &FlatBufferClient::registationRequired);
|
||||
_openConnections.append(client);
|
||||
}
|
||||
else
|
||||
|
@ -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)
|
||||
|
@ -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))
|
||||
{
|
||||
|
@ -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();)
|
||||
|
@ -23,7 +23,6 @@ ProtoClientConnection::ProtoClientConnection(QTcpSocket* socket, const int &time
|
||||
, _timeoutTimer(new QTimer(this))
|
||||
, _timeout(timeout * 1000)
|
||||
, _priority()
|
||||
, _hyperion(HyperionIManager::getInstance()->getHyperionInstance())
|
||||
{
|
||||
// timer setup
|
||||
_timeoutTimer->setSingleShot(true);
|
||||
@ -80,8 +79,8 @@ void ProtoClientConnection::forceClose()
|
||||
void ProtoClientConnection::disconnected()
|
||||
{
|
||||
Debug(_log, "Socket Closed");
|
||||
_socket->deleteLater();
|
||||
_hyperion->clear(_priority);
|
||||
_socket->deleteLater();
|
||||
emit clearGlobalInput(_priority);
|
||||
emit clientDisconnected();
|
||||
}
|
||||
|
||||
@ -134,13 +133,13 @@ void ProtoClientConnection::handleColorCommand(const proto::ColorRequest &messag
|
||||
// make sure the prio is registered before setColor()
|
||||
if(priority != _priority)
|
||||
{
|
||||
_hyperion->clear(_priority);
|
||||
_hyperion->registerInput(priority, hyperion::COMP_PROTOSERVER, "Proto@"+_clientAddress);
|
||||
emit clearGlobalInput(_priority);
|
||||
emit registerGlobalInput(priority, hyperion::COMP_PROTOSERVER, "Proto@"+_clientAddress);
|
||||
_priority = priority;
|
||||
}
|
||||
|
||||
// set output
|
||||
_hyperion->setColor(_priority, color, duration);
|
||||
emit setGlobalInputColor(_priority, color, duration);
|
||||
|
||||
// send reply
|
||||
sendSuccessReply();
|
||||
@ -158,8 +157,8 @@ void ProtoClientConnection::handleImageCommand(const proto::ImageRequest &messag
|
||||
// make sure the prio is registered before setInput()
|
||||
if(priority != _priority)
|
||||
{
|
||||
_hyperion->clear(_priority);
|
||||
_hyperion->registerInput(priority, hyperion::COMP_PROTOSERVER, "Proto@"+_clientAddress);
|
||||
emit clearGlobalInput(_priority);
|
||||
emit registerGlobalInput(priority, hyperion::COMP_PROTOSERVER, "Proto@"+_clientAddress);
|
||||
_priority = priority;
|
||||
}
|
||||
|
||||
@ -174,7 +173,7 @@ void ProtoClientConnection::handleImageCommand(const proto::ImageRequest &messag
|
||||
Image<ColorRgb> image(width, height);
|
||||
memcpy(image.memptr(), imageData.c_str(), imageData.size());
|
||||
|
||||
_hyperion->setInputImage(_priority, image, duration);
|
||||
emit setGlobalInputImage(_priority, image, duration);
|
||||
|
||||
// send reply
|
||||
sendSuccessReply();
|
||||
@ -187,15 +186,15 @@ void ProtoClientConnection::handleClearCommand(const proto::ClearRequest &messag
|
||||
int priority = message.priority();
|
||||
|
||||
// clear priority
|
||||
_hyperion->clear(priority);
|
||||
emit clearGlobalInput(priority);
|
||||
// send reply
|
||||
sendSuccessReply();
|
||||
}
|
||||
|
||||
void ProtoClientConnection::handleClearallCommand()
|
||||
{
|
||||
// clear priority
|
||||
_hyperion->clearall();
|
||||
// clear all priority
|
||||
emit clearAllGlobalInput();
|
||||
|
||||
// send reply
|
||||
sendSuccessReply();
|
||||
|
@ -34,12 +34,42 @@ public:
|
||||
explicit ProtoClientConnection(QTcpSocket* socket, const int &timeout, QObject *parent);
|
||||
|
||||
signals:
|
||||
///
|
||||
/// @brief forward register data to HyperionDaemon
|
||||
///
|
||||
void registerGlobalInput(const int priority, const hyperion::Components& component, const QString& origin = "ProtoBuffer", const QString& owner = "", unsigned smooth_cfg = 0);
|
||||
|
||||
///
|
||||
/// @brief Forward clear command to HyperionDaemon
|
||||
///
|
||||
void clearGlobalInput(const int priority);
|
||||
|
||||
///
|
||||
/// @brief Forward clearAll command to HyperionDaemon
|
||||
///
|
||||
void clearAllGlobalInput(bool forceClearAll=false);
|
||||
|
||||
///
|
||||
/// @brief forward prepared image to HyperionDaemon
|
||||
///
|
||||
const bool setGlobalInputImage(const int priority, const Image<ColorRgb>& image, const int timeout_ms, const bool& clearEffect = false);
|
||||
|
||||
///
|
||||
/// @brief Forward requested color
|
||||
///
|
||||
void setGlobalInputColor(const int priority, const ColorRgb &ledColor, const int timeout_ms, const QString& origin = "ProtoBuffer" ,bool clearEffects = true);
|
||||
|
||||
///
|
||||
/// @brief Emits whenever the client disconnected
|
||||
///
|
||||
void clientDisconnected();
|
||||
|
||||
public slots:
|
||||
///
|
||||
/// @brief Requests a registration from the client
|
||||
///
|
||||
void registationRequired(const int priority) { if (_priority == priority) _priority = -1; };
|
||||
|
||||
///
|
||||
/// @brief close the socket and call disconnected()
|
||||
///
|
||||
@ -127,9 +157,6 @@ private:
|
||||
int _timeout;
|
||||
int _priority;
|
||||
|
||||
/// Link to Hyperion for writing led-values to a priority channel
|
||||
Hyperion* _hyperion;
|
||||
|
||||
/// The buffer used for reading data from the socket
|
||||
QByteArray _receiveBuffer;
|
||||
};
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
// util
|
||||
#include <utils/NetOrigin.h>
|
||||
#include <utils/GlobalSignals.h>
|
||||
|
||||
// qt
|
||||
#include <QJsonObject>
|
||||
@ -68,6 +69,12 @@ void ProtoServer::newConnection()
|
||||
ProtoClientConnection * client = new ProtoClientConnection(socket, _timeout, this);
|
||||
// internal
|
||||
connect(client, &ProtoClientConnection::clientDisconnected, this, &ProtoServer::clientDisconnected);
|
||||
connect(client, &ProtoClientConnection::registerGlobalInput, GlobalSignals::getInstance(), &GlobalSignals::registerGlobalInput);
|
||||
connect(client, &ProtoClientConnection::clearGlobalInput, GlobalSignals::getInstance(), &GlobalSignals::clearGlobalInput);
|
||||
connect(client, &ProtoClientConnection::clearAllGlobalInput, GlobalSignals::getInstance(), &GlobalSignals::clearAllGlobalInput);
|
||||
connect(client, &ProtoClientConnection::setGlobalInputImage, GlobalSignals::getInstance(), &GlobalSignals::setGlobalImage);
|
||||
connect(client, &ProtoClientConnection::setGlobalInputColor, GlobalSignals::getInstance(), &GlobalSignals::setGlobalColor);
|
||||
connect(GlobalSignals::getInstance(), &GlobalSignals::globalRegRequired, client, &ProtoClientConnection::registationRequired);
|
||||
_openConnections.append(client);
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user