StaticChoice.cpp 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. #include "StaticChoice.h"
  2. #include <string.h>
  3. /*! \file Implementation of the state machine 'StaticChoice'
  4. */
  5. StaticChoice::StaticChoice()
  6. {
  7. stateConfVectorPosition = 0;
  8. }
  9. StaticChoice::~StaticChoice()
  10. {
  11. }
  12. void StaticChoice::init()
  13. {
  14. for (int i = 0; i < maxOrthogonalStates; ++i)
  15. stateConfVector[i] = StaticChoice_last_state;
  16. stateConfVectorPosition = 0;
  17. clearInEvents();
  18. clearOutEvents();
  19. /* Default init sequence for statechart StaticChoice */
  20. iface.number = 0;
  21. }
  22. void StaticChoice::enter()
  23. {
  24. /* Default enter sequence for statechart StaticChoice */
  25. enseq_main_region_default();
  26. }
  27. void StaticChoice::exit()
  28. {
  29. /* Default exit sequence for statechart StaticChoice */
  30. exseq_main_region();
  31. }
  32. sc_boolean StaticChoice::isActive() const
  33. {
  34. return stateConfVector[0] != StaticChoice_last_state;
  35. }
  36. /*
  37. * Always returns 'false' since this state machine can never become final.
  38. */
  39. sc_boolean StaticChoice::isFinal() const
  40. {
  41. return false;}
  42. void StaticChoice::runCycle()
  43. {
  44. clearOutEvents();
  45. for (stateConfVectorPosition = 0;
  46. stateConfVectorPosition < maxOrthogonalStates;
  47. stateConfVectorPosition++)
  48. {
  49. switch (stateConfVector[stateConfVectorPosition])
  50. {
  51. case main_region_Start :
  52. {
  53. react_main_region_Start();
  54. break;
  55. }
  56. case main_region_B :
  57. {
  58. react_main_region_B();
  59. break;
  60. }
  61. case main_region_A :
  62. {
  63. react_main_region_A();
  64. break;
  65. }
  66. default:
  67. break;
  68. }
  69. }
  70. clearInEvents();
  71. }
  72. void StaticChoice::clearInEvents()
  73. {
  74. iface.reset_raised = false;
  75. }
  76. void StaticChoice::clearOutEvents()
  77. {
  78. }
  79. sc_boolean StaticChoice::isStateActive(StaticChoiceStates state) const
  80. {
  81. switch (state)
  82. {
  83. case main_region_Start :
  84. return (sc_boolean) (stateConfVector[0] == main_region_Start
  85. );
  86. case main_region_B :
  87. return (sc_boolean) (stateConfVector[0] == main_region_B
  88. );
  89. case main_region_A :
  90. return (sc_boolean) (stateConfVector[0] == main_region_A
  91. );
  92. default: return false;
  93. }
  94. }
  95. StaticChoice::DefaultSCI* StaticChoice::getDefaultSCI()
  96. {
  97. return &iface;
  98. }
  99. void StaticChoice::DefaultSCI::raise_reset()
  100. {
  101. reset_raised = true;
  102. }
  103. void StaticChoice::raise_reset()
  104. {
  105. iface.raise_reset();
  106. }
  107. sc_integer StaticChoice::DefaultSCI::get_number() const
  108. {
  109. return number;
  110. }
  111. sc_integer StaticChoice::get_number() const
  112. {
  113. return iface.number;
  114. }
  115. void StaticChoice::DefaultSCI::set_number(sc_integer value)
  116. {
  117. number = value;
  118. }
  119. void StaticChoice::set_number(sc_integer value)
  120. {
  121. iface.number = value;
  122. }
  123. // implementations of all internal functions
  124. sc_boolean StaticChoice::check_main_region_Start_tr0_tr0()
  125. {
  126. return true;
  127. }
  128. sc_boolean StaticChoice::check_main_region__choice_0_tr1_tr1()
  129. {
  130. return iface.number == 2;
  131. }
  132. sc_boolean StaticChoice::check_main_region__choice_0_tr0()
  133. {
  134. return true;
  135. }
  136. void StaticChoice::effect_main_region_Start_tr0()
  137. {
  138. exseq_main_region_Start();
  139. iface.number += 1;
  140. react_main_region__choice_0();
  141. }
  142. void StaticChoice::effect_main_region__choice_0_tr1()
  143. {
  144. enseq_main_region_A_default();
  145. }
  146. void StaticChoice::effect_main_region__choice_0_tr0()
  147. {
  148. enseq_main_region_B_default();
  149. }
  150. /* Entry action for state 'Start'. */
  151. void StaticChoice::enact_main_region_Start()
  152. {
  153. /* Entry action for state 'Start'. */
  154. iface.number = 1;
  155. }
  156. /* 'default' enter sequence for state Start */
  157. void StaticChoice::enseq_main_region_Start_default()
  158. {
  159. /* 'default' enter sequence for state Start */
  160. enact_main_region_Start();
  161. stateConfVector[0] = main_region_Start;
  162. stateConfVectorPosition = 0;
  163. }
  164. /* 'default' enter sequence for state B */
  165. void StaticChoice::enseq_main_region_B_default()
  166. {
  167. /* 'default' enter sequence for state B */
  168. stateConfVector[0] = main_region_B;
  169. stateConfVectorPosition = 0;
  170. }
  171. /* 'default' enter sequence for state A */
  172. void StaticChoice::enseq_main_region_A_default()
  173. {
  174. /* 'default' enter sequence for state A */
  175. stateConfVector[0] = main_region_A;
  176. stateConfVectorPosition = 0;
  177. }
  178. /* 'default' enter sequence for region main region */
  179. void StaticChoice::enseq_main_region_default()
  180. {
  181. /* 'default' enter sequence for region main region */
  182. react_main_region__entry_Default();
  183. }
  184. /* Default exit sequence for state Start */
  185. void StaticChoice::exseq_main_region_Start()
  186. {
  187. /* Default exit sequence for state Start */
  188. stateConfVector[0] = StaticChoice_last_state;
  189. stateConfVectorPosition = 0;
  190. }
  191. /* Default exit sequence for state B */
  192. void StaticChoice::exseq_main_region_B()
  193. {
  194. /* Default exit sequence for state B */
  195. stateConfVector[0] = StaticChoice_last_state;
  196. stateConfVectorPosition = 0;
  197. }
  198. /* Default exit sequence for state A */
  199. void StaticChoice::exseq_main_region_A()
  200. {
  201. /* Default exit sequence for state A */
  202. stateConfVector[0] = StaticChoice_last_state;
  203. stateConfVectorPosition = 0;
  204. }
  205. /* Default exit sequence for region main region */
  206. void StaticChoice::exseq_main_region()
  207. {
  208. /* Default exit sequence for region main region */
  209. /* Handle exit of all possible states (of StaticChoice.main_region) at position 0... */
  210. switch(stateConfVector[ 0 ])
  211. {
  212. case main_region_Start :
  213. {
  214. exseq_main_region_Start();
  215. break;
  216. }
  217. case main_region_B :
  218. {
  219. exseq_main_region_B();
  220. break;
  221. }
  222. case main_region_A :
  223. {
  224. exseq_main_region_A();
  225. break;
  226. }
  227. default: break;
  228. }
  229. }
  230. /* The reactions of state Start. */
  231. void StaticChoice::react_main_region_Start()
  232. {
  233. /* The reactions of state Start. */
  234. effect_main_region_Start_tr0();
  235. }
  236. /* The reactions of state B. */
  237. void StaticChoice::react_main_region_B()
  238. {
  239. /* The reactions of state B. */
  240. }
  241. /* The reactions of state A. */
  242. void StaticChoice::react_main_region_A()
  243. {
  244. /* The reactions of state A. */
  245. }
  246. /* The reactions of state null. */
  247. void StaticChoice::react_main_region__choice_0()
  248. {
  249. /* The reactions of state null. */
  250. if (check_main_region__choice_0_tr1_tr1())
  251. {
  252. effect_main_region__choice_0_tr1();
  253. } else
  254. {
  255. effect_main_region__choice_0_tr0();
  256. }
  257. }
  258. /* Default react sequence for initial entry */
  259. void StaticChoice::react_main_region__entry_Default()
  260. {
  261. /* Default react sequence for initial entry */
  262. enseq_main_region_Start_default();
  263. }