InEventLifeCycle.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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 = bool_false;
  44. int i;
  45. for(i = 0; i < INEVENTLIFECYCLE_MAX_ORTHOGONAL_STATES; i++)
  46. {
  47. result = result || handle->stateConfVector[i] != InEventLifeCycle_last_state;
  48. }
  49. return result;
  50. }
  51. /*
  52. * Always returns 'false' since this state machine can never become final.
  53. */
  54. sc_boolean inEventLifeCycle_isFinal(const InEventLifeCycle* handle)
  55. {
  56. return bool_false;
  57. }
  58. static void inEventLifeCycle_clearInEvents(InEventLifeCycle* handle)
  59. {
  60. handle->iface.e_raised = bool_false;
  61. }
  62. static void inEventLifeCycle_clearOutEvents(InEventLifeCycle* handle)
  63. {
  64. }
  65. void inEventLifeCycle_runCycle(InEventLifeCycle* handle)
  66. {
  67. inEventLifeCycle_clearOutEvents(handle);
  68. for (handle->stateConfVectorPosition = 0;
  69. handle->stateConfVectorPosition < INEVENTLIFECYCLE_MAX_ORTHOGONAL_STATES;
  70. handle->stateConfVectorPosition++)
  71. {
  72. switch (handle->stateConfVector[handle->stateConfVectorPosition])
  73. {
  74. case InEventLifeCycle_main_region_A :
  75. {
  76. inEventLifeCycle_react_main_region_A(handle);
  77. break;
  78. }
  79. default:
  80. break;
  81. }
  82. }
  83. inEventLifeCycle_clearInEvents(handle);
  84. }
  85. sc_boolean inEventLifeCycle_isStateActive(const InEventLifeCycle* handle, InEventLifeCycleStates state)
  86. {
  87. sc_boolean result = bool_false;
  88. switch (state)
  89. {
  90. case InEventLifeCycle_main_region_A :
  91. result = (sc_boolean) (handle->stateConfVector[SCVI_INEVENTLIFECYCLE_MAIN_REGION_A] == InEventLifeCycle_main_region_A
  92. );
  93. break;
  94. default:
  95. result = bool_false;
  96. break;
  97. }
  98. return result;
  99. }
  100. void inEventLifeCycleIface_raise_e(InEventLifeCycle* handle)
  101. {
  102. handle->iface.e_raised = bool_true;
  103. }
  104. sc_integer inEventLifeCycleIface_get_i(const InEventLifeCycle* handle)
  105. {
  106. return handle->iface.i;
  107. }
  108. void inEventLifeCycleIface_set_i(InEventLifeCycle* handle, sc_integer value)
  109. {
  110. handle->iface.i = value;
  111. }
  112. /* implementations of all internal functions */
  113. static sc_boolean inEventLifeCycle_check_main_region_A_lr0_lr0(const InEventLifeCycle* handle)
  114. {
  115. return handle->iface.e_raised;
  116. }
  117. static void inEventLifeCycle_effect_main_region_A_lr0_lr0(InEventLifeCycle* handle)
  118. {
  119. handle->iface.i += 1;
  120. }
  121. /* 'default' enter sequence for state A */
  122. static void inEventLifeCycle_enseq_main_region_A_default(InEventLifeCycle* handle)
  123. {
  124. /* 'default' enter sequence for state A */
  125. handle->stateConfVector[0] = InEventLifeCycle_main_region_A;
  126. handle->stateConfVectorPosition = 0;
  127. }
  128. /* 'default' enter sequence for region main region */
  129. static void inEventLifeCycle_enseq_main_region_default(InEventLifeCycle* handle)
  130. {
  131. /* 'default' enter sequence for region main region */
  132. inEventLifeCycle_react_main_region__entry_Default(handle);
  133. }
  134. /* Default exit sequence for state A */
  135. static void inEventLifeCycle_exseq_main_region_A(InEventLifeCycle* handle)
  136. {
  137. /* Default exit sequence for state A */
  138. handle->stateConfVector[0] = InEventLifeCycle_last_state;
  139. handle->stateConfVectorPosition = 0;
  140. }
  141. /* Default exit sequence for region main region */
  142. static void inEventLifeCycle_exseq_main_region(InEventLifeCycle* handle)
  143. {
  144. /* Default exit sequence for region main region */
  145. /* Handle exit of all possible states (of InEventLifeCycle.main_region) at position 0... */
  146. switch(handle->stateConfVector[ 0 ])
  147. {
  148. case InEventLifeCycle_main_region_A :
  149. {
  150. inEventLifeCycle_exseq_main_region_A(handle);
  151. break;
  152. }
  153. default: break;
  154. }
  155. }
  156. /* The reactions of state A. */
  157. static void inEventLifeCycle_react_main_region_A(InEventLifeCycle* handle)
  158. {
  159. /* The reactions of state A. */
  160. if (inEventLifeCycle_check_main_region_A_lr0_lr0(handle) == bool_true)
  161. {
  162. inEventLifeCycle_effect_main_region_A_lr0_lr0(handle);
  163. }
  164. }
  165. /* Default react sequence for initial entry */
  166. static void inEventLifeCycle_react_main_region__entry_Default(InEventLifeCycle* handle)
  167. {
  168. /* Default react sequence for initial entry */
  169. inEventLifeCycle_enseq_main_region_A_default(handle);
  170. }