Parenthesis.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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 = bool_false;
  43. int i;
  44. for(i = 0; i < PARENTHESIS_MAX_ORTHOGONAL_STATES; i++)
  45. {
  46. result = result || handle->stateConfVector[i] != Parenthesis_last_state;
  47. }
  48. return result;
  49. }
  50. /*
  51. * Always returns 'false' since this state machine can never become final.
  52. */
  53. sc_boolean parenthesis_isFinal(const Parenthesis* handle)
  54. {
  55. return bool_false;
  56. }
  57. static void parenthesis_clearInEvents(Parenthesis* handle)
  58. {
  59. }
  60. static void parenthesis_clearOutEvents(Parenthesis* handle)
  61. {
  62. }
  63. void parenthesis_runCycle(Parenthesis* handle)
  64. {
  65. parenthesis_clearOutEvents(handle);
  66. for (handle->stateConfVectorPosition = 0;
  67. handle->stateConfVectorPosition < PARENTHESIS_MAX_ORTHOGONAL_STATES;
  68. handle->stateConfVectorPosition++)
  69. {
  70. switch (handle->stateConfVector[handle->stateConfVectorPosition])
  71. {
  72. case Parenthesis_mainRegion_A :
  73. {
  74. parenthesis_react_mainRegion_A(handle);
  75. break;
  76. }
  77. default:
  78. break;
  79. }
  80. }
  81. parenthesis_clearInEvents(handle);
  82. }
  83. sc_boolean parenthesis_isStateActive(const Parenthesis* handle, ParenthesisStates state)
  84. {
  85. sc_boolean result = bool_false;
  86. switch (state)
  87. {
  88. case Parenthesis_mainRegion_A :
  89. result = (sc_boolean) (handle->stateConfVector[SCVI_PARENTHESIS_MAINREGION_A] == Parenthesis_mainRegion_A
  90. );
  91. break;
  92. default:
  93. result = bool_false;
  94. break;
  95. }
  96. return result;
  97. }
  98. sc_integer parenthesisIface_get_erg(const Parenthesis* handle)
  99. {
  100. return handle->iface.erg;
  101. }
  102. void parenthesisIface_set_erg(Parenthesis* handle, sc_integer value)
  103. {
  104. handle->iface.erg = value;
  105. }
  106. /* implementations of all internal functions */
  107. /* Entry action for state 'A'. */
  108. static void parenthesis_enact_mainRegion_A(Parenthesis* handle)
  109. {
  110. /* Entry action for state 'A'. */
  111. handle->iface.erg = 4 * (3 - 1);
  112. }
  113. /* 'default' enter sequence for state A */
  114. static void parenthesis_enseq_mainRegion_A_default(Parenthesis* handle)
  115. {
  116. /* 'default' enter sequence for state A */
  117. parenthesis_enact_mainRegion_A(handle);
  118. handle->stateConfVector[0] = Parenthesis_mainRegion_A;
  119. handle->stateConfVectorPosition = 0;
  120. }
  121. /* 'default' enter sequence for region mainRegion */
  122. static void parenthesis_enseq_mainRegion_default(Parenthesis* handle)
  123. {
  124. /* 'default' enter sequence for region mainRegion */
  125. parenthesis_react_mainRegion__entry_Default(handle);
  126. }
  127. /* Default exit sequence for state A */
  128. static void parenthesis_exseq_mainRegion_A(Parenthesis* handle)
  129. {
  130. /* Default exit sequence for state A */
  131. handle->stateConfVector[0] = Parenthesis_last_state;
  132. handle->stateConfVectorPosition = 0;
  133. }
  134. /* Default exit sequence for region mainRegion */
  135. static void parenthesis_exseq_mainRegion(Parenthesis* handle)
  136. {
  137. /* Default exit sequence for region mainRegion */
  138. /* Handle exit of all possible states (of Parenthesis.mainRegion) at position 0... */
  139. switch(handle->stateConfVector[ 0 ])
  140. {
  141. case Parenthesis_mainRegion_A :
  142. {
  143. parenthesis_exseq_mainRegion_A(handle);
  144. break;
  145. }
  146. default: break;
  147. }
  148. }
  149. /* The reactions of state A. */
  150. static void parenthesis_react_mainRegion_A(Parenthesis* handle)
  151. {
  152. /* The reactions of state A. */
  153. }
  154. /* Default react sequence for initial entry */
  155. static void parenthesis_react_mainRegion__entry_Default(Parenthesis* handle)
  156. {
  157. /* Default react sequence for initial entry */
  158. parenthesis_enseq_mainRegion_A_default(handle);
  159. }