StateIsActive.c 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include "sc_types.h"
  4. #include "StateIsActive.h"
  5. /*! \file Implementation of the state machine 'StateIsActive'
  6. */
  7. /* prototypes of all internal functions */
  8. static sc_boolean stateIsActive_check_R1_R1A_tr0_tr0(const StateIsActive* handle);
  9. static sc_boolean stateIsActive_check_R2_R2A_tr0_tr0(const StateIsActive* handle);
  10. static void stateIsActive_effect_R1_R1A_tr0(StateIsActive* handle);
  11. static void stateIsActive_effect_R2_R2A_tr0(StateIsActive* handle);
  12. static void stateIsActive_enseq_R1_R1A_default(StateIsActive* handle);
  13. static void stateIsActive_enseq_R1_R1B_default(StateIsActive* handle);
  14. static void stateIsActive_enseq_R2_R2A_default(StateIsActive* handle);
  15. static void stateIsActive_enseq_R2_R2B_default(StateIsActive* handle);
  16. static void stateIsActive_enseq_R1_default(StateIsActive* handle);
  17. static void stateIsActive_enseq_R2_default(StateIsActive* handle);
  18. static void stateIsActive_exseq_R1_R1A(StateIsActive* handle);
  19. static void stateIsActive_exseq_R1_R1B(StateIsActive* handle);
  20. static void stateIsActive_exseq_R2_R2A(StateIsActive* handle);
  21. static void stateIsActive_exseq_R2_R2B(StateIsActive* handle);
  22. static void stateIsActive_exseq_R1(StateIsActive* handle);
  23. static void stateIsActive_exseq_R2(StateIsActive* handle);
  24. static void stateIsActive_react_R1_R1A(StateIsActive* handle);
  25. static void stateIsActive_react_R1_R1B(StateIsActive* handle);
  26. static void stateIsActive_react_R2_R2A(StateIsActive* handle);
  27. static void stateIsActive_react_R2_R2B(StateIsActive* handle);
  28. static void stateIsActive_react_R1__entry_Default(StateIsActive* handle);
  29. static void stateIsActive_react_R2__entry_Default(StateIsActive* handle);
  30. static void stateIsActive_clearInEvents(StateIsActive* handle);
  31. static void stateIsActive_clearOutEvents(StateIsActive* handle);
  32. void stateIsActive_init(StateIsActive* handle)
  33. {
  34. sc_integer i;
  35. for (i = 0; i < STATEISACTIVE_MAX_ORTHOGONAL_STATES; ++i)
  36. {
  37. handle->stateConfVector[i] = StateIsActive_last_state;
  38. }
  39. handle->stateConfVectorPosition = 0;
  40. stateIsActive_clearInEvents(handle);
  41. stateIsActive_clearOutEvents(handle);
  42. }
  43. void stateIsActive_enter(StateIsActive* handle)
  44. {
  45. /* Default enter sequence for statechart StateIsActive */
  46. stateIsActive_enseq_R1_default(handle);
  47. stateIsActive_enseq_R2_default(handle);
  48. }
  49. void stateIsActive_exit(StateIsActive* handle)
  50. {
  51. /* Default exit sequence for statechart StateIsActive */
  52. stateIsActive_exseq_R1(handle);
  53. stateIsActive_exseq_R2(handle);
  54. }
  55. sc_boolean stateIsActive_isActive(const StateIsActive* handle)
  56. {
  57. sc_boolean result = bool_false;
  58. int i;
  59. for(i = 0; i < STATEISACTIVE_MAX_ORTHOGONAL_STATES; i++)
  60. {
  61. result = result || handle->stateConfVector[i] != StateIsActive_last_state;
  62. }
  63. return result;
  64. }
  65. /*
  66. * Always returns 'false' since this state machine can never become final.
  67. */
  68. sc_boolean stateIsActive_isFinal(const StateIsActive* handle)
  69. {
  70. return bool_false;
  71. }
  72. static void stateIsActive_clearInEvents(StateIsActive* handle)
  73. {
  74. handle->iface.Event1_raised = bool_false;
  75. }
  76. static void stateIsActive_clearOutEvents(StateIsActive* handle)
  77. {
  78. }
  79. void stateIsActive_runCycle(StateIsActive* handle)
  80. {
  81. stateIsActive_clearOutEvents(handle);
  82. for (handle->stateConfVectorPosition = 0;
  83. handle->stateConfVectorPosition < STATEISACTIVE_MAX_ORTHOGONAL_STATES;
  84. handle->stateConfVectorPosition++)
  85. {
  86. switch (handle->stateConfVector[handle->stateConfVectorPosition])
  87. {
  88. case StateIsActive_R1_R1A :
  89. {
  90. stateIsActive_react_R1_R1A(handle);
  91. break;
  92. }
  93. case StateIsActive_R1_R1B :
  94. {
  95. stateIsActive_react_R1_R1B(handle);
  96. break;
  97. }
  98. case StateIsActive_R2_R2A :
  99. {
  100. stateIsActive_react_R2_R2A(handle);
  101. break;
  102. }
  103. case StateIsActive_R2_R2B :
  104. {
  105. stateIsActive_react_R2_R2B(handle);
  106. break;
  107. }
  108. default:
  109. break;
  110. }
  111. }
  112. stateIsActive_clearInEvents(handle);
  113. }
  114. sc_boolean stateIsActive_isStateActive(const StateIsActive* handle, StateIsActiveStates state)
  115. {
  116. sc_boolean result = bool_false;
  117. switch (state)
  118. {
  119. case StateIsActive_R1_R1A :
  120. result = (sc_boolean) (handle->stateConfVector[SCVI_STATEISACTIVE_R1_R1A] == StateIsActive_R1_R1A
  121. );
  122. break;
  123. case StateIsActive_R1_R1B :
  124. result = (sc_boolean) (handle->stateConfVector[SCVI_STATEISACTIVE_R1_R1B] == StateIsActive_R1_R1B
  125. );
  126. break;
  127. case StateIsActive_R2_R2A :
  128. result = (sc_boolean) (handle->stateConfVector[SCVI_STATEISACTIVE_R2_R2A] == StateIsActive_R2_R2A
  129. );
  130. break;
  131. case StateIsActive_R2_R2B :
  132. result = (sc_boolean) (handle->stateConfVector[SCVI_STATEISACTIVE_R2_R2B] == StateIsActive_R2_R2B
  133. );
  134. break;
  135. default:
  136. result = bool_false;
  137. break;
  138. }
  139. return result;
  140. }
  141. void stateIsActiveIface_raise_event1(StateIsActive* handle)
  142. {
  143. handle->iface.Event1_raised = bool_true;
  144. }
  145. /* implementations of all internal functions */
  146. static sc_boolean stateIsActive_check_R1_R1A_tr0_tr0(const StateIsActive* handle)
  147. {
  148. return stateIsActive_isStateActive(handle, StateIsActive_R2_R2B);
  149. }
  150. static sc_boolean stateIsActive_check_R2_R2A_tr0_tr0(const StateIsActive* handle)
  151. {
  152. return handle->iface.Event1_raised;
  153. }
  154. static void stateIsActive_effect_R1_R1A_tr0(StateIsActive* handle)
  155. {
  156. stateIsActive_exseq_R1_R1A(handle);
  157. stateIsActive_enseq_R1_R1B_default(handle);
  158. }
  159. static void stateIsActive_effect_R2_R2A_tr0(StateIsActive* handle)
  160. {
  161. stateIsActive_exseq_R2_R2A(handle);
  162. stateIsActive_enseq_R2_R2B_default(handle);
  163. }
  164. /* 'default' enter sequence for state R1A */
  165. static void stateIsActive_enseq_R1_R1A_default(StateIsActive* handle)
  166. {
  167. /* 'default' enter sequence for state R1A */
  168. handle->stateConfVector[0] = StateIsActive_R1_R1A;
  169. handle->stateConfVectorPosition = 0;
  170. }
  171. /* 'default' enter sequence for state R1B */
  172. static void stateIsActive_enseq_R1_R1B_default(StateIsActive* handle)
  173. {
  174. /* 'default' enter sequence for state R1B */
  175. handle->stateConfVector[0] = StateIsActive_R1_R1B;
  176. handle->stateConfVectorPosition = 0;
  177. }
  178. /* 'default' enter sequence for state R2A */
  179. static void stateIsActive_enseq_R2_R2A_default(StateIsActive* handle)
  180. {
  181. /* 'default' enter sequence for state R2A */
  182. handle->stateConfVector[1] = StateIsActive_R2_R2A;
  183. handle->stateConfVectorPosition = 1;
  184. }
  185. /* 'default' enter sequence for state R2B */
  186. static void stateIsActive_enseq_R2_R2B_default(StateIsActive* handle)
  187. {
  188. /* 'default' enter sequence for state R2B */
  189. handle->stateConfVector[1] = StateIsActive_R2_R2B;
  190. handle->stateConfVectorPosition = 1;
  191. }
  192. /* 'default' enter sequence for region R1 */
  193. static void stateIsActive_enseq_R1_default(StateIsActive* handle)
  194. {
  195. /* 'default' enter sequence for region R1 */
  196. stateIsActive_react_R1__entry_Default(handle);
  197. }
  198. /* 'default' enter sequence for region R2 */
  199. static void stateIsActive_enseq_R2_default(StateIsActive* handle)
  200. {
  201. /* 'default' enter sequence for region R2 */
  202. stateIsActive_react_R2__entry_Default(handle);
  203. }
  204. /* Default exit sequence for state R1A */
  205. static void stateIsActive_exseq_R1_R1A(StateIsActive* handle)
  206. {
  207. /* Default exit sequence for state R1A */
  208. handle->stateConfVector[0] = StateIsActive_last_state;
  209. handle->stateConfVectorPosition = 0;
  210. }
  211. /* Default exit sequence for state R1B */
  212. static void stateIsActive_exseq_R1_R1B(StateIsActive* handle)
  213. {
  214. /* Default exit sequence for state R1B */
  215. handle->stateConfVector[0] = StateIsActive_last_state;
  216. handle->stateConfVectorPosition = 0;
  217. }
  218. /* Default exit sequence for state R2A */
  219. static void stateIsActive_exseq_R2_R2A(StateIsActive* handle)
  220. {
  221. /* Default exit sequence for state R2A */
  222. handle->stateConfVector[1] = StateIsActive_last_state;
  223. handle->stateConfVectorPosition = 1;
  224. }
  225. /* Default exit sequence for state R2B */
  226. static void stateIsActive_exseq_R2_R2B(StateIsActive* handle)
  227. {
  228. /* Default exit sequence for state R2B */
  229. handle->stateConfVector[1] = StateIsActive_last_state;
  230. handle->stateConfVectorPosition = 1;
  231. }
  232. /* Default exit sequence for region R1 */
  233. static void stateIsActive_exseq_R1(StateIsActive* handle)
  234. {
  235. /* Default exit sequence for region R1 */
  236. /* Handle exit of all possible states (of StateIsActive.R1) at position 0... */
  237. switch(handle->stateConfVector[ 0 ])
  238. {
  239. case StateIsActive_R1_R1A :
  240. {
  241. stateIsActive_exseq_R1_R1A(handle);
  242. break;
  243. }
  244. case StateIsActive_R1_R1B :
  245. {
  246. stateIsActive_exseq_R1_R1B(handle);
  247. break;
  248. }
  249. default: break;
  250. }
  251. }
  252. /* Default exit sequence for region R2 */
  253. static void stateIsActive_exseq_R2(StateIsActive* handle)
  254. {
  255. /* Default exit sequence for region R2 */
  256. /* Handle exit of all possible states (of StateIsActive.R2) at position 1... */
  257. switch(handle->stateConfVector[ 1 ])
  258. {
  259. case StateIsActive_R2_R2A :
  260. {
  261. stateIsActive_exseq_R2_R2A(handle);
  262. break;
  263. }
  264. case StateIsActive_R2_R2B :
  265. {
  266. stateIsActive_exseq_R2_R2B(handle);
  267. break;
  268. }
  269. default: break;
  270. }
  271. }
  272. /* The reactions of state R1A. */
  273. static void stateIsActive_react_R1_R1A(StateIsActive* handle)
  274. {
  275. /* The reactions of state R1A. */
  276. if (stateIsActive_check_R1_R1A_tr0_tr0(handle) == bool_true)
  277. {
  278. stateIsActive_effect_R1_R1A_tr0(handle);
  279. }
  280. }
  281. /* The reactions of state R1B. */
  282. static void stateIsActive_react_R1_R1B(StateIsActive* handle)
  283. {
  284. /* The reactions of state R1B. */
  285. }
  286. /* The reactions of state R2A. */
  287. static void stateIsActive_react_R2_R2A(StateIsActive* handle)
  288. {
  289. /* The reactions of state R2A. */
  290. if (stateIsActive_check_R2_R2A_tr0_tr0(handle) == bool_true)
  291. {
  292. stateIsActive_effect_R2_R2A_tr0(handle);
  293. }
  294. }
  295. /* The reactions of state R2B. */
  296. static void stateIsActive_react_R2_R2B(StateIsActive* handle)
  297. {
  298. }
  299. /* Default react sequence for initial entry */
  300. static void stateIsActive_react_R1__entry_Default(StateIsActive* handle)
  301. {
  302. /* Default react sequence for initial entry */
  303. stateIsActive_enseq_R1_R1A_default(handle);
  304. }
  305. /* Default react sequence for initial entry */
  306. static void stateIsActive_react_R2__entry_Default(StateIsActive* handle)
  307. {
  308. /* Default react sequence for initial entry */
  309. stateIsActive_enseq_R2_R2A_default(handle);
  310. }