SyncFork.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #ifndef SYNCFORK_H_
  2. #define SYNCFORK_H_
  3. #include "sc_types.h"
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. /*! \file Header of the state machine 'SyncFork'.
  8. */
  9. /*! Enumeration of all states */
  10. typedef enum
  11. {
  12. SyncFork_main_region_A,
  13. SyncFork_main_region_B,
  14. SyncFork_main_region_B_r1_C1,
  15. SyncFork_main_region_B_r1_C2,
  16. SyncFork_main_region_B_r2_D1,
  17. SyncFork_main_region_B_r2_D2,
  18. SyncFork_last_state
  19. } SyncForkStates;
  20. /*! Type definition of the data structure for the SyncForkIface interface scope. */
  21. typedef struct
  22. {
  23. sc_boolean e_raised;
  24. sc_boolean f_raised;
  25. } SyncForkIface;
  26. /*! Define dimension of the state configuration vector for orthogonal states. */
  27. #define SYNCFORK_MAX_ORTHOGONAL_STATES 2
  28. /*!
  29. * Type definition of the data structure for the SyncFork state machine.
  30. * This data structure has to be allocated by the client code.
  31. */
  32. typedef struct
  33. {
  34. SyncForkStates stateConfVector[SYNCFORK_MAX_ORTHOGONAL_STATES];
  35. sc_ushort stateConfVectorPosition;
  36. SyncForkIface iface;
  37. } SyncFork;
  38. /*! Initializes the SyncFork state machine data structures. Must be called before first usage.*/
  39. extern void syncFork_init(SyncFork* handle);
  40. /*! Activates the state machine */
  41. extern void syncFork_enter(SyncFork* handle);
  42. /*! Deactivates the state machine */
  43. extern void syncFork_exit(SyncFork* handle);
  44. /*! Performs a 'run to completion' step. */
  45. extern void syncFork_runCycle(SyncFork* handle);
  46. /*! Raises the in event 'e' that is defined in the default interface scope. */
  47. extern void syncForkIface_raise_e(SyncFork* handle);
  48. /*! Raises the in event 'f' that is defined in the default interface scope. */
  49. extern void syncForkIface_raise_f(SyncFork* handle);
  50. /*!
  51. * Checks whether the state machine is active (until 2.4.1 this method was used for states).
  52. * 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.
  53. */
  54. extern sc_boolean syncFork_isActive(const SyncFork* handle);
  55. /*!
  56. * Checks if all active states are final.
  57. * If there are no active states then the state machine is considered being inactive. In this case this method returns false.
  58. */
  59. extern sc_boolean syncFork_isFinal(const SyncFork* handle);
  60. /*! Checks if the specified state is active (until 2.4.1 the used method for states was called isActive()). */
  61. extern sc_boolean syncFork_isStateActive(const SyncFork* handle, SyncForkStates state);
  62. #ifdef __cplusplus
  63. }
  64. #endif
  65. #endif /* SYNCFORK_H_ */