SimpleHierachy.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #ifndef SIMPLEHIERACHY_H_
  2. #define SIMPLEHIERACHY_H_
  3. #include "sc_types.h"
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. /*! \file Header of the state machine 'SimpleHierachy'.
  8. */
  9. /*! Enumeration of all states */
  10. typedef enum
  11. {
  12. SimpleHierachy_last_state,
  13. SimpleHierachy_main_region_A,
  14. SimpleHierachy_main_region_B,
  15. SimpleHierachy_main_region_B_subregion1_B1
  16. } SimpleHierachyStates;
  17. /*! Type definition of the data structure for the SimpleHierachyIface interface scope. */
  18. typedef struct
  19. {
  20. sc_boolean Event1_raised;
  21. } SimpleHierachyIface;
  22. /*! Define dimension of the state configuration vector for orthogonal states. */
  23. #define SIMPLEHIERACHY_MAX_ORTHOGONAL_STATES 1
  24. /*! Define indices of states in the StateConfVector */
  25. #define SCVI_SIMPLEHIERACHY_MAIN_REGION_A 0
  26. #define SCVI_SIMPLEHIERACHY_MAIN_REGION_B 0
  27. #define SCVI_SIMPLEHIERACHY_MAIN_REGION_B_SUBREGION1_B1 0
  28. /*!
  29. * Type definition of the data structure for the SimpleHierachy state machine.
  30. * This data structure has to be allocated by the client code.
  31. */
  32. typedef struct
  33. {
  34. SimpleHierachyStates stateConfVector[SIMPLEHIERACHY_MAX_ORTHOGONAL_STATES];
  35. sc_ushort stateConfVectorPosition;
  36. SimpleHierachyIface iface;
  37. } SimpleHierachy;
  38. /*! Initializes the SimpleHierachy state machine data structures. Must be called before first usage.*/
  39. extern void simpleHierachy_init(SimpleHierachy* handle);
  40. /*! Activates the state machine */
  41. extern void simpleHierachy_enter(SimpleHierachy* handle);
  42. /*! Deactivates the state machine */
  43. extern void simpleHierachy_exit(SimpleHierachy* handle);
  44. /*! Performs a 'run to completion' step. */
  45. extern void simpleHierachy_runCycle(SimpleHierachy* handle);
  46. /*! Raises the in event 'Event1' that is defined in the default interface scope. */
  47. extern void simpleHierachyIface_raise_event1(SimpleHierachy* handle);
  48. /*!
  49. * Checks whether the state machine is active (until 2.4.1 this method was used for states).
  50. * 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.
  51. */
  52. extern sc_boolean simpleHierachy_isActive(const SimpleHierachy* handle);
  53. /*!
  54. * Checks if all active states are final.
  55. * If there are no active states then the state machine is considered being inactive. In this case this method returns false.
  56. */
  57. extern sc_boolean simpleHierachy_isFinal(const SimpleHierachy* handle);
  58. /*! Checks if the specified state is active (until 2.4.1 the used method for states was called isActive()). */
  59. extern sc_boolean simpleHierachy_isStateActive(const SimpleHierachy* handle, SimpleHierachyStates state);
  60. #ifdef __cplusplus
  61. }
  62. #endif
  63. #endif /* SIMPLEHIERACHY_H_ */