QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
ActuatorActions.h
Go to the documentation of this file.
1#pragma once
2
3#include "Common.h"
4#include "VehicleTypes.h"
6#include "MAVLinkEnums.h"
7#include "QGCMAVLinkTypes.h"
9
10class Vehicle;
11
12#include <QtCore/QObject>
13#include <QtCore/QString>
14
15namespace ActuatorActions {
16
17struct Config {
18 enum class Type {
19 beep = ACTUATOR_CONFIGURATION_BEEP,
20 set3DModeOn = ACTUATOR_CONFIGURATION_3D_MODE_ON,
21 set3DModeOff = ACTUATOR_CONFIGURATION_3D_MODE_OFF,
22 setSpinDirection1 = ACTUATOR_CONFIGURATION_SPIN_DIRECTION1,
23 setSpinDirection2 = ACTUATOR_CONFIGURATION_SPIN_DIRECTION2,
24 };
25
26 QString typeToLabel() const;
27
30 QSet<QString> actuatorTypes;
31};
32
33class Action : public QObject
34{
35 Q_OBJECT
36public:
37 Action(QObject* parent, const Config& action, const QString& label,
38 int outputFunction, Vehicle* vehicle);
39
40 Q_PROPERTY(QString label READ label CONSTANT)
41
42 const QString& label() const { return _label; }
43
44 Q_INVOKABLE void trigger();
45
46private:
47 static void ackHandlerEntry(void* resultHandlerData, int compId, const mavlink_command_ack_t& ack, VehicleTypes::MavCmdResultFailureCode_t failureCode);
48 void ackHandler(MAV_RESULT commandResult, VehicleTypes::MavCmdResultFailureCode_t failureCode);
49 void sendMavlinkRequest();
50
51 const QString _label;
52 const int _outputFunction;
53 const Config::Type _type;
54 Vehicle* _vehicle{nullptr};
55
56 bool _commandInProgress{false};
57};
58
59class ActionGroup : public QObject
60{
61 Q_OBJECT
62public:
63 ActionGroup(QObject* parent, const QString& label, Config::Type type);
64
65 Q_PROPERTY(QString label READ label CONSTANT)
66 Q_PROPERTY(QmlObjectListModel* actions READ actions CONSTANT)
67
68 QmlObjectListModel* actions() { return _actions; }
69 const QString& label() const { return _label; }
70
71 void addAction(Action* action) { _actions->append(action); }
72
73 Config::Type type() const { return _type; }
74
75private:
76 const QString _label;
77 QmlObjectListModel* _actions = new QmlObjectListModel(this);
78 const Config::Type _type;
79};
80
81} // namespace ActuatorActions
struct __mavlink_command_ack_t mavlink_command_ack_t
Config::Type type() const
void addAction(Action *action)
const QString & label() const
QmlObjectListModel * actions()
const QString & label() const
Q_INVOKABLE void trigger()
void append(QObject *object)
Caller maintains responsibility for object ownership and deletion.
QSet< QString > actuatorTypes
@ set3DModeOn
motors: enable 3D mode (reversible)
@ setSpinDirection2
motors: set spin direction 2
@ set3DModeOff
motors: disable 3D mode (reversible)
@ setSpinDirection1
motors: set spin direction 1
QString typeToLabel() const