InternalEventLifeCycle.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include "sc_types.h"
  4. #include "InternalEventLifeCycle.h"
  5. /*! \file Implementation of the state machine 'InternalEventLifeCycle'
  6. */
  7. /* prototypes of all internal functions */
  8. static sc_boolean internalEventLifeCycle_check_r1_A_tr0_tr0(const InternalEventLifeCycle* handle);
  9. static sc_boolean internalEventLifeCycle_check_r1_A_lr0_lr0(const InternalEventLifeCycle* handle);
  10. static sc_boolean internalEventLifeCycle_check_r1_B_tr0_tr0(const InternalEventLifeCycle* handle);
  11. static sc_boolean internalEventLifeCycle_check_r2_C_tr0_tr0(const InternalEventLifeCycle* handle);
  12. static sc_boolean internalEventLifeCycle_check_r2_D_tr0_tr0(const InternalEventLifeCycle* handle);
  13. static void internalEventLifeCycle_effect_r1_A_tr0(InternalEventLifeCycle* handle);
  14. static void internalEventLifeCycle_effect_r1_A_lr0_lr0(InternalEventLifeCycle* handle);
  15. static void internalEventLifeCycle_effect_r1_B_tr0(InternalEventLifeCycle* handle);
  16. static void internalEventLifeCycle_effect_r2_C_tr0(InternalEventLifeCycle* handle);
  17. static void internalEventLifeCycle_effect_r2_D_tr0(InternalEventLifeCycle* handle);
  18. static void internalEventLifeCycle_enseq_r1_A_default(InternalEventLifeCycle* handle);
  19. static void internalEventLifeCycle_enseq_r1_B_default(InternalEventLifeCycle* handle);
  20. static void internalEventLifeCycle_enseq_r2_C_default(InternalEventLifeCycle* handle);
  21. static void internalEventLifeCycle_enseq_r2_D_default(InternalEventLifeCycle* handle);
  22. static void internalEventLifeCycle_enseq_r1_default(InternalEventLifeCycle* handle);
  23. static void internalEventLifeCycle_enseq_r2_default(InternalEventLifeCycle* handle);
  24. static void internalEventLifeCycle_exseq_r1_A(InternalEventLifeCycle* handle);
  25. static void internalEventLifeCycle_exseq_r1_B(InternalEventLifeCycle* handle);
  26. static void internalEventLifeCycle_exseq_r2_C(InternalEventLifeCycle* handle);
  27. static void internalEventLifeCycle_exseq_r2_D(InternalEventLifeCycle* handle);
  28. static void internalEventLifeCycle_exseq_r1(InternalEventLifeCycle* handle);
  29. static void internalEventLifeCycle_exseq_r2(InternalEventLifeCycle* handle);
  30. static void internalEventLifeCycle_react_r1_A(InternalEventLifeCycle* handle);
  31. static void internalEventLifeCycle_react_r1_B(InternalEventLifeCycle* handle);
  32. static void internalEventLifeCycle_react_r2_C(InternalEventLifeCycle* handle);
  33. static void internalEventLifeCycle_react_r2_D(InternalEventLifeCycle* handle);
  34. static void internalEventLifeCycle_react_r1__entry_Default(InternalEventLifeCycle* handle);
  35. static void internalEventLifeCycle_react_r2__entry_Default(InternalEventLifeCycle* handle);
  36. static void internalEventLifeCycle_clearInEvents(InternalEventLifeCycle* handle);
  37. static void internalEventLifeCycle_clearOutEvents(InternalEventLifeCycle* handle);
  38. void internalEventLifeCycle_init(InternalEventLifeCycle* handle)
  39. {
  40. sc_integer i;
  41. for (i = 0; i < INTERNALEVENTLIFECYCLE_MAX_ORTHOGONAL_STATES; ++i)
  42. {
  43. handle->stateConfVector[i] = InternalEventLifeCycle_last_state;
  44. }
  45. handle->stateConfVectorPosition = 0;
  46. internalEventLifeCycle_clearInEvents(handle);
  47. internalEventLifeCycle_clearOutEvents(handle);
  48. }
  49. void internalEventLifeCycle_enter(InternalEventLifeCycle* handle)
  50. {
  51. /* Default enter sequence for statechart InternalEventLifeCycle */
  52. internalEventLifeCycle_enseq_r1_default(handle);
  53. internalEventLifeCycle_enseq_r2_default(handle);
  54. }
  55. void internalEventLifeCycle_exit(InternalEventLifeCycle* handle)
  56. {
  57. /* Default exit sequence for statechart InternalEventLifeCycle */
  58. internalEventLifeCycle_exseq_r1(handle);
  59. internalEventLifeCycle_exseq_r2(handle);
  60. }
  61. sc_boolean internalEventLifeCycle_isActive(const InternalEventLifeCycle* handle)
  62. {
  63. sc_boolean result = bool_false;
  64. int i;
  65. for(i = 0; i < INTERNALEVENTLIFECYCLE_MAX_ORTHOGONAL_STATES; i++)
  66. {
  67. result = result || handle->stateConfVector[i] != InternalEventLifeCycle_last_state;
  68. }
  69. return result;
  70. }
  71. /*
  72. * Always returns 'false' since this state machine can never become final.
  73. */
  74. sc_boolean internalEventLifeCycle_isFinal(const InternalEventLifeCycle* handle)
  75. {
  76. return bool_false;
  77. }
  78. static void internalEventLifeCycle_clearInEvents(InternalEventLifeCycle* handle)
  79. {
  80. handle->iface.e_raised = bool_false;
  81. handle->iface.f_raised = bool_false;
  82. handle->internal.i1_raised = bool_false;
  83. handle->internal.i2_raised = bool_false;
  84. }
  85. static void internalEventLifeCycle_clearOutEvents(InternalEventLifeCycle* handle)
  86. {
  87. }
  88. void internalEventLifeCycle_runCycle(InternalEventLifeCycle* handle)
  89. {
  90. internalEventLifeCycle_clearOutEvents(handle);
  91. for (handle->stateConfVectorPosition = 0;
  92. handle->stateConfVectorPosition < INTERNALEVENTLIFECYCLE_MAX_ORTHOGONAL_STATES;
  93. handle->stateConfVectorPosition++)
  94. {
  95. switch (handle->stateConfVector[handle->stateConfVectorPosition])
  96. {
  97. case InternalEventLifeCycle_r1_A :
  98. {
  99. internalEventLifeCycle_react_r1_A(handle);
  100. break;
  101. }
  102. case InternalEventLifeCycle_r1_B :
  103. {
  104. internalEventLifeCycle_react_r1_B(handle);
  105. break;
  106. }
  107. case InternalEventLifeCycle_r2_C :
  108. {
  109. internalEventLifeCycle_react_r2_C(handle);
  110. break;
  111. }
  112. case InternalEventLifeCycle_r2_D :
  113. {
  114. internalEventLifeCycle_react_r2_D(handle);
  115. break;
  116. }
  117. default:
  118. break;
  119. }
  120. }
  121. internalEventLifeCycle_clearInEvents(handle);
  122. }
  123. sc_boolean internalEventLifeCycle_isStateActive(const InternalEventLifeCycle* handle, InternalEventLifeCycleStates state)
  124. {
  125. sc_boolean result = bool_false;
  126. switch (state)
  127. {
  128. case InternalEventLifeCycle_r1_A :
  129. result = (sc_boolean) (handle->stateConfVector[SCVI_INTERNALEVENTLIFECYCLE_R1_A] == InternalEventLifeCycle_r1_A
  130. );
  131. break;
  132. case InternalEventLifeCycle_r1_B :
  133. result = (sc_boolean) (handle->stateConfVector[SCVI_INTERNALEVENTLIFECYCLE_R1_B] == InternalEventLifeCycle_r1_B
  134. );
  135. break;
  136. case InternalEventLifeCycle_r2_C :
  137. result = (sc_boolean) (handle->stateConfVector[SCVI_INTERNALEVENTLIFECYCLE_R2_C] == InternalEventLifeCycle_r2_C
  138. );
  139. break;
  140. case InternalEventLifeCycle_r2_D :
  141. result = (sc_boolean) (handle->stateConfVector[SCVI_INTERNALEVENTLIFECYCLE_R2_D] == InternalEventLifeCycle_r2_D
  142. );
  143. break;
  144. default:
  145. result = bool_false;
  146. break;
  147. }
  148. return result;
  149. }
  150. void internalEventLifeCycleIface_raise_e(InternalEventLifeCycle* handle)
  151. {
  152. handle->iface.e_raised = bool_true;
  153. }
  154. void internalEventLifeCycleIface_raise_f(InternalEventLifeCycle* handle)
  155. {
  156. handle->iface.f_raised = bool_true;
  157. }
  158. /* implementations of all internal functions */
  159. static sc_boolean internalEventLifeCycle_check_r1_A_tr0_tr0(const InternalEventLifeCycle* handle)
  160. {
  161. return handle->internal.i2_raised;
  162. }
  163. static sc_boolean internalEventLifeCycle_check_r1_A_lr0_lr0(const InternalEventLifeCycle* handle)
  164. {
  165. return handle->iface.e_raised;
  166. }
  167. static sc_boolean internalEventLifeCycle_check_r1_B_tr0_tr0(const InternalEventLifeCycle* handle)
  168. {
  169. return handle->iface.e_raised;
  170. }
  171. static sc_boolean internalEventLifeCycle_check_r2_C_tr0_tr0(const InternalEventLifeCycle* handle)
  172. {
  173. return handle->internal.i1_raised;
  174. }
  175. static sc_boolean internalEventLifeCycle_check_r2_D_tr0_tr0(const InternalEventLifeCycle* handle)
  176. {
  177. return handle->iface.f_raised;
  178. }
  179. static void internalEventLifeCycle_effect_r1_A_tr0(InternalEventLifeCycle* handle)
  180. {
  181. internalEventLifeCycle_exseq_r1_A(handle);
  182. internalEventLifeCycle_enseq_r1_B_default(handle);
  183. }
  184. static void internalEventLifeCycle_effect_r1_A_lr0_lr0(InternalEventLifeCycle* handle)
  185. {
  186. handle->internal.i1_raised = bool_true;
  187. }
  188. static void internalEventLifeCycle_effect_r1_B_tr0(InternalEventLifeCycle* handle)
  189. {
  190. internalEventLifeCycle_exseq_r1_B(handle);
  191. internalEventLifeCycle_enseq_r1_A_default(handle);
  192. }
  193. static void internalEventLifeCycle_effect_r2_C_tr0(InternalEventLifeCycle* handle)
  194. {
  195. internalEventLifeCycle_exseq_r2_C(handle);
  196. internalEventLifeCycle_enseq_r2_D_default(handle);
  197. }
  198. static void internalEventLifeCycle_effect_r2_D_tr0(InternalEventLifeCycle* handle)
  199. {
  200. internalEventLifeCycle_exseq_r2_D(handle);
  201. handle->internal.i2_raised = bool_true;
  202. internalEventLifeCycle_enseq_r2_C_default(handle);
  203. }
  204. /* 'default' enter sequence for state A */
  205. static void internalEventLifeCycle_enseq_r1_A_default(InternalEventLifeCycle* handle)
  206. {
  207. /* 'default' enter sequence for state A */
  208. handle->stateConfVector[0] = InternalEventLifeCycle_r1_A;
  209. handle->stateConfVectorPosition = 0;
  210. }
  211. /* 'default' enter sequence for state B */
  212. static void internalEventLifeCycle_enseq_r1_B_default(InternalEventLifeCycle* handle)
  213. {
  214. /* 'default' enter sequence for state B */
  215. handle->stateConfVector[0] = InternalEventLifeCycle_r1_B;
  216. handle->stateConfVectorPosition = 0;
  217. }
  218. /* 'default' enter sequence for state C */
  219. static void internalEventLifeCycle_enseq_r2_C_default(InternalEventLifeCycle* handle)
  220. {
  221. /* 'default' enter sequence for state C */
  222. handle->stateConfVector[1] = InternalEventLifeCycle_r2_C;
  223. handle->stateConfVectorPosition = 1;
  224. }
  225. /* 'default' enter sequence for state D */
  226. static void internalEventLifeCycle_enseq_r2_D_default(InternalEventLifeCycle* handle)
  227. {
  228. /* 'default' enter sequence for state D */
  229. handle->stateConfVector[1] = InternalEventLifeCycle_r2_D;
  230. handle->stateConfVectorPosition = 1;
  231. }
  232. /* 'default' enter sequence for region r1 */
  233. static void internalEventLifeCycle_enseq_r1_default(InternalEventLifeCycle* handle)
  234. {
  235. /* 'default' enter sequence for region r1 */
  236. internalEventLifeCycle_react_r1__entry_Default(handle);
  237. }
  238. /* 'default' enter sequence for region r2 */
  239. static void internalEventLifeCycle_enseq_r2_default(InternalEventLifeCycle* handle)
  240. {
  241. /* 'default' enter sequence for region r2 */
  242. internalEventLifeCycle_react_r2__entry_Default(handle);
  243. }
  244. /* Default exit sequence for state A */
  245. static void internalEventLifeCycle_exseq_r1_A(InternalEventLifeCycle* handle)
  246. {
  247. /* Default exit sequence for state A */
  248. handle->stateConfVector[0] = InternalEventLifeCycle_last_state;
  249. handle->stateConfVectorPosition = 0;
  250. }
  251. /* Default exit sequence for state B */
  252. static void internalEventLifeCycle_exseq_r1_B(InternalEventLifeCycle* handle)
  253. {
  254. /* Default exit sequence for state B */
  255. handle->stateConfVector[0] = InternalEventLifeCycle_last_state;
  256. handle->stateConfVectorPosition = 0;
  257. }
  258. /* Default exit sequence for state C */
  259. static void internalEventLifeCycle_exseq_r2_C(InternalEventLifeCycle* handle)
  260. {
  261. /* Default exit sequence for state C */
  262. handle->stateConfVector[1] = InternalEventLifeCycle_last_state;
  263. handle->stateConfVectorPosition = 1;
  264. }
  265. /* Default exit sequence for state D */
  266. static void internalEventLifeCycle_exseq_r2_D(InternalEventLifeCycle* handle)
  267. {
  268. /* Default exit sequence for state D */
  269. handle->stateConfVector[1] = InternalEventLifeCycle_last_state;
  270. handle->stateConfVectorPosition = 1;
  271. }
  272. /* Default exit sequence for region r1 */
  273. static void internalEventLifeCycle_exseq_r1(InternalEventLifeCycle* handle)
  274. {
  275. /* Default exit sequence for region r1 */
  276. /* Handle exit of all possible states (of InternalEventLifeCycle.r1) at position 0... */
  277. switch(handle->stateConfVector[ 0 ])
  278. {
  279. case InternalEventLifeCycle_r1_A :
  280. {
  281. internalEventLifeCycle_exseq_r1_A(handle);
  282. break;
  283. }
  284. case InternalEventLifeCycle_r1_B :
  285. {
  286. internalEventLifeCycle_exseq_r1_B(handle);
  287. break;
  288. }
  289. default: break;
  290. }
  291. }
  292. /* Default exit sequence for region r2 */
  293. static void internalEventLifeCycle_exseq_r2(InternalEventLifeCycle* handle)
  294. {
  295. /* Default exit sequence for region r2 */
  296. /* Handle exit of all possible states (of InternalEventLifeCycle.r2) at position 1... */
  297. switch(handle->stateConfVector[ 1 ])
  298. {
  299. case InternalEventLifeCycle_r2_C :
  300. {
  301. internalEventLifeCycle_exseq_r2_C(handle);
  302. break;
  303. }
  304. case InternalEventLifeCycle_r2_D :
  305. {
  306. internalEventLifeCycle_exseq_r2_D(handle);
  307. break;
  308. }
  309. default: break;
  310. }
  311. }
  312. /* The reactions of state A. */
  313. static void internalEventLifeCycle_react_r1_A(InternalEventLifeCycle* handle)
  314. {
  315. /* The reactions of state A. */
  316. if (internalEventLifeCycle_check_r1_A_tr0_tr0(handle) == bool_true)
  317. {
  318. internalEventLifeCycle_effect_r1_A_tr0(handle);
  319. } else
  320. {
  321. if (internalEventLifeCycle_check_r1_A_lr0_lr0(handle) == bool_true)
  322. {
  323. internalEventLifeCycle_effect_r1_A_lr0_lr0(handle);
  324. }
  325. }
  326. }
  327. /* The reactions of state B. */
  328. static void internalEventLifeCycle_react_r1_B(InternalEventLifeCycle* handle)
  329. {
  330. /* The reactions of state B. */
  331. if (internalEventLifeCycle_check_r1_B_tr0_tr0(handle) == bool_true)
  332. {
  333. internalEventLifeCycle_effect_r1_B_tr0(handle);
  334. }
  335. }
  336. /* The reactions of state C. */
  337. static void internalEventLifeCycle_react_r2_C(InternalEventLifeCycle* handle)
  338. {
  339. /* The reactions of state C. */
  340. if (internalEventLifeCycle_check_r2_C_tr0_tr0(handle) == bool_true)
  341. {
  342. internalEventLifeCycle_effect_r2_C_tr0(handle);
  343. }
  344. }
  345. /* The reactions of state D. */
  346. static void internalEventLifeCycle_react_r2_D(InternalEventLifeCycle* handle)
  347. {
  348. /* The reactions of state D. */
  349. if (internalEventLifeCycle_check_r2_D_tr0_tr0(handle) == bool_true)
  350. {
  351. internalEventLifeCycle_effect_r2_D_tr0(handle);
  352. }
  353. }
  354. /* Default react sequence for initial entry */
  355. static void internalEventLifeCycle_react_r1__entry_Default(InternalEventLifeCycle* handle)
  356. {
  357. /* Default react sequence for initial entry */
  358. internalEventLifeCycle_enseq_r1_A_default(handle);
  359. }
  360. /* Default react sequence for initial entry */
  361. static void internalEventLifeCycle_react_r2__entry_Default(InternalEventLifeCycle* handle)
  362. {
  363. /* Default react sequence for initial entry */
  364. internalEventLifeCycle_enseq_r2_C_default(handle);
  365. }