EnterState.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #ifndef ENTERSTATE_H_
  2. #define ENTERSTATE_H_
  3. #include "sc_types.h"
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. /*! \file Header of the state machine 'EnterState'.
  8. */
  9. /*! Enumeration of all states */
  10. typedef enum
  11. {
  12. EnterState_last_state,
  13. EnterState_r_A,
  14. EnterState_r_B,
  15. EnterState_r_B_r_E,
  16. EnterState_r_B_r_F
  17. } EnterStateStates;
  18. /*! Type definition of the data structure for the EnterStateIface interface scope. */
  19. typedef struct
  20. {
  21. sc_boolean e_raised;
  22. sc_boolean f_raised;
  23. sc_boolean g_raised;
  24. } EnterStateIface;
  25. /*! Define dimension of the state configuration vector for orthogonal states. */
  26. #define ENTERSTATE_MAX_ORTHOGONAL_STATES 1
  27. /*! Define indices of states in the StateConfVector */
  28. #define SCVI_ENTERSTATE_R_A 0
  29. #define SCVI_ENTERSTATE_R_B 0
  30. #define SCVI_ENTERSTATE_R_B_R_E 0
  31. #define SCVI_ENTERSTATE_R_B_R_F 0
  32. /*!
  33. * Type definition of the data structure for the EnterState state machine.
  34. * This data structure has to be allocated by the client code.
  35. */
  36. typedef struct
  37. {
  38. EnterStateStates stateConfVector[ENTERSTATE_MAX_ORTHOGONAL_STATES];
  39. sc_ushort stateConfVectorPosition;
  40. EnterStateIface iface;
  41. } EnterState;
  42. /*! Initializes the EnterState state machine data structures. Must be called before first usage.*/
  43. extern void enterState_init(EnterState* handle);
  44. /*! Activates the state machine */
  45. extern void enterState_enter(EnterState* handle);
  46. /*! Deactivates the state machine */
  47. extern void enterState_exit(EnterState* handle);
  48. /*! Performs a 'run to completion' step. */
  49. extern void enterState_runCycle(EnterState* handle);
  50. /*! Raises the in event 'e' that is defined in the default interface scope. */
  51. extern void enterStateIface_raise_e(EnterState* handle);
  52. /*! Raises the in event 'f' that is defined in the default interface scope. */
  53. extern void enterStateIface_raise_f(EnterState* handle);
  54. /*! Raises the in event 'g' that is defined in the default interface scope. */
  55. extern void enterStateIface_raise_g(EnterState* handle);
  56. /*!
  57. * Checks whether the state machine is active (until 2.4.1 this method was used for states).
  58. * 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.
  59. */
  60. extern sc_boolean enterState_isActive(const EnterState* handle);
  61. /*!
  62. * Checks if all active states are final.
  63. * If there are no active states then the state machine is considered being inactive. In this case this method returns false.
  64. */
  65. extern sc_boolean enterState_isFinal(const EnterState* handle);
  66. /*! Checks if the specified state is active (until 2.4.1 the used method for states was called isActive()). */
  67. extern sc_boolean enterState_isStateActive(const EnterState* handle, EnterStateStates state);
  68. #ifdef __cplusplus
  69. }
  70. #endif
  71. #endif /* ENTERSTATE_H_ */