|
QGroundControl
Ground Control Station for MAVLink Drones
|
#include <AsyncFunctionState.h>
Inheritance diagram for AsyncFunctionState:
Collaboration diagram for AsyncFunctionState:Public Types | |
| using | SetupFunction = std::function< void(AsyncFunctionState *state)> |
Public Types inherited from QGCAbstractState | |
| using | EntryCallback = std::function< void()> |
| using | ExitCallback = std::function< void()> |
| using | EventHandler = std::function< bool(QEvent *)> |
Public Member Functions | |
| AsyncFunctionState (const QString &stateName, QState *parent, SetupFunction setupFunction, int timeoutMsecs=0) | |
| void | complete () |
| Call this to signal that the async operation has completed successfully. | |
| void | fail () |
| Call this to signal that the async operation has failed. | |
| template<typename Func > | |
| void | connectToCompletion (typename QtPrivate::FunctionPointer< Func >::Object *sender, Func signal) |
| template<typename Func , typename Slot > | |
| void | connectToCompletion (typename QtPrivate::FunctionPointer< Func >::Object *sender, Func signal, Slot slot) |
Public Member Functions inherited from WaitStateBase | |
| 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 | |
| void | connectWaitSignal () override |
| Subclasses override to set up their signal connections. | |
| void | disconnectWaitSignal () override |
| Subclasses override to tear down their signal connections. | |
| void | onWaitEntered () override |
| Called when the state is entered - subclasses should call base implementation. | |
Protected Member Functions inherited from WaitStateBase | |
| 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 () |
| 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 | |
Signals inherited from WaitStateBase | |
| void | completed () |
| void | timeout () |
| void | timedOut () |
Signals inherited from QGCAbstractState | |
| void | advance () |
| void | error () |
Calls a function when entered and waits for an external trigger to advance Unlike FunctionState (which advances immediately), this state waits for:
Useful for async operations like loading from vehicle where you call a function and wait for a completion signal.
Definition at line 14 of file AsyncFunctionState.h.
| using AsyncFunctionState::SetupFunction = std::function<void(AsyncFunctionState* state)> |
Definition at line 20 of file AsyncFunctionState.h.
| AsyncFunctionState::AsyncFunctionState | ( | const QString & | stateName, |
| QState * | parent, | ||
| SetupFunction | setupFunction, | ||
| int | timeoutMsecs = 0 |
||
| ) |
| stateName | Name for this state (for logging) |
| parent | Parent state |
| setupFunction | Function called when state is entered. Should start the async operation. The function receives a pointer to this state so it can call complete() when done. |
| timeoutMsecs | Timeout in milliseconds, 0 for no timeout |
Definition at line 4 of file AsyncFunctionState.cc.
|
inline |
Call this to signal that the async operation has completed successfully.
Definition at line 30 of file AsyncFunctionState.h.
References WaitStateBase::waitComplete().
Referenced by connectToCompletion().
|
inline |
Connect to an external signal that will trigger completion
| sender | The QObject that will emit the completion signal |
| signal | The signal that indicates completion |
Definition at line 39 of file AsyncFunctionState.h.
References complete().
|
inline |
Connect to an external signal that will trigger completion, with a slot Useful when you need to process the signal data before completing
Definition at line 49 of file AsyncFunctionState.h.
|
overrideprotectedvirtual |
Subclasses override to set up their signal connections.
Implements WaitStateBase.
Definition at line 10 of file AsyncFunctionState.cc.
|
overrideprotectedvirtual |
Subclasses override to tear down their signal connections.
Implements WaitStateBase.
Definition at line 15 of file AsyncFunctionState.cc.
|
inline |
Call this to signal that the async operation has failed.
Definition at line 33 of file AsyncFunctionState.h.
References WaitStateBase::waitFailed().
|
overrideprotectedvirtual |
Called when the state is entered - subclasses should call base implementation.
Reimplemented from WaitStateBase.
Definition at line 23 of file AsyncFunctionState.cc.
References QGCAbstractState::stateName(), and WaitStateBase::timeoutMsecs().