HistoryWithExitPoint.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include "sc_types.h"
  4. #include "HistoryWithExitPoint.h"
  5. /*! \file Implementation of the state machine 'HistoryWithExitPoint'
  6. */
  7. /* prototypes of all internal functions */
  8. static sc_boolean historyWithExitPoint_check_mr_A_r_X1_tr0_tr0(const HistoryWithExitPoint* handle);
  9. static sc_boolean historyWithExitPoint_check_mr_A_r_X1_tr1_tr1(const HistoryWithExitPoint* handle);
  10. static sc_boolean historyWithExitPoint_check_mr_A_r_X2_tr0_tr0(const HistoryWithExitPoint* handle);
  11. static sc_boolean historyWithExitPoint_check_mr_A_r_X2_tr1_tr1(const HistoryWithExitPoint* handle);
  12. static sc_boolean historyWithExitPoint_check_mr_B_tr0_tr0(const HistoryWithExitPoint* handle);
  13. static void historyWithExitPoint_effect_mr_A_tr0(HistoryWithExitPoint* handle);
  14. static void historyWithExitPoint_effect_mr_A_r_X1_tr0(HistoryWithExitPoint* handle);
  15. static void historyWithExitPoint_effect_mr_A_r_X1_tr1(HistoryWithExitPoint* handle);
  16. static void historyWithExitPoint_effect_mr_A_r_X2_tr0(HistoryWithExitPoint* handle);
  17. static void historyWithExitPoint_effect_mr_A_r_X2_tr1(HistoryWithExitPoint* handle);
  18. static void historyWithExitPoint_effect_mr_B_tr0(HistoryWithExitPoint* handle);
  19. static void historyWithExitPoint_enseq_mr_A_default(HistoryWithExitPoint* handle);
  20. static void historyWithExitPoint_enseq_mr_A_r_X1_default(HistoryWithExitPoint* handle);
  21. static void historyWithExitPoint_enseq_mr_A_r_X2_default(HistoryWithExitPoint* handle);
  22. static void historyWithExitPoint_enseq_mr_B_default(HistoryWithExitPoint* handle);
  23. static void historyWithExitPoint_enseq_mr_default(HistoryWithExitPoint* handle);
  24. static void historyWithExitPoint_enseq_mr_A_r_default(HistoryWithExitPoint* handle);
  25. static void historyWithExitPoint_shenseq_mr_A_r(HistoryWithExitPoint* handle);
  26. static void historyWithExitPoint_exseq_mr_A(HistoryWithExitPoint* handle);
  27. static void historyWithExitPoint_exseq_mr_A_r_X1(HistoryWithExitPoint* handle);
  28. static void historyWithExitPoint_exseq_mr_A_r_X2(HistoryWithExitPoint* handle);
  29. static void historyWithExitPoint_exseq_mr_B(HistoryWithExitPoint* handle);
  30. static void historyWithExitPoint_exseq_mr(HistoryWithExitPoint* handle);
  31. static void historyWithExitPoint_exseq_mr_A_r(HistoryWithExitPoint* handle);
  32. static void historyWithExitPoint_react_mr_A_r_X1(HistoryWithExitPoint* handle);
  33. static void historyWithExitPoint_react_mr_A_r_X2(HistoryWithExitPoint* handle);
  34. static void historyWithExitPoint_react_mr_B(HistoryWithExitPoint* handle);
  35. static void historyWithExitPoint_react_mr__entry_Default(HistoryWithExitPoint* handle);
  36. static void historyWithExitPoint_react_mr_A_r__entry_Default(HistoryWithExitPoint* handle);
  37. static void historyWithExitPoint_react_mr_A_r_exit_to_B(HistoryWithExitPoint* handle);
  38. static void historyWithExitPoint_clearInEvents(HistoryWithExitPoint* handle);
  39. static void historyWithExitPoint_clearOutEvents(HistoryWithExitPoint* handle);
  40. void historyWithExitPoint_init(HistoryWithExitPoint* handle)
  41. {
  42. sc_integer i;
  43. for (i = 0; i < HISTORYWITHEXITPOINT_MAX_ORTHOGONAL_STATES; ++i)
  44. {
  45. handle->stateConfVector[i] = HistoryWithExitPoint_last_state;
  46. }
  47. for (i = 0; i < HISTORYWITHEXITPOINT_MAX_HISTORY_STATES; ++i)
  48. {
  49. handle->historyVector[i] = HistoryWithExitPoint_last_state;
  50. }
  51. handle->stateConfVectorPosition = 0;
  52. historyWithExitPoint_clearInEvents(handle);
  53. historyWithExitPoint_clearOutEvents(handle);
  54. }
  55. void historyWithExitPoint_enter(HistoryWithExitPoint* handle)
  56. {
  57. /* Default enter sequence for statechart HistoryWithExitPoint */
  58. historyWithExitPoint_enseq_mr_default(handle);
  59. }
  60. void historyWithExitPoint_exit(HistoryWithExitPoint* handle)
  61. {
  62. /* Default exit sequence for statechart HistoryWithExitPoint */
  63. historyWithExitPoint_exseq_mr(handle);
  64. }
  65. sc_boolean historyWithExitPoint_isActive(const HistoryWithExitPoint* handle)
  66. {
  67. sc_boolean result;
  68. if (handle->stateConfVector[0] != HistoryWithExitPoint_last_state)
  69. {
  70. result = bool_true;
  71. }
  72. else
  73. {
  74. result = bool_false;
  75. }
  76. return result;
  77. }
  78. /*
  79. * Always returns 'false' since this state machine can never become final.
  80. */
  81. sc_boolean historyWithExitPoint_isFinal(const HistoryWithExitPoint* handle)
  82. {
  83. return bool_false;
  84. }
  85. static void historyWithExitPoint_clearInEvents(HistoryWithExitPoint* handle)
  86. {
  87. handle->iface.push_raised = bool_false;
  88. handle->iface.back_raised = bool_false;
  89. handle->iface.next_raised = bool_false;
  90. }
  91. static void historyWithExitPoint_clearOutEvents(HistoryWithExitPoint* handle)
  92. {
  93. }
  94. void historyWithExitPoint_runCycle(HistoryWithExitPoint* handle)
  95. {
  96. historyWithExitPoint_clearOutEvents(handle);
  97. for (handle->stateConfVectorPosition = 0;
  98. handle->stateConfVectorPosition < HISTORYWITHEXITPOINT_MAX_ORTHOGONAL_STATES;
  99. handle->stateConfVectorPosition++)
  100. {
  101. switch (handle->stateConfVector[handle->stateConfVectorPosition])
  102. {
  103. case HistoryWithExitPoint_mr_A_r_X1 :
  104. {
  105. historyWithExitPoint_react_mr_A_r_X1(handle);
  106. break;
  107. }
  108. case HistoryWithExitPoint_mr_A_r_X2 :
  109. {
  110. historyWithExitPoint_react_mr_A_r_X2(handle);
  111. break;
  112. }
  113. case HistoryWithExitPoint_mr_B :
  114. {
  115. historyWithExitPoint_react_mr_B(handle);
  116. break;
  117. }
  118. default:
  119. break;
  120. }
  121. }
  122. historyWithExitPoint_clearInEvents(handle);
  123. }
  124. sc_boolean historyWithExitPoint_isStateActive(const HistoryWithExitPoint* handle, HistoryWithExitPointStates state)
  125. {
  126. sc_boolean result = bool_false;
  127. switch (state)
  128. {
  129. case HistoryWithExitPoint_mr_A :
  130. result = (sc_boolean) (handle->stateConfVector[0] >= HistoryWithExitPoint_mr_A
  131. && handle->stateConfVector[0] <= HistoryWithExitPoint_mr_A_r_X2);
  132. break;
  133. case HistoryWithExitPoint_mr_A_r_X1 :
  134. result = (sc_boolean) (handle->stateConfVector[0] == HistoryWithExitPoint_mr_A_r_X1
  135. );
  136. break;
  137. case HistoryWithExitPoint_mr_A_r_X2 :
  138. result = (sc_boolean) (handle->stateConfVector[0] == HistoryWithExitPoint_mr_A_r_X2
  139. );
  140. break;
  141. case HistoryWithExitPoint_mr_B :
  142. result = (sc_boolean) (handle->stateConfVector[0] == HistoryWithExitPoint_mr_B
  143. );
  144. break;
  145. default:
  146. result = bool_false;
  147. break;
  148. }
  149. return result;
  150. }
  151. void historyWithExitPointIface_raise_push(HistoryWithExitPoint* handle)
  152. {
  153. handle->iface.push_raised = bool_true;
  154. }
  155. void historyWithExitPointIface_raise_back(HistoryWithExitPoint* handle)
  156. {
  157. handle->iface.back_raised = bool_true;
  158. }
  159. void historyWithExitPointIface_raise_next(HistoryWithExitPoint* handle)
  160. {
  161. handle->iface.next_raised = bool_true;
  162. }
  163. /* implementations of all internal functions */
  164. static sc_boolean historyWithExitPoint_check_mr_A_r_X1_tr0_tr0(const HistoryWithExitPoint* handle)
  165. {
  166. return handle->iface.next_raised;
  167. }
  168. static sc_boolean historyWithExitPoint_check_mr_A_r_X1_tr1_tr1(const HistoryWithExitPoint* handle)
  169. {
  170. return handle->iface.push_raised;
  171. }
  172. static sc_boolean historyWithExitPoint_check_mr_A_r_X2_tr0_tr0(const HistoryWithExitPoint* handle)
  173. {
  174. return handle->iface.next_raised;
  175. }
  176. static sc_boolean historyWithExitPoint_check_mr_A_r_X2_tr1_tr1(const HistoryWithExitPoint* handle)
  177. {
  178. return handle->iface.push_raised;
  179. }
  180. static sc_boolean historyWithExitPoint_check_mr_B_tr0_tr0(const HistoryWithExitPoint* handle)
  181. {
  182. return handle->iface.back_raised;
  183. }
  184. static void historyWithExitPoint_effect_mr_A_tr0(HistoryWithExitPoint* handle)
  185. {
  186. historyWithExitPoint_exseq_mr_A(handle);
  187. historyWithExitPoint_enseq_mr_B_default(handle);
  188. }
  189. static void historyWithExitPoint_effect_mr_A_r_X1_tr0(HistoryWithExitPoint* handle)
  190. {
  191. historyWithExitPoint_exseq_mr_A_r_X1(handle);
  192. historyWithExitPoint_enseq_mr_A_r_X2_default(handle);
  193. }
  194. static void historyWithExitPoint_effect_mr_A_r_X1_tr1(HistoryWithExitPoint* handle)
  195. {
  196. historyWithExitPoint_exseq_mr_A_r_X1(handle);
  197. historyWithExitPoint_react_mr_A_r_exit_to_B(handle);
  198. }
  199. static void historyWithExitPoint_effect_mr_A_r_X2_tr0(HistoryWithExitPoint* handle)
  200. {
  201. historyWithExitPoint_exseq_mr_A_r_X2(handle);
  202. historyWithExitPoint_enseq_mr_A_r_X1_default(handle);
  203. }
  204. static void historyWithExitPoint_effect_mr_A_r_X2_tr1(HistoryWithExitPoint* handle)
  205. {
  206. historyWithExitPoint_exseq_mr_A_r_X2(handle);
  207. historyWithExitPoint_react_mr_A_r_exit_to_B(handle);
  208. }
  209. static void historyWithExitPoint_effect_mr_B_tr0(HistoryWithExitPoint* handle)
  210. {
  211. historyWithExitPoint_exseq_mr_B(handle);
  212. historyWithExitPoint_enseq_mr_A_default(handle);
  213. }
  214. /* 'default' enter sequence for state A */
  215. static void historyWithExitPoint_enseq_mr_A_default(HistoryWithExitPoint* handle)
  216. {
  217. /* 'default' enter sequence for state A */
  218. historyWithExitPoint_enseq_mr_A_r_default(handle);
  219. }
  220. /* 'default' enter sequence for state X1 */
  221. static void historyWithExitPoint_enseq_mr_A_r_X1_default(HistoryWithExitPoint* handle)
  222. {
  223. /* 'default' enter sequence for state X1 */
  224. handle->stateConfVector[0] = HistoryWithExitPoint_mr_A_r_X1;
  225. handle->stateConfVectorPosition = 0;
  226. handle->historyVector[0] = handle->stateConfVector[0];
  227. }
  228. /* 'default' enter sequence for state X2 */
  229. static void historyWithExitPoint_enseq_mr_A_r_X2_default(HistoryWithExitPoint* handle)
  230. {
  231. /* 'default' enter sequence for state X2 */
  232. handle->stateConfVector[0] = HistoryWithExitPoint_mr_A_r_X2;
  233. handle->stateConfVectorPosition = 0;
  234. handle->historyVector[0] = handle->stateConfVector[0];
  235. }
  236. /* 'default' enter sequence for state B */
  237. static void historyWithExitPoint_enseq_mr_B_default(HistoryWithExitPoint* handle)
  238. {
  239. /* 'default' enter sequence for state B */
  240. handle->stateConfVector[0] = HistoryWithExitPoint_mr_B;
  241. handle->stateConfVectorPosition = 0;
  242. }
  243. /* 'default' enter sequence for region mr */
  244. static void historyWithExitPoint_enseq_mr_default(HistoryWithExitPoint* handle)
  245. {
  246. /* 'default' enter sequence for region mr */
  247. historyWithExitPoint_react_mr__entry_Default(handle);
  248. }
  249. /* 'default' enter sequence for region r */
  250. static void historyWithExitPoint_enseq_mr_A_r_default(HistoryWithExitPoint* handle)
  251. {
  252. /* 'default' enter sequence for region r */
  253. historyWithExitPoint_react_mr_A_r__entry_Default(handle);
  254. }
  255. /* shallow enterSequence with history in child r */
  256. static void historyWithExitPoint_shenseq_mr_A_r(HistoryWithExitPoint* handle)
  257. {
  258. /* shallow enterSequence with history in child r */
  259. /* Handle shallow history entry of r */
  260. switch(handle->historyVector[ 0 ])
  261. {
  262. case HistoryWithExitPoint_mr_A_r_X1 :
  263. {
  264. historyWithExitPoint_enseq_mr_A_r_X1_default(handle);
  265. break;
  266. }
  267. case HistoryWithExitPoint_mr_A_r_X2 :
  268. {
  269. historyWithExitPoint_enseq_mr_A_r_X2_default(handle);
  270. break;
  271. }
  272. default: break;
  273. }
  274. }
  275. /* Default exit sequence for state A */
  276. static void historyWithExitPoint_exseq_mr_A(HistoryWithExitPoint* handle)
  277. {
  278. /* Default exit sequence for state A */
  279. historyWithExitPoint_exseq_mr_A_r(handle);
  280. }
  281. /* Default exit sequence for state X1 */
  282. static void historyWithExitPoint_exseq_mr_A_r_X1(HistoryWithExitPoint* handle)
  283. {
  284. /* Default exit sequence for state X1 */
  285. handle->stateConfVector[0] = HistoryWithExitPoint_last_state;
  286. handle->stateConfVectorPosition = 0;
  287. }
  288. /* Default exit sequence for state X2 */
  289. static void historyWithExitPoint_exseq_mr_A_r_X2(HistoryWithExitPoint* handle)
  290. {
  291. /* Default exit sequence for state X2 */
  292. handle->stateConfVector[0] = HistoryWithExitPoint_last_state;
  293. handle->stateConfVectorPosition = 0;
  294. }
  295. /* Default exit sequence for state B */
  296. static void historyWithExitPoint_exseq_mr_B(HistoryWithExitPoint* handle)
  297. {
  298. /* Default exit sequence for state B */
  299. handle->stateConfVector[0] = HistoryWithExitPoint_last_state;
  300. handle->stateConfVectorPosition = 0;
  301. }
  302. /* Default exit sequence for region mr */
  303. static void historyWithExitPoint_exseq_mr(HistoryWithExitPoint* handle)
  304. {
  305. /* Default exit sequence for region mr */
  306. /* Handle exit of all possible states (of HistoryWithExitPoint.mr) at position 0... */
  307. switch(handle->stateConfVector[ 0 ])
  308. {
  309. case HistoryWithExitPoint_mr_A_r_X1 :
  310. {
  311. historyWithExitPoint_exseq_mr_A_r_X1(handle);
  312. break;
  313. }
  314. case HistoryWithExitPoint_mr_A_r_X2 :
  315. {
  316. historyWithExitPoint_exseq_mr_A_r_X2(handle);
  317. break;
  318. }
  319. case HistoryWithExitPoint_mr_B :
  320. {
  321. historyWithExitPoint_exseq_mr_B(handle);
  322. break;
  323. }
  324. default: break;
  325. }
  326. }
  327. /* Default exit sequence for region r */
  328. static void historyWithExitPoint_exseq_mr_A_r(HistoryWithExitPoint* handle)
  329. {
  330. /* Default exit sequence for region r */
  331. /* Handle exit of all possible states (of HistoryWithExitPoint.mr.A.r) at position 0... */
  332. switch(handle->stateConfVector[ 0 ])
  333. {
  334. case HistoryWithExitPoint_mr_A_r_X1 :
  335. {
  336. historyWithExitPoint_exseq_mr_A_r_X1(handle);
  337. break;
  338. }
  339. case HistoryWithExitPoint_mr_A_r_X2 :
  340. {
  341. historyWithExitPoint_exseq_mr_A_r_X2(handle);
  342. break;
  343. }
  344. default: break;
  345. }
  346. }
  347. /* The reactions of state X1. */
  348. static void historyWithExitPoint_react_mr_A_r_X1(HistoryWithExitPoint* handle)
  349. {
  350. /* The reactions of state X1. */
  351. if (historyWithExitPoint_check_mr_A_r_X1_tr0_tr0(handle) == bool_true)
  352. {
  353. historyWithExitPoint_effect_mr_A_r_X1_tr0(handle);
  354. } else
  355. {
  356. if (historyWithExitPoint_check_mr_A_r_X1_tr1_tr1(handle) == bool_true)
  357. {
  358. historyWithExitPoint_effect_mr_A_r_X1_tr1(handle);
  359. }
  360. }
  361. }
  362. /* The reactions of state X2. */
  363. static void historyWithExitPoint_react_mr_A_r_X2(HistoryWithExitPoint* handle)
  364. {
  365. /* The reactions of state X2. */
  366. if (historyWithExitPoint_check_mr_A_r_X2_tr0_tr0(handle) == bool_true)
  367. {
  368. historyWithExitPoint_effect_mr_A_r_X2_tr0(handle);
  369. } else
  370. {
  371. if (historyWithExitPoint_check_mr_A_r_X2_tr1_tr1(handle) == bool_true)
  372. {
  373. historyWithExitPoint_effect_mr_A_r_X2_tr1(handle);
  374. }
  375. }
  376. }
  377. /* The reactions of state B. */
  378. static void historyWithExitPoint_react_mr_B(HistoryWithExitPoint* handle)
  379. {
  380. /* The reactions of state B. */
  381. if (historyWithExitPoint_check_mr_B_tr0_tr0(handle) == bool_true)
  382. {
  383. historyWithExitPoint_effect_mr_B_tr0(handle);
  384. }
  385. }
  386. /* Default react sequence for initial entry */
  387. static void historyWithExitPoint_react_mr__entry_Default(HistoryWithExitPoint* handle)
  388. {
  389. /* Default react sequence for initial entry */
  390. historyWithExitPoint_enseq_mr_A_default(handle);
  391. }
  392. /* Default react sequence for shallow history entry */
  393. static void historyWithExitPoint_react_mr_A_r__entry_Default(HistoryWithExitPoint* handle)
  394. {
  395. /* Default react sequence for shallow history entry */
  396. /* Enter the region with shallow history */
  397. if (handle->historyVector[0] != HistoryWithExitPoint_last_state)
  398. {
  399. historyWithExitPoint_shenseq_mr_A_r(handle);
  400. } else
  401. {
  402. historyWithExitPoint_enseq_mr_A_r_X1_default(handle);
  403. }
  404. }
  405. /* The reactions of exit exit_to_B. */
  406. static void historyWithExitPoint_react_mr_A_r_exit_to_B(HistoryWithExitPoint* handle)
  407. {
  408. /* The reactions of exit exit_to_B. */
  409. historyWithExitPoint_effect_mr_A_tr0(handle);
  410. }