StatechartKeywords.c 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include "sc_types.h"
  4. #include "StatechartKeywords.h"
  5. #include "StatechartKeywordsRequired.h"
  6. /*! \file Implementation of the state machine 'StatechartKeywords'
  7. */
  8. /* prototypes of all internal functions */
  9. static sc_boolean statechartKeywords_check__lr0(const StatechartKeywords* handle);
  10. static void statechartKeywords_effect__lr0(StatechartKeywords* handle);
  11. static void statechartKeywords_enact(StatechartKeywords* handle);
  12. static void statechartKeywords_exact(StatechartKeywords* handle);
  13. static void statechartKeywords_enseq_main_region_Timer_default(StatechartKeywords* handle);
  14. static void statechartKeywords_enseq_main_region_default(StatechartKeywords* handle);
  15. static void statechartKeywords_exseq_main_region_Timer(StatechartKeywords* handle);
  16. static void statechartKeywords_exseq_main_region(StatechartKeywords* handle);
  17. static void statechartKeywords_react_main_region_Timer(StatechartKeywords* handle);
  18. static void statechartKeywords_react_main_region__entry_Default(StatechartKeywords* handle);
  19. static void statechartKeywords_clearInEvents(StatechartKeywords* handle);
  20. static void statechartKeywords_clearOutEvents(StatechartKeywords* handle);
  21. void statechartKeywords_init(StatechartKeywords* handle)
  22. {
  23. sc_integer i;
  24. for (i = 0; i < STATECHARTKEYWORDS_MAX_ORTHOGONAL_STATES; ++i)
  25. {
  26. handle->stateConfVector[i] = StatechartKeywords_last_state;
  27. }
  28. handle->stateConfVectorPosition = 0;
  29. statechartKeywords_clearInEvents(handle);
  30. statechartKeywords_clearOutEvents(handle);
  31. /* Default init sequence for statechart StatechartKeywords */
  32. handle->ifaceIf.timer = 0;
  33. handle->ifaceIf.isActive = 0;
  34. handle->ifaceIf.init = 0;
  35. handle->ifaceIf.enter = 0;
  36. handle->ifaceIf.runCycle = 0;
  37. handle->internal.timer = 0;
  38. handle->internal.isActive = 0;
  39. handle->internal.init = 0;
  40. handle->internal.enter = 0;
  41. handle->internal.runCycle = 0;
  42. handle->internal.sCIIf = 0;
  43. }
  44. void statechartKeywords_enter(StatechartKeywords* handle)
  45. {
  46. /* Default enter sequence for statechart StatechartKeywords */
  47. statechartKeywords_enact(handle);
  48. statechartKeywords_enseq_main_region_default(handle);
  49. }
  50. void statechartKeywords_exit(StatechartKeywords* handle)
  51. {
  52. /* Default exit sequence for statechart StatechartKeywords */
  53. statechartKeywords_exseq_main_region(handle);
  54. statechartKeywords_exact(handle);
  55. }
  56. sc_boolean statechartKeywords_isActive(const StatechartKeywords* handle)
  57. {
  58. sc_boolean result = bool_false;
  59. int i;
  60. for(i = 0; i < STATECHARTKEYWORDS_MAX_ORTHOGONAL_STATES; i++)
  61. {
  62. result = result || handle->stateConfVector[i] != StatechartKeywords_last_state;
  63. }
  64. return result;
  65. }
  66. /*
  67. * Always returns 'false' since this state machine can never become final.
  68. */
  69. sc_boolean statechartKeywords_isFinal(const StatechartKeywords* handle)
  70. {
  71. return bool_false;
  72. }
  73. static void statechartKeywords_clearInEvents(StatechartKeywords* handle)
  74. {
  75. handle->internal.operationCallback_raised = bool_false;
  76. handle->internal.listeners_raised = bool_false;
  77. handle->timeEvents.statechartKeywords_tev0_raised = bool_false;
  78. }
  79. static void statechartKeywords_clearOutEvents(StatechartKeywords* handle)
  80. {
  81. handle->ifaceIf.operationCallback_raised = bool_false;
  82. handle->ifaceIf.listeners_raised = bool_false;
  83. }
  84. void statechartKeywords_runCycle(StatechartKeywords* handle)
  85. {
  86. statechartKeywords_clearOutEvents(handle);
  87. for (handle->stateConfVectorPosition = 0;
  88. handle->stateConfVectorPosition < STATECHARTKEYWORDS_MAX_ORTHOGONAL_STATES;
  89. handle->stateConfVectorPosition++)
  90. {
  91. switch (handle->stateConfVector[handle->stateConfVectorPosition])
  92. {
  93. case StatechartKeywords_main_region_Timer :
  94. {
  95. statechartKeywords_react_main_region_Timer(handle);
  96. break;
  97. }
  98. default:
  99. break;
  100. }
  101. }
  102. statechartKeywords_clearInEvents(handle);
  103. }
  104. void statechartKeywords_raiseTimeEvent(const StatechartKeywords* handle, sc_eventid evid)
  105. {
  106. if ( ((sc_intptr_t)evid) >= ((sc_intptr_t)&(handle->timeEvents))
  107. && ((sc_intptr_t)evid) < ((sc_intptr_t)&(handle->timeEvents)) + sizeof(StatechartKeywordsTimeEvents))
  108. {
  109. *(sc_boolean*)evid = bool_true;
  110. }
  111. }
  112. sc_boolean statechartKeywords_isStateActive(const StatechartKeywords* handle, StatechartKeywordsStates state)
  113. {
  114. sc_boolean result = bool_false;
  115. switch (state)
  116. {
  117. case StatechartKeywords_main_region_Timer :
  118. result = (sc_boolean) (handle->stateConfVector[SCVI_STATECHARTKEYWORDS_MAIN_REGION_TIMER] == StatechartKeywords_main_region_Timer
  119. );
  120. break;
  121. default:
  122. result = bool_false;
  123. break;
  124. }
  125. return result;
  126. }
  127. sc_boolean statechartKeywordsIfaceIf_israised_operationCallback(const StatechartKeywords* handle)
  128. {
  129. return handle->ifaceIf.operationCallback_raised;
  130. }
  131. sc_boolean statechartKeywordsIfaceIf_israised_listeners(const StatechartKeywords* handle)
  132. {
  133. return handle->ifaceIf.listeners_raised;
  134. }
  135. sc_integer statechartKeywordsIfaceIf_get_timer(const StatechartKeywords* handle)
  136. {
  137. return handle->ifaceIf.timer;
  138. }
  139. void statechartKeywordsIfaceIf_set_timer(StatechartKeywords* handle, sc_integer value)
  140. {
  141. handle->ifaceIf.timer = value;
  142. }
  143. sc_integer statechartKeywordsIfaceIf_get_isActive(const StatechartKeywords* handle)
  144. {
  145. return handle->ifaceIf.isActive;
  146. }
  147. void statechartKeywordsIfaceIf_set_isActive(StatechartKeywords* handle, sc_integer value)
  148. {
  149. handle->ifaceIf.isActive = value;
  150. }
  151. sc_integer statechartKeywordsIfaceIf_get_init(const StatechartKeywords* handle)
  152. {
  153. return handle->ifaceIf.init;
  154. }
  155. void statechartKeywordsIfaceIf_set_init(StatechartKeywords* handle, sc_integer value)
  156. {
  157. handle->ifaceIf.init = value;
  158. }
  159. sc_integer statechartKeywordsIfaceIf_get_enter(const StatechartKeywords* handle)
  160. {
  161. return handle->ifaceIf.enter;
  162. }
  163. void statechartKeywordsIfaceIf_set_enter(StatechartKeywords* handle, sc_integer value)
  164. {
  165. handle->ifaceIf.enter = value;
  166. }
  167. sc_integer statechartKeywordsIfaceIf_get_runCycle(const StatechartKeywords* handle)
  168. {
  169. return handle->ifaceIf.runCycle;
  170. }
  171. void statechartKeywordsIfaceIf_set_runCycle(StatechartKeywords* handle, sc_integer value)
  172. {
  173. handle->ifaceIf.runCycle = value;
  174. }
  175. /* implementations of all internal functions */
  176. static sc_boolean statechartKeywords_check__lr0(const StatechartKeywords* handle)
  177. {
  178. return handle->timeEvents.statechartKeywords_tev0_raised;
  179. }
  180. static void statechartKeywords_effect__lr0(StatechartKeywords* handle)
  181. {
  182. handle->internal.timer += 1;
  183. }
  184. /* Entry action for statechart 'StatechartKeywords'. */
  185. static void statechartKeywords_enact(StatechartKeywords* handle)
  186. {
  187. /* Entry action for statechart 'StatechartKeywords'. */
  188. statechartKeywords_setTimer(handle, (sc_eventid) &(handle->timeEvents.statechartKeywords_tev0_raised) , 1 * 1000, bool_true);
  189. }
  190. /* Exit action for state 'StatechartKeywords'. */
  191. static void statechartKeywords_exact(StatechartKeywords* handle)
  192. {
  193. /* Exit action for state 'StatechartKeywords'. */
  194. statechartKeywords_unsetTimer(handle, (sc_eventid) &(handle->timeEvents.statechartKeywords_tev0_raised) );
  195. }
  196. /* 'default' enter sequence for state Timer */
  197. static void statechartKeywords_enseq_main_region_Timer_default(StatechartKeywords* handle)
  198. {
  199. /* 'default' enter sequence for state Timer */
  200. handle->stateConfVector[0] = StatechartKeywords_main_region_Timer;
  201. handle->stateConfVectorPosition = 0;
  202. }
  203. /* 'default' enter sequence for region main region */
  204. static void statechartKeywords_enseq_main_region_default(StatechartKeywords* handle)
  205. {
  206. /* 'default' enter sequence for region main region */
  207. statechartKeywords_react_main_region__entry_Default(handle);
  208. }
  209. /* Default exit sequence for state Timer */
  210. static void statechartKeywords_exseq_main_region_Timer(StatechartKeywords* handle)
  211. {
  212. /* Default exit sequence for state Timer */
  213. handle->stateConfVector[0] = StatechartKeywords_last_state;
  214. handle->stateConfVectorPosition = 0;
  215. }
  216. /* Default exit sequence for region main region */
  217. static void statechartKeywords_exseq_main_region(StatechartKeywords* handle)
  218. {
  219. /* Default exit sequence for region main region */
  220. /* Handle exit of all possible states (of StatechartKeywords.main_region) at position 0... */
  221. switch(handle->stateConfVector[ 0 ])
  222. {
  223. case StatechartKeywords_main_region_Timer :
  224. {
  225. statechartKeywords_exseq_main_region_Timer(handle);
  226. break;
  227. }
  228. default: break;
  229. }
  230. }
  231. /* The reactions of state Timer. */
  232. static void statechartKeywords_react_main_region_Timer(StatechartKeywords* handle)
  233. {
  234. /* The reactions of state Timer. */
  235. if (statechartKeywords_check__lr0(handle) == bool_true)
  236. {
  237. statechartKeywords_effect__lr0(handle);
  238. }
  239. }
  240. /* Default react sequence for initial entry */
  241. static void statechartKeywords_react_main_region__entry_Default(StatechartKeywords* handle)
  242. {
  243. /* Default react sequence for initial entry */
  244. statechartKeywords_enseq_main_region_Timer_default(handle);
  245. }