ReadOnlyVariable.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #ifndef READONLYVARIABLE_H_
  2. #define READONLYVARIABLE_H_
  3. #include "sc_types.h"
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. /*! \file Header of the state machine 'ReadOnlyVariable'.
  8. */
  9. /*! Enumeration of all states */
  10. typedef enum
  11. {
  12. ReadOnlyVariable_main_region_StateB,
  13. ReadOnlyVariable_main_region_StateA,
  14. ReadOnlyVariable_last_state
  15. } ReadOnlyVariableStates;
  16. /*! Type definition of the data structure for the ReadOnlyVariableIface interface scope. */
  17. typedef struct
  18. {
  19. sc_integer myInt;
  20. sc_string myString;
  21. sc_boolean myBool;
  22. sc_real myReal;
  23. } ReadOnlyVariableIface;
  24. /*! Type definition of the data structure for the ReadOnlyVariableIfaceA interface scope. */
  25. typedef struct
  26. {
  27. sc_integer myInt;
  28. sc_string myString;
  29. sc_boolean myBool;
  30. sc_real myReal;
  31. } ReadOnlyVariableIfaceA;
  32. /*! Define dimension of the state configuration vector for orthogonal states. */
  33. #define READONLYVARIABLE_MAX_ORTHOGONAL_STATES 1
  34. /*!
  35. * Type definition of the data structure for the ReadOnlyVariable state machine.
  36. * This data structure has to be allocated by the client code.
  37. */
  38. typedef struct
  39. {
  40. ReadOnlyVariableStates stateConfVector[READONLYVARIABLE_MAX_ORTHOGONAL_STATES];
  41. sc_ushort stateConfVectorPosition;
  42. ReadOnlyVariableIface iface;
  43. ReadOnlyVariableIfaceA ifaceA;
  44. } ReadOnlyVariable;
  45. /*! Initializes the ReadOnlyVariable state machine data structures. Must be called before first usage.*/
  46. extern void readOnlyVariable_init(ReadOnlyVariable* handle);
  47. /*! Activates the state machine */
  48. extern void readOnlyVariable_enter(ReadOnlyVariable* handle);
  49. /*! Deactivates the state machine */
  50. extern void readOnlyVariable_exit(ReadOnlyVariable* handle);
  51. /*! Performs a 'run to completion' step. */
  52. extern void readOnlyVariable_runCycle(ReadOnlyVariable* handle);
  53. /*! Gets the value of the variable 'myInt' that is defined in the default interface scope. */
  54. extern sc_integer readOnlyVariableIface_get_myInt(const ReadOnlyVariable* handle);
  55. /*! Gets the value of the variable 'myString' that is defined in the default interface scope. */
  56. extern sc_string readOnlyVariableIface_get_myString(const ReadOnlyVariable* handle);
  57. /*! Gets the value of the variable 'myBool' that is defined in the default interface scope. */
  58. extern sc_boolean readOnlyVariableIface_get_myBool(const ReadOnlyVariable* handle);
  59. /*! Gets the value of the variable 'myReal' that is defined in the default interface scope. */
  60. extern sc_real readOnlyVariableIface_get_myReal(const ReadOnlyVariable* handle);
  61. /*! Gets the value of the variable 'myInt' that is defined in the interface scope 'A'. */
  62. extern sc_integer readOnlyVariableIfaceA_get_myInt(const ReadOnlyVariable* handle);
  63. /*! Gets the value of the variable 'myString' that is defined in the interface scope 'A'. */
  64. extern sc_string readOnlyVariableIfaceA_get_myString(const ReadOnlyVariable* handle);
  65. /*! Gets the value of the variable 'myBool' that is defined in the interface scope 'A'. */
  66. extern sc_boolean readOnlyVariableIfaceA_get_myBool(const ReadOnlyVariable* handle);
  67. /*! Gets the value of the variable 'myReal' that is defined in the interface scope 'A'. */
  68. extern sc_real readOnlyVariableIfaceA_get_myReal(const ReadOnlyVariable* handle);
  69. /*!
  70. * Checks whether the state machine is active (until 2.4.1 this method was used for states).
  71. * 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.
  72. */
  73. extern sc_boolean readOnlyVariable_isActive(const ReadOnlyVariable* handle);
  74. /*!
  75. * Checks if all active states are final.
  76. * If there are no active states then the state machine is considered being inactive. In this case this method returns false.
  77. */
  78. extern sc_boolean readOnlyVariable_isFinal(const ReadOnlyVariable* handle);
  79. /*! Checks if the specified state is active (until 2.4.1 the used method for states was called isActive()). */
  80. extern sc_boolean readOnlyVariable_isStateActive(const ReadOnlyVariable* handle, ReadOnlyVariableStates state);
  81. #ifdef __cplusplus
  82. }
  83. #endif
  84. #endif /* READONLYVARIABLE_H_ */