Operations.cpp 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. #include "Operations.h"
  2. #include <string.h>
  3. /*! \file Implementation of the state machine 'Operations'
  4. */
  5. Operations::Operations()
  6. {
  7. ifaceInternalSCI_OCB = null;
  8. ifaceInterface1_OCB = null;
  9. iface_OCB = null;
  10. stateConfVectorPosition = 0;
  11. }
  12. Operations::~Operations()
  13. {
  14. }
  15. void Operations::init()
  16. {
  17. for (int i = 0; i < maxOrthogonalStates; ++i)
  18. stateConfVector[i] = Operations_last_state;
  19. stateConfVectorPosition = 0;
  20. clearInEvents();
  21. clearOutEvents();
  22. /* Default init sequence for statechart Operations */
  23. ifaceInternalSCI.myBool = false;
  24. }
  25. void Operations::enter()
  26. {
  27. /* Default enter sequence for statechart Operations */
  28. enseq_main_region_default();
  29. }
  30. void Operations::exit()
  31. {
  32. /* Default exit sequence for statechart Operations */
  33. exseq_main_region();
  34. }
  35. sc_boolean Operations::isActive() const
  36. {
  37. return stateConfVector[0] != Operations_last_state;
  38. }
  39. /*
  40. * Always returns 'false' since this state machine can never become final.
  41. */
  42. sc_boolean Operations::isFinal() const
  43. {
  44. return false;}
  45. void Operations::runCycle()
  46. {
  47. clearOutEvents();
  48. for (stateConfVectorPosition = 0;
  49. stateConfVectorPosition < maxOrthogonalStates;
  50. stateConfVectorPosition++)
  51. {
  52. switch (stateConfVector[stateConfVectorPosition])
  53. {
  54. case main_region_B :
  55. {
  56. react_main_region_B();
  57. break;
  58. }
  59. case main_region_C :
  60. {
  61. react_main_region_C();
  62. break;
  63. }
  64. case main_region_D :
  65. {
  66. react_main_region_D();
  67. break;
  68. }
  69. case main_region_A :
  70. {
  71. react_main_region_A();
  72. break;
  73. }
  74. default:
  75. break;
  76. }
  77. }
  78. clearInEvents();
  79. }
  80. void Operations::clearInEvents()
  81. {
  82. iface.ev_raised = false;
  83. }
  84. void Operations::clearOutEvents()
  85. {
  86. }
  87. sc_boolean Operations::isStateActive(OperationsStates state) const
  88. {
  89. switch (state)
  90. {
  91. case main_region_B :
  92. return (sc_boolean) (stateConfVector[0] == main_region_B
  93. );
  94. case main_region_C :
  95. return (sc_boolean) (stateConfVector[0] == main_region_C
  96. );
  97. case main_region_D :
  98. return (sc_boolean) (stateConfVector[0] == main_region_D
  99. );
  100. case main_region_A :
  101. return (sc_boolean) (stateConfVector[0] == main_region_A
  102. );
  103. default: return false;
  104. }
  105. }
  106. sc_boolean Operations::InternalSCI::get_myBool() const
  107. {
  108. return myBool;
  109. }
  110. void Operations::InternalSCI::set_myBool(sc_boolean value)
  111. {
  112. myBool = value;
  113. }
  114. void Operations::setInternalSCI_OCB(InternalSCI_OCB* operationCallback)
  115. {
  116. ifaceInternalSCI_OCB = operationCallback;
  117. }
  118. Operations::SCI_Interface1* Operations::getSCI_Interface1()
  119. {
  120. return &ifaceInterface1;
  121. }
  122. void Operations::setSCI_Interface1_OCB(SCI_Interface1_OCB* operationCallback)
  123. {
  124. ifaceInterface1_OCB = operationCallback;
  125. }
  126. Operations::DefaultSCI* Operations::getDefaultSCI()
  127. {
  128. return &iface;
  129. }
  130. void Operations::DefaultSCI::raise_ev()
  131. {
  132. ev_raised = true;
  133. }
  134. void Operations::raise_ev()
  135. {
  136. iface.raise_ev();
  137. }
  138. void Operations::setDefaultSCI_OCB(DefaultSCI_OCB* operationCallback)
  139. {
  140. iface_OCB = operationCallback;
  141. }
  142. // implementations of all internal functions
  143. sc_boolean Operations::check_main_region_B_tr0_tr0()
  144. {
  145. return (iface.ev_raised) && (iface_OCB->alwaysTrue());
  146. }
  147. sc_boolean Operations::check_main_region_C_tr0_tr0()
  148. {
  149. return iface.ev_raised;
  150. }
  151. sc_boolean Operations::check_main_region_A_tr0_tr0()
  152. {
  153. return true;
  154. }
  155. void Operations::effect_main_region_B_tr0()
  156. {
  157. exseq_main_region_B();
  158. enseq_main_region_C_default();
  159. }
  160. void Operations::effect_main_region_C_tr0()
  161. {
  162. exseq_main_region_C();
  163. enseq_main_region_D_default();
  164. }
  165. void Operations::effect_main_region_A_tr0()
  166. {
  167. exseq_main_region_A();
  168. enseq_main_region_B_default();
  169. }
  170. /* Entry action for state 'B'. */
  171. void Operations::enact_main_region_B()
  172. {
  173. /* Entry action for state 'B'. */
  174. ifaceInternalSCI_OCB->internalOperation1();
  175. ifaceInternalSCI.myBool = ifaceInternalSCI_OCB->InternalOperation2(4);
  176. ifaceInternalSCI_OCB->internalOperation3();
  177. ifaceInternalSCI_OCB->internalOperation3a(1.0);
  178. ifaceInternalSCI_OCB->internalOperation4();
  179. ifaceInternalSCI_OCB->internalOperation4a(5);
  180. ifaceInternalSCI_OCB->internalOperation5();
  181. ifaceInternalSCI_OCB->internalOperation5a("");
  182. }
  183. /* Entry action for state 'C'. */
  184. void Operations::enact_main_region_C()
  185. {
  186. /* Entry action for state 'C'. */
  187. ifaceInterface1_OCB->interfaceOperation1();
  188. ifaceInterface1_OCB->InterfaceOperation2(4);
  189. ifaceInterface1_OCB->interfaceOperation3();
  190. ifaceInterface1_OCB->interfaceOperation3a(1.0);
  191. ifaceInterface1_OCB->interfaceOperation4();
  192. ifaceInterface1_OCB->interfaceOperation4a(5);
  193. ifaceInterface1_OCB->interfaceOperation5();
  194. ifaceInterface1_OCB->interfaceOperation5a("");
  195. }
  196. /* Entry action for state 'D'. */
  197. void Operations::enact_main_region_D()
  198. {
  199. /* Entry action for state 'D'. */
  200. iface_OCB->unnamedInterfaceOperation1();
  201. iface_OCB->UnnamedInterfaceOperation2(4);
  202. iface_OCB->unnamedOperation3();
  203. iface_OCB->unnamedOperation3a(1.0);
  204. iface_OCB->unnamedOperation4();
  205. iface_OCB->unnamedOperation4a(5);
  206. iface_OCB->unnamedOperation5();
  207. iface_OCB->unnamedOperation5a("");
  208. }
  209. /* 'default' enter sequence for state B */
  210. void Operations::enseq_main_region_B_default()
  211. {
  212. /* 'default' enter sequence for state B */
  213. enact_main_region_B();
  214. stateConfVector[0] = main_region_B;
  215. stateConfVectorPosition = 0;
  216. }
  217. /* 'default' enter sequence for state C */
  218. void Operations::enseq_main_region_C_default()
  219. {
  220. /* 'default' enter sequence for state C */
  221. enact_main_region_C();
  222. stateConfVector[0] = main_region_C;
  223. stateConfVectorPosition = 0;
  224. }
  225. /* 'default' enter sequence for state D */
  226. void Operations::enseq_main_region_D_default()
  227. {
  228. /* 'default' enter sequence for state D */
  229. enact_main_region_D();
  230. stateConfVector[0] = main_region_D;
  231. stateConfVectorPosition = 0;
  232. }
  233. /* 'default' enter sequence for state A */
  234. void Operations::enseq_main_region_A_default()
  235. {
  236. /* 'default' enter sequence for state A */
  237. stateConfVector[0] = main_region_A;
  238. stateConfVectorPosition = 0;
  239. }
  240. /* 'default' enter sequence for region main region */
  241. void Operations::enseq_main_region_default()
  242. {
  243. /* 'default' enter sequence for region main region */
  244. react_main_region__entry_Default();
  245. }
  246. /* Default exit sequence for state B */
  247. void Operations::exseq_main_region_B()
  248. {
  249. /* Default exit sequence for state B */
  250. stateConfVector[0] = Operations_last_state;
  251. stateConfVectorPosition = 0;
  252. }
  253. /* Default exit sequence for state C */
  254. void Operations::exseq_main_region_C()
  255. {
  256. /* Default exit sequence for state C */
  257. stateConfVector[0] = Operations_last_state;
  258. stateConfVectorPosition = 0;
  259. }
  260. /* Default exit sequence for state D */
  261. void Operations::exseq_main_region_D()
  262. {
  263. /* Default exit sequence for state D */
  264. stateConfVector[0] = Operations_last_state;
  265. stateConfVectorPosition = 0;
  266. }
  267. /* Default exit sequence for state A */
  268. void Operations::exseq_main_region_A()
  269. {
  270. /* Default exit sequence for state A */
  271. stateConfVector[0] = Operations_last_state;
  272. stateConfVectorPosition = 0;
  273. }
  274. /* Default exit sequence for region main region */
  275. void Operations::exseq_main_region()
  276. {
  277. /* Default exit sequence for region main region */
  278. /* Handle exit of all possible states (of Operations.main_region) at position 0... */
  279. switch(stateConfVector[ 0 ])
  280. {
  281. case main_region_B :
  282. {
  283. exseq_main_region_B();
  284. break;
  285. }
  286. case main_region_C :
  287. {
  288. exseq_main_region_C();
  289. break;
  290. }
  291. case main_region_D :
  292. {
  293. exseq_main_region_D();
  294. break;
  295. }
  296. case main_region_A :
  297. {
  298. exseq_main_region_A();
  299. break;
  300. }
  301. default: break;
  302. }
  303. }
  304. /* The reactions of state B. */
  305. void Operations::react_main_region_B()
  306. {
  307. /* The reactions of state B. */
  308. if (check_main_region_B_tr0_tr0())
  309. {
  310. effect_main_region_B_tr0();
  311. }
  312. }
  313. /* The reactions of state C. */
  314. void Operations::react_main_region_C()
  315. {
  316. /* The reactions of state C. */
  317. if (check_main_region_C_tr0_tr0())
  318. {
  319. effect_main_region_C_tr0();
  320. }
  321. }
  322. /* The reactions of state D. */
  323. void Operations::react_main_region_D()
  324. {
  325. /* The reactions of state D. */
  326. }
  327. /* The reactions of state A. */
  328. void Operations::react_main_region_A()
  329. {
  330. /* The reactions of state A. */
  331. effect_main_region_A_tr0();
  332. }
  333. /* Default react sequence for initial entry */
  334. void Operations::react_main_region__entry_Default()
  335. {
  336. /* Default react sequence for initial entry */
  337. enseq_main_region_A_default();
  338. }