Choice.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #ifndef CHOICE_H_
  2. #define CHOICE_H_
  3. #include "sc_types.h"
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. /*! \file Header of the state machine 'Choice'.
  8. */
  9. /*! Enumeration of all states */
  10. typedef enum
  11. {
  12. Choice_last_state,
  13. Choice_main_region_A,
  14. Choice_main_region_B,
  15. Choice_main_region_C
  16. } ChoiceStates;
  17. /*! Type definition of the data structure for the ChoiceIface interface scope. */
  18. typedef struct
  19. {
  20. sc_boolean e_raised;
  21. sc_boolean f_raised;
  22. sc_boolean g_raised;
  23. sc_boolean h_raised;
  24. sc_boolean c;
  25. } ChoiceIface;
  26. /*! Define dimension of the state configuration vector for orthogonal states. */
  27. #define CHOICE_MAX_ORTHOGONAL_STATES 1
  28. /*! Define indices of states in the StateConfVector */
  29. #define SCVI_CHOICE_MAIN_REGION_A 0
  30. #define SCVI_CHOICE_MAIN_REGION_B 0
  31. #define SCVI_CHOICE_MAIN_REGION_C 0
  32. /*!
  33. * Type definition of the data structure for the Choice state machine.
  34. * This data structure has to be allocated by the client code.
  35. */
  36. typedef struct
  37. {
  38. ChoiceStates stateConfVector[CHOICE_MAX_ORTHOGONAL_STATES];
  39. sc_ushort stateConfVectorPosition;
  40. ChoiceIface iface;
  41. } Choice;
  42. /*! Initializes the Choice state machine data structures. Must be called before first usage.*/
  43. extern void choice_init(Choice* handle);
  44. /*! Activates the state machine */
  45. extern void choice_enter(Choice* handle);
  46. /*! Deactivates the state machine */
  47. extern void choice_exit(Choice* handle);
  48. /*! Performs a 'run to completion' step. */
  49. extern void choice_runCycle(Choice* handle);
  50. /*! Raises the in event 'e' that is defined in the default interface scope. */
  51. extern void choiceIface_raise_e(Choice* handle);
  52. /*! Raises the in event 'f' that is defined in the default interface scope. */
  53. extern void choiceIface_raise_f(Choice* handle);
  54. /*! Raises the in event 'g' that is defined in the default interface scope. */
  55. extern void choiceIface_raise_g(Choice* handle);
  56. /*! Raises the in event 'h' that is defined in the default interface scope. */
  57. extern void choiceIface_raise_h(Choice* handle);
  58. /*! Gets the value of the variable 'c' that is defined in the default interface scope. */
  59. extern sc_boolean choiceIface_get_c(const Choice* handle);
  60. /*! Sets the value of the variable 'c' that is defined in the default interface scope. */
  61. extern void choiceIface_set_c(Choice* handle, sc_boolean value);
  62. /*!
  63. * Checks whether the state machine is active (until 2.4.1 this method was used for states).
  64. * 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.
  65. */
  66. extern sc_boolean choice_isActive(const Choice* handle);
  67. /*!
  68. * Checks if all active states are final.
  69. * If there are no active states then the state machine is considered being inactive. In this case this method returns false.
  70. */
  71. extern sc_boolean choice_isFinal(const Choice* handle);
  72. /*! Checks if the specified state is active (until 2.4.1 the used method for states was called isActive()). */
  73. extern sc_boolean choice_isStateActive(const Choice* handle, ChoiceStates state);
  74. #ifdef __cplusplus
  75. }
  76. #endif
  77. #endif /* CHOICE_H_ */