GuardedEntry.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #ifndef GUARDEDENTRY_H_
  2. #define GUARDEDENTRY_H_
  3. #include "sc_types.h"
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. /*! \file Header of the state machine 'GuardedEntry'.
  8. */
  9. /*! Enumeration of all states */
  10. typedef enum
  11. {
  12. GuardedEntry_last_state,
  13. GuardedEntry_main_region_A,
  14. GuardedEntry_main_region_B
  15. } GuardedEntryStates;
  16. /*! Type definition of the data structure for the GuardedEntryIface interface scope. */
  17. typedef struct
  18. {
  19. sc_boolean e_raised;
  20. sc_boolean guard;
  21. sc_boolean done;
  22. } GuardedEntryIface;
  23. /*! Define dimension of the state configuration vector for orthogonal states. */
  24. #define GUARDEDENTRY_MAX_ORTHOGONAL_STATES 1
  25. /*! Define indices of states in the StateConfVector */
  26. #define SCVI_GUARDEDENTRY_MAIN_REGION_A 0
  27. #define SCVI_GUARDEDENTRY_MAIN_REGION_B 0
  28. /*!
  29. * Type definition of the data structure for the GuardedEntry state machine.
  30. * This data structure has to be allocated by the client code.
  31. */
  32. typedef struct
  33. {
  34. GuardedEntryStates stateConfVector[GUARDEDENTRY_MAX_ORTHOGONAL_STATES];
  35. sc_ushort stateConfVectorPosition;
  36. GuardedEntryIface iface;
  37. } GuardedEntry;
  38. /*! Initializes the GuardedEntry state machine data structures. Must be called before first usage.*/
  39. extern void guardedEntry_init(GuardedEntry* handle);
  40. /*! Activates the state machine */
  41. extern void guardedEntry_enter(GuardedEntry* handle);
  42. /*! Deactivates the state machine */
  43. extern void guardedEntry_exit(GuardedEntry* handle);
  44. /*! Performs a 'run to completion' step. */
  45. extern void guardedEntry_runCycle(GuardedEntry* handle);
  46. /*! Raises the in event 'e' that is defined in the default interface scope. */
  47. extern void guardedEntryIface_raise_e(GuardedEntry* handle);
  48. /*! Gets the value of the variable 'guard' that is defined in the default interface scope. */
  49. extern sc_boolean guardedEntryIface_get_guard(const GuardedEntry* handle);
  50. /*! Sets the value of the variable 'guard' that is defined in the default interface scope. */
  51. extern void guardedEntryIface_set_guard(GuardedEntry* handle, sc_boolean value);
  52. /*! Gets the value of the variable 'done' that is defined in the default interface scope. */
  53. extern sc_boolean guardedEntryIface_get_done(const GuardedEntry* handle);
  54. /*! Sets the value of the variable 'done' that is defined in the default interface scope. */
  55. extern void guardedEntryIface_set_done(GuardedEntry* handle, sc_boolean value);
  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 guardedEntry_isActive(const GuardedEntry* 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 guardedEntry_isFinal(const GuardedEntry* 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 guardedEntry_isStateActive(const GuardedEntry* handle, GuardedEntryStates state);
  68. #ifdef __cplusplus
  69. }
  70. #endif
  71. #endif /* GUARDEDENTRY_H_ */