LogicalOr.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. #include <stdlib.h>
  2. #include <string.h>
  3. #include "sc_types.h"
  4. #include "LogicalOr.h"
  5. /*! \file Implementation of the state machine 'LogicalOr'
  6. */
  7. /* prototypes of all internal functions */
  8. static sc_boolean logicalOr_check_main_region_A_tr0_tr0(const LogicalOr* handle);
  9. static void logicalOr_effect_main_region_A_tr0(LogicalOr* handle);
  10. static void logicalOr_enseq_main_region_A_default(LogicalOr* handle);
  11. static void logicalOr_enseq_main_region_default(LogicalOr* handle);
  12. static void logicalOr_exseq_main_region_A(LogicalOr* handle);
  13. static void logicalOr_exseq_main_region(LogicalOr* handle);
  14. static void logicalOr_react_main_region_A(LogicalOr* handle);
  15. static void logicalOr_react_main_region__entry_Default(LogicalOr* handle);
  16. static void logicalOr_clearInEvents(LogicalOr* handle);
  17. static void logicalOr_clearOutEvents(LogicalOr* handle);
  18. void logicalOr_init(LogicalOr* handle)
  19. {
  20. sc_integer i;
  21. for (i = 0; i < LOGICALOR_MAX_ORTHOGONAL_STATES; ++i)
  22. {
  23. handle->stateConfVector[i] = LogicalOr_last_state;
  24. }
  25. handle->stateConfVectorPosition = 0;
  26. logicalOr_clearInEvents(handle);
  27. logicalOr_clearOutEvents(handle);
  28. /* Default init sequence for statechart LogicalOr */
  29. handle->iface.x = 1;
  30. handle->iface.b = bool_false;
  31. }
  32. void logicalOr_enter(LogicalOr* handle)
  33. {
  34. /* Default enter sequence for statechart LogicalOr */
  35. logicalOr_enseq_main_region_default(handle);
  36. }
  37. void logicalOr_exit(LogicalOr* handle)
  38. {
  39. /* Default exit sequence for statechart LogicalOr */
  40. logicalOr_exseq_main_region(handle);
  41. }
  42. sc_boolean logicalOr_isActive(const LogicalOr* handle)
  43. {
  44. sc_boolean result;
  45. if (handle->stateConfVector[0] != LogicalOr_last_state)
  46. {
  47. result = bool_true;
  48. }
  49. else
  50. {
  51. result = bool_false;
  52. }
  53. return result;
  54. }
  55. /*
  56. * Always returns 'false' since this state machine can never become final.
  57. */
  58. sc_boolean logicalOr_isFinal(const LogicalOr* handle)
  59. {
  60. return bool_false;
  61. }
  62. static void logicalOr_clearInEvents(LogicalOr* handle)
  63. {
  64. }
  65. static void logicalOr_clearOutEvents(LogicalOr* handle)
  66. {
  67. }
  68. void logicalOr_runCycle(LogicalOr* handle)
  69. {
  70. logicalOr_clearOutEvents(handle);
  71. for (handle->stateConfVectorPosition = 0;
  72. handle->stateConfVectorPosition < LOGICALOR_MAX_ORTHOGONAL_STATES;
  73. handle->stateConfVectorPosition++)
  74. {
  75. switch (handle->stateConfVector[handle->stateConfVectorPosition])
  76. {
  77. case LogicalOr_main_region_A :
  78. {
  79. logicalOr_react_main_region_A(handle);
  80. break;
  81. }
  82. default:
  83. break;
  84. }
  85. }
  86. logicalOr_clearInEvents(handle);
  87. }
  88. sc_boolean logicalOr_isStateActive(const LogicalOr* handle, LogicalOrStates state)
  89. {
  90. sc_boolean result = bool_false;
  91. switch (state)
  92. {
  93. case LogicalOr_main_region_A :
  94. result = (sc_boolean) (handle->stateConfVector[0] == LogicalOr_main_region_A
  95. );
  96. break;
  97. default:
  98. result = bool_false;
  99. break;
  100. }
  101. return result;
  102. }
  103. sc_integer logicalOrIface_get_x(const LogicalOr* handle)
  104. {
  105. return handle->iface.x;
  106. }
  107. void logicalOrIface_set_x(LogicalOr* handle, sc_integer value)
  108. {
  109. handle->iface.x = value;
  110. }
  111. sc_boolean logicalOrIface_get_b(const LogicalOr* handle)
  112. {
  113. return handle->iface.b;
  114. }
  115. void logicalOrIface_set_b(LogicalOr* handle, sc_boolean value)
  116. {
  117. handle->iface.b = value;
  118. }
  119. /* implementations of all internal functions */
  120. static sc_boolean logicalOr_check_main_region_A_tr0_tr0(const LogicalOr* handle)
  121. {
  122. return (handle->iface.x == 1) ? bool_true : bool_false;
  123. }
  124. static void logicalOr_effect_main_region_A_tr0(LogicalOr* handle)
  125. {
  126. logicalOr_exseq_main_region_A(handle);
  127. handle->iface.b = ((handle->iface.x += 1) != 2 || (handle->iface.x *= 2) == 4);
  128. logicalOr_enseq_main_region_A_default(handle);
  129. }
  130. /* 'default' enter sequence for state A */
  131. static void logicalOr_enseq_main_region_A_default(LogicalOr* handle)
  132. {
  133. /* 'default' enter sequence for state A */
  134. handle->stateConfVector[0] = LogicalOr_main_region_A;
  135. handle->stateConfVectorPosition = 0;
  136. }
  137. /* 'default' enter sequence for region main region */
  138. static void logicalOr_enseq_main_region_default(LogicalOr* handle)
  139. {
  140. /* 'default' enter sequence for region main region */
  141. logicalOr_react_main_region__entry_Default(handle);
  142. }
  143. /* Default exit sequence for state A */
  144. static void logicalOr_exseq_main_region_A(LogicalOr* handle)
  145. {
  146. /* Default exit sequence for state A */
  147. handle->stateConfVector[0] = LogicalOr_last_state;
  148. handle->stateConfVectorPosition = 0;
  149. }
  150. /* Default exit sequence for region main region */
  151. static void logicalOr_exseq_main_region(LogicalOr* handle)
  152. {
  153. /* Default exit sequence for region main region */
  154. /* Handle exit of all possible states (of LogicalOr.main_region) at position 0... */
  155. switch(handle->stateConfVector[ 0 ])
  156. {
  157. case LogicalOr_main_region_A :
  158. {
  159. logicalOr_exseq_main_region_A(handle);
  160. break;
  161. }
  162. default: break;
  163. }
  164. }
  165. /* The reactions of state A. */
  166. static void logicalOr_react_main_region_A(LogicalOr* handle)
  167. {
  168. /* The reactions of state A. */
  169. if (logicalOr_check_main_region_A_tr0_tr0(handle) == bool_true)
  170. {
  171. logicalOr_effect_main_region_A_tr0(handle);
  172. }
  173. }
  174. /* Default react sequence for initial entry */
  175. static void logicalOr_react_main_region__entry_Default(LogicalOr* handle)
  176. {
  177. /* Default react sequence for initial entry */
  178. logicalOr_enseq_main_region_A_default(handle);
  179. }