SyncJoin.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #ifndef SYNCJOIN_H_
  2. #define SYNCJOIN_H_
  3. #include "sc_types.h"
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. /*! \file Header of the state machine 'SyncJoin'.
  8. */
  9. /*! Enumeration of all states */
  10. typedef enum
  11. {
  12. SyncJoin_last_state,
  13. SyncJoin_main_region_A,
  14. SyncJoin_main_region_B,
  15. SyncJoin_main_region_B_r1_C1,
  16. SyncJoin_main_region_B_r1_C2,
  17. SyncJoin_main_region_B_r2_D1,
  18. SyncJoin_main_region_B_r2_D2
  19. } SyncJoinStates;
  20. /*! Type definition of the data structure for the SyncJoinIface interface scope. */
  21. typedef struct
  22. {
  23. sc_boolean e_raised;
  24. sc_boolean f_raised;
  25. sc_boolean jc_raised;
  26. sc_boolean jd_raised;
  27. sc_integer x;
  28. } SyncJoinIface;
  29. /*! Define dimension of the state configuration vector for orthogonal states. */
  30. #define SYNCJOIN_MAX_ORTHOGONAL_STATES 2
  31. /*! Define indices of states in the StateConfVector */
  32. #define SCVI_SYNCJOIN_MAIN_REGION_A 0
  33. #define SCVI_SYNCJOIN_MAIN_REGION_B 0
  34. #define SCVI_SYNCJOIN_MAIN_REGION_B_R1_C1 0
  35. #define SCVI_SYNCJOIN_MAIN_REGION_B_R1_C2 0
  36. #define SCVI_SYNCJOIN_MAIN_REGION_B_R2_D1 1
  37. #define SCVI_SYNCJOIN_MAIN_REGION_B_R2_D2 1
  38. /*!
  39. * Type definition of the data structure for the SyncJoin state machine.
  40. * This data structure has to be allocated by the client code.
  41. */
  42. typedef struct
  43. {
  44. SyncJoinStates stateConfVector[SYNCJOIN_MAX_ORTHOGONAL_STATES];
  45. sc_ushort stateConfVectorPosition;
  46. SyncJoinIface iface;
  47. } SyncJoin;
  48. /*! Initializes the SyncJoin state machine data structures. Must be called before first usage.*/
  49. extern void syncJoin_init(SyncJoin* handle);
  50. /*! Activates the state machine */
  51. extern void syncJoin_enter(SyncJoin* handle);
  52. /*! Deactivates the state machine */
  53. extern void syncJoin_exit(SyncJoin* handle);
  54. /*! Performs a 'run to completion' step. */
  55. extern void syncJoin_runCycle(SyncJoin* handle);
  56. /*! Raises the in event 'e' that is defined in the default interface scope. */
  57. extern void syncJoinIface_raise_e(SyncJoin* handle);
  58. /*! Raises the in event 'f' that is defined in the default interface scope. */
  59. extern void syncJoinIface_raise_f(SyncJoin* handle);
  60. /*! Raises the in event 'jc' that is defined in the default interface scope. */
  61. extern void syncJoinIface_raise_jc(SyncJoin* handle);
  62. /*! Raises the in event 'jd' that is defined in the default interface scope. */
  63. extern void syncJoinIface_raise_jd(SyncJoin* handle);
  64. /*! Gets the value of the variable 'x' that is defined in the default interface scope. */
  65. extern sc_integer syncJoinIface_get_x(const SyncJoin* handle);
  66. /*! Sets the value of the variable 'x' that is defined in the default interface scope. */
  67. extern void syncJoinIface_set_x(SyncJoin* handle, sc_integer value);
  68. /*!
  69. * Checks whether the state machine is active (until 2.4.1 this method was used for states).
  70. * A state machine is active if it was entered. It is inactive if it has not been entered at all or if it has been exited.
  71. */
  72. extern sc_boolean syncJoin_isActive(const SyncJoin* handle);
  73. /*!
  74. * Checks if all active states are final.
  75. * If there are no active states then the state machine is considered being inactive. In this case this method returns false.
  76. */
  77. extern sc_boolean syncJoin_isFinal(const SyncJoin* handle);
  78. /*! Checks if the specified state is active (until 2.4.1 the used method for states was called isActive()). */
  79. extern sc_boolean syncJoin_isStateActive(const SyncJoin* handle, SyncJoinStates state);
  80. #ifdef __cplusplus
  81. }
  82. #endif
  83. #endif /* SYNCJOIN_H_ */