|
QGroundControl
Ground Control Station for MAVLink Drones
|
#include <SequenceState.h>
Inheritance diagram for SequenceState:
Collaboration diagram for SequenceState:Classes | |
| struct | Step |
Public Types | |
| using | StepAction = std::function< bool()> |
| Step action - returns true to continue, false to stop with error. | |
Public Types inherited from QGCAbstractState | |
| using | EntryCallback = std::function< void()> |
| using | ExitCallback = std::function< void()> |
| using | EventHandler = std::function< bool(QEvent *)> |
Signals | |
| void | stepCompleted (const QString &stepName, int index) |
| Emitted after each step completes successfully. | |
Signals inherited from QGCAbstractState | |
| void | advance () |
| void | error () |
Public Member Functions | |
| SequenceState (const QString &stateName, QState *parent) | |
| void | addStep (const QString &name, StepAction action) |
| void | addSteps (const QList< Step > &steps) |
| Add multiple steps at once. | |
| int | currentStepIndex () const |
| Get the current step index. | |
| QString | currentStepName () const |
| Get the current step name. | |
| int | stepCount () const |
| Get the total number of steps. | |
| QString | failedStepName () const |
| Get the name of the step that failed (valid after error()) | |
Public Member Functions inherited from QGCState | |
| QGCState (const QString &stateName, QState *parentState) | |
| template<typename PointerToMemberFunction > | |
| QSignalTransition * | addThisTransition (PointerToMemberFunction signal, QAbstractState *target) |
| Simpler version of QState::addTransition which assumes the sender is this. | |
| void | setLocalErrorState (QAbstractState *errorState) |
| QAbstractState * | localErrorState () const |
| Get the per-state error state (nullptr if using global) | |
| void | setProperty (QObject *object, const char *name, const QVariant &value) |
| void | setEnabled (QObject *object, bool enabled) |
| Convenience overload for setting enabled state on widgets/controls. | |
| void | setVisible (QObject *object, bool visible) |
| Convenience overload for setting visible state on widgets/controls. | |
Public Member Functions inherited from QGCAbstractState | |
| QGCAbstractState (const QString &stateName, QState *parent) | |
| QGCStateMachine * | machine () const |
| Vehicle * | vehicle () const |
| QString | stateName () const |
| class StateContext * | context () const |
| void | setOnEntry (EntryCallback callback) |
| Set a callback to be invoked when the state is entered. | |
| void | setOnExit (ExitCallback callback) |
| Set a callback to be invoked when the state is exited. | |
| void | setCallbacks (EntryCallback onEntry, ExitCallback onExit=nullptr) |
| Set both entry and exit callbacks. | |
| void | setEventHandler (EventHandler handler) |
| Set a custom event handler for this state. | |
Protected Member Functions | |
| void | onEnter () override |
| Override to perform actions on state entry. | |
Protected Member Functions inherited from QGCAbstractState | |
| virtual void | onLeave () |
| Override to perform actions on state exit. | |
| void | onEntry (QEvent *event) override |
| void | onExit (QEvent *event) override |
| bool | event (QEvent *event) override |
A composite state that executes a sequence of actions in order.
Each action is executed in turn. If any action fails (returns false), the sequence stops and error() is emitted. When all actions complete successfully, advance() is emitted.
Example usage:
Definition at line 32 of file SequenceState.h.
| using SequenceState::StepAction = std::function<bool()> |
Step action - returns true to continue, false to stop with error.
Definition at line 39 of file SequenceState.h.
| SequenceState::SequenceState | ( | const QString & | stateName, |
| QState * | parent | ||
| ) |
Definition at line 4 of file SequenceState.cc.
| void SequenceState::addStep | ( | const QString & | name, |
| StepAction | action | ||
| ) |
Add a step to the sequence
| name | Step name for logging |
| action | Action to execute (returns true to continue, false to error) |
Definition at line 9 of file SequenceState.cc.
| void SequenceState::addSteps | ( | const QList< Step > & | steps | ) |
Add multiple steps at once.
Definition at line 14 of file SequenceState.cc.
|
inline |
Get the current step index.
Definition at line 57 of file SequenceState.h.
| QString SequenceState::currentStepName | ( | ) | const |
Get the current step name.
Definition at line 19 of file SequenceState.cc.
|
inline |
Get the name of the step that failed (valid after error())
Definition at line 66 of file SequenceState.h.
|
overrideprotectedvirtual |
Override to perform actions on state entry.
Reimplemented from QGCAbstractState.
Definition at line 27 of file SequenceState.cc.
|
signal |
Emitted after each step completes successfully.
|
inline |
Get the total number of steps.
Definition at line 63 of file SequenceState.h.