InternalEventLifeCycle.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #ifndef INTERNALEVENTLIFECYCLE_H_
  2. #define INTERNALEVENTLIFECYCLE_H_
  3. #include "sc_types.h"
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. /*! \file Header of the state machine 'InternalEventLifeCycle'.
  8. */
  9. /*! Enumeration of all states */
  10. typedef enum
  11. {
  12. InternalEventLifeCycle_last_state,
  13. InternalEventLifeCycle_r1_A,
  14. InternalEventLifeCycle_r1_B,
  15. InternalEventLifeCycle_r2_C,
  16. InternalEventLifeCycle_r2_D
  17. } InternalEventLifeCycleStates;
  18. /*! Type definition of the data structure for the InternalEventLifeCycleIface interface scope. */
  19. typedef struct
  20. {
  21. sc_boolean e_raised;
  22. sc_boolean f_raised;
  23. } InternalEventLifeCycleIface;
  24. /*! Type definition of the data structure for the InternalEventLifeCycleInternal interface scope. */
  25. typedef struct
  26. {
  27. sc_boolean i1_raised;
  28. sc_boolean i2_raised;
  29. } InternalEventLifeCycleInternal;
  30. /*! Define dimension of the state configuration vector for orthogonal states. */
  31. #define INTERNALEVENTLIFECYCLE_MAX_ORTHOGONAL_STATES 2
  32. /*! Define indices of states in the StateConfVector */
  33. #define SCVI_INTERNALEVENTLIFECYCLE_R1_A 0
  34. #define SCVI_INTERNALEVENTLIFECYCLE_R1_B 0
  35. #define SCVI_INTERNALEVENTLIFECYCLE_R2_C 1
  36. #define SCVI_INTERNALEVENTLIFECYCLE_R2_D 1
  37. /*!
  38. * Type definition of the data structure for the InternalEventLifeCycle state machine.
  39. * This data structure has to be allocated by the client code.
  40. */
  41. typedef struct
  42. {
  43. InternalEventLifeCycleStates stateConfVector[INTERNALEVENTLIFECYCLE_MAX_ORTHOGONAL_STATES];
  44. sc_ushort stateConfVectorPosition;
  45. InternalEventLifeCycleIface iface;
  46. InternalEventLifeCycleInternal internal;
  47. } InternalEventLifeCycle;
  48. /*! Initializes the InternalEventLifeCycle state machine data structures. Must be called before first usage.*/
  49. extern void internalEventLifeCycle_init(InternalEventLifeCycle* handle);
  50. /*! Activates the state machine */
  51. extern void internalEventLifeCycle_enter(InternalEventLifeCycle* handle);
  52. /*! Deactivates the state machine */
  53. extern void internalEventLifeCycle_exit(InternalEventLifeCycle* handle);
  54. /*! Performs a 'run to completion' step. */
  55. extern void internalEventLifeCycle_runCycle(InternalEventLifeCycle* handle);
  56. /*! Raises the in event 'e' that is defined in the default interface scope. */
  57. extern void internalEventLifeCycleIface_raise_e(InternalEventLifeCycle* handle);
  58. /*! Raises the in event 'f' that is defined in the default interface scope. */
  59. extern void internalEventLifeCycleIface_raise_f(InternalEventLifeCycle* handle);
  60. /*!
  61. * Checks whether the state machine is active (until 2.4.1 this method was used for states).
  62. * 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.
  63. */
  64. extern sc_boolean internalEventLifeCycle_isActive(const InternalEventLifeCycle* handle);
  65. /*!
  66. * Checks if all active states are final.
  67. * If there are no active states then the state machine is considered being inactive. In this case this method returns false.
  68. */
  69. extern sc_boolean internalEventLifeCycle_isFinal(const InternalEventLifeCycle* handle);
  70. /*! Checks if the specified state is active (until 2.4.1 the used method for states was called isActive()). */
  71. extern sc_boolean internalEventLifeCycle_isStateActive(const InternalEventLifeCycle* handle, InternalEventLifeCycleStates state);
  72. #ifdef __cplusplus
  73. }
  74. #endif
  75. #endif /* INTERNALEVENTLIFECYCLE_H_ */