RaiseEvent.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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_last_state,
  13. RaiseEvent_main_region_StateA,
  14. RaiseEvent_main_region_StateB,
  15. RaiseEvent_second_region_SateA,
  16. RaiseEvent_second_region_StateB
  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. /*! Define indices of states in the StateConfVector */
  27. #define SCVI_RAISEEVENT_MAIN_REGION_STATEA 0
  28. #define SCVI_RAISEEVENT_MAIN_REGION_STATEB 0
  29. #define SCVI_RAISEEVENT_SECOND_REGION_SATEA 1
  30. #define SCVI_RAISEEVENT_SECOND_REGION_STATEB 1
  31. /*!
  32. * Type definition of the data structure for the RaiseEvent state machine.
  33. * This data structure has to be allocated by the client code.
  34. */
  35. typedef struct
  36. {
  37. RaiseEventStates stateConfVector[RAISEEVENT_MAX_ORTHOGONAL_STATES];
  38. sc_ushort stateConfVectorPosition;
  39. RaiseEventIface iface;
  40. } RaiseEvent;
  41. /*! Initializes the RaiseEvent state machine data structures. Must be called before first usage.*/
  42. extern void raiseEvent_init(RaiseEvent* handle);
  43. /*! Activates the state machine */
  44. extern void raiseEvent_enter(RaiseEvent* handle);
  45. /*! Deactivates the state machine */
  46. extern void raiseEvent_exit(RaiseEvent* handle);
  47. /*! Performs a 'run to completion' step. */
  48. extern void raiseEvent_runCycle(RaiseEvent* handle);
  49. /*! Checks if the out event 'e1' that is defined in the default interface scope has been raised. */
  50. extern sc_boolean raiseEventIface_israised_e1(const RaiseEvent* handle);
  51. /*! Raises the in event 'e2' that is defined in the default interface scope. */
  52. extern void raiseEventIface_raise_e2(RaiseEvent* handle);
  53. /*!
  54. * Checks whether the state machine is active (until 2.4.1 this method was used for states).
  55. * 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.
  56. */
  57. extern sc_boolean raiseEvent_isActive(const RaiseEvent* handle);
  58. /*!
  59. * Checks if all active states are final.
  60. * If there are no active states then the state machine is considered being inactive. In this case this method returns false.
  61. */
  62. extern sc_boolean raiseEvent_isFinal(const RaiseEvent* handle);
  63. /*! Checks if the specified state is active (until 2.4.1 the used method for states was called isActive()). */
  64. extern sc_boolean raiseEvent_isStateActive(const RaiseEvent* handle, RaiseEventStates state);
  65. #ifdef __cplusplus
  66. }
  67. #endif
  68. #endif /* RAISEEVENT_H_ */