Operations.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include "sc_types.h"
  4. #include "Operations.h"
  5. #include "OperationsRequired.h"
  6. /*! \file Implementation of the state machine 'Operations'
  7. */
  8. /* prototypes of all internal functions */
  9. static sc_boolean operations_check_main_region_B_tr0_tr0(const Operations* handle);
  10. static sc_boolean operations_check_main_region_C_tr0_tr0(const Operations* handle);
  11. static sc_boolean operations_check_main_region_A_tr0_tr0(const Operations* handle);
  12. static void operations_effect_main_region_B_tr0(Operations* handle);
  13. static void operations_effect_main_region_C_tr0(Operations* handle);
  14. static void operations_effect_main_region_A_tr0(Operations* handle);
  15. static void operations_enact_main_region_B(Operations* handle);
  16. static void operations_enact_main_region_C(Operations* handle);
  17. static void operations_enact_main_region_D(Operations* handle);
  18. static void operations_enseq_main_region_B_default(Operations* handle);
  19. static void operations_enseq_main_region_C_default(Operations* handle);
  20. static void operations_enseq_main_region_D_default(Operations* handle);
  21. static void operations_enseq_main_region_A_default(Operations* handle);
  22. static void operations_enseq_main_region_default(Operations* handle);
  23. static void operations_exseq_main_region_B(Operations* handle);
  24. static void operations_exseq_main_region_C(Operations* handle);
  25. static void operations_exseq_main_region_D(Operations* handle);
  26. static void operations_exseq_main_region_A(Operations* handle);
  27. static void operations_exseq_main_region(Operations* handle);
  28. static void operations_react_main_region_B(Operations* handle);
  29. static void operations_react_main_region_C(Operations* handle);
  30. static void operations_react_main_region_D(Operations* handle);
  31. static void operations_react_main_region_A(Operations* handle);
  32. static void operations_react_main_region__entry_Default(Operations* handle);
  33. static void operations_clearInEvents(Operations* handle);
  34. static void operations_clearOutEvents(Operations* handle);
  35. void operations_init(Operations* handle)
  36. {
  37. sc_integer i;
  38. for (i = 0; i < OPERATIONS_MAX_ORTHOGONAL_STATES; ++i)
  39. {
  40. handle->stateConfVector[i] = Operations_last_state;
  41. }
  42. handle->stateConfVectorPosition = 0;
  43. operations_clearInEvents(handle);
  44. operations_clearOutEvents(handle);
  45. /* Default init sequence for statechart Operations */
  46. handle->internal.myBool = bool_false;
  47. }
  48. void operations_enter(Operations* handle)
  49. {
  50. /* Default enter sequence for statechart Operations */
  51. operations_enseq_main_region_default(handle);
  52. }
  53. void operations_exit(Operations* handle)
  54. {
  55. /* Default exit sequence for statechart Operations */
  56. operations_exseq_main_region(handle);
  57. }
  58. sc_boolean operations_isActive(const Operations* handle)
  59. {
  60. sc_boolean result;
  61. if (handle->stateConfVector[0] != Operations_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 operations_isFinal(const Operations* handle)
  75. {
  76. return bool_false;
  77. }
  78. static void operations_clearInEvents(Operations* handle)
  79. {
  80. handle->iface.ev_raised = bool_false;
  81. }
  82. static void operations_clearOutEvents(Operations* handle)
  83. {
  84. }
  85. void operations_runCycle(Operations* handle)
  86. {
  87. operations_clearOutEvents(handle);
  88. for (handle->stateConfVectorPosition = 0;
  89. handle->stateConfVectorPosition < OPERATIONS_MAX_ORTHOGONAL_STATES;
  90. handle->stateConfVectorPosition++)
  91. {
  92. switch (handle->stateConfVector[handle->stateConfVectorPosition])
  93. {
  94. case Operations_main_region_B :
  95. {
  96. operations_react_main_region_B(handle);
  97. break;
  98. }
  99. case Operations_main_region_C :
  100. {
  101. operations_react_main_region_C(handle);
  102. break;
  103. }
  104. case Operations_main_region_D :
  105. {
  106. operations_react_main_region_D(handle);
  107. break;
  108. }
  109. case Operations_main_region_A :
  110. {
  111. operations_react_main_region_A(handle);
  112. break;
  113. }
  114. default:
  115. break;
  116. }
  117. }
  118. operations_clearInEvents(handle);
  119. }
  120. sc_boolean operations_isStateActive(const Operations* handle, OperationsStates state)
  121. {
  122. sc_boolean result = bool_false;
  123. switch (state)
  124. {
  125. case Operations_main_region_B :
  126. result = (sc_boolean) (handle->stateConfVector[0] == Operations_main_region_B
  127. );
  128. break;
  129. case Operations_main_region_C :
  130. result = (sc_boolean) (handle->stateConfVector[0] == Operations_main_region_C
  131. );
  132. break;
  133. case Operations_main_region_D :
  134. result = (sc_boolean) (handle->stateConfVector[0] == Operations_main_region_D
  135. );
  136. break;
  137. case Operations_main_region_A :
  138. result = (sc_boolean) (handle->stateConfVector[0] == Operations_main_region_A
  139. );
  140. break;
  141. default:
  142. result = bool_false;
  143. break;
  144. }
  145. return result;
  146. }
  147. void operationsIface_raise_ev(Operations* handle)
  148. {
  149. handle->iface.ev_raised = bool_true;
  150. }
  151. /* implementations of all internal functions */
  152. static sc_boolean operations_check_main_region_B_tr0_tr0(const Operations* handle)
  153. {
  154. return ((handle->iface.ev_raised) && (operationsIface_alwaysTrue(handle))) ? bool_true : bool_false;
  155. }
  156. static sc_boolean operations_check_main_region_C_tr0_tr0(const Operations* handle)
  157. {
  158. return handle->iface.ev_raised;
  159. }
  160. static sc_boolean operations_check_main_region_A_tr0_tr0(const Operations* handle)
  161. {
  162. return bool_true;
  163. }
  164. static void operations_effect_main_region_B_tr0(Operations* handle)
  165. {
  166. operations_exseq_main_region_B(handle);
  167. operations_enseq_main_region_C_default(handle);
  168. }
  169. static void operations_effect_main_region_C_tr0(Operations* handle)
  170. {
  171. operations_exseq_main_region_C(handle);
  172. operations_enseq_main_region_D_default(handle);
  173. }
  174. static void operations_effect_main_region_A_tr0(Operations* handle)
  175. {
  176. operations_exseq_main_region_A(handle);
  177. operations_enseq_main_region_B_default(handle);
  178. }
  179. /* Entry action for state 'B'. */
  180. static void operations_enact_main_region_B(Operations* handle)
  181. {
  182. /* Entry action for state 'B'. */
  183. operationsInternal_internalOperation1(handle);
  184. handle->internal.myBool = operationsInternal_internalOperation2(handle, 4);
  185. operationsInternal_internalOperation3(handle);
  186. operationsInternal_internalOperation3a(handle, 1.0);
  187. operationsInternal_internalOperation4(handle);
  188. operationsInternal_internalOperation4a(handle, 5);
  189. operationsInternal_internalOperation5(handle);
  190. operationsInternal_internalOperation5a(handle, "");
  191. }
  192. /* Entry action for state 'C'. */
  193. static void operations_enact_main_region_C(Operations* handle)
  194. {
  195. /* Entry action for state 'C'. */
  196. operationsIfaceInterface1_interfaceOperation1(handle);
  197. operationsIfaceInterface1_interfaceOperation2(handle, 4);
  198. operationsIfaceInterface1_interfaceOperation3(handle);
  199. operationsIfaceInterface1_interfaceOperation3a(handle, 1.0);
  200. operationsIfaceInterface1_interfaceOperation4(handle);
  201. operationsIfaceInterface1_interfaceOperation4a(handle, 5);
  202. operationsIfaceInterface1_interfaceOperation5(handle);
  203. operationsIfaceInterface1_interfaceOperation5a(handle, "");
  204. }
  205. /* Entry action for state 'D'. */
  206. static void operations_enact_main_region_D(Operations* handle)
  207. {
  208. /* Entry action for state 'D'. */
  209. operationsIface_unnamedInterfaceOperation1(handle);
  210. operationsIface_unnamedInterfaceOperation2(handle, 4);
  211. operationsIface_unnamedOperation3(handle);
  212. operationsIface_unnamedOperation3a(handle, 1.0);
  213. operationsIface_unnamedOperation4(handle);
  214. operationsIface_unnamedOperation4a(handle, 5);
  215. operationsIface_unnamedOperation5(handle);
  216. operationsIface_unnamedOperation5a(handle, "");
  217. }
  218. /* 'default' enter sequence for state B */
  219. static void operations_enseq_main_region_B_default(Operations* handle)
  220. {
  221. /* 'default' enter sequence for state B */
  222. operations_enact_main_region_B(handle);
  223. handle->stateConfVector[0] = Operations_main_region_B;
  224. handle->stateConfVectorPosition = 0;
  225. }
  226. /* 'default' enter sequence for state C */
  227. static void operations_enseq_main_region_C_default(Operations* handle)
  228. {
  229. /* 'default' enter sequence for state C */
  230. operations_enact_main_region_C(handle);
  231. handle->stateConfVector[0] = Operations_main_region_C;
  232. handle->stateConfVectorPosition = 0;
  233. }
  234. /* 'default' enter sequence for state D */
  235. static void operations_enseq_main_region_D_default(Operations* handle)
  236. {
  237. /* 'default' enter sequence for state D */
  238. operations_enact_main_region_D(handle);
  239. handle->stateConfVector[0] = Operations_main_region_D;
  240. handle->stateConfVectorPosition = 0;
  241. }
  242. /* 'default' enter sequence for state A */
  243. static void operations_enseq_main_region_A_default(Operations* handle)
  244. {
  245. /* 'default' enter sequence for state A */
  246. handle->stateConfVector[0] = Operations_main_region_A;
  247. handle->stateConfVectorPosition = 0;
  248. }
  249. /* 'default' enter sequence for region main region */
  250. static void operations_enseq_main_region_default(Operations* handle)
  251. {
  252. /* 'default' enter sequence for region main region */
  253. operations_react_main_region__entry_Default(handle);
  254. }
  255. /* Default exit sequence for state B */
  256. static void operations_exseq_main_region_B(Operations* handle)
  257. {
  258. /* Default exit sequence for state B */
  259. handle->stateConfVector[0] = Operations_last_state;
  260. handle->stateConfVectorPosition = 0;
  261. }
  262. /* Default exit sequence for state C */
  263. static void operations_exseq_main_region_C(Operations* handle)
  264. {
  265. /* Default exit sequence for state C */
  266. handle->stateConfVector[0] = Operations_last_state;
  267. handle->stateConfVectorPosition = 0;
  268. }
  269. /* Default exit sequence for state D */
  270. static void operations_exseq_main_region_D(Operations* handle)
  271. {
  272. /* Default exit sequence for state D */
  273. handle->stateConfVector[0] = Operations_last_state;
  274. handle->stateConfVectorPosition = 0;
  275. }
  276. /* Default exit sequence for state A */
  277. static void operations_exseq_main_region_A(Operations* handle)
  278. {
  279. /* Default exit sequence for state A */
  280. handle->stateConfVector[0] = Operations_last_state;
  281. handle->stateConfVectorPosition = 0;
  282. }
  283. /* Default exit sequence for region main region */
  284. static void operations_exseq_main_region(Operations* handle)
  285. {
  286. /* Default exit sequence for region main region */
  287. /* Handle exit of all possible states (of Operations.main_region) at position 0... */
  288. switch(handle->stateConfVector[ 0 ])
  289. {
  290. case Operations_main_region_B :
  291. {
  292. operations_exseq_main_region_B(handle);
  293. break;
  294. }
  295. case Operations_main_region_C :
  296. {
  297. operations_exseq_main_region_C(handle);
  298. break;
  299. }
  300. case Operations_main_region_D :
  301. {
  302. operations_exseq_main_region_D(handle);
  303. break;
  304. }
  305. case Operations_main_region_A :
  306. {
  307. operations_exseq_main_region_A(handle);
  308. break;
  309. }
  310. default: break;
  311. }
  312. }
  313. /* The reactions of state B. */
  314. static void operations_react_main_region_B(Operations* handle)
  315. {
  316. /* The reactions of state B. */
  317. if (operations_check_main_region_B_tr0_tr0(handle) == bool_true)
  318. {
  319. operations_effect_main_region_B_tr0(handle);
  320. }
  321. }
  322. /* The reactions of state C. */
  323. static void operations_react_main_region_C(Operations* handle)
  324. {
  325. /* The reactions of state C. */
  326. if (operations_check_main_region_C_tr0_tr0(handle) == bool_true)
  327. {
  328. operations_effect_main_region_C_tr0(handle);
  329. }
  330. }
  331. /* The reactions of state D. */
  332. static void operations_react_main_region_D(Operations* handle)
  333. {
  334. /* The reactions of state D. */
  335. }
  336. /* The reactions of state A. */
  337. static void operations_react_main_region_A(Operations* handle)
  338. {
  339. /* The reactions of state A. */
  340. operations_effect_main_region_A_tr0(handle);
  341. }
  342. /* Default react sequence for initial entry */
  343. static void operations_react_main_region__entry_Default(Operations* handle)
  344. {
  345. /* Default react sequence for initial entry */
  346. operations_enseq_main_region_A_default(handle);
  347. }