|
QGroundControl
Ground Control Station for MAVLink Drones
|
#include <RetryState.h>
Inheritance diagram for RetryState:
Collaboration diagram for RetryState:Public Types | |
| enum | ExhaustedBehavior { EmitError , EmitAdvance } |
| using | Action = std::function< bool()> |
Public Types inherited from QGCAbstractState | |
| using | EntryCallback = std::function< void()> |
| using | ExitCallback = std::function< void()> |
| using | EventHandler = std::function< bool(QEvent *)> |
Signals | |
| void | retrying (int attempt, int maxAttempts) |
| Emitted before each retry attempt. | |
| void | succeeded () |
| Emitted when the action eventually succeeds. | |
| void | exhausted () |
| Emitted when all retries are exhausted (both behaviors). | |
| void | skipped () |
| Emitted when retries are exhausted and behavior is EmitAdvance. | |
Signals inherited from QGCAbstractState | |
| void | advance () |
| void | error () |
Public Member Functions | |
| RetryState (const QString &stateName, QState *parent, Action action, int maxRetries=0, int retryDelayMsecs=1000, ExhaustedBehavior exhaustedBehavior=EmitError) | |
| int | currentAttempt () const |
| int | maxRetries () const |
| int | totalAttempts () const |
| ExhaustedBehavior | exhaustedBehavior () const |
| bool | wasSkipped () const |
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 state that retries an action and chooses behavior when retries are exhausted.
The action is executed on entry. If it fails, the state retries after a delay. Once retries are exhausted, behavior is controlled by ExhaustedBehavior.
Definition at line 13 of file RetryState.h.
| using RetryState::Action = std::function<bool()> |
Definition at line 19 of file RetryState.h.
| Enumerator | |
|---|---|
| EmitError | Emit error() after retries exhausted. |
| EmitAdvance | Emit advance() after retries exhausted (skip/continue). |
Definition at line 21 of file RetryState.h.
| RetryState::RetryState | ( | const QString & | stateName, |
| QState * | parent, | ||
| Action | action, | ||
| int | maxRetries = 0, |
||
| int | retryDelayMsecs = 1000, |
||
| ExhaustedBehavior | exhaustedBehavior = EmitError |
||
| ) |
Definition at line 4 of file RetryState.cc.
|
inline |
Definition at line 33 of file RetryState.h.
|
signal |
Emitted when all retries are exhausted (both behaviors).
|
inline |
Definition at line 36 of file RetryState.h.
|
inline |
Definition at line 34 of file RetryState.h.
|
overrideprotectedvirtual |
Override to perform actions on state entry.
Reimplemented from QGCAbstractState.
Definition at line 17 of file RetryState.cc.
|
signal |
Emitted before each retry attempt.
|
signal |
Emitted when retries are exhausted and behavior is EmitAdvance.
|
signal |
Emitted when the action eventually succeeds.
|
inline |
Definition at line 35 of file RetryState.h.
|
inline |
Definition at line 37 of file RetryState.h.