StaticChoice.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #ifndef STATICCHOICE_H_
  2. #define STATICCHOICE_H_
  3. #include "sc_types.h"
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. /*! \file Header of the state machine 'StaticChoice'.
  8. */
  9. /*! Enumeration of all states */
  10. typedef enum
  11. {
  12. StaticChoice_last_state,
  13. StaticChoice_main_region_Start,
  14. StaticChoice_main_region_B,
  15. StaticChoice_main_region_A
  16. } StaticChoiceStates;
  17. /*! Type definition of the data structure for the StaticChoiceIface interface scope. */
  18. typedef struct
  19. {
  20. sc_integer number;
  21. sc_boolean reset_raised;
  22. } StaticChoiceIface;
  23. /*! Define dimension of the state configuration vector for orthogonal states. */
  24. #define STATICCHOICE_MAX_ORTHOGONAL_STATES 1
  25. /*! Define indices of states in the StateConfVector */
  26. #define SCVI_STATICCHOICE_MAIN_REGION_START 0
  27. #define SCVI_STATICCHOICE_MAIN_REGION_B 0
  28. #define SCVI_STATICCHOICE_MAIN_REGION_A 0
  29. /*!
  30. * Type definition of the data structure for the StaticChoice state machine.
  31. * This data structure has to be allocated by the client code.
  32. */
  33. typedef struct
  34. {
  35. StaticChoiceStates stateConfVector[STATICCHOICE_MAX_ORTHOGONAL_STATES];
  36. sc_ushort stateConfVectorPosition;
  37. StaticChoiceIface iface;
  38. } StaticChoice;
  39. /*! Initializes the StaticChoice state machine data structures. Must be called before first usage.*/
  40. extern void staticChoice_init(StaticChoice* handle);
  41. /*! Activates the state machine */
  42. extern void staticChoice_enter(StaticChoice* handle);
  43. /*! Deactivates the state machine */
  44. extern void staticChoice_exit(StaticChoice* handle);
  45. /*! Performs a 'run to completion' step. */
  46. extern void staticChoice_runCycle(StaticChoice* handle);
  47. /*! Gets the value of the variable 'number' that is defined in the default interface scope. */
  48. extern sc_integer staticChoiceIface_get_number(const StaticChoice* handle);
  49. /*! Sets the value of the variable 'number' that is defined in the default interface scope. */
  50. extern void staticChoiceIface_set_number(StaticChoice* handle, sc_integer value);
  51. /*! Raises the in event 'reset' that is defined in the default interface scope. */
  52. extern void staticChoiceIface_raise_reset(StaticChoice* 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 staticChoice_isActive(const StaticChoice* 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 staticChoice_isFinal(const StaticChoice* 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 staticChoice_isStateActive(const StaticChoice* handle, StaticChoiceStates state);
  65. #ifdef __cplusplus
  66. }
  67. #endif
  68. #endif /* STATICCHOICE_H_ */