InternalEventLifeCycle.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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_r1_A,
  13. InternalEventLifeCycle_r1_B,
  14. InternalEventLifeCycle_r2_C,
  15. InternalEventLifeCycle_r2_D,
  16. InternalEventLifeCycle_last_state
  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. /*!
  33. * Type definition of the data structure for the InternalEventLifeCycle state machine.
  34. * This data structure has to be allocated by the client code.
  35. */
  36. typedef struct
  37. {
  38. InternalEventLifeCycleStates stateConfVector[INTERNALEVENTLIFECYCLE_MAX_ORTHOGONAL_STATES];
  39. sc_ushort stateConfVectorPosition;
  40. InternalEventLifeCycleIface iface;
  41. InternalEventLifeCycleInternal internal;
  42. } InternalEventLifeCycle;
  43. /*! Initializes the InternalEventLifeCycle state machine data structures. Must be called before first usage.*/
  44. extern void internalEventLifeCycle_init(InternalEventLifeCycle* handle);
  45. /*! Activates the state machine */
  46. extern void internalEventLifeCycle_enter(InternalEventLifeCycle* handle);
  47. /*! Deactivates the state machine */
  48. extern void internalEventLifeCycle_exit(InternalEventLifeCycle* handle);
  49. /*! Performs a 'run to completion' step. */
  50. extern void internalEventLifeCycle_runCycle(InternalEventLifeCycle* handle);
  51. /*! Raises the in event 'e' that is defined in the default interface scope. */
  52. extern void internalEventLifeCycleIface_raise_e(InternalEventLifeCycle* handle);
  53. /*! Raises the in event 'f' that is defined in the default interface scope. */
  54. extern void internalEventLifeCycleIface_raise_f(InternalEventLifeCycle* handle);
  55. /*!
  56. * Checks whether the state machine is active (until 2.4.1 this method was used for states).
  57. * 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.
  58. */
  59. extern sc_boolean internalEventLifeCycle_isActive(const InternalEventLifeCycle* handle);
  60. /*!
  61. * Checks if all active states are final.
  62. * If there are no active states then the state machine is considered being inactive. In this case this method returns false.
  63. */
  64. extern sc_boolean internalEventLifeCycle_isFinal(const InternalEventLifeCycle* handle);
  65. /*! Checks if the specified state is active (until 2.4.1 the used method for states was called isActive()). */
  66. extern sc_boolean internalEventLifeCycle_isStateActive(const InternalEventLifeCycle* handle, InternalEventLifeCycleStates state);
  67. #ifdef __cplusplus
  68. }
  69. #endif
  70. #endif /* INTERNALEVENTLIFECYCLE_H_ */