DynamicChoice.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #ifndef DYNAMICCHOICE_H_
  2. #define DYNAMICCHOICE_H_
  3. #include "sc_types.h"
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. /*! \file Header of the state machine 'DynamicChoice'.
  8. */
  9. /*! Enumeration of all states */
  10. typedef enum
  11. {
  12. DynamicChoice_main_region_Start,
  13. DynamicChoice_main_region_A,
  14. DynamicChoice_main_region_B,
  15. DynamicChoice_last_state
  16. } DynamicChoiceStates;
  17. /*! Type definition of the data structure for the DynamicChoiceIface interface scope. */
  18. typedef struct
  19. {
  20. sc_integer number;
  21. sc_boolean reset_raised;
  22. } DynamicChoiceIface;
  23. /*! Define dimension of the state configuration vector for orthogonal states. */
  24. #define DYNAMICCHOICE_MAX_ORTHOGONAL_STATES 1
  25. /*!
  26. * Type definition of the data structure for the DynamicChoice state machine.
  27. * This data structure has to be allocated by the client code.
  28. */
  29. typedef struct
  30. {
  31. DynamicChoiceStates stateConfVector[DYNAMICCHOICE_MAX_ORTHOGONAL_STATES];
  32. sc_ushort stateConfVectorPosition;
  33. DynamicChoiceIface iface;
  34. } DynamicChoice;
  35. /*! Initializes the DynamicChoice state machine data structures. Must be called before first usage.*/
  36. extern void dynamicChoice_init(DynamicChoice* handle);
  37. /*! Activates the state machine */
  38. extern void dynamicChoice_enter(DynamicChoice* handle);
  39. /*! Deactivates the state machine */
  40. extern void dynamicChoice_exit(DynamicChoice* handle);
  41. /*! Performs a 'run to completion' step. */
  42. extern void dynamicChoice_runCycle(DynamicChoice* handle);
  43. /*! Gets the value of the variable 'number' that is defined in the default interface scope. */
  44. extern sc_integer dynamicChoiceIface_get_number(const DynamicChoice* handle);
  45. /*! Sets the value of the variable 'number' that is defined in the default interface scope. */
  46. extern void dynamicChoiceIface_set_number(DynamicChoice* handle, sc_integer value);
  47. /*! Raises the in event 'reset' that is defined in the default interface scope. */
  48. extern void dynamicChoiceIface_raise_reset(DynamicChoice* handle);
  49. /*!
  50. * Checks whether the state machine is active (until 2.4.1 this method was used for states).
  51. * 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.
  52. */
  53. extern sc_boolean dynamicChoice_isActive(const DynamicChoice* handle);
  54. /*!
  55. * Checks if all active states are final.
  56. * If there are no active states then the state machine is considered being inactive. In this case this method returns false.
  57. */
  58. extern sc_boolean dynamicChoice_isFinal(const DynamicChoice* handle);
  59. /*! Checks if the specified state is active (until 2.4.1 the used method for states was called isActive()). */
  60. extern sc_boolean dynamicChoice_isStateActive(const DynamicChoice* handle, DynamicChoiceStates state);
  61. #ifdef __cplusplus
  62. }
  63. #endif
  64. #endif /* DYNAMICCHOICE_H_ */