Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: qp_hangman qp_dpp qp_blinky
QHsm Class Reference
Hierarchical State Machine base class. More...
#include <qp.h>
Public Member Functions | |
| virtual | ~QHsm () |
| virtual destructor | |
| void | init (QEvt const *const e=static_cast< QEvt const * >(0)) |
| Performs the second step of HSM initialization by triggering the top-most initial transition. | |
| void | dispatch (QEvt const *const e) |
| Dispatches an event to a HSM. | |
| bool | isIn (QStateHandler const s) |
| Tests if a given state is part of the current active state configuratioin. | |
Protected Types | |
| enum | ReservedHsmSignals { Q_ENTRY_SIG = 1, Q_EXIT_SIG, Q_INIT_SIG } |
Protected Member Functions | |
| QHsm (QStateHandler const initial) | |
| Protected constructor of a HSM. | |
| QStateHandler | state (void) const |
| Return the current active state. | |
| QState | tran (QStateHandler const target) |
| internal helper function to record a state transition | |
| QState | super (QStateHandler const superstate) |
| internal helper function to record the superstate | |
Static Protected Member Functions | |
| static QState | top (void *const me, QEvt const *const e) |
| the top-state. | |
| static QState | Q_HANDLED (void) |
| Inline function to specify the return of a state-handler when it handles the event. | |
| static QState | Q_UNHANDLED (void) |
| Macro to specify the return of a state-handler function when it attempts to handle the event but a guard condition evaluates to false and there is no other explicit way of handling the event. | |
Detailed Description
Hierarchical State Machine base class.
QHsm represents a Hierarchical Finite State Machine (HSM). QHsm derives from the QFsm class and extends the capabilities of a basic FSM with state hierarchy.
- Note:
- QHsm is not intended to be instantiated directly, but rather serves as the base structure for derivation of state machines in the application code.
The following example illustrates how to derive a state machine class from QHsm.
Definition at line 448 of file qp.h.
Member Enumeration Documentation
enum ReservedHsmSignals [protected] |
Constructor & Destructor Documentation
| QP_END_ QP_BEGIN_ ~QHsm | ( | ) | [virtual] |
| QHsm | ( | QStateHandler const | initial ) | [protected] |
Protected constructor of a HSM.
Performs the first step of HSM initialization by assigning the initial pseudostate to the currently active state of the state machine.
- Note:
- The constructor is protected to prevent direct instantiating of QHsm objects. This class is intended for subclassing only.
- See also:
- The QHsm example illustrates how to use the QHsm constructor in the constructor initializer list of the derived state machines.
- QFsm::QFsm()
Member Function Documentation
| QP_END_ QP_BEGIN_ void dispatch | ( | QEvt const *const | e ) |
Dispatches an event to a HSM.
QHsm::dispatch() implementation.
Processes one event at a time in Run-to-Completion (RTC) fashion. The argument e is a constant pointer the QEvt or a class derived from QEvt.
- Note:
- Must be called after QHsm::init().
- See also:
- example for QHsm::init()
Performs the second step of HSM initialization by triggering the top-most initial transition.
- Note:
- Must be called only ONCE before QHsm::dispatch()
The following example illustrates how to initialize a HSM, and dispatch events to it:
| bool isIn | ( | QStateHandler const | s ) |
Tests if a given state is part of the current active state configuratioin.
- Parameters:
-
state is a pointer to the state handler function, e.g., &QCalc::on.
| static QState Q_HANDLED | ( | void | ) | [static, protected] |
| static QState Q_UNHANDLED | ( | void | ) | [static, protected] |
| QStateHandler state | ( | void | ) | const [protected] |
| QState super | ( | QStateHandler const | superstate ) | [protected] |
| QP_END_ QP_BEGIN_ QState top | ( | void *const | me, |
| QEvt const *const | e | ||
| ) | [static, protected] |
the top-state.
QHsm::top() implementation.
QHsm::top() is the ultimate root of state hierarchy in all HSMs derived from QHsm. This state handler always returns (QSTATE)0, which means that it "handles" all events.
- See also:
- Example of the QCalc::on() state handler.
Generated on Wed Jul 13 2022 11:50:18 by
1.7.2