StatechartKeywords.c 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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;
  59. if (handle->stateConfVector[0] != StatechartKeywords_last_state)
  60. {
  61. result = bool_true;
  62. }
  63. else
  64. {
  65. result = bool_false;
  66. }
  67. return result;
  68. }
  69. /*
  70. * Always returns 'false' since this state machine can never become final.
  71. */
  72. sc_boolean statechartKeywords_isFinal(const StatechartKeywords* handle)
  73. {
  74. return bool_false;
  75. }
  76. static void statechartKeywords_clearInEvents(StatechartKeywords* handle)
  77. {
  78. handle->internal.operationCallback_raised = bool_false;
  79. handle->internal.listeners_raised = bool_false;
  80. handle->timeEvents.statechartKeywords_tev0_raised = bool_false;
  81. }
  82. static void statechartKeywords_clearOutEvents(StatechartKeywords* handle)
  83. {
  84. handle->ifaceIf.operationCallback_raised = bool_false;
  85. handle->ifaceIf.listeners_raised = bool_false;
  86. }
  87. void statechartKeywords_runCycle(StatechartKeywords* handle)
  88. {
  89. statechartKeywords_clearOutEvents(handle);
  90. for (handle->stateConfVectorPosition = 0;
  91. handle->stateConfVectorPosition < STATECHARTKEYWORDS_MAX_ORTHOGONAL_STATES;
  92. handle->stateConfVectorPosition++)
  93. {
  94. switch (handle->stateConfVector[handle->stateConfVectorPosition])
  95. {
  96. case StatechartKeywords_main_region_Timer :
  97. {
  98. statechartKeywords_react_main_region_Timer(handle);
  99. break;
  100. }
  101. default:
  102. break;
  103. }
  104. }
  105. statechartKeywords_clearInEvents(handle);
  106. }
  107. void statechartKeywords_raiseTimeEvent(const StatechartKeywords* handle, sc_eventid evid)
  108. {
  109. if ( ((sc_intptr_t)evid) >= ((sc_intptr_t)&(handle->timeEvents))
  110. && ((sc_intptr_t)evid) < ((sc_intptr_t)&(handle->timeEvents)) + sizeof(StatechartKeywordsTimeEvents))
  111. {
  112. *(sc_boolean*)evid = bool_true;
  113. }
  114. }
  115. sc_boolean statechartKeywords_isStateActive(const StatechartKeywords* handle, StatechartKeywordsStates state)
  116. {
  117. sc_boolean result = bool_false;
  118. switch (state)
  119. {
  120. case StatechartKeywords_main_region_Timer :
  121. result = (sc_boolean) (handle->stateConfVector[0] == StatechartKeywords_main_region_Timer
  122. );
  123. break;
  124. default:
  125. result = bool_false;
  126. break;
  127. }
  128. return result;
  129. }
  130. sc_boolean statechartKeywordsIfaceIf_israised_operationCallback(const StatechartKeywords* handle)
  131. {
  132. return handle->ifaceIf.operationCallback_raised;
  133. }
  134. sc_boolean statechartKeywordsIfaceIf_israised_listeners(const StatechartKeywords* handle)
  135. {
  136. return handle->ifaceIf.listeners_raised;
  137. }
  138. sc_integer statechartKeywordsIfaceIf_get_timer(const StatechartKeywords* handle)
  139. {
  140. return handle->ifaceIf.timer;
  141. }
  142. void statechartKeywordsIfaceIf_set_timer(StatechartKeywords* handle, sc_integer value)
  143. {
  144. handle->ifaceIf.timer = value;
  145. }
  146. sc_integer statechartKeywordsIfaceIf_get_isActive(const StatechartKeywords* handle)
  147. {
  148. return handle->ifaceIf.isActive;
  149. }
  150. void statechartKeywordsIfaceIf_set_isActive(StatechartKeywords* handle, sc_integer value)
  151. {
  152. handle->ifaceIf.isActive = value;
  153. }
  154. sc_integer statechartKeywordsIfaceIf_get_init(const StatechartKeywords* handle)
  155. {
  156. return handle->ifaceIf.init;
  157. }
  158. void statechartKeywordsIfaceIf_set_init(StatechartKeywords* handle, sc_integer value)
  159. {
  160. handle->ifaceIf.init = value;
  161. }
  162. sc_integer statechartKeywordsIfaceIf_get_enter(const StatechartKeywords* handle)
  163. {
  164. return handle->ifaceIf.enter;
  165. }
  166. void statechartKeywordsIfaceIf_set_enter(StatechartKeywords* handle, sc_integer value)
  167. {
  168. handle->ifaceIf.enter = value;
  169. }
  170. sc_integer statechartKeywordsIfaceIf_get_runCycle(const StatechartKeywords* handle)
  171. {
  172. return handle->ifaceIf.runCycle;
  173. }
  174. void statechartKeywordsIfaceIf_set_runCycle(StatechartKeywords* handle, sc_integer value)
  175. {
  176. handle->ifaceIf.runCycle = value;
  177. }
  178. /* implementations of all internal functions */
  179. static sc_boolean statechartKeywords_check__lr0(const StatechartKeywords* handle)
  180. {
  181. return handle->timeEvents.statechartKeywords_tev0_raised;
  182. }
  183. static void statechartKeywords_effect__lr0(StatechartKeywords* handle)
  184. {
  185. handle->internal.timer += 1;
  186. }
  187. /* Entry action for statechart 'StatechartKeywords'. */
  188. static void statechartKeywords_enact(StatechartKeywords* handle)
  189. {
  190. /* Entry action for statechart 'StatechartKeywords'. */
  191. statechartKeywords_setTimer(handle, (sc_eventid) &(handle->timeEvents.statechartKeywords_tev0_raised) , 1 * 1000, bool_true);
  192. }
  193. /* Exit action for state 'StatechartKeywords'. */
  194. static void statechartKeywords_exact(StatechartKeywords* handle)
  195. {
  196. /* Exit action for state 'StatechartKeywords'. */
  197. statechartKeywords_unsetTimer(handle, (sc_eventid) &(handle->timeEvents.statechartKeywords_tev0_raised) );
  198. }
  199. /* 'default' enter sequence for state Timer */
  200. static void statechartKeywords_enseq_main_region_Timer_default(StatechartKeywords* handle)
  201. {
  202. /* 'default' enter sequence for state Timer */
  203. handle->stateConfVector[0] = StatechartKeywords_main_region_Timer;
  204. handle->stateConfVectorPosition = 0;
  205. }
  206. /* 'default' enter sequence for region main region */
  207. static void statechartKeywords_enseq_main_region_default(StatechartKeywords* handle)
  208. {
  209. /* 'default' enter sequence for region main region */
  210. statechartKeywords_react_main_region__entry_Default(handle);
  211. }
  212. /* Default exit sequence for state Timer */
  213. static void statechartKeywords_exseq_main_region_Timer(StatechartKeywords* handle)
  214. {
  215. /* Default exit sequence for state Timer */
  216. handle->stateConfVector[0] = StatechartKeywords_last_state;
  217. handle->stateConfVectorPosition = 0;
  218. }
  219. /* Default exit sequence for region main region */
  220. static void statechartKeywords_exseq_main_region(StatechartKeywords* handle)
  221. {
  222. /* Default exit sequence for region main region */
  223. /* Handle exit of all possible states (of StatechartKeywords.main_region) at position 0... */
  224. switch(handle->stateConfVector[ 0 ])
  225. {
  226. case StatechartKeywords_main_region_Timer :
  227. {
  228. statechartKeywords_exseq_main_region_Timer(handle);
  229. break;
  230. }
  231. default: break;
  232. }
  233. }
  234. /* The reactions of state Timer. */
  235. static void statechartKeywords_react_main_region_Timer(StatechartKeywords* handle)
  236. {
  237. /* The reactions of state Timer. */
  238. if (statechartKeywords_check__lr0(handle) == bool_true)
  239. {
  240. statechartKeywords_effect__lr0(handle);
  241. }
  242. }
  243. /* Default react sequence for initial entry */
  244. static void statechartKeywords_react_main_region__entry_Default(StatechartKeywords* handle)
  245. {
  246. /* Default react sequence for initial entry */
  247. statechartKeywords_enseq_main_region_Timer_default(handle);
  248. }