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
33class SequenceState : public QGCState
34{
35 Q_OBJECT
36 Q_DISABLE_COPY(SequenceState)
37
38public:
40 using StepAction = std::function<bool()>;
41
42 struct Step {
43 QString name;
45 };
46
47 SequenceState(const QString& stateName, QState* parent);
48
52 void addStep(const QString& name, StepAction action);
53
55 void addSteps(const QList<Step>& steps);
56
58 int currentStepIndex() const { return _currentStep; }
59
61 QString currentStepName() const;
62
64 int stepCount() const { return _steps.size(); }
65
67 QString failedStepName() const { return _failedStep; }
68
69signals:
71 void stepCompleted(const QString& stepName, int index);
72
73protected:
74 void onEnter() override;
75
76private slots:
77 void _executeNextStep();
78
79private:
80 QList<Step> _steps;
81 int _currentStep = -1;
82 QString _failedStep;
83};
QString stateName() const
Full-featured base class for QGroundControl state machine states.
Definition QGCState.h:23
A composite state that executes a sequence of actions in order.
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.