|
QGroundControl
Ground Control Station for MAVLink Drones
|
#include <EventQueuedState.h>
Inheritance diagram for EventQueuedState:
Collaboration diagram for EventQueuedState:Signals | |
| void | eventReceived (const QString &eventName) |
Signals inherited from WaitStateBase | |
| void | completed () |
| void | timeout () |
| void | timedOut () |
Signals inherited from QGCAbstractState | |
| void | advance () |
| void | error () |
Public Member Functions | |
| EventQueuedState (const QString &stateName, QState *parent, const QString &eventName, int timeoutMsecs=0) | |
| EventQueuedState (const QString &stateName, QState *parent, const QSet< QString > &eventNames, int timeoutMsecs=0) | |
| void | addExpectedEvent (const QString &eventName) |
| void | removeExpectedEvent (const QString &eventName) |
| QSet< QString > | expectedEvents () const |
| Get the set of expected event names. | |
| QString | receivedEvent () const |
| Get the event that triggered completion (valid after completed() signal) | |
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 | |
Public Types inherited from QGCAbstractState | |
| using | EntryCallback = std::function< void()> |
| using | ExitCallback = std::function< void()> |
| using | EventHandler = std::function< bool(QEvent *)> |
A state that waits for one or more named events before advancing.
This state integrates with QGCStateMachine's postEvent() and postDelayedEvent() methods to provide event-based state coordination.
Example usage:
Multiple events can be configured using addExpectedEvent(). The state advances when ANY of the expected events is received (OR logic). For AND logic (wait for all events), chain multiple EventQueuedState instances.
Definition at line 29 of file EventQueuedState.h.
| EventQueuedState::EventQueuedState | ( | const QString & | stateName, |
| QState * | parent, | ||
| const QString & | eventName, | ||
| int | timeoutMsecs = 0 |
||
| ) |
Create an EventQueuedState waiting for a single event
| stateName | Name for logging |
| parent | Parent state |
| eventName | The event name to wait for |
| timeoutMsecs | Timeout in milliseconds (0 = no timeout) |
Definition at line 5 of file EventQueuedState.cc.
| EventQueuedState::EventQueuedState | ( | const QString & | stateName, |
| QState * | parent, | ||
| const QSet< QString > & | eventNames, | ||
| int | timeoutMsecs = 0 |
||
| ) |
Create an EventQueuedState waiting for any of multiple events
| stateName | Name for logging |
| parent | Parent state |
| eventNames | Set of event names to wait for (OR logic) |
| timeoutMsecs | Timeout in milliseconds (0 = no timeout) |
Definition at line 12 of file EventQueuedState.cc.
| void EventQueuedState::addExpectedEvent | ( | const QString & | eventName | ) |
Add an additional event to wait for
| eventName | Event name to add |
Definition at line 19 of file EventQueuedState.cc.
|
overrideprotectedvirtual |
Subclasses override to set up their signal connections.
Implements WaitStateBase.
Definition at line 29 of file EventQueuedState.cc.
References QGCAbstractState::machine(), and QGCStateMachine::machineEvent().
|
overrideprotectedvirtual |
Subclasses override to tear down their signal connections.
Implements WaitStateBase.
Definition at line 37 of file EventQueuedState.cc.
|
signal |
Emitted when an expected event is received, before completed()
| eventName | The name of the received event |
|
inline |
Get the set of expected event names.
Definition at line 60 of file EventQueuedState.h.
|
overrideprotectedvirtual |
Called when the state is entered - subclasses should call base implementation.
Reimplemented from WaitStateBase.
Definition at line 45 of file EventQueuedState.cc.
References WaitStateBase::onWaitEntered(), and QGCAbstractState::stateName().
|
inline |
Get the event that triggered completion (valid after completed() signal)
Definition at line 63 of file EventQueuedState.h.
| void EventQueuedState::removeExpectedEvent | ( | const QString & | eventName | ) |
Remove an event from the expected set
| eventName | Event name to remove |
Definition at line 24 of file EventQueuedState.cc.