Powerwindow.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. #ifndef POWERWINDOW_H_
  2. #define POWERWINDOW_H_
  3. #include "sc_types.h"
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. /*! \file Header of the state machine 'powerwindow'.
  8. */
  9. /*! Enumeration of all states */
  10. typedef enum {
  11. Powerwindow_main_region_Normal_operation,
  12. Powerwindow_main_region_Normal_operation_r1_Driver_neutral,
  13. Powerwindow_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_operation,
  14. Powerwindow_main_region_Normal_operation_r1_Driver_neutral_r1_Passenger_down,
  15. Powerwindow_main_region_Normal_operation_r1_Driver_down,
  16. Powerwindow_main_region_Normal_operation_r1_Driver_up,
  17. Powerwindow_main_region_Normal_operation_r1_Passenger_up,
  18. Powerwindow_main_region_Emergency_operation,
  19. Powerwindow_last_state
  20. } PowerwindowStates;
  21. /*! Type definition of the data structure for the PowerwindowIfaceOutput interface scope. */
  22. typedef struct {
  23. sc_boolean up;
  24. sc_boolean down;
  25. } PowerwindowIfaceOutput;
  26. /*! Type definition of the data structure for the PowerwindowIfaceInput interface scope. */
  27. typedef struct {
  28. sc_boolean obj_detected_raised;
  29. sc_boolean passenger_up_raised;
  30. sc_boolean passenger_down_raised;
  31. sc_boolean driver_up_raised;
  32. sc_boolean driver_down_raised;
  33. sc_boolean stop_raised;
  34. } PowerwindowIfaceInput;
  35. /*! Type definition of the data structure for the PowerwindowTimeEvents interface scope. */
  36. typedef struct {
  37. sc_boolean powerwindow_main_region_Emergency_operation_tev0_raised;
  38. } PowerwindowTimeEvents;
  39. /*! Define dimension of the state configuration vector for orthogonal states. */
  40. #define POWERWINDOW_MAX_ORTHOGONAL_STATES 1
  41. /*!
  42. * Type definition of the data structure for the Powerwindow state machine.
  43. * This data structure has to be allocated by the client code.
  44. */
  45. typedef struct {
  46. PowerwindowStates stateConfVector[POWERWINDOW_MAX_ORTHOGONAL_STATES];
  47. sc_ushort stateConfVectorPosition;
  48. PowerwindowIfaceOutput ifaceOutput;
  49. PowerwindowIfaceInput ifaceInput;
  50. PowerwindowTimeEvents timeEvents;
  51. } Powerwindow;
  52. void powerwindow_copy(Powerwindow* original, Powerwindow* copy);
  53. /*! Initializes the Powerwindow state machine data structures. Must be called before first usage.*/
  54. extern void powerwindow_init(Powerwindow* handle);
  55. /*! Activates the state machine */
  56. extern void powerwindow_enter(Powerwindow* handle);
  57. /*! Deactivates the state machine */
  58. extern void powerwindow_exit(Powerwindow* handle);
  59. /*! Performs a 'run to completion' step. */
  60. extern void powerwindow_runCycle(Powerwindow* handle);
  61. /*! Raises a time event. */
  62. extern void powerwindow_raiseTimeEvent(const Powerwindow* handle, sc_eventid evid);
  63. /*! Gets the value of the variable 'up' that is defined in the interface scope 'output'. */
  64. extern sc_boolean powerwindowIfaceOutput_get_up(const Powerwindow* handle);
  65. /*! Gets the value of the variable 'down' that is defined in the interface scope 'output'. */
  66. extern sc_boolean powerwindowIfaceOutput_get_down(const Powerwindow* handle);
  67. /*! Raises the in event 'obj_detected' that is defined in the interface scope 'input'. */
  68. extern void powerwindowIfaceInput_raise_obj_detected(Powerwindow* handle);
  69. /*! Raises the in event 'passenger_up' that is defined in the interface scope 'input'. */
  70. extern void powerwindowIfaceInput_raise_passenger_up(Powerwindow* handle);
  71. /*! Raises the in event 'passenger_down' that is defined in the interface scope 'input'. */
  72. extern void powerwindowIfaceInput_raise_passenger_down(Powerwindow* handle);
  73. /*! Raises the in event 'driver_up' that is defined in the interface scope 'input'. */
  74. extern void powerwindowIfaceInput_raise_driver_up(Powerwindow* handle);
  75. /*! Raises the in event 'driver_down' that is defined in the interface scope 'input'. */
  76. extern void powerwindowIfaceInput_raise_driver_down(Powerwindow* handle);
  77. /*! Raises the in event 'stop' that is defined in the interface scope 'input'. */
  78. extern void powerwindowIfaceInput_raise_stop(Powerwindow* handle);
  79. /*!
  80. * Checks if the statemachine is active (until 2.4.1 this method was used for states).
  81. * A statemachine is active if it was entered. It is inactive if it has not been entered at all or if it was exited.
  82. */
  83. extern sc_boolean powerwindow_isActive(const Powerwindow* handle);
  84. /*!
  85. * Checks if all active states are final.
  86. * If there are no active states then the statemachine is considered as inactive and this method returns false.
  87. */
  88. extern sc_boolean powerwindow_isFinal(const Powerwindow* handle);
  89. /*! Checks if the specified state is active (until 2.4.1 the used method for states was calles isActive()). */
  90. extern sc_boolean powerwindow_isStateActive(const Powerwindow* handle, PowerwindowStates state);
  91. #ifdef __cplusplus
  92. }
  93. #endif
  94. #endif /* POWERWINDOW_H_ */