EntryChoice.c 4.8 KB

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