RKH
rkhsm.h
Go to the documentation of this file.
1 /*
2  * --------------------------------------------------------------------------
3  *
4  * Framework RKH
5  * -------------
6  *
7  * State-machine framework for reactive embedded systems
8  *
9  * Copyright (C) 2010 Leandro Francucci.
10  * All rights reserved. Protected by international copyright laws.
11  *
12  *
13  * RKH is free software: you can redistribute it and/or modify it under the
14  * terms of the GNU General Public License as published by the Free Software
15  * Foundation, either version 3 of the License, or (at your option) any
16  * later version.
17  *
18  * RKH is distributed in the hope that it will be useful, but WITHOUT ANY
19  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
21  * more details.
22  *
23  * You should have received a copy of the GNU General Public License along
24  * with RKH, see copying.txt file.
25  *
26  * Contact information:
27  * RKH web site: http://sourceforge.net/projects/rkh-reactivesys/
28  * e-mail: francuccilea@gmail.com
29  * ---------------------------------------------------------------------------
30  */
31 
40 /* -------------------------- Development history -------------------------- */
41 /*
42  * 2017.04.14 LeFr v2.4.05 Initial version
43  */
44 
45 /* -------------------------------- Authors -------------------------------- */
46 /*
47  * LeFr Leandro Francucci francuccilea@gmail.com
48  */
49 
50 /* --------------------------------- Notes --------------------------------- */
51 /* --------------------------------- Module -------------------------------- */
52 #ifndef __RKHSM_H__
53 #define __RKHSM_H__
54 
55 /* ----------------------------- Include files ----------------------------- */
56 #include "rkhitl.h"
57 
58 /* ---------------------- External C language linkage ---------------------- */
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
62 
63 /* --------------------------------- Macros -------------------------------- */
64 #define RKH_SM_NAME(smName_) s_##smName_
65 #define RKH_SM_CONST_NAME(smName_) rs_##smName_
66 
79 #define ELSE rkh_sm_else
80 
144 #define RKH_CREATE_COMP_REGION_STATE(name, en, ex, parent, defchild, \
145  initialTrn, \
146  kindOfHistory, hDftTrnGuard, \
147  hDftTrnAction, hDftTarget, hRamMem) \
148  \
149  MKFINAL_INCOMP(name); \
150  MKHIST_INCOMP(name, kindOfHistory, hDftTrnGuard, hDftTrnAction, \
151  hDftTarget, hRamMem); \
152  \
153  extern RKHROM RKH_TR_T name##_trtbl[]; \
154  RKHROM RKH_SCMP_T name = \
155  { \
156  {MKBASE(RKH_COMPOSITE, name), MKST(en, ex, parent)}, \
157  MKCOMP(name, defchild, initialTrn, &name##Hist) \
158  }
159 
183 #define RKH_CREATE_COMP_STATE(name, en, ex, parent, defchild, history) \
184  \
185  extern RKHROM RKH_TR_T name##_trtbl[]; \
186  RKHROM RKH_SCMP_T name = \
187  { \
188  {MKBASE(RKH_COMPOSITE, name), MKST(en, ex, parent)}, \
189  MKCOMP(name, defchild, NULL, history) \
190  }
191 
204 #define RKH_CREATE_FINAL_STATE(name, parent) \
205  \
206  static RKHROM RKH_TR_T name##_trtbl[] = \
207  RKH_TRREG(RKH_ANY, NULL, NULL, NULL); \
208  RKHROM RKH_FINAL_T name = \
209  { \
210  {MKBASE(RKH_FINAL, name), MKST(NULL, NULL, parent)}, \
211  MKFINAL(name) \
212  }
213 
269 #define RKH_CREATE_BASIC_STATE(name, en, ex, parent, prepro) \
270  \
271  extern RKHROM RKH_TR_T name##_trtbl[]; \
272  \
273  RKHROM RKH_SBSC_T name = \
274  { \
275  {MKBASE(RKH_BASIC, name), MKST(en,ex,parent)}, \
276  MKBASIC(name,prepro) \
277  }
278 
305 #define RKH_CREATE_COND_STATE(name) \
306  \
307  extern RKHROM RKH_TR_T name##_trtbl[]; \
308  \
309  RKHROM RKH_SCOND_T name = \
310  { \
311  MKBASE(RKH_CONDITIONAL, name), \
312  name##_trtbl \
313  }
314 
341 #define RKH_CREATE_CHOICE_STATE(name) \
342  \
343  extern RKHROM RKH_TR_T name##_trtbl[]; \
344  \
345  RKHROM RKH_SCHOICE_T name = \
346  { \
347  MKBASE(RKH_CHOICE, name), \
348  name##_trtbl \
349  }
350 
385 #define RKH_CREATE_DEEP_HISTORY_STATE(name, parent, dftTrnGuard, \
386  dftTrnAction, dftTarget) \
387  \
388  static RKHROM RKH_ST_T *ram##name; \
389  MKHISTORY(name, parent, RKH_DHISTORY, dftTrnGuard, dftTrnAction, \
390  dftTarget, &ram##name)
391 
428 #define RKH_CREATE_SHALLOW_HISTORY_STATE(name, parent, dftTrnGuard, \
429  dftTrnAction, dftTarget) \
430  \
431  static RKHROM RKH_ST_T *ram##name; \
432  MKHISTORY(name, parent, RKH_SHISTORY, dftTrnGuard, dftTrnAction, \
433  dftTarget, &ram##name)
434 
485 #define RKH_CREATE_SUBMACHINE_STATE(name, en, ex, parent, sbm) \
486  \
487  extern RKHROM RKH_EXPCN_T name##_exptbl[]; \
488  extern RKHROM RKH_TR_T name##_trtbl[]; \
489  \
490  RKHROM RKH_SSBM_T name = \
491  { \
492  {MKBASE(RKH_SUBMACHINE, name), MKST(en,ex,parent)}, \
493  MKSBM(name,sbm) \
494  }
495 
521 #define RKH_CREATE_EX_CNNPNT_TABLE(name) \
522  RKHROM RKH_EXPCN_T name##_exptbl[]= \
523  {
524 
567 #define RKH_EX_CNNPNT(name, expnt, act, ts) \
568  {(RKH_TRN_ACT_T)act, (RKHROM struct RKH_ST_T *)ts}
569 
591 #define RKH_END_EX_CNNPNT_TABLE };
592 
615 #define RKH_EN_CNNPNT(name, enpnt, subm) \
616  \
617  RKHROM RKH_SENP_T name = \
618  { \
619  MKBASE(RKH_ENPOINT, name), \
620  MKENP(enpnt,subm) \
621  }
622 
646 #define RKH_CREATE_REF_SUBMACHINE(name, defchild, iact) \
647  \
648  static RKHROM RKH_ST_T * rdyp_##name; \
649  \
650  RKHROM RKH_RSM_T name = \
651  { \
652  MKBASE(RKH_REF_SUBMACHINE, name), \
653  MKMCH(defchild,iact,name) \
654  }
655 
700 #define RKH_CREATE_REF_EXPNT(name, ix, subm) \
701  \
702  RKHROM RKH_SEXP_T name = \
703  { \
704  MKBASE(RKH_EXPOINT, name), \
705  ix, subm \
706  }
707 
737 #define RKH_CREATE_REF_ENPNT(name, act, ts, subm) \
738  \
739  RKHROM RKH_ENPCN_T name = \
740  { \
741  (RKH_TRN_ACT_T)act, (RKHROM struct RKH_ST_T *)ts \
742  }
743 
769 #define RKH_CREATE_TRANS_TABLE(name) \
770  \
771  RKHROM RKH_TR_T name##_trtbl[]= \
772  {
773 
803 #define RKH_TRREG(evt_, guard_, effect_, target_) \
804  MKTRN(evt_, guard_, effect_, target_)
805 
827 #define RKH_TRINT(e, g, a) {e, (RKH_GUARD_T)g, (RKH_TRN_ACT_T)a, NULL}
828 
862 #define RKH_TRCOMPLETION(guard_, effect_, target_) \
863  {RKH_COMPLETION_EVENT, \
864  (RKH_GUARD_T)guard_, (RKH_TRN_ACT_T)effect_, target_}
865 
886 #define RKH_END_TRANS_TABLE {RKH_ANY, NULL, NULL, NULL}};
887 
912 #define RKH_CREATE_BRANCH_TABLE(name) \
913  \
914  RKH_CREATE_TRANS_TABLE(name)
915 
948 #define RKH_BRANCH(guard_, effect_, target_) \
949  MKTRN(0, guard_, effect_, target_)
950 
964 #define RKH_CREATE_HISTORY_STORAGE(compStateName) \
965  static RKHROM RKH_ST_T *ramHist_##compStateName
966 
978 #define RKH_GET_HISTORY_STORAGE(compStateName) \
979  &ramHist_##compStateName
980 
981 /*
982  * This macro is internal to RKH and the user application should
983  * not call it.
984  */
985 #define RKH_EBTBL {RKH_ANY, NULL, NULL, NULL}
986 
1005 #define RKH_END_BRANCH_TABLE RKH_EBTBL};
1006 
1011 #define RKH_ROOT RKH_NULL
1012 
1040 #define RKH_SM_DCLR(me_) \
1041  RKH_DCLR_PTR_TYPE(RKH_SM_T, me_)
1042 
1065 #define RKH_SM_DCLR_TYPE(type_, me_) \
1066  RKH_DCLR_PTR_TYPE(type_, me_)
1067 
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
1089 
1097 #define RKH_DECLARE_TR_TBL(name) \
1098  extern RKHROM RKH_TR_T name##_trtbl[]
1099 
1122 #define RKH_DCLR_SM_GLOBAL(sma_t, sm, gob) \
1123  sma_t * const gob = &s_##sm;
1124 
1249 #define RKH_INIT_BASIC_STATE(name, en, ex, parent, prepro) \
1250  { \
1251  { \
1252  MKBASE(RKH_BASIC, name), /* RKH_BASE_T */ \
1253  MKST(en, ex, parent) \
1254  }, /* RKH_ST_T */ \
1255  MKBASIC(name, prepro) \
1256  } /* RKH_SBSC_T */ \
1257 
1258 
1272 #define RKH_INIT_COMPOSITE_STATE(name, en, ex, parent, \
1273  defchild, history) \
1274  { \
1275  { \
1276  MKBASE(RKH_COMPOSITE, name), /* RKH_BASE_T */ \
1277  MKST(en, ex, parent) \
1278  }, /* RKH_ST_T */ \
1279  MKCOMP(name, defchild, history) \
1280  } /* RKH_SCMP_T */ \
1281 
1282 
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, \
1329  initialEvt); \
1330  static type s_##name = {MKSM(&RKH_SM_CONST_NAME(name), initialState)}
1331 #else
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)}
1336 #endif
1337 
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)
1377 #else
1378  #define RKH_SM_INIT(me_, nameSMConst_, prio_, ppty_, initialState_, \
1379  initialAction_, initialEvt_) \
1380  MKRT_SM(me_, nameSMConst_, prio_, ppty_, initialState_, \
1381  initialAction_, initialEvt_)
1382 #endif
1383 
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) = \
1418  MKRRKH(name, \
1419  prio, \
1420  ppty, \
1421  initialState, \
1422  initialAction, \
1423  initialEvt)
1424 #else
1425  #define RKH_SM_CONST_CREATE(name, prio, ppty, initialState, \
1426  initialAction, initialEvt)
1427 #endif
1428 
1436 #if RKH_CFG_SMA_SM_CONST_EN == RKH_ENABLED
1437  #define RKH_SM_GET_CONST(sm) \
1438  ((RKH_SM_T *)sm)->romrkh
1439 #else
1440  #define RKH_SM_GET_CONST(sm) \
1441  ((RKH_SM_T *)sm)
1442 #endif
1443 
1450 #if RKH_CFG_SMA_SM_CONST_EN == RKH_ENABLED
1451  #define RKH_SM_GET_CONST_OBJ(sm) \
1452  &RKH_SM_CONST_NAME(sm)
1453 #else
1454  #define RKH_SM_GET_CONST_OBJ(sm) \
1455  ((RKH_SM_T *)sm)
1456 #endif
1457 
1458 #if RKH_CFG_SMA_SM_CONST_EN == RKH_ENABLED
1459  #define RKH_SM_GET_OBJ(type, sm)
1460 #else
1461  #define RKH_SM_GET_OBJ(type, sm) \
1462  (type *)&RKH_SM_NAME(sm)
1463 #endif
1464 
1474 #define RKH_SM_DEF_PTR(sm) \
1475  RKH_SM_T *const sm = (RKH_SM_T *)&RKH_SM_NAME(sm)
1476 
1491 #define RKH_SM_DEF_PTR_TYPE(type, sm) \
1492  type *const sm = (type *)&RKH_SM_NAME(sm)
1493 
1503 #define RKH_GET_CSTATE_ID(me) \
1504  ((RKH_BASE_T *)(((RKH_SM_T *)me)->state))->id
1505 
1506 #if R_TRC_AO_NAME_EN == RKH_ENABLED
1507 
1516  #define RKH_GET_VERTEX_NAME(vx) \
1517  ((struct RKH_BASE_T *)(vx))->name
1518 #else
1519  #define RKH_GET_VERTEX_NAME(vx) noname
1520 #endif
1521 
1522 /* -------------------------------- Constants ------------------------------ */
1523 /* ------------------------------- Data types ------------------------------ */
1530 typedef enum RKH_RCODE_T
1531 {
1537 
1542 
1548 
1553 
1558 
1563 
1569  RKH_NUM_CODES
1570 } RKH_RCODE_T;
1571 
1578 typedef enum
1579 {
1585 
1594 
1597 } RKH_HPPTY_T;
1598 
1610 #if (RKH_CFG_SMA_INIT_ARG_SMA_EN == RKH_ENABLED && \
1611  RKH_CFG_SMA_INIT_EVT_EN == RKH_ENABLED)
1612  typedef void (*RKH_INIT_ACT_T)(const RKH_SM_T *me,
1613  const struct RKH_EVT_T *e);
1614 #elif (RKH_CFG_SMA_INIT_ARG_SMA_EN == RKH_ENABLED && \
1615  RKH_CFG_SMA_INIT_EVT_EN == RKH_DISABLED)
1616  typedef void (*RKH_INIT_ACT_T)(const RKH_SM_T *me);
1617 #elif (RKH_CFG_SMA_INIT_ARG_SMA_EN == RKH_DISABLED && \
1618  RKH_CFG_SMA_INIT_EVT_EN == RKH_ENABLED)
1619  typedef void (*RKH_INIT_ACT_T)(const struct RKH_EVT_T *e);
1620 #else
1621  typedef void (*RKH_INIT_ACT_T)(void);
1622 #endif
1623 
1624 #if RKH_CFG_SMA_SM_CONST_EN == RKH_ENABLED
1625 
1637 {
1645  rui8_t prio;
1646 
1654  rui8_t ppty;
1655 
1664 #if R_TRC_AO_NAME_EN == RKH_ENABLED
1665  const char *name;
1666 #endif
1667 
1675  RKHROM RKH_ST_T *istate;
1676 
1685 
1694 #if RKH_CFG_SMA_INIT_EVT_EN == RKH_ENABLED
1696 #endif
1697 };
1698 #endif
1699 
1711 #if RKH_CFG_SMA_SM_CONST_EN == RKH_ENABLED
1712 struct RKH_SM_T
1713 {
1719 
1724  RKHROM RKH_ST_T *state;
1725 };
1726 #else
1727 struct RKH_SM_T
1728 {
1736  rui8_t prio;
1737 
1745  rui8_t ppty;
1746 
1755 #if R_TRC_AO_NAME_EN == RKH_ENABLED
1756  const char *name;
1757 #endif
1758 
1766  RKHROM RKH_ST_T *istate;
1767 
1775  RKH_INIT_ACT_T iaction;
1776 
1785 #if RKH_CFG_SMA_INIT_EVT_EN == RKH_ENABLED
1786  const RKH_EVT_T *ievent;
1787 #endif
1788 
1793  RKHROM RKH_ST_T *state;
1794 };
1795 #endif
1796 
1823 #if RKH_CFG_SMA_ENT_ARG_SMA_EN == RKH_ENABLED
1824  #if RKH_CFG_SMA_ENT_ARG_STATE_EN == RKH_ENABLED
1825  typedef void (*RKH_ENT_ACT_T)(const RKH_SM_T *me,
1826  const RKH_ST_T *state);
1827  #else
1828  typedef void (*RKH_ENT_ACT_T)(const RKH_SM_T *me);
1829  #endif
1830 #else
1831  #if RKH_CFG_SMA_ENT_ARG_STATE_EN == RKH_ENABLED
1832  typedef void (*RKH_ENT_ACT_T)(const RKH_ST_T *state);
1833  #else
1834  typedef void (*RKH_ENT_ACT_T)(void);
1835  #endif
1836 #endif
1837 
1863 #if RKH_CFG_SMA_EXT_ARG_SMA_EN == RKH_ENABLED
1864  #if RKH_CFG_SMA_ENT_ARG_STATE_EN == RKH_ENABLED
1865  typedef void (*RKH_EXT_ACT_T)(const RKH_SM_T *me,
1866  const RKH_ST_T *state);
1867  #else
1868  typedef void (*RKH_EXT_ACT_T)(const RKH_SM_T *me);
1869  #endif
1870 #else
1871  #if RKH_CFG_SMA_ENT_ARG_STATE_EN == RKH_ENABLED
1872  typedef void (*RKH_EXT_ACT_T)(const RKH_ST_T *state);
1873  #else
1874  typedef void (*RKH_EXT_ACT_T)(void);
1875  #endif
1876 #endif
1877 
1896 #if RKH_CFG_SMA_PPRO_ARG_SMA_EN == RKH_ENABLED
1897  typedef RKH_SIG_T (*RKH_PPRO_T)(const RKH_SM_T *sma,
1898  RKH_EVT_T *pe);
1899 #else
1900  typedef RKH_SIG_T (*RKH_PPRO_T)(RKH_EVT_T *pe);
1901 #endif
1902 
1934 #if (RKH_CFG_SMA_ACT_ARG_EVT_EN == RKH_ENABLED && \
1935  RKH_CFG_SMA_ACT_ARG_SMA_EN == RKH_ENABLED)
1936  typedef void (*RKH_TRN_ACT_T)(const RKH_SM_T *me,
1937  RKH_EVT_T *pe);
1938 #elif (RKH_CFG_SMA_ACT_ARG_EVT_EN == RKH_ENABLED && \
1939  RKH_CFG_SMA_ACT_ARG_SMA_EN == RKH_DISABLED)
1940  typedef void (*RKH_TRN_ACT_T)(RKH_EVT_T *pe);
1941 #elif (RKH_CFG_SMA_ACT_ARG_EVT_EN == RKH_DISABLED && \
1942  RKH_CFG_SMA_ACT_ARG_SMA_EN == RKH_ENABLED)
1943  typedef void (*RKH_TRN_ACT_T)(const RKH_SM_T *me);
1944 #else
1945  typedef void (*RKH_TRN_ACT_T)(void);
1946 #endif
1947 
1972 #if (RKH_CFG_SMA_GRD_ARG_EVT_EN == RKH_ENABLED && \
1973  RKH_CFG_SMA_GRD_ARG_SMA_EN == RKH_ENABLED)
1974 
1975  typedef rbool_t (*RKH_GUARD_T)(const RKH_SM_T *me,
1976  RKH_EVT_T *pe);
1977 #elif (RKH_CFG_SMA_GRD_ARG_EVT_EN == RKH_ENABLED && \
1978  RKH_CFG_SMA_GRD_ARG_SMA_EN == RKH_DISABLED)
1979  typedef rbool_t (*RKH_GUARD_T)(RKH_EVT_T *pe);
1980 #elif (RKH_CFG_SMA_GRD_ARG_EVT_EN == RKH_DISABLED && \
1981  RKH_CFG_SMA_GRD_ARG_SMA_EN == RKH_ENABLED)
1982  typedef rbool_t (*RKH_GUARD_T)(const RKH_SM_T *me);
1983 #else
1984  typedef rbool_t (*RKH_GUARD_T)(void);
1985 #endif
1986 
1992 {
2007  ruint type;
2008 
2017 #if R_TRC_AO_NAME_EN == RKH_ENABLED
2018  const char *name;
2019 #endif
2020 };
2021 
2030 struct RKH_TR_T
2031 {
2037 
2043 
2049 
2054  RKHROM void *target;
2055 };
2056 
2062 struct RKH_ST_T
2063 {
2069 
2070 #if RKH_CFG_SMA_HCAL_EN == RKH_ENABLED
2071 
2076 
2082 
2087  RKHROM RKH_ST_T *parent;
2088 #endif
2089 };
2090 
2096 {
2097  RKH_ST_T st;
2098 
2103  RKHROM RKH_TR_T *trtbl;
2104 
2143 #if RKH_CFG_SMA_PPRO_EN == RKH_ENABLED
2145 #endif
2146 };
2147 
2153 {
2154  RKH_ST_T st;
2155 
2160  RKHROM RKH_TR_T *trtbl;
2161 
2200 #if RKH_CFG_SMA_PPRO_EN == RKH_ENABLED
2202 #endif
2203 
2204 #if RKH_CFG_SMA_HCAL_EN == RKH_ENABLED
2205 
2209  RKHROM void *defchild;
2210 
2216 
2221 #if defined(RKH_HISTORY_ENABLED)
2223 #endif
2224 #endif
2225 };
2226 
2232 {
2238 
2243  RKHROM RKH_TR_T *trtbl;
2244 
2249 #if RKH_CFG_SMA_PPRO_EN == RKH_ENABLED
2251 #endif
2252 };
2253 
2258 #if defined(RKH_SUBMACHINE_ENABLED)
2260 {
2266 
2271  RKHROM void *target;
2272 };
2273 
2279 {
2285 
2290  RKHROM void *target;
2291 };
2292 
2352 {
2353  RKH_ST_T st;
2354 
2359  RKHROM RKH_TR_T *trtbl;
2360 
2366 
2371  RKHROM RKH_RSM_T *sbm;
2372 };
2373 
2379 {
2385 
2390  RKHROM void *defchild;
2391 
2400 
2406  RKHROM RKH_ST_T * *dyp;
2407 };
2408 
2421 {
2427 
2433 
2438  RKHROM RKH_ST_T *parent;
2439 };
2440 
2452 {
2458 
2463  rui8_t ix;
2464 
2470 };
2471 #endif
2472 
2477 #if defined(RKH_CHOICE_OR_CONDITIONAL_ENABLED)
2479 {
2485 
2490  RKHROM RKH_TR_T *trtbl;
2491 };
2492 #endif
2493 
2498 #if defined(RKH_CHOICE_ENABLED)
2500 {
2506 
2511  RKHROM RKH_TR_T *trtbl;
2512 };
2513 #endif
2514 
2522 {
2528 
2533  RKHROM RKH_ST_T *parent;
2534 
2540  RKHROM RKH_ST_T **target;
2541 
2546  RKHROM RKH_TR_T trn;
2547 };
2548 
2549 /* -------------------------- External variables --------------------------- */
2550 /* -------------------------- Function prototypes -------------------------- */
2559 void rkh_sm_init(RKH_SM_T *me);
2560 
2617 ruint rkh_sm_dispatch(RKH_SM_T *me, RKH_EVT_T *e);
2618 
2631 void rkh_sm_ctor(RKH_SM_T *me);
2632 
2641 void rkh_sm_clear_history(RKHROM RKH_SHIST_T *h);
2642 
2643 #if (RKH_CFG_SMA_GRD_ARG_EVT_EN == RKH_ENABLED && \
2644  RKH_CFG_SMA_GRD_ARG_SMA_EN == RKH_ENABLED)
2645 rbool_t rkh_sm_else(const RKH_SM_T *sma, RKH_EVT_T *pe);
2646 #elif (RKH_CFG_SMA_GRD_ARG_EVT_EN == RKH_ENABLED && \
2647  RKH_CFG_SMA_GRD_ARG_SMA_EN == RKH_DISABLED)
2648 rbool_t rkh_sm_else(RKH_EVT_T *pe);
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);
2652 #else
2653 rbool_t rkh_sm_else(void);
2654 #endif
2655 
2656 /* -------------------- External C language linkage end -------------------- */
2657 #ifdef __cplusplus
2658 }
2659 #endif
2660 
2661 /* ------------------------------ Module end ------------------------------- */
2662 #endif
2663 
2664 /* ------------------------------ End of file ------------------------------ */
rui8_t ppty
State machine properties.
Definition: rkhsm.h:1654
RKH_SIG_T e
Signal of the event instance.
Definition: rkhevt.h:173
RKHROM RKH_ROM_T * romrkh
Points to constant parameters of state machine.
Definition: rkhsm.h:1718
RKH_TRN_ACT_T action
Points to transition action.
Definition: rkhsm.h:2284
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.
Definition: rkhsm.h:2081
RKH_PPRO_T prepro
Points to event preprocessor.
Definition: rkhsm.h:2201
RKH_ST_T st
Definition: rkhsm.h:2237
ruint type
State type.
Definition: rkhsm.h:2007
Describes a composite state.
Definition: rkhsm.h:2152
Describes the exit point connection.
Definition: rkhsm.h:2259
const char * name
Name of State Machine Application (a.k.a Active Object).
Definition: rkhsm.h:1665
RKH_RCODE_T
Return codes from rkh_sm_dispatch() function.
Definition: rkhsm.h:1530
RKH_INIT_ACT_T initialAction
Points to state's initial action.
Definition: rkhsm.h:2215
Describes a basic state.
Definition: rkhsm.h:2095
Describes the choice pseudostate.
Definition: rkhsm.h:2499
RKH_BASE_T base
Maintains the basic information of state.
Definition: rkhsm.h:2527
Represents events without parameters.
Definition: rkhevt.h:167
RKHROM RKH_ST_T * istate
Points to initial state.
Definition: rkhsm.h:1675
void(* RKH_EXT_ACT_T)(const RKH_SM_T *me)
Exit action.
Definition: rkhsm.h:1868
RKHROM RKH_ST_T * parent
Points to state's parent (submachine state).
Definition: rkhsm.h:2438
Describes a submachine state.
Definition: rkhsm.h:2351
RKHROM void * target
Points to target state.
Definition: rkhsm.h:2271
RKH_GUARD_T guard
Points to guard function.
Definition: rkhsm.h:2042
rui8_t RKH_SIG_T
Definition: rkhevt.h:98
RKHROM RKH_ST_T * parent
Points to state's parent.
Definition: rkhsm.h:2087
RKH_TRN_ACT_T action
Points to transition action.
Definition: rkhsm.h:2048
RKH_BASE_T base
Maintains the basic information of state.
Definition: rkhsm.h:2484
RKH engine interface.This header file is directly included in RKH interface file, rkh...
RKHROM RKH_TR_T * trtbl
Points to state transition table.
Definition: rkhsm.h:2160
RKHROM RKH_TR_T trn
History default transition.
Definition: rkhsm.h:2546
Maintains the basic information of a state.
Definition: rkhsm.h:1991
RKHROM RKH_TR_T * trtbl
Definition: rkhsm.h:2243
RKHROM RKH_ST_T * parent
Points to state's parent.
Definition: rkhsm.h:2533
RKH_INIT_ACT_T iaction
Points to initializing action (optional).
Definition: rkhsm.h:1684
Constant parameters of state machine.
Definition: rkhsm.h:1636
RKH_TRN_ACT_T iaction
Points to initializing action (optional).
Definition: rkhsm.h:2399
rui8_t prio
SMA (a.k.a Active Object) priority.
Definition: rkhsm.h:1645
Describes the entry point connection.
Definition: rkhsm.h:2278
Describes the entry point pseudostate.
Definition: rkhsm.h:2420
RKHROM void * target
Points to target state.
Definition: rkhsm.h:2290
Describes the state machine.
Definition: rkhsm.h:1712
RKH_TRN_ACT_T action
Points to transition action.
Definition: rkhsm.h:2265
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.
Definition: rkhsm.h:2384
Describes the state transition.
Definition: rkhsm.h:2030
RKHROM void * defchild
Points to state's default child.
Definition: rkhsm.h:2209
RKH_PPRO_T prepro
Definition: rkhsm.h:2250
RKH_BASE_T base
Maintains the basic information of state.
Definition: rkhsm.h:2505
RKHROM RKH_SHIST_T * history
Points to state's history.
Definition: rkhsm.h:2222
RKHROM RKH_ST_T ** dyp
Points to RAM memory location which stores the dynamic parent.
Definition: rkhsm.h:2406
RKHROM RKH_ST_T ** target
Points to RAM memory location which stores the state's history.
Definition: rkhsm.h:2540
RKHROM void * target
Points to target state.
Definition: rkhsm.h:2054
RKHROM RKH_TR_T * trtbl
Points to state transition table.
Definition: rkhsm.h:2103
Describes a final state.
Definition: rkhsm.h:2231
Describes the history pseudostate.
Definition: rkhsm.h:2521
rbool_t(* RKH_GUARD_T)(const RKH_SM_T *me, RKH_EVT_T *pe)
Guard.
Definition: rkhsm.h:1975
Definition: rkhsm.h:1593
RKHROM RKH_TR_T * trtbl
Points to state transition table.
Definition: rkhsm.h:2359
RKHROM RKH_ENPCN_T * enpcn
Points to entry point connection.
Definition: rkhsm.h:2432
Describes a (referenced) submachine state machine.
Definition: rkhsm.h:2378
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.
Definition: rkhsm.h:2463
Describes the common properties of regular states (basic, composite, and submachine).
Definition: rkhsm.h:2062
RKH_BASE_T base
Maintains the basic information of state.
Definition: rkhsm.h:2457
RKHROM RKH_RSM_T * parent
Points to state's parent (referenced submachine).
Definition: rkhsm.h:2469
RKH_HPPTY_T
State machine properties.
Definition: rkhsm.h:1578
RKH_BASE_T base
Maintains the basic information of state.
Definition: rkhsm.h:2426
Describes the exit point pseudostate.
Definition: rkhsm.h:2451
RKH_SIG_T event
Triggering event.
Definition: rkhsm.h:2036
void(* RKH_ENT_ACT_T)(const RKH_SM_T *me)
Entry action.
Definition: rkhsm.h:1828
RKHROM RKH_RSM_T * sbm
Points to submachine object.
Definition: rkhsm.h:2371
RKHROM RKH_EXPCN_T * exptbl
Points to state transition table.
Definition: rkhsm.h:2365
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.
Definition: rkhsm.h:1695
Definition: rkhsm.h:1584
RKH_BASE_T base
Maintains the basic information of state.
Definition: rkhsm.h:2068
RKH_SIG_T(* RKH_PPRO_T)(const RKH_SM_T *sma, RKH_EVT_T *pe)
Event preprocessor.
Definition: rkhsm.h:1897
Describes the conditional pseudostate.
Definition: rkhsm.h:2478
const char * name
Name of state or pseudostate.
Definition: rkhsm.h:2018
void(* RKH_TRN_ACT_T)(const RKH_SM_T *me, RKH_EVT_T *pe)
Transition action.
Definition: rkhsm.h:1936
RKH_ENT_ACT_T enter
Points to entry action.
Definition: rkhsm.h:2075
RKHROM void * defchild
Points to state's default child.
Definition: rkhsm.h:2390
RKHROM RKH_TR_T * trtbl
Points to branch table.
Definition: rkhsm.h:2511
void(* RKH_INIT_ACT_T)(const RKH_SM_T *me, const struct RKH_EVT_T *e)
Initialization action.
Definition: rkhsm.h:1612
RKH_PPRO_T prepro
Points to event preprocessor.
Definition: rkhsm.h:2144
RKHROM RKH_TR_T * trtbl
Points to branch table.
Definition: rkhsm.h:2490
RKHROM RKH_ST_T * state
Points to current stable state (simple or final state).
Definition: rkhsm.h:1724