|
18 | 18 | #include <utils/ColorRgb.h> |
19 | 19 | #include <utils/settings.h> |
20 | 20 | #include <utils/Logger.h> |
| 21 | +#include <utils/Components.h> |
| 22 | +#include <utils/Image.h> |
21 | 23 |
|
| 24 | +// Hyperion includes |
| 25 | +#include <hyperion/PriorityMuxer.h> |
| 26 | + |
| 27 | +// Forward declaration |
22 | 28 | class Hyperion; |
| 29 | +class QTcpSocket; |
| 30 | +class FlatBufferConnection; |
23 | 31 |
|
24 | 32 | class MessageForwarder : public QObject |
25 | 33 | { |
26 | 34 | Q_OBJECT |
27 | 35 | public: |
28 | | - |
29 | | - MessageForwarder(Hyperion* hyperion, const QJsonDocument & config); |
| 36 | + MessageForwarder(Hyperion* hyperion); |
30 | 37 | ~MessageForwarder(); |
31 | 38 |
|
32 | 39 | void addJsonSlave(QString slave); |
33 | 40 | void addProtoSlave(QString slave); |
34 | 41 |
|
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 | | - |
41 | 42 | private slots: |
42 | 43 | /// |
43 | 44 | /// @brief Handle settings update from Hyperion Settingsmanager emit or this constructor |
44 | 45 | /// @param type settingyType from enum |
45 | 46 | /// @param config configuration object |
46 | 47 | /// |
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); |
48 | 81 |
|
49 | 82 | 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 |
53 | 93 | 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; |
54 | 103 | }; |
0 commit comments