EntryChoice.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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 = bool_false;
  43. int i;
  44. for(i = 0; i < ENTRYCHOICE_MAX_ORTHOGONAL_STATES; i++)
  45. {
  46. result = result || handle->stateConfVector[i] != EntryChoice_last_state;
  47. }
  48. return result;
  49. }
  50. /*
  51. * Always returns 'false' since this state machine can never become final.
  52. */
  53. sc_boolean entryChoice_isFinal(const EntryChoice* handle)
  54. {
  55. return bool_false;
  56. }
  57. static void entryChoice_clearInEvents(EntryChoice* handle)
  58. {
  59. }
  60. static void entryChoice_clearOutEvents(EntryChoice* handle)
  61. {
  62. }
  63. void entryChoice_runCycle(EntryChoice* handle)
  64. {
  65. entryChoice_clearOutEvents(handle);
  66. for (handle->stateConfVectorPosition = 0;
  67. handle->stateConfVectorPosition < ENTRYCHOICE_MAX_ORTHOGONAL_STATES;
  68. handle->stateConfVectorPosition++)
  69. {
  70. switch (handle->stateConfVector[handle->stateConfVectorPosition])
  71. {
  72. case EntryChoice_main_region_A :
  73. {
  74. entryChoice_react_main_region_A(handle);
  75. break;
  76. }
  77. default:
  78. break;
  79. }
  80. }
  81. entryChoice_clearInEvents(handle);
  82. }
  83. sc_boolean entryChoice_isStateActive(const EntryChoice* handle, EntryChoiceStates state)
  84. {
  85. sc_boolean result = bool_false;
  86. switch (state)
  87. {
  88. case EntryChoice_main_region_A :
  89. result = (sc_boolean) (handle->stateConfVector[SCVI_ENTRYCHOICE_MAIN_REGION_A] == EntryChoice_main_region_A
  90. );
  91. break;
  92. default:
  93. result = bool_false;
  94. break;
  95. }
  96. return result;
  97. }
  98. /* implementations of all internal functions */
  99. static sc_boolean entryChoice_check_main_region__choice_0_tr0_tr0(const EntryChoice* handle)
  100. {
  101. return bool_true;
  102. }
  103. static void entryChoice_effect_main_region__choice_0_tr0(EntryChoice* handle)
  104. {
  105. entryChoice_enseq_main_region_A_default(handle);
  106. }
  107. /* 'default' enter sequence for state A */
  108. static void entryChoice_enseq_main_region_A_default(EntryChoice* handle)
  109. {
  110. /* 'default' enter sequence for state A */
  111. handle->stateConfVector[0] = EntryChoice_main_region_A;
  112. handle->stateConfVectorPosition = 0;
  113. }
  114. /* 'default' enter sequence for region main region */
  115. static void entryChoice_enseq_main_region_default(EntryChoice* handle)
  116. {
  117. /* 'default' enter sequence for region main region */
  118. entryChoice_react_main_region__entry_Default(handle);
  119. }
  120. /* Default exit sequence for state A */
  121. static void entryChoice_exseq_main_region_A(EntryChoice* handle)
  122. {
  123. /* Default exit sequence for state A */
  124. handle->stateConfVector[0] = EntryChoice_last_state;
  125. handle->stateConfVectorPosition = 0;
  126. }
  127. /* Default exit sequence for region main region */
  128. static void entryChoice_exseq_main_region(EntryChoice* handle)
  129. {
  130. /* Default exit sequence for region main region */
  131. /* Handle exit of all possible states (of EntryChoice.main_region) at position 0... */
  132. switch(handle->stateConfVector[ 0 ])
  133. {
  134. case EntryChoice_main_region_A :
  135. {
  136. entryChoice_exseq_main_region_A(handle);
  137. break;
  138. }
  139. default: break;
  140. }
  141. }
  142. /* The reactions of state A. */
  143. static void entryChoice_react_main_region_A(EntryChoice* handle)
  144. {
  145. /* The reactions of state A. */
  146. }
  147. /* The reactions of state null. */
  148. static void entryChoice_react_main_region__choice_0(EntryChoice* handle)
  149. {
  150. /* The reactions of state null. */
  151. entryChoice_effect_main_region__choice_0_tr0(handle);
  152. }
  153. /* Default react sequence for initial entry */
  154. static void entryChoice_react_main_region__entry_Default(EntryChoice* handle)
  155. {
  156. /* Default react sequence for initial entry */
  157. entryChoice_react_main_region__choice_0(handle);
  158. }