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

#include <TimeoutTransition.h>

+ Inheritance diagram for TimeoutTransition:
+ Collaboration diagram for TimeoutTransition:

Signals

void timeout ()
 Emitted when the timeout expires (internal use - triggers transition)
 

Public Member Functions

 TimeoutTransition (int timeoutMsecs, QAbstractState *target=nullptr)
 
void attachToSourceState (QState *source)
 
int timeoutMsecs () const
 Get the timeout duration.
 
void setTimeoutMsecs (int msecs)
 Set the timeout duration (only effective before state is entered)
 
bool isTimerActive () const
 Check if the timer is currently running.
 
- 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 event (QEvent *e) override
 
void onTransition (QEvent *event) override
 

Detailed Description

Transition that fires automatically after a specified delay. Useful for adding timeout behavior to any state without requiring WaitStateBase.

The timer starts when the source state is entered and stops when exited. If the timer expires while in the source state, the transition is taken.

Example usage:

auto* timeoutTransition = new TimeoutTransition(5000, errorState);
normalState->addTransition(timeoutTransition);

Definition at line 18 of file TimeoutTransition.h.

Constructor & Destructor Documentation

◆ TimeoutTransition()

TimeoutTransition::TimeoutTransition ( int  timeoutMsecs,
QAbstractState *  target = nullptr 
)
explicit

Create a timeout transition

Parameters
timeoutMsecsTime in milliseconds before transition fires
targetTarget state to transition to on timeout

Definition at line 6 of file TimeoutTransition.cc.

References timeout().

Member Function Documentation

◆ attachToSourceState()

void TimeoutTransition::attachToSourceState ( QState *  source)

Bind timeout start/stop hooks to a source state. Safe to call multiple times.

Definition at line 18 of file TimeoutTransition.cc.

◆ event()

bool TimeoutTransition::event ( QEvent *  e)
overrideprotected

Definition at line 45 of file TimeoutTransition.cc.

Referenced by onTransition().

◆ isTimerActive()

bool TimeoutTransition::isTimerActive ( ) const
inline

Check if the timer is currently running.

Definition at line 40 of file TimeoutTransition.h.

◆ onTransition()

void TimeoutTransition::onTransition ( QEvent *  event)
overrideprotected

Definition at line 60 of file TimeoutTransition.cc.

References event().

◆ setTimeoutMsecs()

void TimeoutTransition::setTimeoutMsecs ( int  msecs)
inline

Set the timeout duration (only effective before state is entered)

Definition at line 37 of file TimeoutTransition.h.

◆ timeout

void TimeoutTransition::timeout ( )
signal

Emitted when the timeout expires (internal use - triggers transition)

Referenced by TimeoutTransition().

◆ timeoutMsecs()

int TimeoutTransition::timeoutMsecs ( ) const
inline

Get the timeout duration.

Definition at line 34 of file TimeoutTransition.h.


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