QP/C platform-independent public interface. More...
Go to the source code of this file.
Classes | |
class | QEvt |
Event class. More... | |
struct | QMState |
State object for the QMsm class (QM State Machine) More... | |
struct | QMTranActTable |
Transition-Action Table for the QMsm State Machine. More... | |
union | QAsmAttr |
Attribute of for the QAsm class (Abstract State Machine) More... | |
class | QAsm |
Abstract State Machine class (state machine interface) More... | |
struct | QAsmVtable |
Virtual table for the QAsm class. More... | |
class | QHsm |
Hierarchical State Machine class (QHsm-style state machine implementation strategy) More... | |
class | QMsm |
Hierarchical State Machine class (QMsm-style state machine implementation strategy) More... | |
class | QPSet |
Set of Active Objects of up to QF_MAX_ACTIVE elements. More... | |
struct | QSubscrList |
Subscriber List (for publish-subscribe) More... | |
class | QActive |
Active object class (based on the QHsm implementation strategy) More... | |
class | QMActive |
Active object class (based on QMsm implementation strategy) More... | |
class | QTimeEvt |
Time Event class. More... | |
class | QTicker |
"Ticker" Active Object class More... | |
Macros | |
#define | QP_VERSION_STR "8.0.3" |
Version string complying with Semantic Versioning | |
#define | QP_VERSION 803U |
Version number for internal use (must correspond to QP_VERSION_STR) | |
#define | QP_RELEASE 0x6ABEE96CU |
Encrypted current QP release for internal use (7.3.5 on 2024-05-31) | |
#define | Q_UNUSED_PAR(par_) |
Helper macro to clearly mark unused parameters of functions. | |
#define | Q_DIM(array_) |
#define | Q_UINT2PTR_CAST(type_, uint_) |
Perform cast from unsigned integer uint_ to pointer of type type_ | |
#define | QEVT_INITIALIZER(sig_) |
Initializer for immutable (constant) QEvt instances. | |
#define | QEVT_DYNAMIC ((uint8_t)0) |
dummy parameter for dynamic event initialization (see QEvt::QEvt_init()) | |
#define | Q_EVT_CAST(class_) |
Perform downcast of an event onto a subclass of QEvt class_ | |
#define | Q_STATE_CAST(handler_) |
Perform cast to QStateHandler. | |
#define | Q_ACTION_CAST(action_) |
Perform cast to QActionHandler. | |
#define | Q_ACTION_NULL ((QActionHandler)0) |
Macro to provide strictly-typed zero-action to terminate action lists in the transition-action-tables. | |
#define | Q_RET_SUPER ((QState)0U) |
#define | Q_RET_UNHANDLED ((QState)1U) |
#define | Q_RET_HANDLED ((QState)2U) |
#define | Q_RET_IGNORED ((QState)3U) |
#define | Q_RET_ENTRY ((QState)4U) |
#define | Q_RET_EXIT ((QState)5U) |
#define | Q_RET_NULL ((QState)6U) |
#define | Q_RET_TRAN ((QState)7U) |
#define | Q_RET_TRAN_INIT ((QState)8U) |
#define | Q_RET_TRAN_HIST ((QState)9U) |
#define | Q_EMPTY_SIG ((QSignal)0U) |
reserved signal sent to state handler to execute the default case) | |
#define | Q_ENTRY_SIG ((QSignal)1U) |
reserved signal sent to state handler to execute the entry case) | |
#define | Q_EXIT_SIG ((QSignal)2U) |
reserved signal sent to state handler to execute the exit case) | |
#define | Q_INIT_SIG ((QSignal)3U) |
reserved signal sent to state handler to execute the initial transition) | |
#define | Q_USER_SIG ((enum_t)4) |
offset for the user signals (QP Application)) | |
#define | QASM_INIT(me_, par_, qsId_) |
QVirtual call to the top-most initial transition in a HSM. | |
#define | QASM_DISPATCH(me_, e_, qsId_) |
Virtual call to dispatch an event to a HSM. | |
#define | QASM_IS_IN(me_, stateHndl_) |
Virtual call to check whether a SM is in a given state. | |
#define | Q_ASM_UPCAST(ptr_) |
Perform upcasting from a subclass of QAsm to the base class QAsm. | |
#define | Q_HSM_UPCAST(ptr_) |
Perform upcasting from a subclass of QHsm to the base class QHsm. | |
#define | Q_TRAN(target_) |
Take transition to the specified target_ state. | |
#define | Q_TRAN_HIST(hist_) |
Take transition to the specified history of a given state. Applicable only to HSMs. | |
#define | Q_SUPER(super_) |
Designates the superstate of a given state. Applicable only to QHsm subclasses. | |
#define | Q_HANDLED() |
Indicate that an action has been "handled". Applies to entry/exit actions and to internal transitions. | |
#define | Q_UNHANDLED() |
Indicate that an internal transition has been "unhandled" due to a guard condition. | |
#define | Q_MSM_UPCAST(ptr_) |
Perform upcasting from a subclass of QMsm to the base class QMsm. | |
#define | QM_ENTRY(state_) |
Macro to call in a QM action-handler when it executes an entry action. Applicable only to QMsm subclasses. | |
#define | QM_EXIT(state_) |
Macro to call in a QM action-handler when it executes an exit action. Applicable only to QMsm subclasses. | |
#define | QM_TRAN(tatbl_) |
Macro to call in a QM state-handler when it executes a regular transition. Applicable only to QMsm subclasses. | |
#define | QM_TRAN_INIT(tatbl_) |
Macro to call in a QM state-handler when it executes an initial transition. Applicable only to QMsm subclasses. | |
#define | QM_TRAN_HIST(history_, tatbl_) |
Macro to call in a QM state-handler when it executes a transition to history. Applicable only to QMsm subclasses. | |
#define | QM_HANDLED() |
Macro to call in a QM state-handler when it handled an event. Applicable only to QMsm subclasses. | |
#define | QM_UNHANDLED() |
Indicate that an internal transition has been "unhandled" due to a guard condition. Applicable only to QMsm subclasses. | |
#define | QM_SUPER() |
Macro to call in a QM state-handler when it designates the superstate to handle an event. Applicable only to ::QMSMs. | |
#define | QM_STATE_NULL ((QMState *)0) |
#define | Q_PRIO(prio_, pthre_) |
Create a QPrioSpec object to specify priority of an AO or a thread. | |
#define | QF_NO_MARGIN ((uint_fast16_t)0xFFFFU) |
Special value of margin that causes asserting failure in case event allocation or event posting fails. | |
#define | Q_NEW(evtT_, sig_, ...) |
Allocate a mutable (dynamic) event. | |
#define | Q_NEW_X(evtT_, margin_, sig_, ...) |
Non-asserting allocate a mutable (dynamic) event. | |
#define | Q_NEW_REF(evtRef_, evtT_) |
Create a new reference of the current event e | |
#define | Q_DELETE_REF(evtRef_) |
Delete the event reference. | |
#define | QACTIVE_POST(me_, e_, sender_) |
Invoke the direct event posting facility QActive_post_(). | |
#define | QACTIVE_POST_X(me_, e_, margin_, sender_) |
Invoke the direct event posting facility QActive_post_() without delivery guarantee. | |
#define | QACTIVE_PUBLISH(e_, sender_) |
Publish an event to all subscriber Active Objects. | |
#define | QTIMEEVT_TICK_X(tickRate_, sender_) |
Invoke the system clock tick processing QTimeEvt_tick_() | |
#define | QTICKER_TRIG(ticker_, sender_) |
Asynchronously trigger the QTicker AO to perform tick processing. | |
#define | QACTIVE_POST_LIFO(me_, e_) |
Post an event to an active object using the Last-In-First-Out (LIFO) policy. | |
#define | QTIMEEVT_TICK(sender_) |
Invoke the system clock tick processing for tick rate 0. | |
#define | QF_CRIT_EXIT_NOP() |
No-operation for exiting a critical section. | |
Typedefs | |
typedef int | int_t |
Alias for assertion-ID numbers in QP assertions and return from QF_run() | |
typedef int | enum_t |
typedef uint16_t | QSignal |
The signal of event QEvt. | |
typedef QEvt const * | QEvtPtr |
Pointer to const event instances passed around in QP Framework. | |
typedef uint_fast8_t | QState |
Type returned from state-handler functions. | |
typedef QState(* | QStateHandler) (void *const me, QEvt const *const e) |
Pointer to a state-handler function. | |
typedef QState(* | QActionHandler) (void *const me) |
Pointer to an action-handler function. | |
typedef void(* | QXThreadHandler) (struct QXThread *const me) |
Pointer to an extended-thread handler function. | |
typedef uint16_t | QPrioSpec |
Priority specification for Active Objects in QP. | |
typedef uint32_t | QTimeEvtCtr |
Data type to store the block-size defined based on the macro QF_TIMEEVT_CTR_SIZE. | |
typedef uint32_t | QPSetBits |
Bitmask for the internal representation of QPSet elements. | |
Functions | |
uint_fast8_t | QF_LOG2 (QPSetBits const bitmask) |
Log-base-2 calculation when hardware acceleration is NOT provided (QF_LOG2 not defined) | |
Variables | |
char const | QP_versionStr [24] |
QP/C platform-independent public interface.
Definition in file qp.h.
#define QP_VERSION_STR "8.0.3" |
Version string complying with Semantic Versioning
MAJOR.MINOR.PATCH
compliant with Semantic Versioning. #define QP_VERSION 803U |
Version number for internal use (must correspond to QP_VERSION_STR)
MAJOR|MINOR|PATCH
corresponding to QP_VERSION_STR, with digits merged together. For example QP_VERSION_STR == "7.3.5-rc.1" results in QP_VERSION == 735. #define QP_RELEASE 0x6ABEE96CU |
Encrypted current QP release for internal use (7.3.5 on 2024-05-31)
#define Q_UNUSED_PAR | ( | par_ | ) |
#define Q_DIM | ( | array_ | ) |
#define Q_UINT2PTR_CAST | ( | type_, | |
uint_ ) |
Perform cast from unsigned integer uint_
to pointer of type type_
#define QEVT_INITIALIZER | ( | sig_ | ) |
Initializer for immutable (constant) QEvt instances.
QEvt. evtTag_
attribute. #define QEVT_DYNAMIC ((uint8_t)0) |
dummy parameter for dynamic event initialization (see QEvt::QEvt_init())
#define Q_EVT_CAST | ( | class_ | ) |
Perform downcast of an event onto a subclass of QEvt class_
class_ | a subclass of QEvt |
#define Q_STATE_CAST | ( | handler_ | ) |
Perform cast to QStateHandler.
#define Q_ACTION_CAST | ( | action_ | ) |
Perform cast to QActionHandler.
#define Q_ACTION_NULL ((QActionHandler)0) |
#define Q_EMPTY_SIG ((QSignal)0U) |
#define Q_ENTRY_SIG ((QSignal)1U) |
#define Q_EXIT_SIG ((QSignal)2U) |
#define Q_INIT_SIG ((QSignal)3U) |
#define Q_USER_SIG ((enum_t)4) |
offset for the user signals (QP Application))
#define QASM_INIT | ( | me_, | |
par_, | |||
qsId_ ) |
QVirtual call to the top-most initial transition in a HSM.
[in,out] | me_ | current instance pointer (see SAS_QP_OO) |
[in] | par_ | pointer the optional initialization parameter |
[in] | qsId_ | QS local filter ID (used only when Q_SPY is defined) |
#define QASM_DISPATCH | ( | me_, | |
e_, | |||
qsId_ ) |
Virtual call to dispatch an event to a HSM.
[in,out] | me_ | current instance pointer (see SAS_QP_OO) |
[in] | e_ | constant pointer the QEvt or a class derived from QEvt (see SAS_QP_OO) |
[in] | qsId_ | QS local filter ID (used only when Q_SPY is defined) |
#define QASM_IS_IN | ( | me_, | |
stateHndl_ ) |
Virtual call to check whether a SM is in a given state.
[in,out] | me_ | current instance pointer (see SAS_QP_OO) |
[in] | state_ | state handler (QStateHandler type) |
#define Q_ASM_UPCAST | ( | ptr_ | ) |
Perform upcasting from a subclass of QAsm to the base class QAsm.
[in,out] | ptr_ | pointer to subclass of QAsm |
#define Q_HSM_UPCAST | ( | ptr_ | ) |
Perform upcasting from a subclass of QHsm to the base class QHsm.
[in,out] | ptr_ | pointer to subclass of QHsm |
#define Q_TRAN | ( | target_ | ) |
Take transition to the specified target_
state.
#define Q_TRAN_HIST | ( | hist_ | ) |
Take transition to the specified history of a given state. Applicable only to HSMs.
#define Q_SUPER | ( | super_ | ) |
Designates the superstate of a given state. Applicable only to QHsm subclasses.
#define Q_HANDLED | ( | ) |
Indicate that an action has been "handled". Applies to entry/exit actions and to internal transitions.
#define Q_UNHANDLED | ( | ) |
Indicate that an internal transition has been "unhandled" due to a guard condition.
#define Q_MSM_UPCAST | ( | ptr_ | ) |
Perform upcasting from a subclass of QMsm to the base class QMsm.
[in,out] | ptr_ | pointer to subclass of QMsm |
#define QM_ENTRY | ( | state_ | ) |
Macro to call in a QM action-handler when it executes an entry action. Applicable only to QMsm subclasses.
#define QM_EXIT | ( | state_ | ) |
Macro to call in a QM action-handler when it executes an exit action. Applicable only to QMsm subclasses.
#define QM_TRAN | ( | tatbl_ | ) |
Macro to call in a QM state-handler when it executes a regular transition. Applicable only to QMsm subclasses.
#define QM_TRAN_INIT | ( | tatbl_ | ) |
Macro to call in a QM state-handler when it executes an initial transition. Applicable only to QMsm subclasses.
#define QM_TRAN_HIST | ( | history_, | |
tatbl_ ) |
Macro to call in a QM state-handler when it executes a transition to history. Applicable only to QMsm subclasses.
#define QM_HANDLED | ( | ) |
Macro to call in a QM state-handler when it handled an event. Applicable only to QMsm subclasses.
#define QM_UNHANDLED | ( | ) |
Indicate that an internal transition has been "unhandled" due to a guard condition. Applicable only to QMsm subclasses.
#define QM_SUPER | ( | ) |
Macro to call in a QM state-handler when it designates the superstate to handle an event. Applicable only to ::QMSMs.
#define Q_PRIO | ( | prio_, | |
pthre_ ) |
Create a QPrioSpec object to specify priority of an AO or a thread.
[in] | prio_ | QF priority [1..QF_MAX_ACTIVE] |
[in] | pthre_ | Preemption threshold [1..QF_MAX_ACTIVE] |
prio_
in bits [0..7] and pthre_
in bits [8..15]. #define QF_NO_MARGIN ((uint_fast16_t)0xFFFFU) |
#define Q_NEW | ( | evtT_, | |
sig_, | |||
... ) |
Allocate a mutable (dynamic) event.
The macro calls the internal QF function QF_newX_() with argument margin
== QF_NO_MARGIN, which causes an assertion failure when the event cannot be successfully allocated.
[in] | evtT_ | event type (class name) of the event to allocate |
[in] | sig_ | signal to assign to the newly allocated event |
evtT_
. init()
function needs to take at least one parameter and must return the event pointer (me
).The following example illustrates variadic version of Q_NEW() and the RAII principle (Resource Acquisition Is Initialization) (when QEVT_PAR_INIT IS defined) :
#define Q_NEW_X | ( | evtT_, | |
margin_, | |||
sig_, | |||
... ) |
Non-asserting allocate a mutable (dynamic) event.
margin
of free events left. If the event pool has insufficient number of events left, the macro returns NULL. The caller of this macro is responsible for checking the returned event pointer for NULL. [in] | evtT_ | event type (class name) of the event to allocate |
[in] | margin_ | number of events that must remain available in the given pool after this allocation. The special value QF_NO_MARGIN causes asserting failure in case event allocation fails. |
[in] | sig_ | signal to assign to the newly allocated event |
evtT_
or NULL if the event cannot be allocated with the specified margin
of events still left in the event pool. init()
function needs to take at least one parameter and must return the event pointer (me
).#define Q_NEW_REF | ( | evtRef_, | |
evtT_ ) |
Create a new reference of the current event e
[in,out] | evtRef_ | event reference to create |
[in] | evtT_ | event type (class name) of the event reference |
examples/win32/defer
illustrates the use of Q_NEW_REF() #define Q_DELETE_REF | ( | evtRef_ | ) |
Delete the event reference.
[in,out] | evtRef_ | event reference to delete |
examples/win32/defer
illustrates the use of Q_DELETE_REF() #define QACTIVE_POST | ( | me_, | |
e_, | |||
sender_ ) |
Invoke the direct event posting facility QActive_post_().
[in,out] | me_ | current instance pointer (see SAS_QP_OO) |
[in] | e_ | pointer to the event to post |
[in] | sender_ | pointer to the sender object. |
sender_
parameter is actually only used when QS software tracing is enabled (macro Q_SPY is defined). When QS software tracing is disabled, this macro does not use the sender_
parameter, so it does not need to be defined. sender_
parameter is actually only used when QS software tracing is enabled (macro Q_SPY is defined). When QS software tracing is disabled, this macro does not use the sender_
parameter, so it does not need to be defined. #define QACTIVE_POST_X | ( | me_, | |
e_, | |||
margin_, | |||
sender_ ) |
Invoke the direct event posting facility QActive_post_() without delivery guarantee.
[in,out] | me_ | current instance pointer (see SAS_QP_OO) |
[in] | e_ | pointer to the event to post |
[in] | margin_ | the minimum free slots in the queue, which must still be available after posting the event. The special value QF_NO_MARGIN causes asserting failure in case event posting fails. |
[in] | sender_ | pointer to the sender object. |
sender_
parameter is actually only used when QS software tracing is enabled (macro Q_SPY is defined). When QS software tracing is disabled, this macro does not use the sender_
parameter, so it does not need to be defined. sender
object is not necessarily a pointer to an active object. In fact, if QACTIVE_POST_X() is called from an interrupt or other context, you can create a unique object just to unambiguously identify the sender of the event.#define QACTIVE_PUBLISH | ( | e_, | |
sender_ ) |
Publish an event to all subscriber Active Objects.
sender_
parameter to identify the publisher of the event. Otherwise, sender_
is not used. [in] | e_ | pointer to the posted event |
[in] | sender_ | pointer to the sender object (actually used only when Q_SPY is defined) |
sender_
parameter is actually only used when QS software tracing is enabled (macro Q_SPY is defined). When QS software tracing is disabled, the QACTIVE_PUBLISH() macro does not use the sender_
parameter, so it does not need to be defined.#define QTIMEEVT_TICK_X | ( | tickRate_, | |
sender_ ) |
Invoke the system clock tick processing QTimeEvt_tick_()
[in] | tickRate_ | clock tick rate to be serviced through this call |
[in] | sender_ | pointer to the sender object. This parameter is actually only used when QS software tracing is enabled (macro Q_SPY is defined) |
sender_
parameter is actually only used when QS software tracing is enabled (macro Q_SPY is defined). When QS software tracing is disabled, the sender_
parameter is unused and does not even need to be defined in the program.#define QTICKER_TRIG | ( | ticker_, | |
sender_ ) |
Asynchronously trigger the QTicker AO to perform tick processing.
[in] | ticker_ | pointer to the QTicker active object |
[in] | sender_ | pointer to the sender object. This parameter is actually only used when QS software tracing is enabled (macro Q_SPY is defined) |
sender_
parameter, so it does not need to be defined. sender_
object is not necessarily a pointer to an active object. In fact, when QTICKER_TRIG() is called from an interrupt, you would create a unique object just to unambiguously identify the ISR as the sender of the time events.#define QACTIVE_POST_LIFO | ( | me_, | |
e_ ) |
Post an event to an active object using the Last-In-First-Out (LIFO) policy.
[in,out] | me_ | current instance pointer (see SAS_QP_OO) |
[in] | e_ | pointer to the event to post |
#define QTIMEEVT_TICK | ( | sender_ | ) |
Invoke the system clock tick processing for tick rate 0.
#define QF_CRIT_EXIT_NOP | ( | ) |
No-operation for exiting a critical section.
typedef int int_t |
typedef uint16_t QSignal |
The signal of event QEvt.
typedef uint_fast8_t QState |
typedef QState(* QActionHandler) (void *const me) |
typedef void(* QXThreadHandler) (struct QXThread *const me) |
typedef uint16_t QPrioSpec |
Priority specification for Active Objects in QP.
QPrioSpec allows an application developer to assign two priorities to a given AO (see also Q_PRIO()):
In the QP native preemptive kernels, like QK, the "preemption-threshold" priority is used as to implement the "preemption-threshold scheduling" (PTS). It determines the conditions under which a given thread can be preempted by other threads. Specifically, a given thread can be preempted only by another thread with a higher priority than the "preemption-threshold" of the original thread.
typedef uint32_t QTimeEvtCtr |
Data type to store the block-size defined based on the macro QF_TIMEEVT_CTR_SIZE.
typedef uint32_t QPSetBits |
uint_fast8_t QF_LOG2 | ( | QPSetBits const | bitmask | ) |