ValuedEvents.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. #ifndef VALUEDEVENTS_H_
  2. #define VALUEDEVENTS_H_
  3. #include "sc_types.h"
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. /*! \file Header of the state machine 'ValuedEvents'.
  8. */
  9. /*! Enumeration of all states */
  10. typedef enum
  11. {
  12. ValuedEvents_last_state,
  13. ValuedEvents_main_region1_A,
  14. ValuedEvents_integer_region_B,
  15. ValuedEvents_integer_region_C,
  16. ValuedEvents_integer_region_D,
  17. ValuedEvents_boolean_region_B,
  18. ValuedEvents_boolean_region_C,
  19. ValuedEvents_boolean_region_D,
  20. ValuedEvents_real_region_B,
  21. ValuedEvents_real_region_C,
  22. ValuedEvents_real_region_D,
  23. ValuedEvents_string_region_B,
  24. ValuedEvents_string_region_C,
  25. ValuedEvents_string_region_D
  26. } ValuedEventsStates;
  27. /*! Type definition of the data structure for the ValuedEventsIface interface scope. */
  28. typedef struct
  29. {
  30. sc_boolean integerEvent_raised;
  31. sc_integer integerEvent_value;
  32. sc_integer myInt;
  33. sc_boolean booleanEvent_raised;
  34. sc_boolean booleanEvent_value;
  35. sc_boolean myBool;
  36. sc_boolean realEvent_raised;
  37. sc_real realEvent_value;
  38. sc_real myReal;
  39. sc_boolean stringEvent_raised;
  40. sc_string stringEvent_value;
  41. sc_string myString;
  42. } ValuedEventsIface;
  43. /*! Define dimension of the state configuration vector for orthogonal states. */
  44. #define VALUEDEVENTS_MAX_ORTHOGONAL_STATES 5
  45. /*! Define indices of states in the StateConfVector */
  46. #define SCVI_VALUEDEVENTS_MAIN_REGION1_A 0
  47. #define SCVI_VALUEDEVENTS_INTEGER_REGION_B 1
  48. #define SCVI_VALUEDEVENTS_INTEGER_REGION_C 1
  49. #define SCVI_VALUEDEVENTS_INTEGER_REGION_D 1
  50. #define SCVI_VALUEDEVENTS_BOOLEAN_REGION_B 2
  51. #define SCVI_VALUEDEVENTS_BOOLEAN_REGION_C 2
  52. #define SCVI_VALUEDEVENTS_BOOLEAN_REGION_D 2
  53. #define SCVI_VALUEDEVENTS_REAL_REGION_B 3
  54. #define SCVI_VALUEDEVENTS_REAL_REGION_C 3
  55. #define SCVI_VALUEDEVENTS_REAL_REGION_D 3
  56. #define SCVI_VALUEDEVENTS_STRING_REGION_B 4
  57. #define SCVI_VALUEDEVENTS_STRING_REGION_C 4
  58. #define SCVI_VALUEDEVENTS_STRING_REGION_D 4
  59. /*!
  60. * Type definition of the data structure for the ValuedEvents state machine.
  61. * This data structure has to be allocated by the client code.
  62. */
  63. typedef struct
  64. {
  65. ValuedEventsStates stateConfVector[VALUEDEVENTS_MAX_ORTHOGONAL_STATES];
  66. sc_ushort stateConfVectorPosition;
  67. ValuedEventsIface iface;
  68. } ValuedEvents;
  69. /*! Initializes the ValuedEvents state machine data structures. Must be called before first usage.*/
  70. extern void valuedEvents_init(ValuedEvents* handle);
  71. /*! Activates the state machine */
  72. extern void valuedEvents_enter(ValuedEvents* handle);
  73. /*! Deactivates the state machine */
  74. extern void valuedEvents_exit(ValuedEvents* handle);
  75. /*! Performs a 'run to completion' step. */
  76. extern void valuedEvents_runCycle(ValuedEvents* handle);
  77. /*! Raises the in event 'integerEvent' that is defined in the default interface scope. */
  78. extern void valuedEventsIface_raise_integerEvent(ValuedEvents* handle, sc_integer value);
  79. /*! Gets the value of the variable 'myInt' that is defined in the default interface scope. */
  80. extern sc_integer valuedEventsIface_get_myInt(const ValuedEvents* handle);
  81. /*! Sets the value of the variable 'myInt' that is defined in the default interface scope. */
  82. extern void valuedEventsIface_set_myInt(ValuedEvents* handle, sc_integer value);
  83. /*! Raises the in event 'booleanEvent' that is defined in the default interface scope. */
  84. extern void valuedEventsIface_raise_booleanEvent(ValuedEvents* handle, sc_boolean value);
  85. /*! Gets the value of the variable 'myBool' that is defined in the default interface scope. */
  86. extern sc_boolean valuedEventsIface_get_myBool(const ValuedEvents* handle);
  87. /*! Sets the value of the variable 'myBool' that is defined in the default interface scope. */
  88. extern void valuedEventsIface_set_myBool(ValuedEvents* handle, sc_boolean value);
  89. /*! Raises the in event 'realEvent' that is defined in the default interface scope. */
  90. extern void valuedEventsIface_raise_realEvent(ValuedEvents* handle, sc_real value);
  91. /*! Gets the value of the variable 'myReal' that is defined in the default interface scope. */
  92. extern sc_real valuedEventsIface_get_myReal(const ValuedEvents* handle);
  93. /*! Sets the value of the variable 'myReal' that is defined in the default interface scope. */
  94. extern void valuedEventsIface_set_myReal(ValuedEvents* handle, sc_real value);
  95. /*! Raises the in event 'stringEvent' that is defined in the default interface scope. */
  96. extern void valuedEventsIface_raise_stringEvent(ValuedEvents* handle, sc_string value);
  97. /*! Gets the value of the variable 'myString' that is defined in the default interface scope. */
  98. extern sc_string valuedEventsIface_get_myString(const ValuedEvents* handle);
  99. /*! Sets the value of the variable 'myString' that is defined in the default interface scope. */
  100. extern void valuedEventsIface_set_myString(ValuedEvents* handle, sc_string value);
  101. /*!
  102. * Checks whether the state machine is active (until 2.4.1 this method was used for states).
  103. * 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.
  104. */
  105. extern sc_boolean valuedEvents_isActive(const ValuedEvents* handle);
  106. /*!
  107. * Checks if all active states are final.
  108. * If there are no active states then the state machine is considered being inactive. In this case this method returns false.
  109. */
  110. extern sc_boolean valuedEvents_isFinal(const ValuedEvents* handle);
  111. /*! Checks if the specified state is active (until 2.4.1 the used method for states was called isActive()). */
  112. extern sc_boolean valuedEvents_isStateActive(const ValuedEvents* handle, ValuedEventsStates state);
  113. #ifdef __cplusplus
  114. }
  115. #endif
  116. #endif /* VALUEDEVENTS_H_ */