DynamicChoice.c 9.4 KB

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