QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
WaitStateBase Class Referenceabstract

#include <WaitStateBase.h>

+ Inheritance diagram for WaitStateBase:
+ Collaboration diagram for WaitStateBase:

Signals

void completed ()
 
void timeout ()
 
void timedOut ()
 
- Signals inherited from QGCAbstractState
void advance ()
 
void error ()
 

Public Member Functions

 WaitStateBase (const QString &stateName, QState *parent, int timeoutMsecs=0)
 
void restartWait ()
 
- 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)
 
QGCStateMachinemachine () const
 
Vehiclevehicle () const
 
QString stateName () const
 
class StateContextcontext () 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

virtual void onWaitEntered ()
 Called when the state is entered - subclasses should call base implementation.
 
virtual void onWaitExited ()
 Called when the state is exited - subclasses should call base implementation.
 
virtual void onWaitTimeout ()
 Called when the timeout expires - default emits timeout(), subclasses can override.
 
void waitComplete ()
 
void waitFailed ()
 
virtual void connectWaitSignal ()=0
 Subclasses override to set up their signal connections.
 
virtual void disconnectWaitSignal ()=0
 Subclasses override to tear down their signal connections.
 
int timeoutMsecs () const
 
- Protected Member Functions inherited from QGCAbstractState
virtual void onEnter ()
 Override to perform actions on state entry.
 
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
 

Additional Inherited Members

- Public Types inherited from QGCAbstractState
using EntryCallback = std::function< void()>
 
using ExitCallback = std::function< void()>
 
using EventHandler = std::function< bool(QEvent *)>
 

Detailed Description

Base class for states that wait for something with optional timeout Provides common timeout handling infrastructure

Definition at line 9 of file WaitStateBase.h.

Constructor & Destructor Documentation

◆ WaitStateBase()

WaitStateBase::WaitStateBase ( const QString &  stateName,
QState *  parent,
int  timeoutMsecs = 0 
)
Parameters
stateNameName for this state (for logging)
parentParent state
timeoutMsecsTimeout in milliseconds, 0 for no timeout

Definition at line 5 of file WaitStateBase.cc.

Member Function Documentation

◆ completed

void WaitStateBase::completed ( )
signal

Emitted when the wait condition is satisfied (alias for advance()) Prefer using completed() over advance() for clarity in wait states

Referenced by waitComplete().

◆ connectWaitSignal()

virtual void WaitStateBase::connectWaitSignal ( )
protectedpure virtual

◆ disconnectWaitSignal()

virtual void WaitStateBase::disconnectWaitSignal ( )
protectedpure virtual

◆ onWaitEntered()

void WaitStateBase::onWaitEntered ( )
protectedvirtual

◆ onWaitExited()

void WaitStateBase::onWaitExited ( )
protectedvirtual

Called when the state is exited - subclasses should call base implementation.

Reimplemented in RetryableRequestMessageState.

Definition at line 65 of file WaitStateBase.cc.

Referenced by RetryableRequestMessageState::onWaitExited().

◆ onWaitTimeout()

void WaitStateBase::onWaitTimeout ( )
protectedvirtual

Called when the timeout expires - default emits timeout(), subclasses can override.

Reimplemented in RequestMessageState, and RetryableRequestMessageState.

Definition at line 70 of file WaitStateBase.cc.

References timedOut(), and timeout().

Referenced by RequestMessageState::onWaitTimeout(), and RetryableRequestMessageState::onWaitTimeout().

◆ restartWait()

void WaitStateBase::restartWait ( )

Rearm wait signal connections and timeout after a handled timeout event. Intended for retry loops that stay in the same state.

Definition at line 103 of file WaitStateBase.cc.

References connectWaitSignal(), disconnectWaitSignal(), and QGCAbstractState::machine().

◆ timedOut

void WaitStateBase::timedOut ( )
signal

Emitted when the timeout expires (alias for timeout()) Prefer using timedOut() over timeout() for consistency with other signals

Referenced by onWaitTimeout().

◆ timeout

void WaitStateBase::timeout ( )
signal

Emitted when the timeout expires before the wait condition is met

Note
For transition wiring, timedOut() is preferred over timeout() for clarity

Referenced by onWaitTimeout().

◆ timeoutMsecs()

int WaitStateBase::timeoutMsecs ( ) const
inlineprotected

Definition at line 61 of file WaitStateBase.h.

Referenced by AsyncFunctionState::onWaitEntered().

◆ waitComplete()

void WaitStateBase::waitComplete ( )
protected

◆ waitFailed()

void WaitStateBase::waitFailed ( )
protected

Call this when the wait fails Stops the timer, calls cleanup, and emits error()

Definition at line 90 of file WaitStateBase.cc.

References disconnectWaitSignal(), and QGCAbstractState::error().

Referenced by AsyncFunctionState::fail(), SkippableAsyncState::fail(), RequestMessageState::onWaitEntered(), and SendMavlinkCommandState::onWaitEntered().


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