StatechartActive.c 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include "sc_types.h"
  4. #include "StatechartActive.h"
  5. /*! \file Implementation of the state machine 'StatechartActive'
  6. */
  7. /* prototypes of all internal functions */
  8. static void statechartActive_enseq_r_A_default(StatechartActive* handle);
  9. static void statechartActive_enseq_r_default(StatechartActive* handle);
  10. static void statechartActive_exseq_r_A(StatechartActive* handle);
  11. static void statechartActive_exseq_r(StatechartActive* handle);
  12. static void statechartActive_react_r_A(StatechartActive* handle);
  13. static void statechartActive_react_r__entry_Default(StatechartActive* handle);
  14. static void statechartActive_clearInEvents(StatechartActive* handle);
  15. static void statechartActive_clearOutEvents(StatechartActive* handle);
  16. void statechartActive_init(StatechartActive* handle)
  17. {
  18. sc_integer i;
  19. for (i = 0; i < STATECHARTACTIVE_MAX_ORTHOGONAL_STATES; ++i)
  20. {
  21. handle->stateConfVector[i] = StatechartActive_last_state;
  22. }
  23. handle->stateConfVectorPosition = 0;
  24. statechartActive_clearInEvents(handle);
  25. statechartActive_clearOutEvents(handle);
  26. }
  27. void statechartActive_enter(StatechartActive* handle)
  28. {
  29. /* Default enter sequence for statechart StatechartActive */
  30. statechartActive_enseq_r_default(handle);
  31. }
  32. void statechartActive_exit(StatechartActive* handle)
  33. {
  34. /* Default exit sequence for statechart StatechartActive */
  35. statechartActive_exseq_r(handle);
  36. }
  37. sc_boolean statechartActive_isActive(const StatechartActive* handle)
  38. {
  39. sc_boolean result;
  40. if (handle->stateConfVector[0] != StatechartActive_last_state)
  41. {
  42. result = bool_true;
  43. }
  44. else
  45. {
  46. result = bool_false;
  47. }
  48. return result;
  49. }
  50. /*
  51. * Always returns 'false' since this state machine can never become final.
  52. */
  53. sc_boolean statechartActive_isFinal(const StatechartActive* handle)
  54. {
  55. return bool_false;
  56. }
  57. static void statechartActive_clearInEvents(StatechartActive* handle)
  58. {
  59. }
  60. static void statechartActive_clearOutEvents(StatechartActive* handle)
  61. {
  62. }
  63. void statechartActive_runCycle(StatechartActive* handle)
  64. {
  65. statechartActive_clearOutEvents(handle);
  66. for (handle->stateConfVectorPosition = 0;
  67. handle->stateConfVectorPosition < STATECHARTACTIVE_MAX_ORTHOGONAL_STATES;
  68. handle->stateConfVectorPosition++)
  69. {
  70. switch (handle->stateConfVector[handle->stateConfVectorPosition])
  71. {
  72. case StatechartActive_r_A :
  73. {
  74. statechartActive_react_r_A(handle);
  75. break;
  76. }
  77. default:
  78. break;
  79. }
  80. }
  81. statechartActive_clearInEvents(handle);
  82. }
  83. sc_boolean statechartActive_isStateActive(const StatechartActive* handle, StatechartActiveStates state)
  84. {
  85. sc_boolean result = bool_false;
  86. switch (state)
  87. {
  88. case StatechartActive_r_A :
  89. result = (sc_boolean) (handle->stateConfVector[0] == StatechartActive_r_A
  90. );
  91. break;
  92. default:
  93. result = bool_false;
  94. break;
  95. }
  96. return result;
  97. }
  98. /* implementations of all internal functions */
  99. /* 'default' enter sequence for state A */
  100. static void statechartActive_enseq_r_A_default(StatechartActive* handle)
  101. {
  102. /* 'default' enter sequence for state A */
  103. handle->stateConfVector[0] = StatechartActive_r_A;
  104. handle->stateConfVectorPosition = 0;
  105. }
  106. /* 'default' enter sequence for region r */
  107. static void statechartActive_enseq_r_default(StatechartActive* handle)
  108. {
  109. /* 'default' enter sequence for region r */
  110. statechartActive_react_r__entry_Default(handle);
  111. }
  112. /* Default exit sequence for state A */
  113. static void statechartActive_exseq_r_A(StatechartActive* handle)
  114. {
  115. /* Default exit sequence for state A */
  116. handle->stateConfVector[0] = StatechartActive_last_state;
  117. handle->stateConfVectorPosition = 0;
  118. }
  119. /* Default exit sequence for region r */
  120. static void statechartActive_exseq_r(StatechartActive* handle)
  121. {
  122. /* Default exit sequence for region r */
  123. /* Handle exit of all possible states (of StatechartActive.r) at position 0... */
  124. switch(handle->stateConfVector[ 0 ])
  125. {
  126. case StatechartActive_r_A :
  127. {
  128. statechartActive_exseq_r_A(handle);
  129. break;
  130. }
  131. default: break;
  132. }
  133. }
  134. /* The reactions of state A. */
  135. static void statechartActive_react_r_A(StatechartActive* handle)
  136. {
  137. /* The reactions of state A. */
  138. }
  139. /* Default react sequence for initial entry */
  140. static void statechartActive_react_r__entry_Default(StatechartActive* handle)
  141. {
  142. /* Default react sequence for initial entry */
  143. statechartActive_enseq_r_A_default(handle);
  144. }