DynamicChoice.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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_last_state,
  13. DynamicChoice_main_region_Start,
  14. DynamicChoice_main_region_A,
  15. DynamicChoice_main_region_B
  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. /*! Define indices of states in the StateConfVector */
  26. #define SCVI_DYNAMICCHOICE_MAIN_REGION_START 0
  27. #define SCVI_DYNAMICCHOICE_MAIN_REGION_A 0
  28. #define SCVI_DYNAMICCHOICE_MAIN_REGION_B 0
  29. /*!
  30. * Type definition of the data structure for the DynamicChoice state machine.
  31. * This data structure has to be allocated by the client code.
  32. */
  33. typedef struct
  34. {
  35. DynamicChoiceStates stateConfVector[DYNAMICCHOICE_MAX_ORTHOGONAL_STATES];
  36. sc_ushort stateConfVectorPosition;
  37. DynamicChoiceIface iface;
  38. } DynamicChoice;
  39. /*! Initializes the DynamicChoice state machine data structures. Must be called before first usage.*/
  40. extern void dynamicChoice_init(DynamicChoice* handle);
  41. /*! Activates the state machine */
  42. extern void dynamicChoice_enter(DynamicChoice* handle);
  43. /*! Deactivates the state machine */
  44. extern void dynamicChoice_exit(DynamicChoice* handle);
  45. /*! Performs a 'run to completion' step. */
  46. extern void dynamicChoice_runCycle(DynamicChoice* handle);
  47. /*! Gets the value of the variable 'number' that is defined in the default interface scope. */
  48. extern sc_integer dynamicChoiceIface_get_number(const DynamicChoice* handle);
  49. /*! Sets the value of the variable 'number' that is defined in the default interface scope. */
  50. extern void dynamicChoiceIface_set_number(DynamicChoice* handle, sc_integer value);
  51. /*! Raises the in event 'reset' that is defined in the default interface scope. */
  52. extern void dynamicChoiceIface_raise_reset(DynamicChoice* handle);
  53. /*!
  54. * Checks whether the state machine is active (until 2.4.1 this method was used for states).
  55. * 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.
  56. */
  57. extern sc_boolean dynamicChoice_isActive(const DynamicChoice* handle);
  58. /*!
  59. * Checks if all active states are final.
  60. * If there are no active states then the state machine is considered being inactive. In this case this method returns false.
  61. */
  62. extern sc_boolean dynamicChoice_isFinal(const DynamicChoice* handle);
  63. /*! Checks if the specified state is active (until 2.4.1 the used method for states was called isActive()). */
  64. extern sc_boolean dynamicChoice_isStateActive(const DynamicChoice* handle, DynamicChoiceStates state);
  65. #ifdef __cplusplus
  66. }
  67. #endif
  68. #endif /* DYNAMICCHOICE_H_ */