ArDrone SDK 1.8 added
[mardrone] / mardrone / ARDrone_SDK_Version_1_8_20110726 / ARDroneLib / VP_SDK / VP_Api / vp_api_supervisor.h
1 /**
2  *  @file     vp_api_supervisor.h
3  *  @brief    VP Api. Pipeline supervisor
4  */
5
6
7 #ifndef _VP_API_SUPERVISOR_H_
8 #define _VP_API_SUPERVISOR_H_
9
10 /**
11  * @addtogroup VP_SDK
12  * @{ */
13
14 /**
15  * @addtogroup VP_Api
16  * @{ */
17
18 /**
19  * @defgroup vp_api_supervisor Api supervisor
20  *
21  * \section Brief
22  * \code
23  Supervise pipelines :
24  Handle multiple pipelines per application.
25  Handle pipeline messages and dispatch them to stages.
26  * \endcode
27  *
28  * \section History
29  *
30  * \par date: 2007-06-14  author: <julien.floret.ext\@parrot.com>
31  *  - Handle different message dispatchs : Pipeline level, stage broadcast
32  *
33  * \par date: 2007-05-28  author: <julien.floret.ext\@parrot.com>
34  *  - Add supervisor
35  *
36  * @{ */
37
38 ///////////////////////////////////////////////
39 // INCLUDES
40
41 #include <VP_Os/vp_os_types.h>
42 #include <VP_Os/vp_os_signal.h>
43
44 ///////////////////////////////////////////////
45 // GLOBALS
46
47 struct _vp_api_io_pipeline_;
48
49
50 ///////////////////////////////////////////////
51 // DEFINES
52
53 /**
54  *  @def VP_API_DEST_PIPELINE_LEVEL
55  *  Pipeline level : no dispatch to stages
56  */
57 /**
58  *  @def VP_API_DEST_STAGE_BROADCAST
59  *  Broadcast message to all stages
60  */
61
62 #define VP_API_DEST_PIPELINE_LEVEL            0x7fff
63 #define VP_API_DEST_STAGE_BROADCAST           0x7ffe
64
65
66 typedef int32_t PIPELINE_ADDRESS;   ///< Pipeline address
67 typedef int16_t PIPELINE_HANDLE;    ///< Pipeline handle
68
69
70 /** Pipeline message identifiers
71  */
72 typedef enum _PIPELINE_MSG
73 {
74   PIPELINE_MSG_START,
75   PIPELINE_MSG_STOP,
76   PIPELINE_MSG_SUSPEND,
77   PIPELINE_MSG_RESUME,
78   PIPELINE_MSG_RESET,
79   PIPELINE_MSG_END,
80   PIPELINE_MSG_SYNCHRONIZE,
81   PIPELINE_MSG_COMMAND
82 }
83 PIPELINE_MSG;
84
85
86 /**
87  *  @brief   Pipeline messages fifo
88  */
89 typedef struct _vp_api_fifo_
90 {
91   char   *pbase;             ///< Base address of the fifo
92   char   *pget;              ///< Pointer to the next message to get
93   char   *ppost;             ///< Where to post a new message in the fifo
94   int32_t    nb_waiting;        ///< Number of messages waiting to be handled
95   vp_os_mutex_t mutex;
96 }
97 vp_api_fifo_t;
98
99
100 /**
101  *  @brief   Handle to a message destination
102  */
103 typedef union _DEST_HANDLE
104 {
105   int32_t   handle;             ///< Pipeline handle (16 bits) + stage number (16bits)
106   struct
107   {
108     PIPELINE_HANDLE pipeline;   ///< Pipeline handle
109     int16_t         stage;      ///< Stage number
110   };
111 }
112 DEST_HANDLE;
113
114
115 typedef C_RESULT (*vp_api_handle_msg_t)(  struct _vp_api_io_pipeline_ *pipeline,
116                                           PIPELINE_MSG                 msg_id,
117                                           void                        *callback,
118                                           void                        *param
119                                        );
120
121
122 ///////////////////////////////////////////////
123 // PROTOTYPES
124
125 /**
126  *  @fn      vp_api_add_pipeline(struct _vp_api_io_pipeline_ *, PIPELINE_HANDLE *)
127  *  @brief   Add a pipeline and get its handle
128  *  @param   pipeline Pipeline to add
129  *  @param   handle   Handle to the added pipeline
130  *  @return  C_RESULT : VP_SUCCESS
131  *  @author  Julien Floret <julien.floret.ext\@parrot.com>
132  *  @date    28/05/2007
133  */
134 C_RESULT vp_api_add_pipeline(struct _vp_api_io_pipeline_ *pipeline, PIPELINE_HANDLE *handle);
135
136
137 /**
138  *  @fn      vp_api_remove_pipeline(struct _vp_api_io_pipeline_ *, PIPELINE_HANDLE *)
139  *  @brief   Remove a pipeline and release handle
140  *  @param   pipeline Pipeline to remove
141  *  @param   handle   Handle of the pipeline
142  *  @return  C_RESULT : VP_SUCCESS
143  *  @author  Aurelien Morelle <aurelien.morelle@parrot.com>
144  *  @date    18/09/2008
145  */
146 C_RESULT vp_api_remove_pipeline(struct _vp_api_io_pipeline_ *pipeline, PIPELINE_HANDLE *handle);
147
148
149 /**
150  *  @fn      vp_api_get_pipeline(PIPELINE_HANDLE)
151  *  @brief   Get a pipeline address from its handle
152  *  @param   handle Pipeline handle
153  *  @return  struct _vp_api_io_pipeline_ * : Pipeline to get
154  *  @author  Julien Floret <julien.floret.ext\@parrot.com>
155  *  @date    28/05/2007
156  */
157 struct _vp_api_io_pipeline_ * vp_api_get_pipeline(PIPELINE_HANDLE handle);
158
159
160 /**
161  *  @fn      vp_api_post_message(DEST_HANDLE, PIPELINE_MSG, void *, void *)
162  *  @brief   Post a message to a pipeline
163  *  @param   dest     Message destination
164  *  @param   msg_id   Message identifier
165  *  @param   callback Optional callback function called after processing of the message
166  *  @param   param    Optional message parameters
167  *  @return  C_RESULT : VP_SUCCESS or VP_FAILURE
168  *  @author  Julien Floret <julien.floret.ext\@parrot.com>
169  *  @date    28/05/2007
170  */
171 C_RESULT vp_api_post_message(DEST_HANDLE dest, PIPELINE_MSG msg_id, void *callback, void *param);
172
173
174 /**
175  *  @fn      vp_api_handle_messages(struct _vp_api_io_pipeline_ *)
176  *  @brief   Handle pipeline messages
177  *
178  *  This function handles pipeline messages by calling user defined callback functions
179  *  @param   pipeline   Current pipeline
180  *  @return  C_RESULT : VP_SUCCESS
181  *  @author  Julien Floret <julien.floret.ext\@parrot.com>
182  *  @date    28/05/2007
183  */
184 C_RESULT vp_api_handle_messages(struct _vp_api_io_pipeline_ *pipeline);
185
186 // vp_api_supervisor
187 /** @} */
188 // VP_Api
189 /** @} */
190 // VP_SDK
191 /** @} */
192
193 #endif // ! _VP_API_SUPERVISOR_H_