Cync
[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 typedef int vp_os_mutex_t ;
45 ///////////////////////////////////////////////
46 // GLOBALS
47
48 struct _vp_api_io_pipeline_;
49
50
51 ///////////////////////////////////////////////
52 // DEFINES
53
54 /**
55  *  @def VP_API_DEST_PIPELINE_LEVEL
56  *  Pipeline level : no dispatch to stages
57  */
58 /**
59  *  @def VP_API_DEST_STAGE_BROADCAST
60  *  Broadcast message to all stages
61  */
62
63 #define VP_API_DEST_PIPELINE_LEVEL            0x7fff
64 #define VP_API_DEST_STAGE_BROADCAST           0x7ffe
65
66
67 typedef int32_t PIPELINE_ADDRESS;   ///< Pipeline address
68 typedef int16_t PIPELINE_HANDLE;    ///< Pipeline handle
69
70
71 /** Pipeline message identifiers
72  */
73 typedef enum _PIPELINE_MSG
74 {
75   PIPELINE_MSG_START,
76   PIPELINE_MSG_STOP,
77   PIPELINE_MSG_SUSPEND,
78   PIPELINE_MSG_RESUME,
79   PIPELINE_MSG_RESET,
80   PIPELINE_MSG_END,
81   PIPELINE_MSG_SYNCHRONIZE,
82   PIPELINE_MSG_COMMAND
83 }
84 PIPELINE_MSG;
85
86
87 /**
88  *  @brief   Pipeline messages fifo
89  */
90 typedef struct _vp_api_fifo_
91 {
92   char   *pbase;             ///< Base address of the fifo
93   char   *pget;              ///< Pointer to the next message to get
94   char   *ppost;             ///< Where to post a new message in the fifo
95   int32_t    nb_waiting;        ///< Number of messages waiting to be handled
96   vp_os_mutex_t mutex;
97 }
98 vp_api_fifo_t;
99
100
101 /**
102  *  @brief   Handle to a message destination
103  */
104 typedef union _DEST_HANDLE
105 {
106   int32_t   handle;             ///< Pipeline handle (16 bits) + stage number (16bits)
107   struct
108   {
109     PIPELINE_HANDLE pipeline;   ///< Pipeline handle
110     int16_t         stage;      ///< Stage number
111   };
112 }
113 DEST_HANDLE;
114
115
116 typedef C_RESULT (*vp_api_handle_msg_t)(  struct _vp_api_io_pipeline_ *pipeline,
117                                           PIPELINE_MSG                 msg_id,
118                                           void                        *callback,
119                                           void                        *param
120                                        );
121
122
123 ///////////////////////////////////////////////
124 // PROTOTYPES
125
126 /**
127  *  @fn      vp_api_add_pipeline(struct _vp_api_io_pipeline_ *, PIPELINE_HANDLE *)
128  *  @brief   Add a pipeline and get its handle
129  *  @param   pipeline Pipeline to add
130  *  @param   handle   Handle to the added pipeline
131  *  @return  C_RESULT : VP_SUCCESS
132  *  @author  Julien Floret <julien.floret.ext\@parrot.com>
133  *  @date    28/05/2007
134  */
135 C_RESULT vp_api_add_pipeline(struct _vp_api_io_pipeline_ *pipeline, PIPELINE_HANDLE *handle);
136
137
138 /**
139  *  @fn      vp_api_remove_pipeline(struct _vp_api_io_pipeline_ *, PIPELINE_HANDLE *)
140  *  @brief   Remove a pipeline and release handle
141  *  @param   pipeline Pipeline to remove
142  *  @param   handle   Handle of the pipeline
143  *  @return  C_RESULT : VP_SUCCESS
144  *  @author  Aurelien Morelle <aurelien.morelle@parrot.com>
145  *  @date    18/09/2008
146  */
147 C_RESULT vp_api_remove_pipeline(struct _vp_api_io_pipeline_ *pipeline, PIPELINE_HANDLE *handle);
148
149
150 /**
151  *  @fn      vp_api_get_pipeline(PIPELINE_HANDLE)
152  *  @brief   Get a pipeline address from its handle
153  *  @param   handle Pipeline handle
154  *  @return  struct _vp_api_io_pipeline_ * : Pipeline to get
155  *  @author  Julien Floret <julien.floret.ext\@parrot.com>
156  *  @date    28/05/2007
157  */
158 struct _vp_api_io_pipeline_ * vp_api_get_pipeline(PIPELINE_HANDLE handle);
159
160
161 /**
162  *  @fn      vp_api_post_message(DEST_HANDLE, PIPELINE_MSG, void *, void *)
163  *  @brief   Post a message to a pipeline
164  *  @param   dest     Message destination
165  *  @param   msg_id   Message identifier
166  *  @param   callback Optional callback function called after processing of the message
167  *  @param   param    Optional message parameters
168  *  @return  C_RESULT : VP_SUCCESS or VP_FAILURE
169  *  @author  Julien Floret <julien.floret.ext\@parrot.com>
170  *  @date    28/05/2007
171  */
172 C_RESULT vp_api_post_message(DEST_HANDLE dest, PIPELINE_MSG msg_id, void *callback, void *param);
173
174
175 /**
176  *  @fn      vp_api_handle_messages(struct _vp_api_io_pipeline_ *)
177  *  @brief   Handle pipeline messages
178  *
179  *  This function handles pipeline messages by calling user defined callback functions
180  *  @param   pipeline   Current pipeline
181  *  @return  C_RESULT : VP_SUCCESS
182  *  @author  Julien Floret <julien.floret.ext\@parrot.com>
183  *  @date    28/05/2007
184  */
185 C_RESULT vp_api_handle_messages(struct _vp_api_io_pipeline_ *pipeline);
186
187 // vp_api_supervisor
188 /** @} */
189 // VP_Api
190 /** @} */
191 // VP_SDK
192 /** @} */
193
194 #endif // ! _VP_API_SUPERVISOR_H_