66 #define RKH_SM_NAME(smName_) s_##smName_
67 #define RKH_SM_CONST_NAME(smName_) rs_##smName_
81 #define ELSE rkh_sm_else
152 #define RKH_CREATE_COMP_REGION_STATE(name, en, ex, parent, defchild, \
154 kindOfHistory, hDftTrnGuard, \
155 hDftTrnAction, hDftTarget, hRamMem) \
157 MKFINAL_INCOMP(name); \
158 MKHIST_INCOMP(name, kindOfHistory, hDftTrnGuard, hDftTrnAction, \
159 hDftTarget, hRamMem); \
161 extern RKHROM RKH_TR_T name##_trtbl[]; \
162 RKHROM RKH_SCMP_T name = \
164 {MKBASE(RKH_COMPOSITE, name), MKST(en, ex, parent)}, \
165 MKCOMP(name, defchild, initialTrn, &name##Hist) \
191 #define RKH_CREATE_COMP_STATE(name, en, ex, parent, defchild, history) \
193 extern RKHROM RKH_TR_T name##_trtbl[]; \
194 RKHROM RKH_SCMP_T name = \
196 {MKBASE(RKH_COMPOSITE, name), MKST(en, ex, parent)}, \
197 MKCOMP(name, defchild, NULL, history) \
212 #define RKH_CREATE_FINAL_STATE(name, parent) \
214 static RKHROM RKH_TR_T name##_trtbl[] = \
215 RKH_TRREG(RKH_ANY, NULL, NULL, NULL); \
216 RKHROM RKH_FINAL_T name = \
218 {MKBASE(RKH_FINAL, name), MKST(NULL, NULL, parent)}, \
277 #define RKH_CREATE_BASIC_STATE(name, en, ex, parent, prepro) \
279 extern RKHROM RKH_TR_T name##_trtbl[]; \
281 RKHROM RKH_SBSC_T name = \
283 {MKBASE(RKH_BASIC, name), MKST(en,ex,parent)}, \
284 MKBASIC(name,prepro) \
313 #define RKH_CREATE_COND_STATE(name) \
315 extern RKHROM RKH_TR_T name##_trtbl[]; \
317 RKHROM RKH_SCOND_T name = \
319 MKBASE(RKH_CONDITIONAL, name), \
349 #define RKH_CREATE_CHOICE_STATE(name) \
351 extern RKHROM RKH_TR_T name##_trtbl[]; \
353 RKHROM RKH_SCHOICE_T name = \
355 MKBASE(RKH_CHOICE, name), \
393 #define RKH_CREATE_DEEP_HISTORY_STATE(name, parent, dftTrnGuard, \
394 dftTrnAction, dftTarget) \
396 static RKHROM RKH_ST_T *ram##name; \
397 MKHISTORY(name, parent, RKH_DHISTORY, dftTrnGuard, dftTrnAction, \
398 dftTarget, &ram##name)
436 #define RKH_CREATE_SHALLOW_HISTORY_STATE(name, parent, dftTrnGuard, \
437 dftTrnAction, dftTarget) \
439 static RKHROM RKH_ST_T *ram##name; \
440 MKHISTORY(name, parent, RKH_SHISTORY, dftTrnGuard, dftTrnAction, \
441 dftTarget, &ram##name)
493 #define RKH_CREATE_SUBMACHINE_STATE(name, en, ex, parent, sbm) \
495 extern RKHROM RKH_EXPCN_T name##_exptbl[]; \
496 extern RKHROM RKH_TR_T name##_trtbl[]; \
498 RKHROM RKH_SSBM_T name = \
500 {MKBASE(RKH_SUBMACHINE, name), MKST(en,ex,parent)}, \
529 #define RKH_CREATE_EX_CNNPNT_TABLE(name) \
530 RKHROM RKH_EXPCN_T name##_exptbl[]= \
575 #define RKH_EX_CNNPNT(name, expnt, act, ts) \
576 {(RKH_TRN_ACT_T)act, (RKHROM struct RKH_ST_T *)ts}
599 #define RKH_END_EX_CNNPNT_TABLE };
623 #define RKH_EN_CNNPNT(name, enpnt, subm) \
625 RKHROM RKH_SENP_T name = \
627 MKBASE(RKH_ENPOINT, name), \
654 #define RKH_CREATE_REF_SUBMACHINE(name, defchild, iact) \
656 static RKHROM RKH_ST_T * rdyp_##name; \
658 RKHROM RKH_RSM_T name = \
660 MKBASE(RKH_REF_SUBMACHINE, name), \
661 MKMCH(defchild,iact,name) \
708 #define RKH_CREATE_REF_EXPNT(name, ix, subm) \
710 RKHROM RKH_SEXP_T name = \
712 MKBASE(RKH_EXPOINT, name), \
745 #define RKH_CREATE_REF_ENPNT(name, act, ts, subm) \
747 RKHROM RKH_ENPCN_T name = \
749 (RKH_TRN_ACT_T)act, (RKHROM struct RKH_ST_T *)ts \
777 #define RKH_CREATE_TRANS_TABLE(name) \
779 RKHROM RKH_TR_T name##_trtbl[]= \
811 #define RKH_TRREG(evt_, guard_, effect_, target_) \
812 MKTRN(evt_, guard_, effect_, target_)
835 #define RKH_TRINT(e, g, a) {e, (RKH_GUARD_T)g, (RKH_TRN_ACT_T)a, NULL}
870 #define RKH_TRCOMPLETION(guard_, effect_, target_) \
871 {RKH_COMPLETION_EVENT, \
872 (RKH_GUARD_T)guard_, (RKH_TRN_ACT_T)effect_, target_}
894 #define RKH_END_TRANS_TABLE {RKH_ANY, NULL, NULL, NULL}};
920 #define RKH_CREATE_BRANCH_TABLE(name) \
922 RKH_CREATE_TRANS_TABLE(name)
956 #define RKH_BRANCH(guard_, effect_, target_) \
957 MKTRN(0, guard_, effect_, target_)
972 #define RKH_CREATE_HISTORY_STORAGE(compStateName) \
973 static RKHROM RKH_ST_T *ramHist_##compStateName
986 #define RKH_GET_HISTORY_STORAGE(compStateName) \
987 &ramHist_##compStateName
993 #define RKH_EBTBL {RKH_ANY, NULL, NULL, NULL}
1013 #define RKH_END_BRANCH_TABLE RKH_EBTBL};
1019 #define RKH_ROOT RKH_NULL
1048 #define RKH_SM_DCLR(me_) \
1049 RKH_DCLR_PTR_TYPE(RKH_SM_T, me_)
1073 #define RKH_SM_DCLR_TYPE(type_, me_) \
1074 RKH_DCLR_PTR_TYPE(type_, me_)
1085 #define RKH_DCLR_COMP_STATE extern RKHROM RKH_SCMP_T
1086 #define RKH_DCLR_BASIC_STATE extern RKHROM RKH_SBSC_T
1087 #define RKH_DCLR_FINAL_STATE extern RKHROM RKH_FINAL_T
1088 #define RKH_DCLR_COND_STATE extern RKHROM RKH_SCOND_T
1089 #define RKH_DCLR_CHOICE_STATE extern RKHROM RKH_SCHOICE_T
1090 #define RKH_DCLR_DHIST_STATE extern RKHROM RKH_SHIST_T
1091 #define RKH_DCLR_SHIST_STATE extern RKHROM RKH_SHIST_T
1092 #define RKH_DCLR_SUBM_STATE extern RKHROM RKH_SSBM_T
1093 #define RKH_DCLR_REF_SUBM extern RKHROM RKH_RSM_T
1094 #define RKH_DCLR_ENPNT extern RKHROM RKH_SENP_T
1095 #define RKH_DCLR_REF_EXPNT extern RKHROM RKH_SEXP_T
1096 #define RKH_DCLR_REF_ENPNT extern RKHROM RKH_ENPCN_T
1105 #define RKH_DECLARE_TR_TBL(name) \
1106 extern RKHROM RKH_TR_T name##_trtbl[]
1131 #define RKH_DCLR_SM_GLOBAL(sm_t, sm, gob) \
1132 sm_t * const gob = &s_##sm;
1149 #define RKH_DCLR_SM_CONST_GLOBAL(smName) \
1150 extern RKHROM RKH_ROM_T RKH_SM_CONST_NAME(smName)
1276 #define RKH_INIT_BASIC_STATE(name, en, ex, parent, prepro) \
1279 MKBASE(RKH_BASIC, name), \
1280 MKST(en, ex, parent) \
1282 MKBASIC(name, prepro) \
1299 #define RKH_INIT_COMPOSITE_STATE(name, en, ex, parent, \
1300 defchild, history) \
1303 MKBASE(RKH_COMPOSITE, name), \
1304 MKST(en, ex, parent) \
1306 MKCOMP(name, defchild, history) \
1317 #define RKH_GFALSE RKH_FALSE
1318 #define RKH_GTRUE RKH_TRUE
1352 #if RKH_CFG_SMA_SM_CONST_EN == RKH_ENABLED
1353 #define RKH_SM_CREATE(type, name, prio, ppty, initialState, \
1354 initialAction, initialEvt) \
1355 static RKH_SM_CONST_CREATE(name, prio, ppty, initialState, \
1356 initialAction, initialEvt); \
1357 static type s_##name = {MKSM(&RKH_SM_CONST_NAME(name), initialState)}
1359 #define RKH_SM_CREATE(type, name, prio, ppty, initialState, \
1360 initialAction, initialEvt) \
1361 static type RKH_SMA_NAME(name) = {MKSM(name, prio, ppty, initialState, \
1362 initialAction, initialEvt)}
1396 #if RKH_CFG_SMA_SM_CONST_EN == RKH_ENABLED
1397 #define RKH_SM_INIT(me_, nameSMConst_, prio_, ppty_, initialState_, \
1398 initialAction_, initialEvt_) \
1399 ((RKH_SM_T *)me_)->romrkh = \
1400 (RKHROM RKH_ROM_T *)(RKH_SM_GET_CONST_OBJ(nameSMConst_)); \
1401 ((RKH_SM_T *)me_)->state = \
1402 (RKHROM struct RKH_ST_T *) \
1403 ((RKH_SM_GET_CONST_OBJ(nameSMConst_))->istate)
1405 #define RKH_SM_INIT(me_, nameSMConst_, prio_, ppty_, initialState_, \
1406 initialAction_, initialEvt_) \
1407 MKRT_SM(me_, nameSMConst_, prio_, ppty_, initialState_, \
1408 initialAction_, initialEvt_)
1441 #if RKH_CFG_SMA_SM_CONST_EN == RKH_ENABLED
1442 #define RKH_SM_CONST_CREATE(name, prio, ppty, initialState, \
1443 initialAction, initialEvt) \
1444 RKHROM RKH_ROM_T RKH_SM_CONST_NAME(name) = \
1452 #define RKH_SM_CONST_CREATE(name, prio, ppty, initialState, \
1453 initialAction, initialEvt)
1463 #if RKH_CFG_SMA_SM_CONST_EN == RKH_ENABLED
1464 #define RKH_SM_GET_CONST(sm) \
1465 ((RKH_SM_T *)sm)->romrkh
1467 #define RKH_SM_GET_CONST(sm) \
1477 #if RKH_CFG_SMA_SM_CONST_EN == RKH_ENABLED
1478 #define RKH_SM_GET_CONST_OBJ(sm) \
1479 &RKH_SM_CONST_NAME(sm)
1481 #define RKH_SM_GET_CONST_OBJ(sm) \
1485 #if RKH_CFG_SMA_SM_CONST_EN == RKH_ENABLED
1486 #define RKH_SM_GET_OBJ(type, sm)
1488 #define RKH_SM_GET_OBJ(type, sm) \
1489 (type *)&RKH_SM_NAME(sm)
1501 #define RKH_SM_DEF_PTR(sm) \
1502 RKH_SM_T *const sm = (RKH_SM_T *)&RKH_SM_NAME(sm)
1518 #define RKH_SM_DEF_PTR_TYPE(type, sm) \
1519 type *const sm = (type *)&RKH_SM_NAME(sm)
1530 #define RKH_GET_CSTATE_ID(me) \
1531 ((RKH_BASE_T *)(((RKH_SM_T *)me)->state))->id
1533 #if R_TRC_AO_NAME_EN == RKH_ENABLED
1543 #define RKH_GET_VERTEX_NAME(vx) \
1544 ((struct RKH_BASE_T *)(vx))->name
1546 #define RKH_GET_VERTEX_NAME(vx) noname
1652 #if RKH_CFG_SMA_ENT_ARG_SMA_EN == RKH_ENABLED
1653 #if RKH_CFG_SMA_ENT_ARG_STATE_EN == RKH_ENABLED
1660 #if RKH_CFG_SMA_ENT_ARG_STATE_EN == RKH_ENABLED
1692 #if RKH_CFG_SMA_EXT_ARG_SMA_EN == RKH_ENABLED
1693 #if RKH_CFG_SMA_ENT_ARG_STATE_EN == RKH_ENABLED
1700 #if RKH_CFG_SMA_ENT_ARG_STATE_EN == RKH_ENABLED
1725 #if RKH_CFG_SMA_PPRO_ARG_SMA_EN == RKH_ENABLED
1763 #if (RKH_CFG_SMA_ACT_ARG_EVT_EN == RKH_ENABLED && \
1764 RKH_CFG_SMA_ACT_ARG_SMA_EN == RKH_ENABLED)
1767 #elif (RKH_CFG_SMA_ACT_ARG_EVT_EN == RKH_ENABLED && \
1768 RKH_CFG_SMA_ACT_ARG_SMA_EN == RKH_DISABLED)
1770 #elif (RKH_CFG_SMA_ACT_ARG_EVT_EN == RKH_DISABLED && \
1771 RKH_CFG_SMA_ACT_ARG_SMA_EN == RKH_ENABLED)
1801 #if (RKH_CFG_SMA_GRD_ARG_EVT_EN == RKH_ENABLED && \
1802 RKH_CFG_SMA_GRD_ARG_SMA_EN == RKH_ENABLED)
1806 #elif (RKH_CFG_SMA_GRD_ARG_EVT_EN == RKH_ENABLED && \
1807 RKH_CFG_SMA_GRD_ARG_SMA_EN == RKH_DISABLED)
1809 #elif (RKH_CFG_SMA_GRD_ARG_EVT_EN == RKH_DISABLED && \
1810 RKH_CFG_SMA_GRD_ARG_SMA_EN == RKH_ENABLED)
1816 #if RKH_CFG_SMA_SM_CONST_EN == RKH_ENABLED
1856 #if R_TRC_AO_NAME_EN == RKH_ENABLED
1886 #if RKH_CFG_SMA_INIT_EVT_EN == RKH_ENABLED
1903 #if RKH_CFG_SMA_SM_CONST_EN == RKH_ENABLED
1947 #if R_TRC_AO_NAME_EN == RKH_ENABLED
1977 #if RKH_CFG_SMA_INIT_EVT_EN == RKH_ENABLED
2019 #if R_TRC_AO_NAME_EN == RKH_ENABLED
2072 #if RKH_CFG_SMA_HCAL_EN == RKH_ENABLED
2145 #if RKH_CFG_SMA_PPRO_EN == RKH_ENABLED
2202 #if RKH_CFG_SMA_PPRO_EN == RKH_ENABLED
2206 #if RKH_CFG_SMA_HCAL_EN == RKH_ENABLED
2223 #if defined(RKH_HISTORY_ENABLED)
2251 #if RKH_CFG_SMA_PPRO_EN == RKH_ENABLED
2260 #if defined(RKH_SUBMACHINE_ENABLED)
2479 #if defined(RKH_CHOICE_OR_CONDITIONAL_ENABLED)
2500 #if defined(RKH_CHOICE_ENABLED)
2645 #if (RKH_CFG_SMA_GRD_ARG_EVT_EN == RKH_ENABLED && \
2646 RKH_CFG_SMA_GRD_ARG_SMA_EN == RKH_ENABLED)
2648 #elif (RKH_CFG_SMA_GRD_ARG_EVT_EN == RKH_ENABLED && \
2649 RKH_CFG_SMA_GRD_ARG_SMA_EN == RKH_DISABLED)
2651 #elif (RKH_CFG_SMA_GRD_ARG_EVT_EN == RKH_DISABLED && \
2652 RKH_CFG_SMA_GRD_ARG_SMA_EN == RKH_ENABLED)
2653 rbool_t rkh_sm_else(
const RKH_SM_T *sma);
2655 rbool_t rkh_sm_else(
void);
ruint rkh_sm_dispatch(RKH_SM_T *me, RKH_EVT_T *e)
Executes a state machine in a run-to-completation (RTC) model.
RKH_HPPTY_T
State machine properties.
void rkh_sm_ctor(RKH_SM_T *me)
Initializes the attributes of the state machine instance.
RKH_RCODE_T
Return codes from rkh_sm_dispatch() function.
void rkh_sm_init(RKH_SM_T *me)
Inits a previously created state machine calling its initializing action.
void rkh_sm_clear_history(RKHROM RKH_SHIST_T *h)
Erase the history of a state. It can be a shallow or deep history.
RKH engine interface.This header file is directly included in RKH interface file, rkh....
void(* RKH_EXT_ACT_T)(const RKH_SM_T *me)
Exit action.
void(* RKH_ENT_ACT_T)(const RKH_SM_T *me)
Entry action.
RKH_SIG_T(* RKH_PPRO_T)(const RKH_SM_T *sma, RKH_EVT_T *pe)
Event preprocessor.
rbool_t(* RKH_GUARD_T)(const RKH_SM_T *me, RKH_EVT_T *pe)
Guard.
void(* RKH_TRN_ACT_T)(const RKH_SM_T *me, RKH_EVT_T *pe)
Transition action.
Maintains the basic information of a state.
const char * name
Name of state or pseudostate.
Describes the entry point connection.
RKHROM void * target
Points to target state.
RKH_TRN_ACT_T action
Points to transition action.
Represents events without parameters.
Describes the exit point connection.
RKHROM void * target
Points to target state.
RKH_TRN_ACT_T action
Points to transition action.
Constant parameters of state machine.
RKH_TRN_ACT_T iaction
Points to initializing action (optional).
rui8_t ppty
State machine properties.
const RKH_EVT_T * ievent
Pointer to an event that will be passed to state machine application when it starts....
const char * name
Name of State Machine Application (a.k.a Active Object).
RKHROM RKH_ST_T * istate
Points to initial state.
rui8_t prio
SMA (a.k.a Active Object) priority.
Describes a (referenced) submachine state machine.
RKH_TRN_ACT_T iaction
Points to initializing action (optional).
RKHROM RKH_ST_T ** dyp
Points to RAM memory location which stores the dynamic parent.
RKH_BASE_T base
Maintains the basic information of state.
RKHROM void * defchild
Points to state's default child.
RKH_PPRO_T prepro
Points to event preprocessor.
RKHROM RKH_TR_T * trtbl
Points to state transition table.
Describes the choice pseudostate.
RKH_BASE_T base
Maintains the basic information of state.
RKHROM RKH_TR_T * trtbl
Points to branch table.
Describes a composite state.
RKH_PPRO_T prepro
Points to event preprocessor.
RKHROM RKH_SHIST_T * history
Points to state's history.
RKHROM void * defchild
Points to state's default child.
RKHROM RKH_TR_T * trtbl
Points to state transition table.
RKH_TRN_ACT_T initialAction
Points to state's initial action.
Describes the conditional pseudostate.
RKH_BASE_T base
Maintains the basic information of state.
RKHROM RKH_TR_T * trtbl
Points to branch table.
Describes the entry point pseudostate.
RKHROM RKH_ENPCN_T * enpcn
Points to entry point connection.
RKH_BASE_T base
Maintains the basic information of state.
RKHROM RKH_ST_T * parent
Points to state's parent (submachine state).
Describes the exit point pseudostate.
rui8_t ix
Index of exit point table.
RKH_BASE_T base
Maintains the basic information of state.
RKHROM RKH_RSM_T * parent
Points to state's parent (referenced submachine).
Describes the history pseudostate.
RKH_BASE_T base
Maintains the basic information of state.
RKHROM RKH_TR_T trn
History default transition.
RKHROM RKH_ST_T * parent
Points to state's parent.
RKHROM RKH_ST_T ** target
Points to RAM memory location which stores the state's history.
Describes the state machine.
RKHROM RKH_ROM_T * romrkh
Points to constant parameters of state machine.
RKHROM RKH_ST_T * state
Points to current stable state (simple or final state).
Describes a submachine state.
RKHROM RKH_EXPCN_T * exptbl
Points to state transition table.
RKHROM RKH_TR_T * trtbl
Points to state transition table.
RKHROM RKH_RSM_T * sbm
Points to submachine object.
Describes the common properties of regular states (basic, composite, and submachine).
RKH_EXT_ACT_T exit
Points to exit action.
RKH_BASE_T base
Maintains the basic information of state.
RKH_ENT_ACT_T enter
Points to entry action.
RKHROM RKH_ST_T * parent
Points to state's parent.
Describes the state transition.
RKHROM void * target
Points to target state.
RKH_GUARD_T guard
Points to guard function.
RKH_TRN_ACT_T action
Points to transition action.
RKH_SIG_T event
Triggering event.