Guard.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #ifndef GUARD_H_
  2. #define GUARD_H_
  3. #include "sc_types.h"
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. /*! \file Header of the state machine 'Guard'.
  8. */
  9. /*! Enumeration of all states */
  10. typedef enum
  11. {
  12. Guard_main_region_A,
  13. Guard_main_region_B,
  14. Guard_last_state
  15. } GuardStates;
  16. /*! Type definition of the data structure for the GuardIface interface scope. */
  17. typedef struct
  18. {
  19. sc_boolean Event1_raised;
  20. sc_boolean Event2_raised;
  21. sc_boolean Return_raised;
  22. sc_integer MyVar;
  23. } GuardIface;
  24. /*! Define dimension of the state configuration vector for orthogonal states. */
  25. #define GUARD_MAX_ORTHOGONAL_STATES 1
  26. /*!
  27. * Type definition of the data structure for the Guard state machine.
  28. * This data structure has to be allocated by the client code.
  29. */
  30. typedef struct
  31. {
  32. GuardStates stateConfVector[GUARD_MAX_ORTHOGONAL_STATES];
  33. sc_ushort stateConfVectorPosition;
  34. GuardIface iface;
  35. } Guard;
  36. /*! Initializes the Guard state machine data structures. Must be called before first usage.*/
  37. extern void guard_init(Guard* handle);
  38. /*! Activates the state machine */
  39. extern void guard_enter(Guard* handle);
  40. /*! Deactivates the state machine */
  41. extern void guard_exit(Guard* handle);
  42. /*! Performs a 'run to completion' step. */
  43. extern void guard_runCycle(Guard* handle);
  44. /*! Raises the in event 'Event1' that is defined in the default interface scope. */
  45. extern void guardIface_raise_event1(Guard* handle);
  46. /*! Raises the in event 'Event2' that is defined in the default interface scope. */
  47. extern void guardIface_raise_event2(Guard* handle);
  48. /*! Raises the in event 'Return' that is defined in the default interface scope. */
  49. extern void guardIface_raise_return(Guard* handle);
  50. /*! Gets the value of the variable 'MyVar' that is defined in the default interface scope. */
  51. extern sc_integer guardIface_get_myVar(const Guard* handle);
  52. /*! Sets the value of the variable 'MyVar' that is defined in the default interface scope. */
  53. extern void guardIface_set_myVar(Guard* handle, sc_integer value);
  54. /*!
  55. * Checks whether the state machine is active (until 2.4.1 this method was used for states).
  56. * 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.
  57. */
  58. extern sc_boolean guard_isActive(const Guard* handle);
  59. /*!
  60. * Checks if all active states are final.
  61. * If there are no active states then the state machine is considered being inactive. In this case this method returns false.
  62. */
  63. extern sc_boolean guard_isFinal(const Guard* handle);
  64. /*! Checks if the specified state is active (until 2.4.1 the used method for states was called isActive()). */
  65. extern sc_boolean guard_isStateActive(const Guard* handle, GuardStates state);
  66. #ifdef __cplusplus
  67. }
  68. #endif
  69. #endif /* GUARD_H_ */