StaticChoice.c 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include "sc_types.h"
  4. #include "StaticChoice.h"
  5. /*! \file Implementation of the state machine 'StaticChoice'
  6. */
  7. /* prototypes of all internal functions */
  8. static sc_boolean staticChoice_check_main_region_Start_tr0_tr0(const StaticChoice* handle);
  9. static sc_boolean staticChoice_check_main_region__choice_0_tr1_tr1(const StaticChoice* handle);
  10. static sc_boolean staticChoice_check_main_region__choice_0_tr0(const StaticChoice* handle);
  11. static void staticChoice_effect_main_region_Start_tr0(StaticChoice* handle);
  12. static void staticChoice_effect_main_region__choice_0_tr1(StaticChoice* handle);
  13. static void staticChoice_effect_main_region__choice_0_tr0(StaticChoice* handle);
  14. static void staticChoice_enact_main_region_Start(StaticChoice* handle);
  15. static void staticChoice_enseq_main_region_Start_default(StaticChoice* handle);
  16. static void staticChoice_enseq_main_region_B_default(StaticChoice* handle);
  17. static void staticChoice_enseq_main_region_A_default(StaticChoice* handle);
  18. static void staticChoice_enseq_main_region_default(StaticChoice* handle);
  19. static void staticChoice_exseq_main_region_Start(StaticChoice* handle);
  20. static void staticChoice_exseq_main_region_B(StaticChoice* handle);
  21. static void staticChoice_exseq_main_region_A(StaticChoice* handle);
  22. static void staticChoice_exseq_main_region(StaticChoice* handle);
  23. static void staticChoice_react_main_region_Start(StaticChoice* handle);
  24. static void staticChoice_react_main_region_B(StaticChoice* handle);
  25. static void staticChoice_react_main_region_A(StaticChoice* handle);
  26. static void staticChoice_react_main_region__choice_0(StaticChoice* handle);
  27. static void staticChoice_react_main_region__entry_Default(StaticChoice* handle);
  28. static void staticChoice_clearInEvents(StaticChoice* handle);
  29. static void staticChoice_clearOutEvents(StaticChoice* handle);
  30. void staticChoice_init(StaticChoice* handle)
  31. {
  32. sc_integer i;
  33. for (i = 0; i < STATICCHOICE_MAX_ORTHOGONAL_STATES; ++i)
  34. {
  35. handle->stateConfVector[i] = StaticChoice_last_state;
  36. }
  37. handle->stateConfVectorPosition = 0;
  38. staticChoice_clearInEvents(handle);
  39. staticChoice_clearOutEvents(handle);
  40. /* Default init sequence for statechart StaticChoice */
  41. handle->iface.number = 0;
  42. }
  43. void staticChoice_enter(StaticChoice* handle)
  44. {
  45. /* Default enter sequence for statechart StaticChoice */
  46. staticChoice_enseq_main_region_default(handle);
  47. }
  48. void staticChoice_exit(StaticChoice* handle)
  49. {
  50. /* Default exit sequence for statechart StaticChoice */
  51. staticChoice_exseq_main_region(handle);
  52. }
  53. sc_boolean staticChoice_isActive(const StaticChoice* handle)
  54. {
  55. sc_boolean result = bool_false;
  56. int i;
  57. for(i = 0; i < STATICCHOICE_MAX_ORTHOGONAL_STATES; i++)
  58. {
  59. result = result || handle->stateConfVector[i] != StaticChoice_last_state;
  60. }
  61. return result;
  62. }
  63. /*
  64. * Always returns 'false' since this state machine can never become final.
  65. */
  66. sc_boolean staticChoice_isFinal(const StaticChoice* handle)
  67. {
  68. return bool_false;
  69. }
  70. static void staticChoice_clearInEvents(StaticChoice* handle)
  71. {
  72. handle->iface.reset_raised = bool_false;
  73. }
  74. static void staticChoice_clearOutEvents(StaticChoice* handle)
  75. {
  76. }
  77. void staticChoice_runCycle(StaticChoice* handle)
  78. {
  79. staticChoice_clearOutEvents(handle);
  80. for (handle->stateConfVectorPosition = 0;
  81. handle->stateConfVectorPosition < STATICCHOICE_MAX_ORTHOGONAL_STATES;
  82. handle->stateConfVectorPosition++)
  83. {
  84. switch (handle->stateConfVector[handle->stateConfVectorPosition])
  85. {
  86. case StaticChoice_main_region_Start :
  87. {
  88. staticChoice_react_main_region_Start(handle);
  89. break;
  90. }
  91. case StaticChoice_main_region_B :
  92. {
  93. staticChoice_react_main_region_B(handle);
  94. break;
  95. }
  96. case StaticChoice_main_region_A :
  97. {
  98. staticChoice_react_main_region_A(handle);
  99. break;
  100. }
  101. default:
  102. break;
  103. }
  104. }
  105. staticChoice_clearInEvents(handle);
  106. }
  107. sc_boolean staticChoice_isStateActive(const StaticChoice* handle, StaticChoiceStates state)
  108. {
  109. sc_boolean result = bool_false;
  110. switch (state)
  111. {
  112. case StaticChoice_main_region_Start :
  113. result = (sc_boolean) (handle->stateConfVector[SCVI_STATICCHOICE_MAIN_REGION_START] == StaticChoice_main_region_Start
  114. );
  115. break;
  116. case StaticChoice_main_region_B :
  117. result = (sc_boolean) (handle->stateConfVector[SCVI_STATICCHOICE_MAIN_REGION_B] == StaticChoice_main_region_B
  118. );
  119. break;
  120. case StaticChoice_main_region_A :
  121. result = (sc_boolean) (handle->stateConfVector[SCVI_STATICCHOICE_MAIN_REGION_A] == StaticChoice_main_region_A
  122. );
  123. break;
  124. default:
  125. result = bool_false;
  126. break;
  127. }
  128. return result;
  129. }
  130. void staticChoiceIface_raise_reset(StaticChoice* handle)
  131. {
  132. handle->iface.reset_raised = bool_true;
  133. }
  134. sc_integer staticChoiceIface_get_number(const StaticChoice* handle)
  135. {
  136. return handle->iface.number;
  137. }
  138. void staticChoiceIface_set_number(StaticChoice* handle, sc_integer value)
  139. {
  140. handle->iface.number = value;
  141. }
  142. /* implementations of all internal functions */
  143. static sc_boolean staticChoice_check_main_region_Start_tr0_tr0(const StaticChoice* handle)
  144. {
  145. return bool_true;
  146. }
  147. static sc_boolean staticChoice_check_main_region__choice_0_tr1_tr1(const StaticChoice* handle)
  148. {
  149. return (handle->iface.number == 2) ? bool_true : bool_false;
  150. }
  151. static sc_boolean staticChoice_check_main_region__choice_0_tr0(const StaticChoice* handle)
  152. {
  153. return bool_true;
  154. }
  155. static void staticChoice_effect_main_region_Start_tr0(StaticChoice* handle)
  156. {
  157. staticChoice_exseq_main_region_Start(handle);
  158. handle->iface.number += 1;
  159. staticChoice_react_main_region__choice_0(handle);
  160. }
  161. static void staticChoice_effect_main_region__choice_0_tr1(StaticChoice* handle)
  162. {
  163. staticChoice_enseq_main_region_A_default(handle);
  164. }
  165. static void staticChoice_effect_main_region__choice_0_tr0(StaticChoice* handle)
  166. {
  167. staticChoice_enseq_main_region_B_default(handle);
  168. }
  169. /* Entry action for state 'Start'. */
  170. static void staticChoice_enact_main_region_Start(StaticChoice* handle)
  171. {
  172. /* Entry action for state 'Start'. */
  173. handle->iface.number = 1;
  174. }
  175. /* 'default' enter sequence for state Start */
  176. static void staticChoice_enseq_main_region_Start_default(StaticChoice* handle)
  177. {
  178. /* 'default' enter sequence for state Start */
  179. staticChoice_enact_main_region_Start(handle);
  180. handle->stateConfVector[0] = StaticChoice_main_region_Start;
  181. handle->stateConfVectorPosition = 0;
  182. }
  183. /* 'default' enter sequence for state B */
  184. static void staticChoice_enseq_main_region_B_default(StaticChoice* handle)
  185. {
  186. /* 'default' enter sequence for state B */
  187. handle->stateConfVector[0] = StaticChoice_main_region_B;
  188. handle->stateConfVectorPosition = 0;
  189. }
  190. /* 'default' enter sequence for state A */
  191. static void staticChoice_enseq_main_region_A_default(StaticChoice* handle)
  192. {
  193. /* 'default' enter sequence for state A */
  194. handle->stateConfVector[0] = StaticChoice_main_region_A;
  195. handle->stateConfVectorPosition = 0;
  196. }
  197. /* 'default' enter sequence for region main region */
  198. static void staticChoice_enseq_main_region_default(StaticChoice* handle)
  199. {
  200. /* 'default' enter sequence for region main region */
  201. staticChoice_react_main_region__entry_Default(handle);
  202. }
  203. /* Default exit sequence for state Start */
  204. static void staticChoice_exseq_main_region_Start(StaticChoice* handle)
  205. {
  206. /* Default exit sequence for state Start */
  207. handle->stateConfVector[0] = StaticChoice_last_state;
  208. handle->stateConfVectorPosition = 0;
  209. }
  210. /* Default exit sequence for state B */
  211. static void staticChoice_exseq_main_region_B(StaticChoice* handle)
  212. {
  213. /* Default exit sequence for state B */
  214. handle->stateConfVector[0] = StaticChoice_last_state;
  215. handle->stateConfVectorPosition = 0;
  216. }
  217. /* Default exit sequence for state A */
  218. static void staticChoice_exseq_main_region_A(StaticChoice* handle)
  219. {
  220. /* Default exit sequence for state A */
  221. handle->stateConfVector[0] = StaticChoice_last_state;
  222. handle->stateConfVectorPosition = 0;
  223. }
  224. /* Default exit sequence for region main region */
  225. static void staticChoice_exseq_main_region(StaticChoice* handle)
  226. {
  227. /* Default exit sequence for region main region */
  228. /* Handle exit of all possible states (of StaticChoice.main_region) at position 0... */
  229. switch(handle->stateConfVector[ 0 ])
  230. {
  231. case StaticChoice_main_region_Start :
  232. {
  233. staticChoice_exseq_main_region_Start(handle);
  234. break;
  235. }
  236. case StaticChoice_main_region_B :
  237. {
  238. staticChoice_exseq_main_region_B(handle);
  239. break;
  240. }
  241. case StaticChoice_main_region_A :
  242. {
  243. staticChoice_exseq_main_region_A(handle);
  244. break;
  245. }
  246. default: break;
  247. }
  248. }
  249. /* The reactions of state Start. */
  250. static void staticChoice_react_main_region_Start(StaticChoice* handle)
  251. {
  252. /* The reactions of state Start. */
  253. staticChoice_effect_main_region_Start_tr0(handle);
  254. }
  255. /* The reactions of state B. */
  256. static void staticChoice_react_main_region_B(StaticChoice* handle)
  257. {
  258. /* The reactions of state B. */
  259. }
  260. /* The reactions of state A. */
  261. static void staticChoice_react_main_region_A(StaticChoice* handle)
  262. {
  263. /* The reactions of state A. */
  264. }
  265. /* The reactions of state null. */
  266. static void staticChoice_react_main_region__choice_0(StaticChoice* handle)
  267. {
  268. /* The reactions of state null. */
  269. if (staticChoice_check_main_region__choice_0_tr1_tr1(handle) == bool_true)
  270. {
  271. staticChoice_effect_main_region__choice_0_tr1(handle);
  272. } else
  273. {
  274. staticChoice_effect_main_region__choice_0_tr0(handle);
  275. }
  276. }
  277. /* Default react sequence for initial entry */
  278. static void staticChoice_react_main_region__entry_Default(StaticChoice* handle)
  279. {
  280. /* Default react sequence for initial entry */
  281. staticChoice_enseq_main_region_Start_default(handle);
  282. }