Guard.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. #ifndef GUARD_H_
  2. #define GUARD_H_
  3. #include "sc_types.h"
  4. #include "StatemachineInterface.h"
  5. /*! \file Header of the state machine 'Guard'.
  6. */
  7. class Guard : public StatemachineInterface
  8. {
  9. public:
  10. Guard();
  11. ~Guard();
  12. /*! Enumeration of all states */
  13. typedef enum
  14. {
  15. main_region_A,
  16. main_region_B,
  17. Guard_last_state
  18. } GuardStates;
  19. //! Inner class for default interface scope.
  20. class DefaultSCI
  21. {
  22. public:
  23. /*! Raises the in event 'Event1' that is defined in the default interface scope. */
  24. void raise_event1();
  25. /*! Raises the in event 'Event2' that is defined in the default interface scope. */
  26. void raise_event2();
  27. /*! Raises the in event 'Return' that is defined in the default interface scope. */
  28. void raise_return();
  29. /*! Gets the value of the variable 'MyVar' that is defined in the default interface scope. */
  30. sc_integer get_myVar() const;
  31. /*! Sets the value of the variable 'MyVar' that is defined in the default interface scope. */
  32. void set_myVar(sc_integer value);
  33. private:
  34. friend class Guard;
  35. sc_boolean Event1_raised;
  36. sc_boolean Event2_raised;
  37. sc_boolean Return_raised;
  38. sc_integer MyVar;
  39. };
  40. /*! Returns an instance of the interface class 'DefaultSCI'. */
  41. DefaultSCI* getDefaultSCI();
  42. /*! Raises the in event 'Event1' that is defined in the default interface scope. */
  43. void raise_event1();
  44. /*! Raises the in event 'Event2' that is defined in the default interface scope. */
  45. void raise_event2();
  46. /*! Raises the in event 'Return' that is defined in the default interface scope. */
  47. void raise_return();
  48. /*! Gets the value of the variable 'MyVar' that is defined in the default interface scope. */
  49. sc_integer get_myVar() const;
  50. /*! Sets the value of the variable 'MyVar' that is defined in the default interface scope. */
  51. void set_myVar(sc_integer value);
  52. /*
  53. * Functions inherited from StatemachineInterface
  54. */
  55. virtual void init();
  56. virtual void enter();
  57. virtual void exit();
  58. virtual void runCycle();
  59. /*!
  60. * Checks if the state machine is active (until 2.4.1 this method was used for states).
  61. * A state machine is active if it has been entered. It is inactive if it has not been entered at all or if it has been exited.
  62. */
  63. virtual sc_boolean isActive() const;
  64. /*!
  65. * Checks if all active states are final.
  66. * If there are no active states then the state machine is considered being inactive. In this case this method returns false.
  67. */
  68. virtual sc_boolean isFinal() const;
  69. /*! Checks if the specified state is active (until 2.4.1 the used method for states was calles isActive()). */
  70. sc_boolean isStateActive(GuardStates state) const;
  71. private:
  72. //! the maximum number of orthogonal states defines the dimension of the state configuration vector.
  73. static const sc_integer maxOrthogonalStates = 1;
  74. GuardStates stateConfVector[maxOrthogonalStates];
  75. sc_ushort stateConfVectorPosition;
  76. DefaultSCI iface;
  77. // prototypes of all internal functions
  78. sc_boolean check_main_region_A_tr0_tr0();
  79. sc_boolean check_main_region_A_tr1_tr1();
  80. sc_boolean check_main_region_B_tr0_tr0();
  81. void effect_main_region_A_tr0();
  82. void effect_main_region_A_tr1();
  83. void effect_main_region_B_tr0();
  84. void enact_main_region_B();
  85. void enseq_main_region_A_default();
  86. void enseq_main_region_B_default();
  87. void enseq_main_region_default();
  88. void exseq_main_region_A();
  89. void exseq_main_region_B();
  90. void exseq_main_region();
  91. void react_main_region_A();
  92. void react_main_region_B();
  93. void react_main_region__entry_Default();
  94. void clearInEvents();
  95. void clearOutEvents();
  96. };
  97. #endif /* GUARD_H_ */