ExitState.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #ifndef EXITSTATE_H_
  2. #define EXITSTATE_H_
  3. #include "sc_types.h"
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. /*! \file Header of the state machine 'ExitState'.
  8. */
  9. /*! Enumeration of all states */
  10. typedef enum
  11. {
  12. ExitState_r_A,
  13. ExitState_r_A_r_B,
  14. ExitState_r_E,
  15. ExitState_r_F,
  16. ExitState_last_state
  17. } ExitStateStates;
  18. /*! Type definition of the data structure for the ExitStateIface interface scope. */
  19. typedef struct
  20. {
  21. sc_boolean e_raised;
  22. sc_boolean f_raised;
  23. sc_boolean g_raised;
  24. } ExitStateIface;
  25. /*! Define dimension of the state configuration vector for orthogonal states. */
  26. #define EXITSTATE_MAX_ORTHOGONAL_STATES 1
  27. /*!
  28. * Type definition of the data structure for the ExitState state machine.
  29. * This data structure has to be allocated by the client code.
  30. */
  31. typedef struct
  32. {
  33. ExitStateStates stateConfVector[EXITSTATE_MAX_ORTHOGONAL_STATES];
  34. sc_ushort stateConfVectorPosition;
  35. ExitStateIface iface;
  36. } ExitState;
  37. /*! Initializes the ExitState state machine data structures. Must be called before first usage.*/
  38. extern void exitState_init(ExitState* handle);
  39. /*! Activates the state machine */
  40. extern void exitState_enter(ExitState* handle);
  41. /*! Deactivates the state machine */
  42. extern void exitState_exit(ExitState* handle);
  43. /*! Performs a 'run to completion' step. */
  44. extern void exitState_runCycle(ExitState* handle);
  45. /*! Raises the in event 'e' that is defined in the default interface scope. */
  46. extern void exitStateIface_raise_e(ExitState* handle);
  47. /*! Raises the in event 'f' that is defined in the default interface scope. */
  48. extern void exitStateIface_raise_f(ExitState* handle);
  49. /*! Raises the in event 'g' that is defined in the default interface scope. */
  50. extern void exitStateIface_raise_g(ExitState* 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 exitState_isActive(const ExitState* 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 exitState_isFinal(const ExitState* 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 exitState_isStateActive(const ExitState* handle, ExitStateStates state);
  63. #ifdef __cplusplus
  64. }
  65. #endif
  66. #endif /* EXITSTATE_H_ */