LocalReactions.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include "sc_types.h"
  4. #include "LocalReactions.h"
  5. /*! \file Implementation of the state machine 'LocalReactions'
  6. */
  7. /* prototypes of all internal functions */
  8. static sc_boolean localReactions_check_main_region_A_lr0_lr0(const LocalReactions* handle);
  9. static void localReactions_effect_main_region_A_lr0_lr0(LocalReactions* handle);
  10. static void localReactions_enseq_main_region_A_default(LocalReactions* handle);
  11. static void localReactions_enseq_main_region_default(LocalReactions* handle);
  12. static void localReactions_exseq_main_region_A(LocalReactions* handle);
  13. static void localReactions_exseq_main_region(LocalReactions* handle);
  14. static void localReactions_react_main_region_A(LocalReactions* handle);
  15. static void localReactions_react_main_region__entry_Default(LocalReactions* handle);
  16. static void localReactions_clearInEvents(LocalReactions* handle);
  17. static void localReactions_clearOutEvents(LocalReactions* handle);
  18. void localReactions_init(LocalReactions* handle)
  19. {
  20. sc_integer i;
  21. for (i = 0; i < LOCALREACTIONS_MAX_ORTHOGONAL_STATES; ++i)
  22. {
  23. handle->stateConfVector[i] = LocalReactions_last_state;
  24. }
  25. handle->stateConfVectorPosition = 0;
  26. localReactions_clearInEvents(handle);
  27. localReactions_clearOutEvents(handle);
  28. /* Default init sequence for statechart LocalReactions */
  29. handle->iface.x = 0;
  30. }
  31. void localReactions_enter(LocalReactions* handle)
  32. {
  33. /* Default enter sequence for statechart LocalReactions */
  34. localReactions_enseq_main_region_default(handle);
  35. }
  36. void localReactions_exit(LocalReactions* handle)
  37. {
  38. /* Default exit sequence for statechart LocalReactions */
  39. localReactions_exseq_main_region(handle);
  40. }
  41. sc_boolean localReactions_isActive(const LocalReactions* handle)
  42. {
  43. sc_boolean result;
  44. if (handle->stateConfVector[0] != LocalReactions_last_state)
  45. {
  46. result = bool_true;
  47. }
  48. else
  49. {
  50. result = bool_false;
  51. }
  52. return result;
  53. }
  54. /*
  55. * Always returns 'false' since this state machine can never become final.
  56. */
  57. sc_boolean localReactions_isFinal(const LocalReactions* handle)
  58. {
  59. return bool_false;
  60. }
  61. static void localReactions_clearInEvents(LocalReactions* handle)
  62. {
  63. }
  64. static void localReactions_clearOutEvents(LocalReactions* handle)
  65. {
  66. }
  67. void localReactions_runCycle(LocalReactions* handle)
  68. {
  69. localReactions_clearOutEvents(handle);
  70. for (handle->stateConfVectorPosition = 0;
  71. handle->stateConfVectorPosition < LOCALREACTIONS_MAX_ORTHOGONAL_STATES;
  72. handle->stateConfVectorPosition++)
  73. {
  74. switch (handle->stateConfVector[handle->stateConfVectorPosition])
  75. {
  76. case LocalReactions_main_region_A :
  77. {
  78. localReactions_react_main_region_A(handle);
  79. break;
  80. }
  81. default:
  82. break;
  83. }
  84. }
  85. localReactions_clearInEvents(handle);
  86. }
  87. sc_boolean localReactions_isStateActive(const LocalReactions* handle, LocalReactionsStates state)
  88. {
  89. sc_boolean result = bool_false;
  90. switch (state)
  91. {
  92. case LocalReactions_main_region_A :
  93. result = (sc_boolean) (handle->stateConfVector[0] == LocalReactions_main_region_A
  94. );
  95. break;
  96. default:
  97. result = bool_false;
  98. break;
  99. }
  100. return result;
  101. }
  102. sc_integer localReactionsIface_get_x(const LocalReactions* handle)
  103. {
  104. return handle->iface.x;
  105. }
  106. void localReactionsIface_set_x(LocalReactions* handle, sc_integer value)
  107. {
  108. handle->iface.x = value;
  109. }
  110. /* implementations of all internal functions */
  111. static sc_boolean localReactions_check_main_region_A_lr0_lr0(const LocalReactions* handle)
  112. {
  113. return (handle->iface.x == 0) ? bool_true : bool_false;
  114. }
  115. static void localReactions_effect_main_region_A_lr0_lr0(LocalReactions* handle)
  116. {
  117. handle->iface.x += 1;
  118. }
  119. /* 'default' enter sequence for state A */
  120. static void localReactions_enseq_main_region_A_default(LocalReactions* handle)
  121. {
  122. /* 'default' enter sequence for state A */
  123. handle->stateConfVector[0] = LocalReactions_main_region_A;
  124. handle->stateConfVectorPosition = 0;
  125. }
  126. /* 'default' enter sequence for region main region */
  127. static void localReactions_enseq_main_region_default(LocalReactions* handle)
  128. {
  129. /* 'default' enter sequence for region main region */
  130. localReactions_react_main_region__entry_Default(handle);
  131. }
  132. /* Default exit sequence for state A */
  133. static void localReactions_exseq_main_region_A(LocalReactions* handle)
  134. {
  135. /* Default exit sequence for state A */
  136. handle->stateConfVector[0] = LocalReactions_last_state;
  137. handle->stateConfVectorPosition = 0;
  138. }
  139. /* Default exit sequence for region main region */
  140. static void localReactions_exseq_main_region(LocalReactions* handle)
  141. {
  142. /* Default exit sequence for region main region */
  143. /* Handle exit of all possible states (of LocalReactions.main_region) at position 0... */
  144. switch(handle->stateConfVector[ 0 ])
  145. {
  146. case LocalReactions_main_region_A :
  147. {
  148. localReactions_exseq_main_region_A(handle);
  149. break;
  150. }
  151. default: break;
  152. }
  153. }
  154. /* The reactions of state A. */
  155. static void localReactions_react_main_region_A(LocalReactions* handle)
  156. {
  157. /* The reactions of state A. */
  158. if (localReactions_check_main_region_A_lr0_lr0(handle) == bool_true)
  159. {
  160. localReactions_effect_main_region_A_lr0_lr0(handle);
  161. }
  162. }
  163. /* Default react sequence for initial entry */
  164. static void localReactions_react_main_region__entry_Default(LocalReactions* handle)
  165. {
  166. /* Default react sequence for initial entry */
  167. localReactions_enseq_main_region_A_default(handle);
  168. }