ReadOnlyVariable.cpp 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. #include "ReadOnlyVariable.h"
  2. #include <string.h>
  3. /*! \file Implementation of the state machine 'ReadOnlyVariable'
  4. */
  5. ReadOnlyVariable::ReadOnlyVariable()
  6. {
  7. stateConfVectorPosition = 0;
  8. }
  9. ReadOnlyVariable::~ReadOnlyVariable()
  10. {
  11. }
  12. void ReadOnlyVariable::init()
  13. {
  14. for (int i = 0; i < maxOrthogonalStates; ++i)
  15. stateConfVector[i] = ReadOnlyVariable_last_state;
  16. stateConfVectorPosition = 0;
  17. clearInEvents();
  18. clearOutEvents();
  19. /* Default init sequence for statechart ReadOnlyVariable */
  20. iface.myInt = 0;
  21. iface.myString = "testString";
  22. iface.myBool = true;
  23. iface.myReal = 1.1;
  24. ifaceA.myInt = 0;
  25. ifaceA.myString = "testString";
  26. ifaceA.myBool = true;
  27. ifaceA.myReal = 1.1;
  28. }
  29. void ReadOnlyVariable::enter()
  30. {
  31. /* Default enter sequence for statechart ReadOnlyVariable */
  32. enseq_main_region_default();
  33. }
  34. void ReadOnlyVariable::exit()
  35. {
  36. /* Default exit sequence for statechart ReadOnlyVariable */
  37. exseq_main_region();
  38. }
  39. sc_boolean ReadOnlyVariable::isActive() const
  40. {
  41. return stateConfVector[0] != ReadOnlyVariable_last_state;
  42. }
  43. /*
  44. * Always returns 'false' since this state machine can never become final.
  45. */
  46. sc_boolean ReadOnlyVariable::isFinal() const
  47. {
  48. return false;}
  49. void ReadOnlyVariable::runCycle()
  50. {
  51. clearOutEvents();
  52. for (stateConfVectorPosition = 0;
  53. stateConfVectorPosition < maxOrthogonalStates;
  54. stateConfVectorPosition++)
  55. {
  56. switch (stateConfVector[stateConfVectorPosition])
  57. {
  58. case main_region_StateB :
  59. {
  60. react_main_region_StateB();
  61. break;
  62. }
  63. case main_region_StateA :
  64. {
  65. react_main_region_StateA();
  66. break;
  67. }
  68. default:
  69. break;
  70. }
  71. }
  72. clearInEvents();
  73. }
  74. void ReadOnlyVariable::clearInEvents()
  75. {
  76. }
  77. void ReadOnlyVariable::clearOutEvents()
  78. {
  79. }
  80. sc_boolean ReadOnlyVariable::isStateActive(ReadOnlyVariableStates state) const
  81. {
  82. switch (state)
  83. {
  84. case main_region_StateB :
  85. return (sc_boolean) (stateConfVector[0] == main_region_StateB
  86. );
  87. case main_region_StateA :
  88. return (sc_boolean) (stateConfVector[0] == main_region_StateA
  89. );
  90. default: return false;
  91. }
  92. }
  93. ReadOnlyVariable::DefaultSCI* ReadOnlyVariable::getDefaultSCI()
  94. {
  95. return &iface;
  96. }
  97. sc_integer ReadOnlyVariable::DefaultSCI::get_myInt() const
  98. {
  99. return myInt;
  100. }
  101. sc_integer ReadOnlyVariable::get_myInt() const
  102. {
  103. return iface.myInt;
  104. }
  105. sc_string ReadOnlyVariable::DefaultSCI::get_myString() const
  106. {
  107. return myString;
  108. }
  109. sc_string ReadOnlyVariable::get_myString() const
  110. {
  111. return iface.myString;
  112. }
  113. sc_boolean ReadOnlyVariable::DefaultSCI::get_myBool() const
  114. {
  115. return myBool;
  116. }
  117. sc_boolean ReadOnlyVariable::get_myBool() const
  118. {
  119. return iface.myBool;
  120. }
  121. sc_real ReadOnlyVariable::DefaultSCI::get_myReal() const
  122. {
  123. return myReal;
  124. }
  125. sc_real ReadOnlyVariable::get_myReal() const
  126. {
  127. return iface.myReal;
  128. }
  129. ReadOnlyVariable::SCI_A* ReadOnlyVariable::getSCI_A()
  130. {
  131. return &ifaceA;
  132. }
  133. sc_integer ReadOnlyVariable::SCI_A::get_myInt() const
  134. {
  135. return myInt;
  136. }
  137. sc_string ReadOnlyVariable::SCI_A::get_myString() const
  138. {
  139. return myString;
  140. }
  141. sc_boolean ReadOnlyVariable::SCI_A::get_myBool() const
  142. {
  143. return myBool;
  144. }
  145. sc_real ReadOnlyVariable::SCI_A::get_myReal() const
  146. {
  147. return myReal;
  148. }
  149. // implementations of all internal functions
  150. sc_boolean ReadOnlyVariable::check_main_region_StateA_tr0_tr0()
  151. {
  152. return true;
  153. }
  154. void ReadOnlyVariable::effect_main_region_StateA_tr0()
  155. {
  156. exseq_main_region_StateA();
  157. enseq_main_region_StateB_default();
  158. }
  159. /* Entry action for state 'StateB'. */
  160. void ReadOnlyVariable::enact_main_region_StateB()
  161. {
  162. /* Entry action for state 'StateB'. */
  163. iface.myInt = 100;
  164. iface.myString = "fail";
  165. iface.myBool = false;
  166. iface.myReal = 6.6;
  167. ifaceA.myInt = 200;
  168. ifaceA.myString = "A_fail";
  169. ifaceA.myBool = false;
  170. ifaceA.myReal = 7.7;
  171. }
  172. /* 'default' enter sequence for state StateB */
  173. void ReadOnlyVariable::enseq_main_region_StateB_default()
  174. {
  175. /* 'default' enter sequence for state StateB */
  176. enact_main_region_StateB();
  177. stateConfVector[0] = main_region_StateB;
  178. stateConfVectorPosition = 0;
  179. }
  180. /* 'default' enter sequence for state StateA */
  181. void ReadOnlyVariable::enseq_main_region_StateA_default()
  182. {
  183. /* 'default' enter sequence for state StateA */
  184. stateConfVector[0] = main_region_StateA;
  185. stateConfVectorPosition = 0;
  186. }
  187. /* 'default' enter sequence for region main region */
  188. void ReadOnlyVariable::enseq_main_region_default()
  189. {
  190. /* 'default' enter sequence for region main region */
  191. react_main_region__entry_Default();
  192. }
  193. /* Default exit sequence for state StateB */
  194. void ReadOnlyVariable::exseq_main_region_StateB()
  195. {
  196. /* Default exit sequence for state StateB */
  197. stateConfVector[0] = ReadOnlyVariable_last_state;
  198. stateConfVectorPosition = 0;
  199. }
  200. /* Default exit sequence for state StateA */
  201. void ReadOnlyVariable::exseq_main_region_StateA()
  202. {
  203. /* Default exit sequence for state StateA */
  204. stateConfVector[0] = ReadOnlyVariable_last_state;
  205. stateConfVectorPosition = 0;
  206. }
  207. /* Default exit sequence for region main region */
  208. void ReadOnlyVariable::exseq_main_region()
  209. {
  210. /* Default exit sequence for region main region */
  211. /* Handle exit of all possible states (of ReadOnlyVariable.main_region) at position 0... */
  212. switch(stateConfVector[ 0 ])
  213. {
  214. case main_region_StateB :
  215. {
  216. exseq_main_region_StateB();
  217. break;
  218. }
  219. case main_region_StateA :
  220. {
  221. exseq_main_region_StateA();
  222. break;
  223. }
  224. default: break;
  225. }
  226. }
  227. /* The reactions of state StateB. */
  228. void ReadOnlyVariable::react_main_region_StateB()
  229. {
  230. /* The reactions of state StateB. */
  231. }
  232. /* The reactions of state StateA. */
  233. void ReadOnlyVariable::react_main_region_StateA()
  234. {
  235. /* The reactions of state StateA. */
  236. effect_main_region_StateA_tr0();
  237. }
  238. /* Default react sequence for initial entry */
  239. void ReadOnlyVariable::react_main_region__entry_Default()
  240. {
  241. /* Default react sequence for initial entry */
  242. enseq_main_region_StateA_default();
  243. }