|
QGroundControl
Ground Control Station for MAVLink Drones
|
#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) | |
| 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 | |
| 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 *)> |
Base class for states that wait for something with optional timeout Provides common timeout handling infrastructure
Definition at line 9 of file WaitStateBase.h.
| WaitStateBase::WaitStateBase | ( | const QString & | stateName, |
| QState * | parent, | ||
| int | timeoutMsecs = 0 |
||
| ) |
| stateName | Name for this state (for logging) |
| parent | Parent state |
| timeoutMsecs | Timeout in milliseconds, 0 for no timeout |
Definition at line 5 of file WaitStateBase.cc.
|
signal |
Emitted when the wait condition is satisfied (alias for advance()) Prefer using completed() over advance() for clarity in wait states
Referenced by waitComplete().
|
protectedpure virtual |
Subclasses override to set up their signal connections.
Implemented in AsyncFunctionState, EventQueuedState, RequestMessageState, RetryableRequestMessageState, SendMavlinkCommandState, SkippableAsyncState, WaitForMavlinkMessageState, and WaitForSignalState.
Referenced by restartWait().
|
protectedpure virtual |
Subclasses override to tear down their signal connections.
Implemented in AsyncFunctionState, EventQueuedState, RequestMessageState, RetryableRequestMessageState, SendMavlinkCommandState, SkippableAsyncState, WaitForMavlinkMessageState, and WaitForSignalState.
Referenced by restartWait(), waitComplete(), and waitFailed().
|
protectedvirtual |
Called when the state is entered - subclasses should call base implementation.
Reimplemented in AsyncFunctionState, EventQueuedState, RequestMessageState, RetryableRequestMessageState, SendMavlinkCommandState, and SkippableAsyncState.
Definition at line 60 of file WaitStateBase.cc.
Referenced by EventQueuedState::onWaitEntered(), RequestMessageState::onWaitEntered(), and RetryableRequestMessageState::onWaitEntered().
|
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().
|
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().
| 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().
|
signal |
Emitted when the timeout expires (alias for timeout()) Prefer using timedOut() over timeout() for consistency with other signals
Referenced by onWaitTimeout().
|
signal |
Emitted when the timeout expires before the wait condition is met
Referenced by onWaitTimeout().
|
inlineprotected |
Definition at line 61 of file WaitStateBase.h.
Referenced by AsyncFunctionState::onWaitEntered().
|
protected |
Call this when the wait condition is satisfied Stops the timer, calls cleanup, and emits advance()
Definition at line 76 of file WaitStateBase.cc.
References QGCAbstractState::advance(), completed(), and disconnectWaitSignal().
Referenced by AsyncFunctionState::complete(), SkippableAsyncState::complete(), RequestMessageState::onWaitEntered(), RetryableRequestMessageState::onWaitEntered(), and RetryableRequestMessageState::onWaitTimeout().
|
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().