EnterState.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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_r_A,
  13. EnterState_r_B,
  14. EnterState_r_B_r_E,
  15. EnterState_r_B_r_F,
  16. EnterState_last_state
  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. /*!
  28. * Type definition of the data structure for the EnterState state machine.
  29. * This data structure has to be allocated by the client code.
  30. */
  31. typedef struct
  32. {
  33. EnterStateStates stateConfVector[ENTERSTATE_MAX_ORTHOGONAL_STATES];
  34. sc_ushort stateConfVectorPosition;
  35. EnterStateIface iface;
  36. } EnterState;
  37. /*! Initializes the EnterState state machine data structures. Must be called before first usage.*/
  38. extern void enterState_init(EnterState* handle);
  39. /*! Activates the state machine */
  40. extern void enterState_enter(EnterState* handle);
  41. /*! Deactivates the state machine */
  42. extern void enterState_exit(EnterState* handle);
  43. /*! Performs a 'run to completion' step. */
  44. extern void enterState_runCycle(EnterState* handle);
  45. /*! Raises the in event 'e' that is defined in the default interface scope. */
  46. extern void enterStateIface_raise_e(EnterState* handle);
  47. /*! Raises the in event 'f' that is defined in the default interface scope. */
  48. extern void enterStateIface_raise_f(EnterState* handle);
  49. /*! Raises the in event 'g' that is defined in the default interface scope. */
  50. extern void enterStateIface_raise_g(EnterState* handle);
  51. /*!
  52. * Checks whether the state machine is active (until 2.4.1 this method was used for states).
  53. * 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.
  54. */
  55. extern sc_boolean enterState_isActive(const EnterState* handle);
  56. /*!
  57. * Checks if all active states are final.
  58. * If there are no active states then the state machine is considered being inactive. In this case this method returns false.
  59. */
  60. extern sc_boolean enterState_isFinal(const EnterState* handle);
  61. /*! Checks if the specified state is active (until 2.4.1 the used method for states was called isActive()). */
  62. extern sc_boolean enterState_isStateActive(const EnterState* handle, EnterStateStates state);
  63. #ifdef __cplusplus
  64. }
  65. #endif
  66. #endif /* ENTERSTATE_H_ */