StatechartLocalReactions.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include "sc_types.h"
  4. #include "StatechartLocalReactions.h"
  5. /*! \file Implementation of the state machine 'StatechartLocalReactions'
  6. */
  7. /* prototypes of all internal functions */
  8. static sc_boolean statechartLocalReactions_check__lr0(const StatechartLocalReactions* handle);
  9. static sc_boolean statechartLocalReactions_check__lr1(const StatechartLocalReactions* handle);
  10. static sc_boolean statechartLocalReactions_check_main_region_S1_tr0_tr0(const StatechartLocalReactions* handle);
  11. static sc_boolean statechartLocalReactions_check_main_region_S2_tr0_tr0(const StatechartLocalReactions* handle);
  12. static void statechartLocalReactions_effect__lr0(StatechartLocalReactions* handle);
  13. static void statechartLocalReactions_effect__lr1(StatechartLocalReactions* handle);
  14. static void statechartLocalReactions_effect_main_region_S1_tr0(StatechartLocalReactions* handle);
  15. static void statechartLocalReactions_effect_main_region_S2_tr0(StatechartLocalReactions* handle);
  16. static void statechartLocalReactions_enseq_main_region_S1_default(StatechartLocalReactions* handle);
  17. static void statechartLocalReactions_enseq_main_region_S2_default(StatechartLocalReactions* handle);
  18. static void statechartLocalReactions_enseq_region2_a_default(StatechartLocalReactions* handle);
  19. static void statechartLocalReactions_enseq_main_region_default(StatechartLocalReactions* handle);
  20. static void statechartLocalReactions_enseq_region2_default(StatechartLocalReactions* handle);
  21. static void statechartLocalReactions_exseq_main_region_S1(StatechartLocalReactions* handle);
  22. static void statechartLocalReactions_exseq_main_region_S2(StatechartLocalReactions* handle);
  23. static void statechartLocalReactions_exseq_region2_a(StatechartLocalReactions* handle);
  24. static void statechartLocalReactions_exseq_main_region(StatechartLocalReactions* handle);
  25. static void statechartLocalReactions_exseq_region2(StatechartLocalReactions* handle);
  26. static void statechartLocalReactions_react_main_region_S1(StatechartLocalReactions* handle);
  27. static void statechartLocalReactions_react_main_region_S2(StatechartLocalReactions* handle);
  28. static void statechartLocalReactions_react_region2_a(StatechartLocalReactions* handle);
  29. static void statechartLocalReactions_react_main_region__entry_Default(StatechartLocalReactions* handle);
  30. static void statechartLocalReactions_react_region2__entry_Default(StatechartLocalReactions* handle);
  31. static void statechartLocalReactions_clearInEvents(StatechartLocalReactions* handle);
  32. static void statechartLocalReactions_clearOutEvents(StatechartLocalReactions* handle);
  33. void statechartLocalReactions_init(StatechartLocalReactions* handle)
  34. {
  35. sc_integer i;
  36. for (i = 0; i < STATECHARTLOCALREACTIONS_MAX_ORTHOGONAL_STATES; ++i)
  37. {
  38. handle->stateConfVector[i] = StatechartLocalReactions_last_state;
  39. }
  40. handle->stateConfVectorPosition = 0;
  41. statechartLocalReactions_clearInEvents(handle);
  42. statechartLocalReactions_clearOutEvents(handle);
  43. /* Default init sequence for statechart StatechartLocalReactions */
  44. handle->iface.myInt = 0;
  45. }
  46. void statechartLocalReactions_enter(StatechartLocalReactions* handle)
  47. {
  48. /* Default enter sequence for statechart StatechartLocalReactions */
  49. statechartLocalReactions_enseq_main_region_default(handle);
  50. statechartLocalReactions_enseq_region2_default(handle);
  51. }
  52. void statechartLocalReactions_exit(StatechartLocalReactions* handle)
  53. {
  54. /* Default exit sequence for statechart StatechartLocalReactions */
  55. statechartLocalReactions_exseq_main_region(handle);
  56. statechartLocalReactions_exseq_region2(handle);
  57. }
  58. sc_boolean statechartLocalReactions_isActive(const StatechartLocalReactions* handle)
  59. {
  60. sc_boolean result;
  61. if (handle->stateConfVector[0] != StatechartLocalReactions_last_state || handle->stateConfVector[1] != StatechartLocalReactions_last_state)
  62. {
  63. result = bool_true;
  64. }
  65. else
  66. {
  67. result = bool_false;
  68. }
  69. return result;
  70. }
  71. /*
  72. * Always returns 'false' since this state machine can never become final.
  73. */
  74. sc_boolean statechartLocalReactions_isFinal(const StatechartLocalReactions* handle)
  75. {
  76. return bool_false;
  77. }
  78. static void statechartLocalReactions_clearInEvents(StatechartLocalReactions* handle)
  79. {
  80. }
  81. static void statechartLocalReactions_clearOutEvents(StatechartLocalReactions* handle)
  82. {
  83. }
  84. void statechartLocalReactions_runCycle(StatechartLocalReactions* handle)
  85. {
  86. statechartLocalReactions_clearOutEvents(handle);
  87. for (handle->stateConfVectorPosition = 0;
  88. handle->stateConfVectorPosition < STATECHARTLOCALREACTIONS_MAX_ORTHOGONAL_STATES;
  89. handle->stateConfVectorPosition++)
  90. {
  91. switch (handle->stateConfVector[handle->stateConfVectorPosition])
  92. {
  93. case StatechartLocalReactions_main_region_S1 :
  94. {
  95. statechartLocalReactions_react_main_region_S1(handle);
  96. break;
  97. }
  98. case StatechartLocalReactions_main_region_S2 :
  99. {
  100. statechartLocalReactions_react_main_region_S2(handle);
  101. break;
  102. }
  103. case StatechartLocalReactions_region2_a :
  104. {
  105. statechartLocalReactions_react_region2_a(handle);
  106. break;
  107. }
  108. default:
  109. break;
  110. }
  111. }
  112. statechartLocalReactions_clearInEvents(handle);
  113. }
  114. sc_boolean statechartLocalReactions_isStateActive(const StatechartLocalReactions* handle, StatechartLocalReactionsStates state)
  115. {
  116. sc_boolean result = bool_false;
  117. switch (state)
  118. {
  119. case StatechartLocalReactions_main_region_S1 :
  120. result = (sc_boolean) (handle->stateConfVector[0] == StatechartLocalReactions_main_region_S1
  121. );
  122. break;
  123. case StatechartLocalReactions_main_region_S2 :
  124. result = (sc_boolean) (handle->stateConfVector[0] == StatechartLocalReactions_main_region_S2
  125. );
  126. break;
  127. case StatechartLocalReactions_region2_a :
  128. result = (sc_boolean) (handle->stateConfVector[1] == StatechartLocalReactions_region2_a
  129. );
  130. break;
  131. default:
  132. result = bool_false;
  133. break;
  134. }
  135. return result;
  136. }
  137. sc_integer statechartLocalReactionsIface_get_myInt(const StatechartLocalReactions* handle)
  138. {
  139. return handle->iface.myInt;
  140. }
  141. void statechartLocalReactionsIface_set_myInt(StatechartLocalReactions* handle, sc_integer value)
  142. {
  143. handle->iface.myInt = value;
  144. }
  145. /* implementations of all internal functions */
  146. static sc_boolean statechartLocalReactions_check__lr0(const StatechartLocalReactions* handle)
  147. {
  148. return bool_true;
  149. }
  150. static sc_boolean statechartLocalReactions_check__lr1(const StatechartLocalReactions* handle)
  151. {
  152. return (handle->iface.myInt == 100) ? bool_true : bool_false;
  153. }
  154. static sc_boolean statechartLocalReactions_check_main_region_S1_tr0_tr0(const StatechartLocalReactions* handle)
  155. {
  156. return bool_true;
  157. }
  158. static sc_boolean statechartLocalReactions_check_main_region_S2_tr0_tr0(const StatechartLocalReactions* handle)
  159. {
  160. return bool_true;
  161. }
  162. static void statechartLocalReactions_effect__lr0(StatechartLocalReactions* handle)
  163. {
  164. handle->iface.myInt += 1;
  165. }
  166. static void statechartLocalReactions_effect__lr1(StatechartLocalReactions* handle)
  167. {
  168. handle->iface.myInt = 0;
  169. }
  170. static void statechartLocalReactions_effect_main_region_S1_tr0(StatechartLocalReactions* handle)
  171. {
  172. statechartLocalReactions_exseq_main_region_S1(handle);
  173. statechartLocalReactions_enseq_main_region_S2_default(handle);
  174. }
  175. static void statechartLocalReactions_effect_main_region_S2_tr0(StatechartLocalReactions* handle)
  176. {
  177. statechartLocalReactions_exseq_main_region_S2(handle);
  178. statechartLocalReactions_enseq_main_region_S1_default(handle);
  179. }
  180. /* 'default' enter sequence for state S1 */
  181. static void statechartLocalReactions_enseq_main_region_S1_default(StatechartLocalReactions* handle)
  182. {
  183. /* 'default' enter sequence for state S1 */
  184. handle->stateConfVector[0] = StatechartLocalReactions_main_region_S1;
  185. handle->stateConfVectorPosition = 0;
  186. }
  187. /* 'default' enter sequence for state S2 */
  188. static void statechartLocalReactions_enseq_main_region_S2_default(StatechartLocalReactions* handle)
  189. {
  190. /* 'default' enter sequence for state S2 */
  191. handle->stateConfVector[0] = StatechartLocalReactions_main_region_S2;
  192. handle->stateConfVectorPosition = 0;
  193. }
  194. /* 'default' enter sequence for state a */
  195. static void statechartLocalReactions_enseq_region2_a_default(StatechartLocalReactions* handle)
  196. {
  197. /* 'default' enter sequence for state a */
  198. handle->stateConfVector[1] = StatechartLocalReactions_region2_a;
  199. handle->stateConfVectorPosition = 1;
  200. }
  201. /* 'default' enter sequence for region main region */
  202. static void statechartLocalReactions_enseq_main_region_default(StatechartLocalReactions* handle)
  203. {
  204. /* 'default' enter sequence for region main region */
  205. statechartLocalReactions_react_main_region__entry_Default(handle);
  206. }
  207. /* 'default' enter sequence for region region2 */
  208. static void statechartLocalReactions_enseq_region2_default(StatechartLocalReactions* handle)
  209. {
  210. /* 'default' enter sequence for region region2 */
  211. statechartLocalReactions_react_region2__entry_Default(handle);
  212. }
  213. /* Default exit sequence for state S1 */
  214. static void statechartLocalReactions_exseq_main_region_S1(StatechartLocalReactions* handle)
  215. {
  216. /* Default exit sequence for state S1 */
  217. handle->stateConfVector[0] = StatechartLocalReactions_last_state;
  218. handle->stateConfVectorPosition = 0;
  219. }
  220. /* Default exit sequence for state S2 */
  221. static void statechartLocalReactions_exseq_main_region_S2(StatechartLocalReactions* handle)
  222. {
  223. /* Default exit sequence for state S2 */
  224. handle->stateConfVector[0] = StatechartLocalReactions_last_state;
  225. handle->stateConfVectorPosition = 0;
  226. }
  227. /* Default exit sequence for state a */
  228. static void statechartLocalReactions_exseq_region2_a(StatechartLocalReactions* handle)
  229. {
  230. /* Default exit sequence for state a */
  231. handle->stateConfVector[1] = StatechartLocalReactions_last_state;
  232. handle->stateConfVectorPosition = 1;
  233. }
  234. /* Default exit sequence for region main region */
  235. static void statechartLocalReactions_exseq_main_region(StatechartLocalReactions* handle)
  236. {
  237. /* Default exit sequence for region main region */
  238. /* Handle exit of all possible states (of StatechartLocalReactions.main_region) at position 0... */
  239. switch(handle->stateConfVector[ 0 ])
  240. {
  241. case StatechartLocalReactions_main_region_S1 :
  242. {
  243. statechartLocalReactions_exseq_main_region_S1(handle);
  244. break;
  245. }
  246. case StatechartLocalReactions_main_region_S2 :
  247. {
  248. statechartLocalReactions_exseq_main_region_S2(handle);
  249. break;
  250. }
  251. default: break;
  252. }
  253. }
  254. /* Default exit sequence for region region2 */
  255. static void statechartLocalReactions_exseq_region2(StatechartLocalReactions* handle)
  256. {
  257. /* Default exit sequence for region region2 */
  258. /* Handle exit of all possible states (of StatechartLocalReactions.region2) at position 1... */
  259. switch(handle->stateConfVector[ 1 ])
  260. {
  261. case StatechartLocalReactions_region2_a :
  262. {
  263. statechartLocalReactions_exseq_region2_a(handle);
  264. break;
  265. }
  266. default: break;
  267. }
  268. }
  269. /* The reactions of state S1. */
  270. static void statechartLocalReactions_react_main_region_S1(StatechartLocalReactions* handle)
  271. {
  272. /* The reactions of state S1. */
  273. statechartLocalReactions_effect__lr0(handle);
  274. if (statechartLocalReactions_check__lr1(handle) == bool_true)
  275. {
  276. statechartLocalReactions_effect__lr1(handle);
  277. }
  278. statechartLocalReactions_effect_main_region_S1_tr0(handle);
  279. }
  280. /* The reactions of state S2. */
  281. static void statechartLocalReactions_react_main_region_S2(StatechartLocalReactions* handle)
  282. {
  283. /* The reactions of state S2. */
  284. statechartLocalReactions_effect__lr0(handle);
  285. if (statechartLocalReactions_check__lr1(handle) == bool_true)
  286. {
  287. statechartLocalReactions_effect__lr1(handle);
  288. }
  289. statechartLocalReactions_effect_main_region_S2_tr0(handle);
  290. }
  291. /* The reactions of state a. */
  292. static void statechartLocalReactions_react_region2_a(StatechartLocalReactions* handle)
  293. {
  294. }
  295. /* Default react sequence for initial entry */
  296. static void statechartLocalReactions_react_main_region__entry_Default(StatechartLocalReactions* handle)
  297. {
  298. /* Default react sequence for initial entry */
  299. statechartLocalReactions_enseq_main_region_S1_default(handle);
  300. }
  301. /* Default react sequence for initial entry */
  302. static void statechartLocalReactions_react_region2__entry_Default(StatechartLocalReactions* handle)
  303. {
  304. /* Default react sequence for initial entry */
  305. statechartLocalReactions_enseq_region2_a_default(handle);
  306. }