Skip to content

Commit 657fe00

Browse files
Paulchen-PantherPaulchen-Panther
Paulchen-Panther
authored and
Paulchen-Panther
committed
Troubleshooting and ...
- More i18n - Easy use of mutual exclusion in JsonAPI with QMutexLocker - Smoothing type "linear" hidden in the WebUI, because there is currently only one - Message forwarding implemented again - For compatibility to home assistants and other remote controls, "activeEffects" and "activeLedColor" has been added to the JSON-RPC - FlatBuffer clear now the Priority on disconnect - The information "available V4L2 devices" is now only displayed if the device list is not empty - LED device "PiBlaster" excluded from OSX build
1 parent a412c34 commit 657fe00

28 files changed

+339
-146
lines changed

assets/webconfig/i18n/de.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -565,12 +565,14 @@
565565
"edt_conf_fw_proto_itemtitle" : "Proto Ziel",
566566
"edt_conf_js_heading_title" : "JSON Server",
567567
"edt_conf_fbs_heading_title" : "Flatbuffers Server",
568+
"edt_conf_fbs_timeout_title" : "Zeitüberschreitung",
569+
"edt_conf_fbs_timeout_expl" : "Wenn für die angegebene Zeit keine Daten empfangen werden, wird die Komponente (vorübergehend) deaktiviert",
568570
"edt_conf_bobls_heading_title" : "Boblight Server",
569571
"edt_conf_udpl_heading_title" : "UDP Listener",
570572
"edt_conf_udpl_address_title" : "Adresse",
571573
"edt_conf_udpl_address_expl" : "Die Adresse auf der UDP Pakete akzeptiert werden.",
572574
"edt_conf_udpl_timeout_title" : "Zeitüberschreitung",
573-
"edt_conf_udpl_timeout_expl" : "Wenn für die angegeben Zeit keine UDP Pakete empfangen werden, wird die Komponente (vorübergehend) deaktiviert",
575+
"edt_conf_udpl_timeout_expl" : "Wenn für die angegebene Zeit keine UDP Pakete empfangen werden, wird die Komponente (vorübergehend) deaktiviert",
574576
"edt_conf_udpl_shared_title" : "Gemeinsam genutzt",
575577
"edt_conf_udpl_shared_expl" : "Wird gemeinsam über alle Hyperion Instanzen genutzt.",
576578
"edt_conf_webc_heading_title" : "Web Konfiguration",

assets/webconfig/i18n/en.json

+2
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,8 @@
566566
"edt_conf_fw_proto_itemtitle" : "Proto target",
567567
"edt_conf_js_heading_title" : "JSON Server",
568568
"edt_conf_fbs_heading_title" : "Flatbuffers Server",
569+
"edt_conf_fbs_timeout_title" : "Timeout",
570+
"edt_conf_fbs_timeout_expl" : "If no data are received for the given period, the component will be (soft) disabled.",
569571
"edt_conf_bobls_heading_title" : "Boblight Server",
570572
"edt_conf_udpl_heading_title" : "UDP Listener",
571573
"edt_conf_udpl_address_title" : "Address",

assets/webconfig/js/content_effectsconfigurator.js

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ $(document).ready( function() {
5050

5151
fileReader.onload = function () {
5252
imageData = this.result.split(',')[1];
53-
console.log(imageData);
5453
cbs.success(file.name);
5554
};
5655

assets/webconfig/js/ui_utils.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,9 @@ function createHelpTable(list, phead){
587587
{
588588
if(list[key].access != 'system')
589589
{
590+
// break one iteration (in the loop), if the schema has the entry hidden=true
591+
if ("options" in list[key] && "hidden" in list[key].options && (list[key].options.hidden))
592+
continue;
590593
var text = list[key].title.replace('title', 'expl');
591594
tbody.appendChild(createTableRow([$.i18n(list[key].title), $.i18n(text)], false, false));
592595

@@ -595,7 +598,9 @@ function createHelpTable(list, phead){
595598
var ilist = sortProperties(list[key].items.properties);
596599
for (ikey in ilist)
597600
{
598-
601+
// break one iteration (in the loop), if the schema has the entry hidden=true
602+
if ("options" in ilist[ikey] && "hidden" in ilist[ikey].options && (ilist[ikey].options.hidden))
603+
continue;
599604
var itext = ilist[ikey].title.replace('title', 'expl');
600605
tbody.appendChild(createTableRow([$.i18n(ilist[ikey].title), $.i18n(itext)], false, false));
601606
}

include/hyperion/Hyperion.h

+4-7
Original file line numberDiff line numberDiff line change
@@ -326,12 +326,6 @@ public slots:
326326
///
327327
ColorAdjustment * getAdjustment(const QString& id);
328328

329-
///
330-
/// Returns MessageForwarder Object
331-
/// @return instance of message forwarder object
332-
///
333-
MessageForwarder * getForwarder();
334-
335329
/// Tell Hyperion that the corrections have changed and the leds need to be updated
336330
void adjustmentsUpdated();
337331

@@ -345,7 +339,7 @@ public slots:
345339
const bool clear(int priority);
346340

347341
///
348-
/// Clears all priority channels. This will switch the leds off until a new priority is written.
342+
/// @brief Clears all priority channels. This will switch the leds off until a new priority is written.
349343
///
350344
void clearall(bool forceClearAll=false);
351345

@@ -416,6 +410,9 @@ public slots:
416410
/// Signal which is emitted, when a new json message should be forwarded
417411
void forwardJsonMessage(QJsonObject);
418412

413+
/// Signal which is emitted, when a new proto image should be forwarded
414+
void forwardProtoMessage(Image<ColorRgb>);
415+
419416
///
420417
/// @brief Is emitted from clients who request a videoMode change
421418
///

include/hyperion/MessageForwarder.h

+61-12
Original file line numberDiff line numberDiff line change
@@ -18,37 +18,86 @@
1818
#include <utils/ColorRgb.h>
1919
#include <utils/settings.h>
2020
#include <utils/Logger.h>
21+
#include <utils/Components.h>
22+
#include <utils/Image.h>
2123

24+
// Hyperion includes
25+
#include <hyperion/PriorityMuxer.h>
26+
27+
// Forward declaration
2228
class Hyperion;
29+
class QTcpSocket;
30+
class FlatBufferConnection;
2331

2432
class MessageForwarder : public QObject
2533
{
2634
Q_OBJECT
2735
public:
28-
29-
MessageForwarder(Hyperion* hyperion, const QJsonDocument & config);
36+
MessageForwarder(Hyperion* hyperion);
3037
~MessageForwarder();
3138

3239
void addJsonSlave(QString slave);
3340
void addProtoSlave(QString slave);
3441

35-
bool protoForwardingEnabled();
36-
bool jsonForwardingEnabled();
37-
bool forwardingEnabled() { return jsonForwardingEnabled() || protoForwardingEnabled(); };
38-
QStringList getProtoSlaves() const { return _protoSlaves; };
39-
QStringList getJsonSlaves() const { return _jsonSlaves; };
40-
4142
private slots:
4243
///
4344
/// @brief Handle settings update from Hyperion Settingsmanager emit or this constructor
4445
/// @param type settingyType from enum
4546
/// @param config configuration object
4647
///
47-
void handleSettingsUpdate(const settings::type& type, const QJsonDocument& config);
48+
void handleSettingsUpdate(const settings::type &type, const QJsonDocument &config);
49+
50+
///
51+
/// @brief Handle component state change MessageForwarder
52+
/// @param component The component from enum
53+
/// @param enable The new state
54+
///
55+
void componentStateChanged(const hyperion::Components component, bool enable);
56+
57+
///
58+
/// @brief Handle priority updates from Priority Muxer
59+
/// @param priority The new visible priority
60+
///
61+
void handlePriorityChanges(const quint8 &priority);
62+
63+
///
64+
/// @brief Forward message to all json slaves
65+
/// @param message The JSON message to send
66+
///
67+
void forwardJsonMessage(const QJsonObject &message);
68+
69+
///
70+
/// @brief Forward image to all proto slaves
71+
/// @param image The PROTO image to send
72+
///
73+
void forwardProtoMessage(const Image<ColorRgb> &image);
74+
75+
///
76+
/// @brief Forward message to a single json slave
77+
/// @param message The JSON message to send
78+
/// @param socket The TCP-Socket with the connection to the slave
79+
///
80+
void sendJsonMessage(const QJsonObject &message, QTcpSocket *socket);
4881

4982
private:
50-
Hyperion* _hyperion;
51-
Logger* _log;
52-
QStringList _protoSlaves;
83+
/// Hyperion instance
84+
Hyperion *_hyperion;
85+
86+
/// Logger instance
87+
Logger *_log;
88+
89+
/// Muxer instance
90+
PriorityMuxer *_muxer;
91+
92+
// JSON connection for forwarding
5393
QStringList _jsonSlaves;
94+
95+
/// Proto connection for forwarding
96+
QStringList _protoSlaves;
97+
QList<FlatBufferConnection*> _forwardClients;
98+
99+
/// Flag if forwarder is enabled
100+
bool _forwarder_enabled = true;
101+
102+
const int _priority;
54103
};

include/hyperion/PriorityMuxer.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class PriorityMuxer : public QObject
107107
///
108108
/// @return The current priority
109109
///
110-
int getCurrentPriority() const;
110+
int getCurrentPriority() const { return _currentPriority; }
111111

112112
///
113113
/// Returns the state (enabled/disabled) of a specific priority channel
@@ -197,7 +197,7 @@ class PriorityMuxer : public QObject
197197

198198
///
199199
/// @brief Emits whenever the visible priority has changed
200-
/// @param priority The new visible prioritiy
200+
/// @param priority The new visible priority
201201
///
202202
void visiblePriorityChanged(const quint8& priority);
203203

include/jsonserver/JsonServer.h

+1-9
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,9 @@ private slots:
4949
void closedConnection(void);
5050

5151
public slots:
52-
53-
///
54-
/// forward message to a single json slaves
55-
///
56-
/// @param message The JSON message to send
57-
///
58-
void sendMessage(const QJsonObject & message, QTcpSocket * socket);
59-
6052
///
6153
/// @brief Handle settings update from Hyperion Settingsmanager emit or this constructor
62-
/// @param type settingyType from enum
54+
/// @param type settings type from enum
6355
/// @param config configuration object
6456
///
6557
void handleSettingsUpdate(const settings::type& type, const QJsonDocument& config);

include/udplistener/UDPListener.h

-5
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,6 @@ public slots:
7676
///
7777
const bool setGlobalInput(const int priority, const std::vector<ColorRgb>& ledColors, const int timeout_ms = -1, const bool& clearEffect = true);
7878

79-
///
80-
/// @brief forward clear to HyperionDaemon
81-
///
82-
void clearGlobalPriority(const int& _priority, const hyperion::Components& component);
83-
8479
private slots:
8580
///
8681
/// Slot which is called when a client tries to create a new connection

include/utils/hyperion.h

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#pragma once
22

3+
#include <sstream>
4+
35
#include <hyperion/ColorAdjustment.h>
46
#include <hyperion/MultiColorAdjustment.h>
57
#include <hyperion/LedString.h>

libsrc/api/JsonAPI.cpp

+65-12
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <QByteArray>
1515
#include <QDateTime>
1616
#include <QHostInfo>
17+
#include <QMutexLocker>
1718

1819
// hyperion includes
1920
#include <utils/jsonschema/QJsonFactory.h>
@@ -55,9 +56,6 @@ JsonAPI::JsonAPI(QString peerAddress, Logger* log, QObject* parent, bool noListe
5556

5657
// notify hyperion about a jsonMessageForward
5758
connect(this, &JsonAPI::forwardJsonMessage, _hyperion, &Hyperion::forwardJsonMessage);
58-
59-
_image_stream_mutex.unlock();
60-
_led_stream_mutex.unlock();
6159
}
6260

6361
void JsonAPI::handleMessage(const QString& messageString)
@@ -475,10 +473,10 @@ void JsonAPI::handleServerInfoCommand(const QJsonObject& message, const QString&
475473
// BEGIN | The following entries are derecated but used to ensure backward compatibility with hyperion Classic remote control
476474
// TODO Output the real transformation information instead of default
477475

478-
// host name
476+
// HOST NAME
479477
info["hostname"] = QHostInfo::localHostName();
480478

481-
// transform information (default values)
479+
// TRANSFORM INFORMATION (DEFAULT VALUES)
482480
QJsonArray transformArray;
483481
for (const QString& transformId : _hyperion->getAdjustmentIds())
484482
{
@@ -507,9 +505,66 @@ void JsonAPI::handleServerInfoCommand(const QJsonObject& message, const QString&
507505

508506
transformArray.append(transform);
509507
}
510-
511508
info["transform"] = transformArray;
512509

510+
// ACTIVE EFFECT INFO
511+
QJsonArray activeEffects;
512+
const std::list<ActiveEffectDefinition> & activeEffectsDefinitions = _hyperion->getActiveEffects();
513+
for (const ActiveEffectDefinition & activeEffectDefinition : activeEffectsDefinitions)
514+
{
515+
if (activeEffectDefinition.priority != PriorityMuxer::LOWEST_PRIORITY -1)
516+
{
517+
QJsonObject activeEffect;
518+
activeEffect["script"] = activeEffectDefinition.script;
519+
activeEffect["name"] = activeEffectDefinition.name;
520+
activeEffect["priority"] = activeEffectDefinition.priority;
521+
activeEffect["timeout"] = activeEffectDefinition.timeout;
522+
activeEffect["args"] = activeEffectDefinition.args;
523+
activeEffects.append(activeEffect);
524+
}
525+
}
526+
info["activeEffects"] = activeEffects;
527+
528+
// ACTIVE STATIC LED COLOR
529+
QJsonArray activeLedColors;
530+
const Hyperion::InputInfo & priorityInfo = _hyperion->getPriorityInfo(_hyperion->getCurrentPriority());
531+
if(priorityInfo.componentId == hyperion::COMP_COLOR && !priorityInfo.ledColors.empty())
532+
{
533+
QJsonObject LEDcolor;
534+
// check if LED Color not Black (0,0,0)
535+
if ((priorityInfo.ledColors.begin()->red +
536+
priorityInfo.ledColors.begin()->green +
537+
priorityInfo.ledColors.begin()->blue != 0))
538+
{
539+
QJsonObject LEDcolor;
540+
541+
// add RGB Value to Array
542+
QJsonArray RGBValue;
543+
RGBValue.append(priorityInfo.ledColors.begin()->red);
544+
RGBValue.append(priorityInfo.ledColors.begin()->green);
545+
RGBValue.append(priorityInfo.ledColors.begin()->blue);
546+
LEDcolor.insert("RGB Value", RGBValue);
547+
548+
uint16_t Hue;
549+
float Saturation, Luminace;
550+
551+
// add HSL Value to Array
552+
QJsonArray HSLValue;
553+
ColorSys::rgb2hsl(priorityInfo.ledColors.begin()->red,
554+
priorityInfo.ledColors.begin()->green,
555+
priorityInfo.ledColors.begin()->blue,
556+
Hue, Saturation, Luminace);
557+
558+
HSLValue.append(Hue);
559+
HSLValue.append(Saturation);
560+
HSLValue.append(Luminace);
561+
LEDcolor.insert("HSL Value", HSLValue);
562+
563+
activeLedColors.append(LEDcolor);
564+
}
565+
}
566+
info["activeLedColor"] = activeLedColors;
567+
513568
// END
514569

515570
sendSuccessDataReply(QJsonDocument(info), command, tan);
@@ -952,7 +1007,8 @@ void JsonAPI::sendErrorReply(const QString &error, const QString &command, const
9521007

9531008
void JsonAPI::streamLedcolorsUpdate(const std::vector<ColorRgb>& ledColors)
9541009
{
955-
if ( (_led_stream_timeout+100) < QDateTime::currentMSecsSinceEpoch() && _led_stream_mutex.tryLock(0) )
1010+
QMutexLocker lock(&_led_stream_mutex);
1011+
if ( (_led_stream_timeout+100) < QDateTime::currentMSecsSinceEpoch() )
9561012
{
9571013
_led_stream_timeout = QDateTime::currentMSecsSinceEpoch();
9581014
QJsonObject result;
@@ -973,14 +1029,13 @@ void JsonAPI::streamLedcolorsUpdate(const std::vector<ColorRgb>& ledColors)
9731029

9741030
// send the result
9751031
emit callbackMessage(_streaming_leds_reply);
976-
977-
_led_stream_mutex.unlock();
9781032
}
9791033
}
9801034

9811035
void JsonAPI::setImage(const Image<ColorRgb> & image)
9821036
{
983-
if ( (_image_stream_timeout+100) < QDateTime::currentMSecsSinceEpoch() && _image_stream_mutex.tryLock(0) )
1037+
QMutexLocker lock(&_image_stream_mutex);
1038+
if ( (_image_stream_timeout+100) < QDateTime::currentMSecsSinceEpoch() )
9841039
{
9851040
_image_stream_timeout = QDateTime::currentMSecsSinceEpoch();
9861041

@@ -994,8 +1049,6 @@ void JsonAPI::setImage(const Image<ColorRgb> & image)
9941049
result["image"] = "data:image/jpg;base64,"+QString(ba.toBase64());
9951050
_streaming_image_reply["result"] = result;
9961051
emit callbackMessage(_streaming_image_reply);
997-
998-
_image_stream_mutex.unlock();
9991052
}
10001053
}
10011054

0 commit comments

Comments
 (0)