QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
EventHandler.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QString>
4#include <QtCore/QVector>
5#include <QtCore/QTimer>
6
7#include <functional>
8
10
11class EventHandler : public QObject
12{
13 Q_OBJECT
14public:
15 using send_request_event_message_f = std::function<void(const mavlink_request_event_t& msg)>;
16 using handle_event_f = std::function<void(std::unique_ptr<events::parser::ParsedEvent>)>;
17
18 EventHandler(QObject* parent, const QString& profile, handle_event_f handleEventCB,
19 send_request_event_message_f sendRequestCB,
20 uint8_t ourSystemId, uint8_t ourComponentId, uint8_t systemId, uint8_t componentId);
22
23
24 void handleEvents(const mavlink_message_t& message);
25
26 void setMetadata(const QString& metadataJsonFileName);
27
28 const events::HealthAndArmingChecks::Results& healthAndArmingCheckResults() const { return _healthAndArmingChecks.results(); }
29 bool healthAndArmingCheckResultsValid() const { return _healthAndArmingChecksValid; }
30
31 int getModeGroup(int32_t customMode);
32
34 const auto& protocols = _parser.supportedProtocols(_compid);
35 return protocols.find("health_and_arming_check") != protocols.end();
36 }
37
38signals:
40
41private:
42 void gotEvent(const mavlink_event_t& event);
43
44 events::ReceiveProtocol* _protocol{nullptr};
45 QTimer _timer;
46 events::parser::Parser _parser;
47 events::HealthAndArmingChecks _healthAndArmingChecks;
48 bool _healthAndArmingChecksValid{false};
49 QVector<mavlink_event_t> _pendingEvents;
50 handle_event_f _handleEventCB;
51 send_request_event_message_f _sendRequestCB;
52 const uint8_t _compid;
53};
struct __mavlink_message mavlink_message_t
void handleEvents(const mavlink_message_t &message)
void healthAndArmingChecksUpdated()
void setMetadata(const QString &metadataJsonFileName)
std::function< void(std::unique_ptr< events::parser::ParsedEvent >)> handle_event_f
std::function< void(const mavlink_request_event_t &msg)> send_request_event_message_f
const events::HealthAndArmingChecks::Results & healthAndArmingCheckResults() const
bool healthAndArmingChecksSupported() const
int getModeGroup(int32_t customMode)
bool healthAndArmingCheckResultsValid() const