SimpleEvent.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #ifndef SIMPLEEVENT_H_
  2. #define SIMPLEEVENT_H_
  3. #include "sc_types.h"
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. /*! \file Header of the state machine 'SimpleEvent'.
  8. */
  9. /*! Enumeration of all states */
  10. typedef enum
  11. {
  12. SimpleEvent_last_state,
  13. SimpleEvent_main_region_A,
  14. SimpleEvent_main_region_B,
  15. SimpleEvent_main_region__final_
  16. } SimpleEventStates;
  17. /*! Type definition of the data structure for the SimpleEventIface interface scope. */
  18. typedef struct
  19. {
  20. sc_boolean Event1_raised;
  21. } SimpleEventIface;
  22. /*! Define dimension of the state configuration vector for orthogonal states. */
  23. #define SIMPLEEVENT_MAX_ORTHOGONAL_STATES 1
  24. /*! Define indices of states in the StateConfVector */
  25. #define SCVI_SIMPLEEVENT_MAIN_REGION_A 0
  26. #define SCVI_SIMPLEEVENT_MAIN_REGION_B 0
  27. #define SCVI_SIMPLEEVENT_MAIN_REGION__FINAL_ 0
  28. /*!
  29. * Type definition of the data structure for the SimpleEvent state machine.
  30. * This data structure has to be allocated by the client code.
  31. */
  32. typedef struct
  33. {
  34. SimpleEventStates stateConfVector[SIMPLEEVENT_MAX_ORTHOGONAL_STATES];
  35. sc_ushort stateConfVectorPosition;
  36. SimpleEventIface iface;
  37. } SimpleEvent;
  38. /*! Initializes the SimpleEvent state machine data structures. Must be called before first usage.*/
  39. extern void simpleEvent_init(SimpleEvent* handle);
  40. /*! Activates the state machine */
  41. extern void simpleEvent_enter(SimpleEvent* handle);
  42. /*! Deactivates the state machine */
  43. extern void simpleEvent_exit(SimpleEvent* handle);
  44. /*! Performs a 'run to completion' step. */
  45. extern void simpleEvent_runCycle(SimpleEvent* handle);
  46. /*! Raises the in event 'Event1' that is defined in the default interface scope. */
  47. extern void simpleEventIface_raise_event1(SimpleEvent* 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 simpleEvent_isActive(const SimpleEvent* 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 simpleEvent_isFinal(const SimpleEvent* 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 simpleEvent_isStateActive(const SimpleEvent* handle, SimpleEventStates state);
  60. #ifdef __cplusplus
  61. }
  62. #endif
  63. #endif /* SIMPLEEVENT_H_ */