11 _steps.append({name, std::move(action)});
21 if (_currentStep >= 0 && _currentStep < _steps.size()) {
22 return _steps[_currentStep].name;
33 QMetaObject::invokeMethod(
this, &SequenceState::_executeNextStep, Qt::QueuedConnection);
36void SequenceState::_executeNextStep()
40 if (_currentStep >= _steps.size()) {
42 qCDebug(QGCStateMachineLog) <<
stateName() <<
"sequence completed successfully";
47 const Step& step = _steps[_currentStep];
48 qCDebug(QGCStateMachineLog) <<
stateName() <<
"executing step" << _currentStep <<
":" << step.name;
52 success = step.action();
58 QMetaObject::invokeMethod(
this, &SequenceState::_executeNextStep, Qt::QueuedConnection);
60 _failedStep = step.name;
61 qCDebug(QGCStateMachineLog) <<
stateName() <<
"step failed:" << step.name;
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.
void addStep(const QString &name, StepAction action)
SequenceState(const QString &stateName, QState *parent)
QString currentStepName() const
Get the current step name.
void addSteps(const QList< Step > &steps)
Add multiple steps at once.
void onEnter() override
Override to perform actions on state entry.