Parenthesis.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include "sc_types.h"
  4. #include "Parenthesis.h"
  5. /*! \file Implementation of the state machine 'Parenthesis'
  6. */
  7. /* prototypes of all internal functions */
  8. static void parenthesis_enact_mainRegion_A(Parenthesis* handle);
  9. static void parenthesis_enseq_mainRegion_A_default(Parenthesis* handle);
  10. static void parenthesis_enseq_mainRegion_default(Parenthesis* handle);
  11. static void parenthesis_exseq_mainRegion_A(Parenthesis* handle);
  12. static void parenthesis_exseq_mainRegion(Parenthesis* handle);
  13. static void parenthesis_react_mainRegion_A(Parenthesis* handle);
  14. static void parenthesis_react_mainRegion__entry_Default(Parenthesis* handle);
  15. static void parenthesis_clearInEvents(Parenthesis* handle);
  16. static void parenthesis_clearOutEvents(Parenthesis* handle);
  17. void parenthesis_init(Parenthesis* handle)
  18. {
  19. sc_integer i;
  20. for (i = 0; i < PARENTHESIS_MAX_ORTHOGONAL_STATES; ++i)
  21. {
  22. handle->stateConfVector[i] = Parenthesis_last_state;
  23. }
  24. handle->stateConfVectorPosition = 0;
  25. parenthesis_clearInEvents(handle);
  26. parenthesis_clearOutEvents(handle);
  27. /* Default init sequence for statechart Parenthesis */
  28. handle->iface.erg = 0;
  29. }
  30. void parenthesis_enter(Parenthesis* handle)
  31. {
  32. /* Default enter sequence for statechart Parenthesis */
  33. parenthesis_enseq_mainRegion_default(handle);
  34. }
  35. void parenthesis_exit(Parenthesis* handle)
  36. {
  37. /* Default exit sequence for statechart Parenthesis */
  38. parenthesis_exseq_mainRegion(handle);
  39. }
  40. sc_boolean parenthesis_isActive(const Parenthesis* handle)
  41. {
  42. sc_boolean result;
  43. if (handle->stateConfVector[0] != Parenthesis_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 parenthesis_isFinal(const Parenthesis* handle)
  57. {
  58. return bool_false;
  59. }
  60. static void parenthesis_clearInEvents(Parenthesis* handle)
  61. {
  62. }
  63. static void parenthesis_clearOutEvents(Parenthesis* handle)
  64. {
  65. }
  66. void parenthesis_runCycle(Parenthesis* handle)
  67. {
  68. parenthesis_clearOutEvents(handle);
  69. for (handle->stateConfVectorPosition = 0;
  70. handle->stateConfVectorPosition < PARENTHESIS_MAX_ORTHOGONAL_STATES;
  71. handle->stateConfVectorPosition++)
  72. {
  73. switch (handle->stateConfVector[handle->stateConfVectorPosition])
  74. {
  75. case Parenthesis_mainRegion_A :
  76. {
  77. parenthesis_react_mainRegion_A(handle);
  78. break;
  79. }
  80. default:
  81. break;
  82. }
  83. }
  84. parenthesis_clearInEvents(handle);
  85. }
  86. sc_boolean parenthesis_isStateActive(const Parenthesis* handle, ParenthesisStates state)
  87. {
  88. sc_boolean result = bool_false;
  89. switch (state)
  90. {
  91. case Parenthesis_mainRegion_A :
  92. result = (sc_boolean) (handle->stateConfVector[0] == Parenthesis_mainRegion_A
  93. );
  94. break;
  95. default:
  96. result = bool_false;
  97. break;
  98. }
  99. return result;
  100. }
  101. sc_integer parenthesisIface_get_erg(const Parenthesis* handle)
  102. {
  103. return handle->iface.erg;
  104. }
  105. void parenthesisIface_set_erg(Parenthesis* handle, sc_integer value)
  106. {
  107. handle->iface.erg = value;
  108. }
  109. /* implementations of all internal functions */
  110. /* Entry action for state 'A'. */
  111. static void parenthesis_enact_mainRegion_A(Parenthesis* handle)
  112. {
  113. /* Entry action for state 'A'. */
  114. handle->iface.erg = 4 * (3 - 1);
  115. }
  116. /* 'default' enter sequence for state A */
  117. static void parenthesis_enseq_mainRegion_A_default(Parenthesis* handle)
  118. {
  119. /* 'default' enter sequence for state A */
  120. parenthesis_enact_mainRegion_A(handle);
  121. handle->stateConfVector[0] = Parenthesis_mainRegion_A;
  122. handle->stateConfVectorPosition = 0;
  123. }
  124. /* 'default' enter sequence for region mainRegion */
  125. static void parenthesis_enseq_mainRegion_default(Parenthesis* handle)
  126. {
  127. /* 'default' enter sequence for region mainRegion */
  128. parenthesis_react_mainRegion__entry_Default(handle);
  129. }
  130. /* Default exit sequence for state A */
  131. static void parenthesis_exseq_mainRegion_A(Parenthesis* handle)
  132. {
  133. /* Default exit sequence for state A */
  134. handle->stateConfVector[0] = Parenthesis_last_state;
  135. handle->stateConfVectorPosition = 0;
  136. }
  137. /* Default exit sequence for region mainRegion */
  138. static void parenthesis_exseq_mainRegion(Parenthesis* handle)
  139. {
  140. /* Default exit sequence for region mainRegion */
  141. /* Handle exit of all possible states (of Parenthesis.mainRegion) at position 0... */
  142. switch(handle->stateConfVector[ 0 ])
  143. {
  144. case Parenthesis_mainRegion_A :
  145. {
  146. parenthesis_exseq_mainRegion_A(handle);
  147. break;
  148. }
  149. default: break;
  150. }
  151. }
  152. /* The reactions of state A. */
  153. static void parenthesis_react_mainRegion_A(Parenthesis* handle)
  154. {
  155. /* The reactions of state A. */
  156. }
  157. /* Default react sequence for initial entry */
  158. static void parenthesis_react_mainRegion__entry_Default(Parenthesis* handle)
  159. {
  160. /* Default react sequence for initial entry */
  161. parenthesis_enseq_mainRegion_A_default(handle);
  162. }