RaiseEvent.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #ifndef RAISEEVENT_H_
  2. #define RAISEEVENT_H_
  3. #include "sc_types.h"
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. /*! \file Header of the state machine 'RaiseEvent'.
  8. */
  9. /*! Enumeration of all states */
  10. typedef enum
  11. {
  12. RaiseEvent_main_region_StateA,
  13. RaiseEvent_main_region_StateB,
  14. RaiseEvent_second_region_SateA,
  15. RaiseEvent_second_region_StateB,
  16. RaiseEvent_last_state
  17. } RaiseEventStates;
  18. /*! Type definition of the data structure for the RaiseEventIface interface scope. */
  19. typedef struct
  20. {
  21. sc_boolean e1_raised;
  22. sc_boolean e2_raised;
  23. } RaiseEventIface;
  24. /*! Define dimension of the state configuration vector for orthogonal states. */
  25. #define RAISEEVENT_MAX_ORTHOGONAL_STATES 2
  26. /*!
  27. * Type definition of the data structure for the RaiseEvent state machine.
  28. * This data structure has to be allocated by the client code.
  29. */
  30. typedef struct
  31. {
  32. RaiseEventStates stateConfVector[RAISEEVENT_MAX_ORTHOGONAL_STATES];
  33. sc_ushort stateConfVectorPosition;
  34. RaiseEventIface iface;
  35. } RaiseEvent;
  36. /*! Initializes the RaiseEvent state machine data structures. Must be called before first usage.*/
  37. extern void raiseEvent_init(RaiseEvent* handle);
  38. /*! Activates the state machine */
  39. extern void raiseEvent_enter(RaiseEvent* handle);
  40. /*! Deactivates the state machine */
  41. extern void raiseEvent_exit(RaiseEvent* handle);
  42. /*! Performs a 'run to completion' step. */
  43. extern void raiseEvent_runCycle(RaiseEvent* handle);
  44. /*! Checks if the out event 'e1' that is defined in the default interface scope has been raised. */
  45. extern sc_boolean raiseEventIface_israised_e1(const RaiseEvent* handle);
  46. /*! Raises the in event 'e2' that is defined in the default interface scope. */
  47. extern void raiseEventIface_raise_e2(RaiseEvent* handle);
  48. /*!
  49. * Checks whether the state machine is active (until 2.4.1 this method was used for states).
  50. * 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.
  51. */
  52. extern sc_boolean raiseEvent_isActive(const RaiseEvent* handle);
  53. /*!
  54. * Checks if all active states are final.
  55. * If there are no active states then the state machine is considered being inactive. In this case this method returns false.
  56. */
  57. extern sc_boolean raiseEvent_isFinal(const RaiseEvent* handle);
  58. /*! Checks if the specified state is active (until 2.4.1 the used method for states was called isActive()). */
  59. extern sc_boolean raiseEvent_isStateActive(const RaiseEvent* handle, RaiseEventStates state);
  60. #ifdef __cplusplus
  61. }
  62. #endif
  63. #endif /* RAISEEVENT_H_ */