InternalEventLifeCycle.c 13 KB

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