ShallowHistory.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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_last_state,
  13. ShallowHistory_mainRegion_State1,
  14. ShallowHistory_mainRegion_State2,
  15. ShallowHistory_mainRegion_State2__region0_State3,
  16. ShallowHistory_mainRegion_State2__region0_State4,
  17. ShallowHistory_mainRegion_State2__region0_State4__region0_State6,
  18. ShallowHistory_mainRegion_State2__region0_State4__region0_State7,
  19. ShallowHistory_mainRegion_State2__region0_State4__region0_State7__region0_State8,
  20. ShallowHistory_mainRegion_State2__region0_State4__region0_State7__region0_State9,
  21. ShallowHistory_mainRegion_State2__region0_State5
  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. /*! Define indices of states in the StateConfVector */
  40. #define SCVI_SHALLOWHISTORY_MAINREGION_STATE1 0
  41. #define SCVI_SHALLOWHISTORY_MAINREGION_STATE2 0
  42. #define SCVI_SHALLOWHISTORY_MAINREGION_STATE2__REGION0_STATE3 0
  43. #define SCVI_SHALLOWHISTORY_MAINREGION_STATE2__REGION0_STATE4 0
  44. #define SCVI_SHALLOWHISTORY_MAINREGION_STATE2__REGION0_STATE4__REGION0_STATE6 0
  45. #define SCVI_SHALLOWHISTORY_MAINREGION_STATE2__REGION0_STATE4__REGION0_STATE7 0
  46. #define SCVI_SHALLOWHISTORY_MAINREGION_STATE2__REGION0_STATE4__REGION0_STATE7__REGION0_STATE8 0
  47. #define SCVI_SHALLOWHISTORY_MAINREGION_STATE2__REGION0_STATE4__REGION0_STATE7__REGION0_STATE9 0
  48. #define SCVI_SHALLOWHISTORY_MAINREGION_STATE2__REGION0_STATE5 0
  49. /*!
  50. * Type definition of the data structure for the ShallowHistory state machine.
  51. * This data structure has to be allocated by the client code.
  52. */
  53. typedef struct
  54. {
  55. ShallowHistoryStates stateConfVector[SHALLOWHISTORY_MAX_ORTHOGONAL_STATES];
  56. ShallowHistoryStates historyVector[SHALLOWHISTORY_MAX_HISTORY_STATES];
  57. sc_ushort stateConfVectorPosition;
  58. ShallowHistoryIface iface;
  59. } ShallowHistory;
  60. /*! Initializes the ShallowHistory state machine data structures. Must be called before first usage.*/
  61. extern void shallowHistory_init(ShallowHistory* handle);
  62. /*! Activates the state machine */
  63. extern void shallowHistory_enter(ShallowHistory* handle);
  64. /*! Deactivates the state machine */
  65. extern void shallowHistory_exit(ShallowHistory* handle);
  66. /*! Performs a 'run to completion' step. */
  67. extern void shallowHistory_runCycle(ShallowHistory* handle);
  68. /*! Raises the in event 'event1' that is defined in the default interface scope. */
  69. extern void shallowHistoryIface_raise_event1(ShallowHistory* handle);
  70. /*! Raises the in event 'event2' that is defined in the default interface scope. */
  71. extern void shallowHistoryIface_raise_event2(ShallowHistory* handle);
  72. /*! Raises the in event 'event3' that is defined in the default interface scope. */
  73. extern void shallowHistoryIface_raise_event3(ShallowHistory* handle);
  74. /*! Raises the in event 'event4' that is defined in the default interface scope. */
  75. extern void shallowHistoryIface_raise_event4(ShallowHistory* handle);
  76. /*! Raises the in event 'event5' that is defined in the default interface scope. */
  77. extern void shallowHistoryIface_raise_event5(ShallowHistory* handle);
  78. /*! Raises the in event 'event6' that is defined in the default interface scope. */
  79. extern void shallowHistoryIface_raise_event6(ShallowHistory* handle);
  80. /*! Raises the in event 'event7' that is defined in the default interface scope. */
  81. extern void shallowHistoryIface_raise_event7(ShallowHistory* handle);
  82. /*! Raises the in event 'event8' that is defined in the default interface scope. */
  83. extern void shallowHistoryIface_raise_event8(ShallowHistory* handle);
  84. /*!
  85. * Checks whether the state machine is active (until 2.4.1 this method was used for states).
  86. * 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.
  87. */
  88. extern sc_boolean shallowHistory_isActive(const ShallowHistory* handle);
  89. /*!
  90. * Checks if all active states are final.
  91. * If there are no active states then the state machine is considered being inactive. In this case this method returns false.
  92. */
  93. extern sc_boolean shallowHistory_isFinal(const ShallowHistory* handle);
  94. /*! Checks if the specified state is active (until 2.4.1 the used method for states was called isActive()). */
  95. extern sc_boolean shallowHistory_isStateActive(const ShallowHistory* handle, ShallowHistoryStates state);
  96. #ifdef __cplusplus
  97. }
  98. #endif
  99. #endif /* SHALLOWHISTORY_H_ */