StatechartActive.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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 = bool_false;
  40. int i;
  41. for(i = 0; i < STATECHARTACTIVE_MAX_ORTHOGONAL_STATES; i++)
  42. {
  43. result = result || handle->stateConfVector[i] != StatechartActive_last_state;
  44. }
  45. return result;
  46. }
  47. /*
  48. * Always returns 'false' since this state machine can never become final.
  49. */
  50. sc_boolean statechartActive_isFinal(const StatechartActive* handle)
  51. {
  52. return bool_false;
  53. }
  54. static void statechartActive_clearInEvents(StatechartActive* handle)
  55. {
  56. }
  57. static void statechartActive_clearOutEvents(StatechartActive* handle)
  58. {
  59. }
  60. void statechartActive_runCycle(StatechartActive* handle)
  61. {
  62. statechartActive_clearOutEvents(handle);
  63. for (handle->stateConfVectorPosition = 0;
  64. handle->stateConfVectorPosition < STATECHARTACTIVE_MAX_ORTHOGONAL_STATES;
  65. handle->stateConfVectorPosition++)
  66. {
  67. switch (handle->stateConfVector[handle->stateConfVectorPosition])
  68. {
  69. case StatechartActive_r_A :
  70. {
  71. statechartActive_react_r_A(handle);
  72. break;
  73. }
  74. default:
  75. break;
  76. }
  77. }
  78. statechartActive_clearInEvents(handle);
  79. }
  80. sc_boolean statechartActive_isStateActive(const StatechartActive* handle, StatechartActiveStates state)
  81. {
  82. sc_boolean result = bool_false;
  83. switch (state)
  84. {
  85. case StatechartActive_r_A :
  86. result = (sc_boolean) (handle->stateConfVector[SCVI_STATECHARTACTIVE_R_A] == StatechartActive_r_A
  87. );
  88. break;
  89. default:
  90. result = bool_false;
  91. break;
  92. }
  93. return result;
  94. }
  95. /* implementations of all internal functions */
  96. /* 'default' enter sequence for state A */
  97. static void statechartActive_enseq_r_A_default(StatechartActive* handle)
  98. {
  99. /* 'default' enter sequence for state A */
  100. handle->stateConfVector[0] = StatechartActive_r_A;
  101. handle->stateConfVectorPosition = 0;
  102. }
  103. /* 'default' enter sequence for region r */
  104. static void statechartActive_enseq_r_default(StatechartActive* handle)
  105. {
  106. /* 'default' enter sequence for region r */
  107. statechartActive_react_r__entry_Default(handle);
  108. }
  109. /* Default exit sequence for state A */
  110. static void statechartActive_exseq_r_A(StatechartActive* handle)
  111. {
  112. /* Default exit sequence for state A */
  113. handle->stateConfVector[0] = StatechartActive_last_state;
  114. handle->stateConfVectorPosition = 0;
  115. }
  116. /* Default exit sequence for region r */
  117. static void statechartActive_exseq_r(StatechartActive* handle)
  118. {
  119. /* Default exit sequence for region r */
  120. /* Handle exit of all possible states (of StatechartActive.r) at position 0... */
  121. switch(handle->stateConfVector[ 0 ])
  122. {
  123. case StatechartActive_r_A :
  124. {
  125. statechartActive_exseq_r_A(handle);
  126. break;
  127. }
  128. default: break;
  129. }
  130. }
  131. /* The reactions of state A. */
  132. static void statechartActive_react_r_A(StatechartActive* handle)
  133. {
  134. /* The reactions of state A. */
  135. }
  136. /* Default react sequence for initial entry */
  137. static void statechartActive_react_r__entry_Default(StatechartActive* handle)
  138. {
  139. /* Default react sequence for initial entry */
  140. statechartActive_enseq_r_A_default(handle);
  141. }