64 #define RKH_SM_NAME(smName_) s_##smName_
65 #define RKH_SM_CONST_NAME(smName_) rs_##smName_
79 #define ELSE rkh_sm_else
144 #define RKH_CREATE_COMP_REGION_STATE(name, en, ex, parent, defchild, \
146 kindOfHistory, hDftTrnGuard, \
147 hDftTrnAction, hDftTarget, hRamMem) \
149 MKFINAL_INCOMP(name); \
150 MKHIST_INCOMP(name, kindOfHistory, hDftTrnGuard, hDftTrnAction, \
151 hDftTarget, hRamMem); \
153 extern RKHROM RKH_TR_T name##_trtbl[]; \
154 RKHROM RKH_SCMP_T name = \
156 {MKBASE(RKH_COMPOSITE, name), MKST(en, ex, parent)}, \
157 MKCOMP(name, defchild, initialTrn, &name##Hist) \
183 #define RKH_CREATE_COMP_STATE(name, en, ex, parent, defchild, history) \
185 extern RKHROM RKH_TR_T name##_trtbl[]; \
186 RKHROM RKH_SCMP_T name = \
188 {MKBASE(RKH_COMPOSITE, name), MKST(en, ex, parent)}, \
189 MKCOMP(name, defchild, NULL, history) \
204 #define RKH_CREATE_FINAL_STATE(name, parent) \
206 static RKHROM RKH_TR_T name##_trtbl[] = \
207 RKH_TRREG(RKH_ANY, NULL, NULL, NULL); \
208 RKHROM RKH_FINAL_T name = \
210 {MKBASE(RKH_FINAL, name), MKST(NULL, NULL, parent)}, \
269 #define RKH_CREATE_BASIC_STATE(name, en, ex, parent, prepro) \
271 extern RKHROM RKH_TR_T name##_trtbl[]; \
273 RKHROM RKH_SBSC_T name = \
275 {MKBASE(RKH_BASIC, name), MKST(en,ex,parent)}, \
276 MKBASIC(name,prepro) \
305 #define RKH_CREATE_COND_STATE(name) \
307 extern RKHROM RKH_TR_T name##_trtbl[]; \
309 RKHROM RKH_SCOND_T name = \
311 MKBASE(RKH_CONDITIONAL, name), \
341 #define RKH_CREATE_CHOICE_STATE(name) \
343 extern RKHROM RKH_TR_T name##_trtbl[]; \
345 RKHROM RKH_SCHOICE_T name = \
347 MKBASE(RKH_CHOICE, name), \
385 #define RKH_CREATE_DEEP_HISTORY_STATE(name, parent, dftTrnGuard, \
386 dftTrnAction, dftTarget) \
388 static RKHROM RKH_ST_T *ram##name; \
389 MKHISTORY(name, parent, RKH_DHISTORY, dftTrnGuard, dftTrnAction, \
390 dftTarget, &ram##name)
428 #define RKH_CREATE_SHALLOW_HISTORY_STATE(name, parent, dftTrnGuard, \
429 dftTrnAction, dftTarget) \
431 static RKHROM RKH_ST_T *ram##name; \
432 MKHISTORY(name, parent, RKH_SHISTORY, dftTrnGuard, dftTrnAction, \
433 dftTarget, &ram##name)
485 #define RKH_CREATE_SUBMACHINE_STATE(name, en, ex, parent, sbm) \
487 extern RKHROM RKH_EXPCN_T name##_exptbl[]; \
488 extern RKHROM RKH_TR_T name##_trtbl[]; \
490 RKHROM RKH_SSBM_T name = \
492 {MKBASE(RKH_SUBMACHINE, name), MKST(en,ex,parent)}, \
521 #define RKH_CREATE_EX_CNNPNT_TABLE(name) \
522 RKHROM RKH_EXPCN_T name##_exptbl[]= \
567 #define RKH_EX_CNNPNT(name, expnt, act, ts) \
568 {(RKH_TRN_ACT_T)act, (RKHROM struct RKH_ST_T *)ts}
591 #define RKH_END_EX_CNNPNT_TABLE };
615 #define RKH_EN_CNNPNT(name, enpnt, subm) \
617 RKHROM RKH_SENP_T name = \
619 MKBASE(RKH_ENPOINT, name), \
646 #define RKH_CREATE_REF_SUBMACHINE(name, defchild, iact) \
648 static RKHROM RKH_ST_T * rdyp_##name; \
650 RKHROM RKH_RSM_T name = \
652 MKBASE(RKH_REF_SUBMACHINE, name), \
653 MKMCH(defchild,iact,name) \
700 #define RKH_CREATE_REF_EXPNT(name, ix, subm) \
702 RKHROM RKH_SEXP_T name = \
704 MKBASE(RKH_EXPOINT, name), \
737 #define RKH_CREATE_REF_ENPNT(name, act, ts, subm) \
739 RKHROM RKH_ENPCN_T name = \
741 (RKH_TRN_ACT_T)act, (RKHROM struct RKH_ST_T *)ts \
769 #define RKH_CREATE_TRANS_TABLE(name) \
771 RKHROM RKH_TR_T name##_trtbl[]= \
803 #define RKH_TRREG(evt_, guard_, effect_, target_) \
804 MKTRN(evt_, guard_, effect_, target_)
827 #define RKH_TRINT(e, g, a) {e, (RKH_GUARD_T)g, (RKH_TRN_ACT_T)a, NULL}
862 #define RKH_TRCOMPLETION(guard_, effect_, target_) \
863 {RKH_COMPLETION_EVENT, \
864 (RKH_GUARD_T)guard_, (RKH_TRN_ACT_T)effect_, target_}
886 #define RKH_END_TRANS_TABLE {RKH_ANY, NULL, NULL, NULL}};
912 #define RKH_CREATE_BRANCH_TABLE(name) \
914 RKH_CREATE_TRANS_TABLE(name)
948 #define RKH_BRANCH(guard_, effect_, target_) \
949 MKTRN(0, guard_, effect_, target_)
964 #define RKH_CREATE_HISTORY_STORAGE(compStateName) \
965 static RKHROM RKH_ST_T *ramHist_##compStateName
978 #define RKH_GET_HISTORY_STORAGE(compStateName) \
979 &ramHist_##compStateName
985 #define RKH_EBTBL {RKH_ANY, NULL, NULL, NULL}
1005 #define RKH_END_BRANCH_TABLE RKH_EBTBL};
1011 #define RKH_ROOT RKH_NULL
1040 #define RKH_SM_DCLR(me_) \
1041 RKH_DCLR_PTR_TYPE(RKH_SM_T, me_)
1065 #define RKH_SM_DCLR_TYPE(type_, me_) \
1066 RKH_DCLR_PTR_TYPE(type_, me_)
1077 #define RKH_DCLR_COMP_STATE extern RKHROM RKH_SCMP_T
1078 #define RKH_DCLR_BASIC_STATE extern RKHROM RKH_SBSC_T
1079 #define RKH_DCLR_FINAL_STATE extern RKHROM RKH_FINAL_T
1080 #define RKH_DCLR_COND_STATE extern RKHROM RKH_SCOND_T
1081 #define RKH_DCLR_CHOICE_STATE extern RKHROM RKH_SCHOICE_T
1082 #define RKH_DCLR_DHIST_STATE extern RKHROM RKH_SHIST_T
1083 #define RKH_DCLR_SHIST_STATE extern RKHROM RKH_SHIST_T
1084 #define RKH_DCLR_SUBM_STATE extern RKHROM RKH_SSBM_T
1085 #define RKH_DCLR_REF_SUBM extern RKHROM RKH_RSM_T
1086 #define RKH_DCLR_ENPNT extern RKHROM RKH_SENP_T
1087 #define RKH_DCLR_REF_EXPNT extern RKHROM RKH_SEXP_T
1088 #define RKH_DCLR_REF_ENPNT extern RKHROM RKH_ENPCN_T
1097 #define RKH_DECLARE_TR_TBL(name) \
1098 extern RKHROM RKH_TR_T name##_trtbl[]
1122 #define RKH_DCLR_SM_GLOBAL(sma_t, sm, gob) \
1123 sma_t * const gob = &s_##sm;
1249 #define RKH_INIT_BASIC_STATE(name, en, ex, parent, prepro) \
1252 MKBASE(RKH_BASIC, name), \
1253 MKST(en, ex, parent) \
1255 MKBASIC(name, prepro) \
1272 #define RKH_INIT_COMPOSITE_STATE(name, en, ex, parent, \
1273 defchild, history) \
1276 MKBASE(RKH_COMPOSITE, name), \
1277 MKST(en, ex, parent) \
1279 MKCOMP(name, defchild, history) \
1290 #define RKH_GFALSE RKH_FALSE
1291 #define RKH_GTRUE RKH_TRUE
1325 #if RKH_CFG_SMA_SM_CONST_EN == RKH_ENABLED
1326 #define RKH_SM_CREATE(type, name, prio, ppty, initialState, \
1327 initialAction, initialEvt) \
1328 RKH_SM_CONST_CREATE(name, prio, ppty, initialState, initialAction, \
1330 static type s_##name = {MKSM(&RKH_SM_CONST_NAME(name), initialState)}
1332 #define RKH_SM_CREATE(type, name, prio, ppty, initialState, \
1333 initialAction, initialEvt) \
1334 static type RKH_SMA_NAME(name) = {MKSM(name, prio, ppty, initialState, \
1335 initialAction, initialEvt)}
1369 #if RKH_CFG_SMA_SM_CONST_EN == RKH_ENABLED
1370 #define RKH_SM_INIT(me_, nameSMConst_, prio_, ppty_, initialState_, \
1371 initialAction_, initialEvt_) \
1372 ((RKH_SM_T *)me_)->romrkh = \
1373 (RKHROM RKH_ROM_T *)(RKH_SM_GET_CONST_OBJ(nameSMConst_)); \
1374 ((RKH_SM_T *)me_)->state = \
1375 (RKHROM struct RKH_ST_T *) \
1376 ((RKH_SM_GET_CONST_OBJ(nameSMConst_))->istate)
1378 #define RKH_SM_INIT(me_, nameSMConst_, prio_, ppty_, initialState_, \
1379 initialAction_, initialEvt_) \
1380 MKRT_SM(me_, nameSMConst_, prio_, ppty_, initialState_, \
1381 initialAction_, initialEvt_)
1414 #if RKH_CFG_SMA_SM_CONST_EN == RKH_ENABLED
1415 #define RKH_SM_CONST_CREATE(name, prio, ppty, initialState, \
1416 initialAction, initialEvt) \
1417 static RKHROM RKH_ROM_T RKH_SM_CONST_NAME(name) = \
1425 #define RKH_SM_CONST_CREATE(name, prio, ppty, initialState, \
1426 initialAction, initialEvt)
1436 #if RKH_CFG_SMA_SM_CONST_EN == RKH_ENABLED
1437 #define RKH_SM_GET_CONST(sm) \
1438 ((RKH_SM_T *)sm)->romrkh
1440 #define RKH_SM_GET_CONST(sm) \
1450 #if RKH_CFG_SMA_SM_CONST_EN == RKH_ENABLED
1451 #define RKH_SM_GET_CONST_OBJ(sm) \
1452 &RKH_SM_CONST_NAME(sm)
1454 #define RKH_SM_GET_CONST_OBJ(sm) \
1458 #if RKH_CFG_SMA_SM_CONST_EN == RKH_ENABLED
1459 #define RKH_SM_GET_OBJ(type, sm)
1461 #define RKH_SM_GET_OBJ(type, sm) \
1462 (type *)&RKH_SM_NAME(sm)
1474 #define RKH_SM_DEF_PTR(sm) \
1475 RKH_SM_T *const sm = (RKH_SM_T *)&RKH_SM_NAME(sm)
1491 #define RKH_SM_DEF_PTR_TYPE(type, sm) \
1492 type *const sm = (type *)&RKH_SM_NAME(sm)
1503 #define RKH_GET_CSTATE_ID(me) \
1504 ((RKH_BASE_T *)(((RKH_SM_T *)me)->state))->id
1506 #if R_TRC_AO_NAME_EN == RKH_ENABLED
1516 #define RKH_GET_VERTEX_NAME(vx) \
1517 ((struct RKH_BASE_T *)(vx))->name
1519 #define RKH_GET_VERTEX_NAME(vx) noname
1610 #if (RKH_CFG_SMA_INIT_ARG_SMA_EN == RKH_ENABLED && \
1611 RKH_CFG_SMA_INIT_EVT_EN == RKH_ENABLED)
1614 #elif (RKH_CFG_SMA_INIT_ARG_SMA_EN == RKH_ENABLED && \
1615 RKH_CFG_SMA_INIT_EVT_EN == RKH_DISABLED)
1617 #elif (RKH_CFG_SMA_INIT_ARG_SMA_EN == RKH_DISABLED && \
1618 RKH_CFG_SMA_INIT_EVT_EN == RKH_ENABLED)
1624 #if RKH_CFG_SMA_SM_CONST_EN == RKH_ENABLED
1664 #if R_TRC_AO_NAME_EN == RKH_ENABLED
1694 #if RKH_CFG_SMA_INIT_EVT_EN == RKH_ENABLED
1711 #if RKH_CFG_SMA_SM_CONST_EN == RKH_ENABLED
1755 #if R_TRC_AO_NAME_EN == RKH_ENABLED
1785 #if RKH_CFG_SMA_INIT_EVT_EN == RKH_ENABLED
1823 #if RKH_CFG_SMA_ENT_ARG_SMA_EN == RKH_ENABLED
1824 #if RKH_CFG_SMA_ENT_ARG_STATE_EN == RKH_ENABLED
1831 #if RKH_CFG_SMA_ENT_ARG_STATE_EN == RKH_ENABLED
1863 #if RKH_CFG_SMA_EXT_ARG_SMA_EN == RKH_ENABLED
1864 #if RKH_CFG_SMA_ENT_ARG_STATE_EN == RKH_ENABLED
1871 #if RKH_CFG_SMA_ENT_ARG_STATE_EN == RKH_ENABLED
1896 #if RKH_CFG_SMA_PPRO_ARG_SMA_EN == RKH_ENABLED
1934 #if (RKH_CFG_SMA_ACT_ARG_EVT_EN == RKH_ENABLED && \
1935 RKH_CFG_SMA_ACT_ARG_SMA_EN == RKH_ENABLED)
1938 #elif (RKH_CFG_SMA_ACT_ARG_EVT_EN == RKH_ENABLED && \
1939 RKH_CFG_SMA_ACT_ARG_SMA_EN == RKH_DISABLED)
1941 #elif (RKH_CFG_SMA_ACT_ARG_EVT_EN == RKH_DISABLED && \
1942 RKH_CFG_SMA_ACT_ARG_SMA_EN == RKH_ENABLED)
1972 #if (RKH_CFG_SMA_GRD_ARG_EVT_EN == RKH_ENABLED && \
1973 RKH_CFG_SMA_GRD_ARG_SMA_EN == RKH_ENABLED)
1977 #elif (RKH_CFG_SMA_GRD_ARG_EVT_EN == RKH_ENABLED && \
1978 RKH_CFG_SMA_GRD_ARG_SMA_EN == RKH_DISABLED)
1980 #elif (RKH_CFG_SMA_GRD_ARG_EVT_EN == RKH_DISABLED && \
1981 RKH_CFG_SMA_GRD_ARG_SMA_EN == RKH_ENABLED)
2017 #if R_TRC_AO_NAME_EN == RKH_ENABLED
2070 #if RKH_CFG_SMA_HCAL_EN == RKH_ENABLED
2143 #if RKH_CFG_SMA_PPRO_EN == RKH_ENABLED
2200 #if RKH_CFG_SMA_PPRO_EN == RKH_ENABLED
2204 #if RKH_CFG_SMA_HCAL_EN == RKH_ENABLED
2221 #if defined(RKH_HISTORY_ENABLED)
2249 #if RKH_CFG_SMA_PPRO_EN == RKH_ENABLED
2258 #if defined(RKH_SUBMACHINE_ENABLED)
2477 #if defined(RKH_CHOICE_OR_CONDITIONAL_ENABLED)
2498 #if defined(RKH_CHOICE_ENABLED)
2643 #if (RKH_CFG_SMA_GRD_ARG_EVT_EN == RKH_ENABLED && \
2644 RKH_CFG_SMA_GRD_ARG_SMA_EN == RKH_ENABLED)
2646 #elif (RKH_CFG_SMA_GRD_ARG_EVT_EN == RKH_ENABLED && \
2647 RKH_CFG_SMA_GRD_ARG_SMA_EN == RKH_DISABLED)
2649 #elif (RKH_CFG_SMA_GRD_ARG_EVT_EN == RKH_DISABLED && \
2650 RKH_CFG_SMA_GRD_ARG_SMA_EN == RKH_ENABLED)
2651 rbool_t rkh_sm_else(
const RKH_SM_T *sma);
2653 rbool_t rkh_sm_else(
void);
rui8_t ppty
State machine properties.
RKH_SIG_T e
Signal of the event instance.
RKHROM RKH_ROM_T * romrkh
Points to constant parameters of state machine.
RKH_TRN_ACT_T action
Points to transition 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.
void rkh_sm_ctor(RKH_SM_T *me)
Initializes the attributes of the state machine instance.
RKH_EXT_ACT_T exit
Points to exit action.
RKH_PPRO_T prepro
Points to event preprocessor.
Describes a composite state.
Describes the exit point connection.
const char * name
Name of State Machine Application (a.k.a Active Object).
RKH_RCODE_T
Return codes from rkh_sm_dispatch() function.
RKH_INIT_ACT_T initialAction
Points to state's initial action.
Describes the choice pseudostate.
RKH_BASE_T base
Maintains the basic information of state.
Represents events without parameters.
RKHROM RKH_ST_T * istate
Points to initial state.
void(* RKH_EXT_ACT_T)(const RKH_SM_T *me)
Exit action.
RKHROM RKH_ST_T * parent
Points to state's parent (submachine state).
Describes a submachine state.
RKHROM void * target
Points to target state.
RKH_GUARD_T guard
Points to guard function.
RKHROM RKH_ST_T * parent
Points to state's parent.
RKH_TRN_ACT_T action
Points to transition action.
RKH_BASE_T base
Maintains the basic information of state.
RKH engine interface.This header file is directly included in RKH interface file, rkh...
RKHROM RKH_TR_T * trtbl
Points to state transition table.
RKHROM RKH_TR_T trn
History default transition.
Maintains the basic information of a state.
RKHROM RKH_ST_T * parent
Points to state's parent.
RKH_INIT_ACT_T iaction
Points to initializing action (optional).
Constant parameters of state machine.
RKH_TRN_ACT_T iaction
Points to initializing action (optional).
rui8_t prio
SMA (a.k.a Active Object) priority.
Describes the entry point connection.
Describes the entry point pseudostate.
RKHROM void * target
Points to target state.
Describes the state machine.
RKH_TRN_ACT_T action
Points to transition action.
void rkh_sm_init(RKH_SM_T *me)
Inits a previously created state machine calling its initializing action.
RKH_BASE_T base
Maintains the basic information of state.
Describes the state transition.
RKHROM void * defchild
Points to state's default child.
RKH_BASE_T base
Maintains the basic information of state.
RKHROM RKH_SHIST_T * history
Points to state's history.
RKHROM RKH_ST_T ** dyp
Points to RAM memory location which stores the dynamic parent.
RKHROM RKH_ST_T ** target
Points to RAM memory location which stores the state's history.
RKHROM void * target
Points to target state.
RKHROM RKH_TR_T * trtbl
Points to state transition table.
Describes the history pseudostate.
rbool_t(* RKH_GUARD_T)(const RKH_SM_T *me, RKH_EVT_T *pe)
Guard.
RKHROM RKH_TR_T * trtbl
Points to state transition table.
RKHROM RKH_ENPCN_T * enpcn
Points to entry point connection.
Describes a (referenced) submachine state machine.
ruint rkh_sm_dispatch(RKH_SM_T *me, RKH_EVT_T *e)
Executes a state machine in a run-to-completation (RTC) model.
rui8_t ix
Index of exit point table.
Describes the common properties of regular states (basic, composite, and submachine).
RKH_BASE_T base
Maintains the basic information of state.
RKHROM RKH_RSM_T * parent
Points to state's parent (referenced submachine).
RKH_HPPTY_T
State machine properties.
RKH_BASE_T base
Maintains the basic information of state.
Describes the exit point pseudostate.
RKH_SIG_T event
Triggering event.
void(* RKH_ENT_ACT_T)(const RKH_SM_T *me)
Entry action.
RKHROM RKH_RSM_T * sbm
Points to submachine object.
RKHROM RKH_EXPCN_T * exptbl
Points to state transition table.
const RKH_EVT_T * ievent
Pointer to an event that will be passed to state machine application when it starts. Could be used to pass arguments to the state machine like an argc/argv. This argument is optional, thus it could be declared as NULL or eliminated in compile-time with RKH_CFG_SMA_INIT_EVT_EN = 0.
RKH_BASE_T base
Maintains the basic information of state.
RKH_SIG_T(* RKH_PPRO_T)(const RKH_SM_T *sma, RKH_EVT_T *pe)
Event preprocessor.
Describes the conditional pseudostate.
const char * name
Name of state or pseudostate.
void(* RKH_TRN_ACT_T)(const RKH_SM_T *me, RKH_EVT_T *pe)
Transition action.
RKH_ENT_ACT_T enter
Points to entry action.
RKHROM void * defchild
Points to state's default child.
RKHROM RKH_TR_T * trtbl
Points to branch table.
void(* RKH_INIT_ACT_T)(const RKH_SM_T *me, const struct RKH_EVT_T *e)
Initialization action.
RKH_PPRO_T prepro
Points to event preprocessor.
RKHROM RKH_TR_T * trtbl
Points to branch table.
RKHROM RKH_ST_T * state
Points to current stable state (simple or final state).