LocalReactions.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. #include "LocalReactions.h"
  2. #include <string.h>
  3. /*! \file Implementation of the state machine 'LocalReactions'
  4. */
  5. LocalReactions::LocalReactions()
  6. {
  7. stateConfVectorPosition = 0;
  8. }
  9. LocalReactions::~LocalReactions()
  10. {
  11. }
  12. void LocalReactions::init()
  13. {
  14. for (int i = 0; i < maxOrthogonalStates; ++i)
  15. stateConfVector[i] = LocalReactions_last_state;
  16. stateConfVectorPosition = 0;
  17. clearInEvents();
  18. clearOutEvents();
  19. /* Default init sequence for statechart LocalReactions */
  20. iface.x = 0;
  21. }
  22. void LocalReactions::enter()
  23. {
  24. /* Default enter sequence for statechart LocalReactions */
  25. enseq_main_region_default();
  26. }
  27. void LocalReactions::exit()
  28. {
  29. /* Default exit sequence for statechart LocalReactions */
  30. exseq_main_region();
  31. }
  32. sc_boolean LocalReactions::isActive() const
  33. {
  34. return stateConfVector[0] != LocalReactions_last_state;
  35. }
  36. /*
  37. * Always returns 'false' since this state machine can never become final.
  38. */
  39. sc_boolean LocalReactions::isFinal() const
  40. {
  41. return false;}
  42. void LocalReactions::runCycle()
  43. {
  44. clearOutEvents();
  45. for (stateConfVectorPosition = 0;
  46. stateConfVectorPosition < maxOrthogonalStates;
  47. stateConfVectorPosition++)
  48. {
  49. switch (stateConfVector[stateConfVectorPosition])
  50. {
  51. case main_region_A :
  52. {
  53. react_main_region_A();
  54. break;
  55. }
  56. default:
  57. break;
  58. }
  59. }
  60. clearInEvents();
  61. }
  62. void LocalReactions::clearInEvents()
  63. {
  64. }
  65. void LocalReactions::clearOutEvents()
  66. {
  67. }
  68. sc_boolean LocalReactions::isStateActive(LocalReactionsStates state) const
  69. {
  70. switch (state)
  71. {
  72. case main_region_A :
  73. return (sc_boolean) (stateConfVector[0] == main_region_A
  74. );
  75. default: return false;
  76. }
  77. }
  78. LocalReactions::DefaultSCI* LocalReactions::getDefaultSCI()
  79. {
  80. return &iface;
  81. }
  82. sc_integer LocalReactions::DefaultSCI::get_x() const
  83. {
  84. return x;
  85. }
  86. sc_integer LocalReactions::get_x() const
  87. {
  88. return iface.x;
  89. }
  90. void LocalReactions::DefaultSCI::set_x(sc_integer value)
  91. {
  92. x = value;
  93. }
  94. void LocalReactions::set_x(sc_integer value)
  95. {
  96. iface.x = value;
  97. }
  98. // implementations of all internal functions
  99. sc_boolean LocalReactions::check_main_region_A_lr0_lr0()
  100. {
  101. return iface.x == 0;
  102. }
  103. void LocalReactions::effect_main_region_A_lr0_lr0()
  104. {
  105. iface.x += 1;
  106. }
  107. /* 'default' enter sequence for state A */
  108. void LocalReactions::enseq_main_region_A_default()
  109. {
  110. /* 'default' enter sequence for state A */
  111. stateConfVector[0] = main_region_A;
  112. stateConfVectorPosition = 0;
  113. }
  114. /* 'default' enter sequence for region main region */
  115. void LocalReactions::enseq_main_region_default()
  116. {
  117. /* 'default' enter sequence for region main region */
  118. react_main_region__entry_Default();
  119. }
  120. /* Default exit sequence for state A */
  121. void LocalReactions::exseq_main_region_A()
  122. {
  123. /* Default exit sequence for state A */
  124. stateConfVector[0] = LocalReactions_last_state;
  125. stateConfVectorPosition = 0;
  126. }
  127. /* Default exit sequence for region main region */
  128. void LocalReactions::exseq_main_region()
  129. {
  130. /* Default exit sequence for region main region */
  131. /* Handle exit of all possible states (of LocalReactions.main_region) at position 0... */
  132. switch(stateConfVector[ 0 ])
  133. {
  134. case main_region_A :
  135. {
  136. exseq_main_region_A();
  137. break;
  138. }
  139. default: break;
  140. }
  141. }
  142. /* The reactions of state A. */
  143. void LocalReactions::react_main_region_A()
  144. {
  145. /* The reactions of state A. */
  146. if (check_main_region_A_lr0_lr0())
  147. {
  148. effect_main_region_A_lr0_lr0();
  149. }
  150. }
  151. /* Default react sequence for initial entry */
  152. void LocalReactions::react_main_region__entry_Default()
  153. {
  154. /* Default react sequence for initial entry */
  155. enseq_main_region_A_default();
  156. }