EntryReactionAction.cpp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. #include "EntryReactionAction.h"
  2. #include <string.h>
  3. /*! \file Implementation of the state machine 'EntryReactionAction'
  4. */
  5. EntryReactionAction::EntryReactionAction()
  6. {
  7. for (int i = 0; i < maxHistoryStates; ++i)
  8. historyVector[i] = EntryReactionAction_last_state;
  9. stateConfVectorPosition = 0;
  10. }
  11. EntryReactionAction::~EntryReactionAction()
  12. {
  13. }
  14. void EntryReactionAction::init()
  15. {
  16. for (int i = 0; i < maxOrthogonalStates; ++i)
  17. stateConfVector[i] = EntryReactionAction_last_state;
  18. for (int i = 0; i < maxHistoryStates; ++i)
  19. historyVector[i] = EntryReactionAction_last_state;
  20. stateConfVectorPosition = 0;
  21. clearInEvents();
  22. clearOutEvents();
  23. /* Default init sequence for statechart EntryReactionAction */
  24. iface.enteredR1 = false;
  25. iface.enteredR2 = false;
  26. iface.enteredBdefault = false;
  27. iface.enteredBother = false;
  28. }
  29. void EntryReactionAction::enter()
  30. {
  31. /* Default enter sequence for statechart EntryReactionAction */
  32. enseq_EntryReactionAction_r2_default();
  33. enseq_EntryReactionAction_r1_default();
  34. }
  35. void EntryReactionAction::exit()
  36. {
  37. /* Default exit sequence for statechart EntryReactionAction */
  38. exseq_EntryReactionAction_r2();
  39. exseq_EntryReactionAction_r1();
  40. }
  41. sc_boolean EntryReactionAction::isActive() const
  42. {
  43. return stateConfVector[0] != EntryReactionAction_last_state||stateConfVector[1] != EntryReactionAction_last_state;
  44. }
  45. /*
  46. * Always returns 'false' since this state machine can never become final.
  47. */
  48. sc_boolean EntryReactionAction::isFinal() const
  49. {
  50. return false;}
  51. void EntryReactionAction::runCycle()
  52. {
  53. clearOutEvents();
  54. for (stateConfVectorPosition = 0;
  55. stateConfVectorPosition < maxOrthogonalStates;
  56. stateConfVectorPosition++)
  57. {
  58. switch (stateConfVector[stateConfVectorPosition])
  59. {
  60. case EntryReactionAction_r2_B_r_BA :
  61. {
  62. react_EntryReactionAction_r2_B_r_BA();
  63. break;
  64. }
  65. case EntryReactionAction_r2_B_r_BB :
  66. {
  67. react_EntryReactionAction_r2_B_r_BB();
  68. break;
  69. }
  70. case EntryReactionAction_r2_D :
  71. {
  72. react_EntryReactionAction_r2_D();
  73. break;
  74. }
  75. case EntryReactionAction_r1_A :
  76. {
  77. react_EntryReactionAction_r1_A();
  78. break;
  79. }
  80. default:
  81. break;
  82. }
  83. }
  84. clearInEvents();
  85. }
  86. void EntryReactionAction::clearInEvents()
  87. {
  88. iface.b_raised = false;
  89. iface.d_raised = false;
  90. }
  91. void EntryReactionAction::clearOutEvents()
  92. {
  93. }
  94. sc_boolean EntryReactionAction::isStateActive(EntryReactionActionStates state) const
  95. {
  96. switch (state)
  97. {
  98. case EntryReactionAction_r2_B :
  99. return (sc_boolean) (stateConfVector[0] >= EntryReactionAction_r2_B
  100. && stateConfVector[0] <= EntryReactionAction_r2_B_r_BB);
  101. case EntryReactionAction_r2_B_r_BA :
  102. return (sc_boolean) (stateConfVector[0] == EntryReactionAction_r2_B_r_BA
  103. );
  104. case EntryReactionAction_r2_B_r_BB :
  105. return (sc_boolean) (stateConfVector[0] == EntryReactionAction_r2_B_r_BB
  106. );
  107. case EntryReactionAction_r2_D :
  108. return (sc_boolean) (stateConfVector[0] == EntryReactionAction_r2_D
  109. );
  110. case EntryReactionAction_r1_A :
  111. return (sc_boolean) (stateConfVector[1] == EntryReactionAction_r1_A
  112. );
  113. default: return false;
  114. }
  115. }
  116. EntryReactionAction::DefaultSCI* EntryReactionAction::getDefaultSCI()
  117. {
  118. return &iface;
  119. }
  120. void EntryReactionAction::DefaultSCI::raise_b()
  121. {
  122. b_raised = true;
  123. }
  124. void EntryReactionAction::raise_b()
  125. {
  126. iface.raise_b();
  127. }
  128. void EntryReactionAction::DefaultSCI::raise_d()
  129. {
  130. d_raised = true;
  131. }
  132. void EntryReactionAction::raise_d()
  133. {
  134. iface.raise_d();
  135. }
  136. sc_boolean EntryReactionAction::DefaultSCI::get_enteredR1() const
  137. {
  138. return enteredR1;
  139. }
  140. sc_boolean EntryReactionAction::get_enteredR1() const
  141. {
  142. return iface.enteredR1;
  143. }
  144. void EntryReactionAction::DefaultSCI::set_enteredR1(sc_boolean value)
  145. {
  146. enteredR1 = value;
  147. }
  148. void EntryReactionAction::set_enteredR1(sc_boolean value)
  149. {
  150. iface.enteredR1 = value;
  151. }
  152. sc_boolean EntryReactionAction::DefaultSCI::get_enteredR2() const
  153. {
  154. return enteredR2;
  155. }
  156. sc_boolean EntryReactionAction::get_enteredR2() const
  157. {
  158. return iface.enteredR2;
  159. }
  160. void EntryReactionAction::DefaultSCI::set_enteredR2(sc_boolean value)
  161. {
  162. enteredR2 = value;
  163. }
  164. void EntryReactionAction::set_enteredR2(sc_boolean value)
  165. {
  166. iface.enteredR2 = value;
  167. }
  168. sc_boolean EntryReactionAction::DefaultSCI::get_enteredBdefault() const
  169. {
  170. return enteredBdefault;
  171. }
  172. sc_boolean EntryReactionAction::get_enteredBdefault() const
  173. {
  174. return iface.enteredBdefault;
  175. }
  176. void EntryReactionAction::DefaultSCI::set_enteredBdefault(sc_boolean value)
  177. {
  178. enteredBdefault = value;
  179. }
  180. void EntryReactionAction::set_enteredBdefault(sc_boolean value)
  181. {
  182. iface.enteredBdefault = value;
  183. }
  184. sc_boolean EntryReactionAction::DefaultSCI::get_enteredBother() const
  185. {
  186. return enteredBother;
  187. }
  188. sc_boolean EntryReactionAction::get_enteredBother() const
  189. {
  190. return iface.enteredBother;
  191. }
  192. void EntryReactionAction::DefaultSCI::set_enteredBother(sc_boolean value)
  193. {
  194. enteredBother = value;
  195. }
  196. void EntryReactionAction::set_enteredBother(sc_boolean value)
  197. {
  198. iface.enteredBother = value;
  199. }
  200. // implementations of all internal functions
  201. sc_boolean EntryReactionAction::check_EntryReactionAction_r2_B_tr0_tr0()
  202. {
  203. return iface.d_raised;
  204. }
  205. sc_boolean EntryReactionAction::check_EntryReactionAction_r2_B_r_BA_tr0_tr0()
  206. {
  207. return iface.b_raised;
  208. }
  209. sc_boolean EntryReactionAction::check_EntryReactionAction_r2_B_r_BB_tr0_tr0()
  210. {
  211. return iface.b_raised;
  212. }
  213. sc_boolean EntryReactionAction::check_EntryReactionAction_r2_D_tr0_tr0()
  214. {
  215. return iface.b_raised;
  216. }
  217. sc_boolean EntryReactionAction::check_EntryReactionAction_r2_D_tr1_tr1()
  218. {
  219. return iface.d_raised;
  220. }
  221. void EntryReactionAction::effect_EntryReactionAction_r2_B_tr0()
  222. {
  223. exseq_EntryReactionAction_r2_B();
  224. enseq_EntryReactionAction_r2_D_default();
  225. }
  226. void EntryReactionAction::effect_EntryReactionAction_r2_B_r_BA_tr0()
  227. {
  228. exseq_EntryReactionAction_r2_B_r_BA();
  229. enseq_EntryReactionAction_r2_B_r_BB_default();
  230. }
  231. void EntryReactionAction::effect_EntryReactionAction_r2_B_r_BB_tr0()
  232. {
  233. exseq_EntryReactionAction_r2_B_r_BB();
  234. enseq_EntryReactionAction_r2_B_r_BA_default();
  235. }
  236. void EntryReactionAction::effect_EntryReactionAction_r2_D_tr0()
  237. {
  238. exseq_EntryReactionAction_r2_D();
  239. enseq_EntryReactionAction_r2_B_other();
  240. }
  241. void EntryReactionAction::effect_EntryReactionAction_r2_D_tr1()
  242. {
  243. exseq_EntryReactionAction_r2_D();
  244. enseq_EntryReactionAction_r2_B_default();
  245. }
  246. /* 'default' enter sequence for state B */
  247. void EntryReactionAction::enseq_EntryReactionAction_r2_B_default()
  248. {
  249. /* 'default' enter sequence for state B */
  250. enseq_EntryReactionAction_r2_B_r_default();
  251. }
  252. /* 'other' enter sequence for state B */
  253. void EntryReactionAction::enseq_EntryReactionAction_r2_B_other()
  254. {
  255. /* 'other' enter sequence for state B */
  256. enseq_EntryReactionAction_r2_B_r_other();
  257. }
  258. /* 'default' enter sequence for state BA */
  259. void EntryReactionAction::enseq_EntryReactionAction_r2_B_r_BA_default()
  260. {
  261. /* 'default' enter sequence for state BA */
  262. stateConfVector[0] = EntryReactionAction_r2_B_r_BA;
  263. stateConfVectorPosition = 0;
  264. historyVector[0] = stateConfVector[0];
  265. }
  266. /* 'default' enter sequence for state BB */
  267. void EntryReactionAction::enseq_EntryReactionAction_r2_B_r_BB_default()
  268. {
  269. /* 'default' enter sequence for state BB */
  270. stateConfVector[0] = EntryReactionAction_r2_B_r_BB;
  271. stateConfVectorPosition = 0;
  272. historyVector[0] = stateConfVector[0];
  273. }
  274. /* 'default' enter sequence for state D */
  275. void EntryReactionAction::enseq_EntryReactionAction_r2_D_default()
  276. {
  277. /* 'default' enter sequence for state D */
  278. stateConfVector[0] = EntryReactionAction_r2_D;
  279. stateConfVectorPosition = 0;
  280. }
  281. /* 'default' enter sequence for state A */
  282. void EntryReactionAction::enseq_EntryReactionAction_r1_A_default()
  283. {
  284. /* 'default' enter sequence for state A */
  285. stateConfVector[1] = EntryReactionAction_r1_A;
  286. stateConfVectorPosition = 1;
  287. }
  288. /* 'default' enter sequence for region r2 */
  289. void EntryReactionAction::enseq_EntryReactionAction_r2_default()
  290. {
  291. /* 'default' enter sequence for region r2 */
  292. react_EntryReactionAction_r2_default();
  293. }
  294. /* 'default' enter sequence for region r */
  295. void EntryReactionAction::enseq_EntryReactionAction_r2_B_r_default()
  296. {
  297. /* 'default' enter sequence for region r */
  298. react_EntryReactionAction_r2_B_r_default();
  299. }
  300. /* 'other' enter sequence for region r */
  301. void EntryReactionAction::enseq_EntryReactionAction_r2_B_r_other()
  302. {
  303. /* 'other' enter sequence for region r */
  304. react_EntryReactionAction_r2_B_r_other();
  305. }
  306. /* shallow enterSequence with history in child r */
  307. void EntryReactionAction::shenseq_EntryReactionAction_r2_B_r()
  308. {
  309. /* shallow enterSequence with history in child r */
  310. /* Handle shallow history entry of r */
  311. switch(historyVector[ 0 ])
  312. {
  313. case EntryReactionAction_r2_B_r_BA :
  314. {
  315. enseq_EntryReactionAction_r2_B_r_BA_default();
  316. break;
  317. }
  318. case EntryReactionAction_r2_B_r_BB :
  319. {
  320. enseq_EntryReactionAction_r2_B_r_BB_default();
  321. break;
  322. }
  323. default: break;
  324. }
  325. }
  326. /* 'default' enter sequence for region r1 */
  327. void EntryReactionAction::enseq_EntryReactionAction_r1_default()
  328. {
  329. /* 'default' enter sequence for region r1 */
  330. react_EntryReactionAction_r1__entry_Default();
  331. }
  332. /* Default exit sequence for state B */
  333. void EntryReactionAction::exseq_EntryReactionAction_r2_B()
  334. {
  335. /* Default exit sequence for state B */
  336. exseq_EntryReactionAction_r2_B_r();
  337. }
  338. /* Default exit sequence for state BA */
  339. void EntryReactionAction::exseq_EntryReactionAction_r2_B_r_BA()
  340. {
  341. /* Default exit sequence for state BA */
  342. stateConfVector[0] = EntryReactionAction_last_state;
  343. stateConfVectorPosition = 0;
  344. }
  345. /* Default exit sequence for state BB */
  346. void EntryReactionAction::exseq_EntryReactionAction_r2_B_r_BB()
  347. {
  348. /* Default exit sequence for state BB */
  349. stateConfVector[0] = EntryReactionAction_last_state;
  350. stateConfVectorPosition = 0;
  351. }
  352. /* Default exit sequence for state D */
  353. void EntryReactionAction::exseq_EntryReactionAction_r2_D()
  354. {
  355. /* Default exit sequence for state D */
  356. stateConfVector[0] = EntryReactionAction_last_state;
  357. stateConfVectorPosition = 0;
  358. }
  359. /* Default exit sequence for state A */
  360. void EntryReactionAction::exseq_EntryReactionAction_r1_A()
  361. {
  362. /* Default exit sequence for state A */
  363. stateConfVector[1] = EntryReactionAction_last_state;
  364. stateConfVectorPosition = 1;
  365. }
  366. /* Default exit sequence for region r2 */
  367. void EntryReactionAction::exseq_EntryReactionAction_r2()
  368. {
  369. /* Default exit sequence for region r2 */
  370. /* Handle exit of all possible states (of entries.EntryReactionAction.r2) at position 0... */
  371. switch(stateConfVector[ 0 ])
  372. {
  373. case EntryReactionAction_r2_B_r_BA :
  374. {
  375. exseq_EntryReactionAction_r2_B_r_BA();
  376. break;
  377. }
  378. case EntryReactionAction_r2_B_r_BB :
  379. {
  380. exseq_EntryReactionAction_r2_B_r_BB();
  381. break;
  382. }
  383. case EntryReactionAction_r2_D :
  384. {
  385. exseq_EntryReactionAction_r2_D();
  386. break;
  387. }
  388. default: break;
  389. }
  390. }
  391. /* Default exit sequence for region r */
  392. void EntryReactionAction::exseq_EntryReactionAction_r2_B_r()
  393. {
  394. /* Default exit sequence for region r */
  395. /* Handle exit of all possible states (of entries.EntryReactionAction.r2.B.r) at position 0... */
  396. switch(stateConfVector[ 0 ])
  397. {
  398. case EntryReactionAction_r2_B_r_BA :
  399. {
  400. exseq_EntryReactionAction_r2_B_r_BA();
  401. break;
  402. }
  403. case EntryReactionAction_r2_B_r_BB :
  404. {
  405. exseq_EntryReactionAction_r2_B_r_BB();
  406. break;
  407. }
  408. default: break;
  409. }
  410. }
  411. /* Default exit sequence for region r1 */
  412. void EntryReactionAction::exseq_EntryReactionAction_r1()
  413. {
  414. /* Default exit sequence for region r1 */
  415. /* Handle exit of all possible states (of entries.EntryReactionAction.r1) at position 1... */
  416. switch(stateConfVector[ 1 ])
  417. {
  418. case EntryReactionAction_r1_A :
  419. {
  420. exseq_EntryReactionAction_r1_A();
  421. break;
  422. }
  423. default: break;
  424. }
  425. }
  426. /* The reactions of state BA. */
  427. void EntryReactionAction::react_EntryReactionAction_r2_B_r_BA()
  428. {
  429. /* The reactions of state BA. */
  430. if (check_EntryReactionAction_r2_B_tr0_tr0())
  431. {
  432. effect_EntryReactionAction_r2_B_tr0();
  433. } else
  434. {
  435. if (check_EntryReactionAction_r2_B_r_BA_tr0_tr0())
  436. {
  437. effect_EntryReactionAction_r2_B_r_BA_tr0();
  438. }
  439. }
  440. }
  441. /* The reactions of state BB. */
  442. void EntryReactionAction::react_EntryReactionAction_r2_B_r_BB()
  443. {
  444. /* The reactions of state BB. */
  445. if (check_EntryReactionAction_r2_B_tr0_tr0())
  446. {
  447. effect_EntryReactionAction_r2_B_tr0();
  448. } else
  449. {
  450. if (check_EntryReactionAction_r2_B_r_BB_tr0_tr0())
  451. {
  452. effect_EntryReactionAction_r2_B_r_BB_tr0();
  453. }
  454. }
  455. }
  456. /* The reactions of state D. */
  457. void EntryReactionAction::react_EntryReactionAction_r2_D()
  458. {
  459. /* The reactions of state D. */
  460. if (check_EntryReactionAction_r2_D_tr0_tr0())
  461. {
  462. effect_EntryReactionAction_r2_D_tr0();
  463. } else
  464. {
  465. if (check_EntryReactionAction_r2_D_tr1_tr1())
  466. {
  467. effect_EntryReactionAction_r2_D_tr1();
  468. }
  469. }
  470. }
  471. /* The reactions of state A. */
  472. void EntryReactionAction::react_EntryReactionAction_r1_A()
  473. {
  474. }
  475. /* Default react sequence for initial entry default */
  476. void EntryReactionAction::react_EntryReactionAction_r2_default()
  477. {
  478. /* Default react sequence for initial entry default */
  479. iface.enteredR2 = true;
  480. enseq_EntryReactionAction_r2_B_default();
  481. }
  482. /* Default react sequence for shallow history entry default */
  483. void EntryReactionAction::react_EntryReactionAction_r2_B_r_default()
  484. {
  485. /* Default react sequence for shallow history entry default */
  486. /* Enter the region with shallow history */
  487. if (historyVector[0] != EntryReactionAction_last_state)
  488. {
  489. shenseq_EntryReactionAction_r2_B_r();
  490. } else
  491. {
  492. iface.enteredBdefault = true;
  493. enseq_EntryReactionAction_r2_B_r_BA_default();
  494. }
  495. }
  496. /* Default react sequence for initial entry other */
  497. void EntryReactionAction::react_EntryReactionAction_r2_B_r_other()
  498. {
  499. /* Default react sequence for initial entry other */
  500. iface.enteredBother = true;
  501. enseq_EntryReactionAction_r2_B_r_BB_default();
  502. }
  503. /* Default react sequence for initial entry */
  504. void EntryReactionAction::react_EntryReactionAction_r1__entry_Default()
  505. {
  506. /* Default react sequence for initial entry */
  507. iface.enteredR1 = true;
  508. enseq_EntryReactionAction_r1_A_default();
  509. }