QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
RetryTransition Class Reference

#include <RetryTransition.h>

+ Inheritance diagram for RetryTransition:
+ Collaboration diagram for RetryTransition:

Public Types

using RetryAction = std::function< void()>
 

Public Member Functions

template<typename Func >
 RetryTransition (const typename QtPrivate::FunctionPointer< Func >::Object *sender, Func signalFn, QAbstractState *target, RetryAction retryAction, int maxRetries=1)
 
void reset ()
 Reset retry count (call when re-entering the source state)
 
int retryCount () const
 Get current retry count.
 
int maxRetries () const
 Get max retries setting.
 
- Public Member Functions inherited from QGCSignalTransition
 QGCSignalTransition (QState *sourceState=nullptr)
 
 QGCSignalTransition (const QObject *sender, const char *signal, QState *sourceState=nullptr)
 
template<typename Func >
 QGCSignalTransition (const typename QtPrivate::FunctionPointer< Func >::Object *sender, Func signalFn, QState *sourceState=nullptr)
 
QGCStateMachinemachine () const
 Get the QGCStateMachine this transition belongs to.
 
Vehiclevehicle () const
 Get the Vehicle associated with the state machine.
 

Protected Member Functions

bool eventTest (QEvent *event) override
 
void onTransition (QEvent *event) override
 Called when transition fires (after max retries)
 

Detailed Description

Transition that retries an action N times before advancing to target state. Useful for timeout handling where you want to retry before giving up.

On each trigger (e.g., timeout signal):

  • If retry count < max: increment count, invoke retryAction, block transition
  • If retry count >= max: reset count, allow transition to target

Example usage:

auto* retry = new RetryTransition(
nextState,
[this]() { _requestAutopilotVersion(_stateAutopilotVersion); },
1 // max retries
);
state->addTransition(retry);

Definition at line 26 of file RetryTransition.h.

Member Typedef Documentation

◆ RetryAction

using RetryTransition::RetryAction = std::function<void()>

Definition at line 32 of file RetryTransition.h.

Constructor & Destructor Documentation

◆ RetryTransition()

template<typename Func >
RetryTransition::RetryTransition ( const typename QtPrivate::FunctionPointer< Func >::Object *  sender,
Func  signalFn,
QAbstractState *  target,
RetryAction  retryAction,
int  maxRetries = 1 
)
inline

Create a retry transition

Parameters
senderObject emitting the trigger signal (usually the state itself)
signalSignal that triggers retry/advance (usually timeout)
targetState to transition to after max retries exhausted
retryActionAction to invoke on each retry attempt
maxRetriesMaximum retry attempts before transitioning (default: 1)

Definition at line 41 of file RetryTransition.h.

Member Function Documentation

◆ eventTest()

bool RetryTransition::eventTest ( QEvent *  event)
overrideprotected

Override to implement retry logic Returns false during retries (blocking transition), true after max retries

Definition at line 9 of file RetryTransition.cc.

◆ maxRetries()

int RetryTransition::maxRetries ( ) const
inline

Get max retries setting.

Definition at line 60 of file RetryTransition.h.

◆ onTransition()

void RetryTransition::onTransition ( QEvent *  event)
overrideprotected

Called when transition fires (after max retries)

Definition at line 42 of file RetryTransition.cc.

◆ reset()

void RetryTransition::reset ( )
inline

Reset retry count (call when re-entering the source state)

Definition at line 54 of file RetryTransition.h.

◆ retryCount()

int RetryTransition::retryCount ( ) const
inline

Get current retry count.

Definition at line 57 of file RetryTransition.h.


The documentation for this class was generated from the following files: