ShallowHistory.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #ifndef SHALLOWHISTORY_H_
  2. #define SHALLOWHISTORY_H_
  3. #include "sc_types.h"
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. /*! \file Header of the state machine 'ShallowHistory'.
  8. */
  9. /*! Enumeration of all states */
  10. typedef enum
  11. {
  12. ShallowHistory_mainRegion_State1,
  13. ShallowHistory_mainRegion_State2,
  14. ShallowHistory_mainRegion_State2__region0_State3,
  15. ShallowHistory_mainRegion_State2__region0_State4,
  16. ShallowHistory_mainRegion_State2__region0_State4__region0_State6,
  17. ShallowHistory_mainRegion_State2__region0_State4__region0_State7,
  18. ShallowHistory_mainRegion_State2__region0_State4__region0_State7__region0_State8,
  19. ShallowHistory_mainRegion_State2__region0_State4__region0_State7__region0_State9,
  20. ShallowHistory_mainRegion_State2__region0_State5,
  21. ShallowHistory_last_state
  22. } ShallowHistoryStates;
  23. /*! Type definition of the data structure for the ShallowHistoryIface interface scope. */
  24. typedef struct
  25. {
  26. sc_boolean event1_raised;
  27. sc_boolean event2_raised;
  28. sc_boolean event3_raised;
  29. sc_boolean event4_raised;
  30. sc_boolean event5_raised;
  31. sc_boolean event6_raised;
  32. sc_boolean event7_raised;
  33. sc_boolean event8_raised;
  34. } ShallowHistoryIface;
  35. /*! Define dimension of the state configuration vector for orthogonal states. */
  36. #define SHALLOWHISTORY_MAX_ORTHOGONAL_STATES 1
  37. /*! Define dimension of the state configuration vector for history states. */
  38. #define SHALLOWHISTORY_MAX_HISTORY_STATES 2
  39. /*!
  40. * Type definition of the data structure for the ShallowHistory state machine.
  41. * This data structure has to be allocated by the client code.
  42. */
  43. typedef struct
  44. {
  45. ShallowHistoryStates stateConfVector[SHALLOWHISTORY_MAX_ORTHOGONAL_STATES];
  46. ShallowHistoryStates historyVector[SHALLOWHISTORY_MAX_HISTORY_STATES];
  47. sc_ushort stateConfVectorPosition;
  48. ShallowHistoryIface iface;
  49. } ShallowHistory;
  50. /*! Initializes the ShallowHistory state machine data structures. Must be called before first usage.*/
  51. extern void shallowHistory_init(ShallowHistory* handle);
  52. /*! Activates the state machine */
  53. extern void shallowHistory_enter(ShallowHistory* handle);
  54. /*! Deactivates the state machine */
  55. extern void shallowHistory_exit(ShallowHistory* handle);
  56. /*! Performs a 'run to completion' step. */
  57. extern void shallowHistory_runCycle(ShallowHistory* handle);
  58. /*! Raises the in event 'event1' that is defined in the default interface scope. */
  59. extern void shallowHistoryIface_raise_event1(ShallowHistory* handle);
  60. /*! Raises the in event 'event2' that is defined in the default interface scope. */
  61. extern void shallowHistoryIface_raise_event2(ShallowHistory* handle);
  62. /*! Raises the in event 'event3' that is defined in the default interface scope. */
  63. extern void shallowHistoryIface_raise_event3(ShallowHistory* handle);
  64. /*! Raises the in event 'event4' that is defined in the default interface scope. */
  65. extern void shallowHistoryIface_raise_event4(ShallowHistory* handle);
  66. /*! Raises the in event 'event5' that is defined in the default interface scope. */
  67. extern void shallowHistoryIface_raise_event5(ShallowHistory* handle);
  68. /*! Raises the in event 'event6' that is defined in the default interface scope. */
  69. extern void shallowHistoryIface_raise_event6(ShallowHistory* handle);
  70. /*! Raises the in event 'event7' that is defined in the default interface scope. */
  71. extern void shallowHistoryIface_raise_event7(ShallowHistory* handle);
  72. /*! Raises the in event 'event8' that is defined in the default interface scope. */
  73. extern void shallowHistoryIface_raise_event8(ShallowHistory* handle);
  74. /*!
  75. * Checks whether the state machine is active (until 2.4.1 this method was used for states).
  76. * 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.
  77. */
  78. extern sc_boolean shallowHistory_isActive(const ShallowHistory* handle);
  79. /*!
  80. * Checks if all active states are final.
  81. * If there are no active states then the state machine is considered being inactive. In this case this method returns false.
  82. */
  83. extern sc_boolean shallowHistory_isFinal(const ShallowHistory* handle);
  84. /*! Checks if the specified state is active (until 2.4.1 the used method for states was called isActive()). */
  85. extern sc_boolean shallowHistory_isStateActive(const ShallowHistory* handle, ShallowHistoryStates state);
  86. #ifdef __cplusplus
  87. }
  88. #endif
  89. #endif /* SHALLOWHISTORY_H_ */