QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
SequenceState.h
Go to the documentation of this file.
1#pragma once
2
3#include "QGCState.h"
4
5#include <functional>
6
32class SequenceState : public QGCState
33{
34 Q_OBJECT
35 Q_DISABLE_COPY(SequenceState)
36
37public:
39 using StepAction = std::function<bool()>;
40
41 struct Step {
42 QString name;
44 };
45
46 SequenceState(const QString& stateName, QState* parent);
47
51 void addStep(const QString& name, StepAction action);
52
54 void addSteps(const QList<Step>& steps);
55
57 int currentStepIndex() const { return _currentStep; }
58
60 QString currentStepName() const;
61
63 int stepCount() const { return _steps.size(); }
64
66 QString failedStepName() const { return _failedStep; }
67
68signals:
70 void stepCompleted(const QString& stepName, int index);
71
72protected:
73 void onEnter() override;
74
75private slots:
76 void _executeNextStep();
77
78private:
79 QList<Step> _steps;
80 int _currentStep = -1;
81 QString _failedStep;
82};
QString stateName() const
void stepCompleted(const QString &stepName, int index)
Emitted after each step completes successfully.
std::function< bool()> StepAction
Step action - returns true to continue, false to stop with error.
int currentStepIndex() const
Get the current step index.
int stepCount() const
Get the total number of steps.
void addStep(const QString &name, StepAction action)
QString currentStepName() const
Get the current step name.
QString failedStepName() const
Get the name of the step that failed (valid after error())
void addSteps(const QList< Step > &steps)
Add multiple steps at once.
void onEnter() override
Override to perform actions on state entry.