Hello,
I have a question regarding the usage of QASM_IS_IN() / QHsm_isIn_() in QP/C.
I noticed that QASM_IS_IN() is only available when Q_SPY is enabled:
#ifdef Q_SPY
#define QASM_IS_IN(me_, stateHndl_) \
(*((QAsm *)(me_))->vptr->isIn)((QAsm *)(me_), (stateHndl_))
#endif
Internally, this calls QHsm_isIn_():
bool QHsm_isIn_(QAsm * const me,
QStateHandler const stateHndl)
My use case is very simple:
I would like to check whether an HSM is currently inside a specific state (or substate hierarchy) during runtime, for example:
if (QASM_IS_IN(&myHsm.super, &SomeState)) {
...
}
However, I do not want to enable Q_SPY in production builds just to use this functionality.
I also noticed comments in the headers mentioning that this API is protected/private/internal, so I wanted to ask:
- Is there any technical or architectural reason why
QASM_IS_IN() is restricted to Q_SPY builds?
- Is using
QHsm_isIn_() directly considered unsafe or unsupported?
- Is there a recommended public API for checking the current state/substate membership of an HSM?
- Would it be acceptable to expose
QASM_IS_IN() outside of Q_SPY, or is there a hidden invariant/performance concern behind this design?
From reading the implementation, it seems to only walk the superstate hierarchy and restore the invariant afterwards, so I wanted to understand whether there are any side effects or design reasons I might be missing.
Thank you.
Hello,
I have a question regarding the usage of
QASM_IS_IN()/QHsm_isIn_()in QP/C.I noticed that
QASM_IS_IN()is only available whenQ_SPYis enabled:Internally, this calls
QHsm_isIn_():My use case is very simple:
I would like to check whether an HSM is currently inside a specific state (or substate hierarchy) during runtime, for example:
However, I do not want to enable
Q_SPYin production builds just to use this functionality.I also noticed comments in the headers mentioning that this API is protected/private/internal, so I wanted to ask:
QASM_IS_IN()is restricted toQ_SPYbuilds?QHsm_isIn_()directly considered unsafe or unsupported?QASM_IS_IN()outside ofQ_SPY, or is there a hidden invariant/performance concern behind this design?From reading the implementation, it seems to only walk the superstate hierarchy and restore the invariant afterwards, so I wanted to understand whether there are any side effects or design reasons I might be missing.
Thank you.