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 "Vehicle.h"
6
7#include <QtCore/QObject>
8#include <QtCore/QString>
9
10namespace ActuatorActions {
11
12struct Config {
13 enum class Type {
14 beep = ACTUATOR_CONFIGURATION_BEEP,
15 set3DModeOn = ACTUATOR_CONFIGURATION_3D_MODE_ON,
16 set3DModeOff = ACTUATOR_CONFIGURATION_3D_MODE_OFF,
17 setSpinDirection1 = ACTUATOR_CONFIGURATION_SPIN_DIRECTION1,
18 setSpinDirection2 = ACTUATOR_CONFIGURATION_SPIN_DIRECTION2,
19 };
20
21 QString typeToLabel() const;
22
25 QSet<QString> actuatorTypes;
26};
27
28class Action : public QObject
29{
30 Q_OBJECT
31public:
32 Action(QObject* parent, const Config& action, const QString& label,
33 int outputFunction, Vehicle* vehicle);
34
35 Q_PROPERTY(QString label READ label CONSTANT)
36
37 const QString& label() const { return _label; }
38
39 Q_INVOKABLE void trigger();
40
41private:
42 static void ackHandlerEntry(void* resultHandlerData, int compId, const mavlink_command_ack_t& ack, Vehicle::MavCmdResultFailureCode_t failureCode);
43 void ackHandler(MAV_RESULT commandResult, Vehicle::MavCmdResultFailureCode_t failureCode);
44 void sendMavlinkRequest();
45
46 const QString _label;
47 const int _outputFunction;
48 const Config::Type _type;
49 Vehicle* _vehicle{nullptr};
50
51 bool _commandInProgress{false};
52};
53
54class ActionGroup : public QObject
55{
56 Q_OBJECT
57public:
58 ActionGroup(QObject* parent, const QString& label, Config::Type type);
59
60 Q_PROPERTY(QString label READ label CONSTANT)
61 Q_PROPERTY(QmlObjectListModel* actions READ actions CONSTANT)
62
63 QmlObjectListModel* actions() { return _actions; }
64 const QString& label() const { return _label; }
65
66 void addAction(Action* action) { _actions->append(action); }
67
68 Config::Type type() const { return _type; }
69
70private:
71 const QString _label;
72 QmlObjectListModel* _actions = new QmlObjectListModel(this);
73 const Config::Type _type;
74};
75
76} // namespace ActuatorActions
Config::Type type() const
void addAction(Action *action)
const QString & label() const
QString label READ label CONSTANT(QmlObjectListModel *actions READ actions CONSTANT) QmlObjectListModel *actions()
QString label READ label CONSTANT const QString & label() const
void append(QObject *object)
Caller maintains responsibility for object ownership and deletion.
MavCmdResultFailureCode_t
Definition Vehicle.h:618
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