InEventLifeCycle.c 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include "sc_types.h"
  4. #include "InEventLifeCycle.h"
  5. /*! \file Implementation of the state machine 'InEventLifeCycle'
  6. */
  7. /* prototypes of all internal functions */
  8. static sc_boolean inEventLifeCycle_check_main_region_A_lr0_lr0(const InEventLifeCycle* handle);
  9. static void inEventLifeCycle_effect_main_region_A_lr0_lr0(InEventLifeCycle* handle);
  10. static void inEventLifeCycle_enseq_main_region_A_default(InEventLifeCycle* handle);
  11. static void inEventLifeCycle_enseq_main_region_default(InEventLifeCycle* handle);
  12. static void inEventLifeCycle_exseq_main_region_A(InEventLifeCycle* handle);
  13. static void inEventLifeCycle_exseq_main_region(InEventLifeCycle* handle);
  14. static void inEventLifeCycle_react_main_region_A(InEventLifeCycle* handle);
  15. static void inEventLifeCycle_react_main_region__entry_Default(InEventLifeCycle* handle);
  16. static void inEventLifeCycle_clearInEvents(InEventLifeCycle* handle);
  17. static void inEventLifeCycle_clearOutEvents(InEventLifeCycle* handle);
  18. void inEventLifeCycle_init(InEventLifeCycle* handle)
  19. {
  20. sc_integer i;
  21. for (i = 0; i < INEVENTLIFECYCLE_MAX_ORTHOGONAL_STATES; ++i)
  22. {
  23. handle->stateConfVector[i] = InEventLifeCycle_last_state;
  24. }
  25. handle->stateConfVectorPosition = 0;
  26. inEventLifeCycle_clearInEvents(handle);
  27. inEventLifeCycle_clearOutEvents(handle);
  28. /* Default init sequence for statechart InEventLifeCycle */
  29. handle->iface.i = 0;
  30. }
  31. void inEventLifeCycle_enter(InEventLifeCycle* handle)
  32. {
  33. /* Default enter sequence for statechart InEventLifeCycle */
  34. inEventLifeCycle_enseq_main_region_default(handle);
  35. }
  36. void inEventLifeCycle_exit(InEventLifeCycle* handle)
  37. {
  38. /* Default exit sequence for statechart InEventLifeCycle */
  39. inEventLifeCycle_exseq_main_region(handle);
  40. }
  41. sc_boolean inEventLifeCycle_isActive(const InEventLifeCycle* handle)
  42. {
  43. sc_boolean result;
  44. if (handle->stateConfVector[0] != InEventLifeCycle_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 inEventLifeCycle_isFinal(const InEventLifeCycle* handle)
  58. {
  59. return bool_false;
  60. }
  61. static void inEventLifeCycle_clearInEvents(InEventLifeCycle* handle)
  62. {
  63. handle->iface.e_raised = bool_false;
  64. }
  65. static void inEventLifeCycle_clearOutEvents(InEventLifeCycle* handle)
  66. {
  67. }
  68. void inEventLifeCycle_runCycle(InEventLifeCycle* handle)
  69. {
  70. inEventLifeCycle_clearOutEvents(handle);
  71. for (handle->stateConfVectorPosition = 0;
  72. handle->stateConfVectorPosition < INEVENTLIFECYCLE_MAX_ORTHOGONAL_STATES;
  73. handle->stateConfVectorPosition++)
  74. {
  75. switch (handle->stateConfVector[handle->stateConfVectorPosition])
  76. {
  77. case InEventLifeCycle_main_region_A :
  78. {
  79. inEventLifeCycle_react_main_region_A(handle);
  80. break;
  81. }
  82. default:
  83. break;
  84. }
  85. }
  86. inEventLifeCycle_clearInEvents(handle);
  87. }
  88. sc_boolean inEventLifeCycle_isStateActive(const InEventLifeCycle* handle, InEventLifeCycleStates state)
  89. {
  90. sc_boolean result = bool_false;
  91. switch (state)
  92. {
  93. case InEventLifeCycle_main_region_A :
  94. result = (sc_boolean) (handle->stateConfVector[0] == InEventLifeCycle_main_region_A
  95. );
  96. break;
  97. default:
  98. result = bool_false;
  99. break;
  100. }
  101. return result;
  102. }
  103. void inEventLifeCycleIface_raise_e(InEventLifeCycle* handle)
  104. {
  105. handle->iface.e_raised = bool_true;
  106. }
  107. sc_integer inEventLifeCycleIface_get_i(const InEventLifeCycle* handle)
  108. {
  109. return handle->iface.i;
  110. }
  111. void inEventLifeCycleIface_set_i(InEventLifeCycle* handle, sc_integer value)
  112. {
  113. handle->iface.i = value;
  114. }
  115. /* implementations of all internal functions */
  116. static sc_boolean inEventLifeCycle_check_main_region_A_lr0_lr0(const InEventLifeCycle* handle)
  117. {
  118. return handle->iface.e_raised;
  119. }
  120. static void inEventLifeCycle_effect_main_region_A_lr0_lr0(InEventLifeCycle* handle)
  121. {
  122. handle->iface.i += 1;
  123. }
  124. /* 'default' enter sequence for state A */
  125. static void inEventLifeCycle_enseq_main_region_A_default(InEventLifeCycle* handle)
  126. {
  127. /* 'default' enter sequence for state A */
  128. handle->stateConfVector[0] = InEventLifeCycle_main_region_A;
  129. handle->stateConfVectorPosition = 0;
  130. }
  131. /* 'default' enter sequence for region main region */
  132. static void inEventLifeCycle_enseq_main_region_default(InEventLifeCycle* handle)
  133. {
  134. /* 'default' enter sequence for region main region */
  135. inEventLifeCycle_react_main_region__entry_Default(handle);
  136. }
  137. /* Default exit sequence for state A */
  138. static void inEventLifeCycle_exseq_main_region_A(InEventLifeCycle* handle)
  139. {
  140. /* Default exit sequence for state A */
  141. handle->stateConfVector[0] = InEventLifeCycle_last_state;
  142. handle->stateConfVectorPosition = 0;
  143. }
  144. /* Default exit sequence for region main region */
  145. static void inEventLifeCycle_exseq_main_region(InEventLifeCycle* handle)
  146. {
  147. /* Default exit sequence for region main region */
  148. /* Handle exit of all possible states (of InEventLifeCycle.main_region) at position 0... */
  149. switch(handle->stateConfVector[ 0 ])
  150. {
  151. case InEventLifeCycle_main_region_A :
  152. {
  153. inEventLifeCycle_exseq_main_region_A(handle);
  154. break;
  155. }
  156. default: break;
  157. }
  158. }
  159. /* The reactions of state A. */
  160. static void inEventLifeCycle_react_main_region_A(InEventLifeCycle* handle)
  161. {
  162. /* The reactions of state A. */
  163. if (inEventLifeCycle_check_main_region_A_lr0_lr0(handle) == bool_true)
  164. {
  165. inEventLifeCycle_effect_main_region_A_lr0_lr0(handle);
  166. }
  167. }
  168. /* Default react sequence for initial entry */
  169. static void inEventLifeCycle_react_main_region__entry_Default(InEventLifeCycle* handle)
  170. {
  171. /* Default react sequence for initial entry */
  172. inEventLifeCycle_enseq_main_region_A_default(handle);
  173. }