HistoryWithExitPoint.c 14 KB

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