]> rtime.felk.cvut.cz Git - frescor/fna.git/blob - src_frescan/frescan_servers.h
0e967cbe5a560481bbfdd9c16f2b69e95b573b96
[frescor/fna.git] / src_frescan / frescan_servers.h
1 /*!
2  * @file frescan_servers.h
3  *
4  * @brief FRESCAN sporadic servers
5  *
6  * @version 0.01
7  *
8  * @date 27-Feb-2008
9  *
10  * @author
11  *      Daniel Sangorrin
12  *
13  * @comments
14  *
15  * This file contains the FRESCAN sporadic servers that allow to isolate
16  * different streams of data by assigning them a budget and replenishment
17  * period.
18  *
19  * @license
20  *
21  * -----------------------------------------------------------------------
22  *  Copyright (C) 2006 - 2008 FRESCOR consortium partners:
23  *
24  *    Universidad de Cantabria,              SPAIN
25  *    University of York,                    UK
26  *    Scuola Superiore Sant'Anna,            ITALY
27  *    Kaiserslautern University,             GERMANY
28  *    Univ. Politécnica  Valencia,           SPAIN
29  *    Czech Technical University in Prague,  CZECH REPUBLIC
30  *    ENEA                                   SWEDEN
31  *    Thales Communication S.A.              FRANCE
32  *    Visual Tools S.A.                      SPAIN
33  *    Rapita Systems Ltd                     UK
34  *    Evidence                               ITALY
35  *
36  *    See http://www.frescor.org for a link to partners' websites
37  *
38  *           FRESCOR project (FP6/2005/IST/5-034026) is funded
39  *        in part by the European Union Sixth Framework Programme
40  *        The European Union is not liable of any use that may be
41  *        made of this code.
42  *
43  *  This file is part of FRESCAN
44  *
45  *  FRESCAN is free software; you can  redistribute it and/or  modify
46  *  it under the terms of  the GNU General Public License as published by
47  *  the Free Software Foundation;  either  version 2, or (at  your option)
48  *  any later version.
49  *
50  *  FRESCAN  is distributed  in  the hope  that  it  will  be useful,  but
51  *  WITHOUT  ANY  WARRANTY;     without  even the   implied   warranty  of
52  *  MERCHANTABILITY  or  FITNESS FOR  A  PARTICULAR PURPOSE. See  the  GNU
53  *  General Public License for more details.
54  *
55  *  You should have  received a  copy of  the  GNU  General Public License
56  *  distributed  with  FRESCAN;  see file COPYING.   If not,  write to the
57  *  Free Software  Foundation,  59 Temple Place  -  Suite 330,  Boston, MA
58  *  02111-1307, USA.
59  *
60  * As a special exception, including FRESCAN header files in a file,
61  * instantiating FRESCAN generics or templates, or linking other files
62  * with FRESCAN objects to produce an executable application, does not
63  * by itself cause the resulting executable application to be covered
64  * by the GNU General Public License. This exception does not
65  * however invalidate any other reasons why the executable file might be
66  * covered by the GNU Public License.
67  * -----------------------------------------------------------------------
68  *
69  */
70
71 #ifndef _MARTE_FRESCAN_SERVERS_H_
72 #define _MARTE_FRESCAN_SERVERS_H_
73
74 #include "frescan_types.h"
75
76 /**
77  * frescan_servers_init() - initialize server structures
78  *
79  * @net: the network instance
80  */
81
82 extern int frescan_servers_init(frescan_network_t net);
83
84 /**
85  * frescan_servers_create() - create a sporadic server
86  *
87  * @net: the network instance
88  * @params: the parameters for the server
89  * @id: the identificator for the server as a return value
90  *
91  */
92
93 extern int frescan_servers_create(frescan_network_t net,
94                                   const frescan_server_params_t *params,
95                                   frescan_ss_t *id);
96
97 /**
98  * frescan_servers_set_perceived() - update a sporadic server perceived data
99  *
100  * @net: the network instance
101  * @params: the parameters for the server
102  * @id: the identificator for the server
103  *
104  */
105
106 extern int frescan_servers_set_perceived(frescan_network_t net,
107                                          const frescan_server_params_t *params,
108                                          frescan_ss_t id);
109
110 /**
111  * frescan_servers_commit_perceived() - commit sporadic server perceived data
112  *
113  * @net: the network instance
114  * @params: the parameters for the server
115  * @id: the identificator for the server
116  *
117  */
118
119 extern int frescan_servers_commit_perceived(frescan_network_t net,
120                                             frescan_ss_t id);
121
122 /**
123  * frescan_servers_update() - update a sporadic server data
124  *
125  * It is similar to call 'frescan_servers_set_perceived' and then
126  * 'frescan_servers_commit_perceived'
127  *
128  * @net: the network instance
129  * @params: the parameters for the server
130  * @id: the identificator for the server
131  *
132  */
133
134 extern int frescan_servers_update(frescan_network_t net,
135                                   const frescan_server_params_t *params,
136                                   frescan_ss_t id);
137
138 /**
139  * frescan_servers_destroy() - delete a sporadic server
140  *
141  * @net: the network instance
142  * @id: the identificator for the server
143  *
144  */
145
146 extern int frescan_servers_destroy(frescan_network_t net, frescan_ss_t id);
147
148 /**
149  * frescan_servers_get_data() - get a sporadic server data
150  *
151  * @net: the network instance
152  * @params: the parameters of the server
153  * @id: the identificator for the server
154  *
155  */
156
157 extern  int frescan_servers_get_data(frescan_network_t net,
158                                      frescan_server_params_t *params,
159                                      frescan_ss_t id);
160
161 /**
162  * frescan_servers_get_current_budget() - get the current sporadic server budget
163  *
164  * @net: the network instance
165  * @id: the identificator for the server
166  * @current_budget: the current budget of the server
167  *
168  */
169
170 extern int frescan_servers_get_current_budget(frescan_network_t net,
171                                               frescan_ss_t id,
172                                               frescan_budget_t *current_budget);
173
174 /**
175  * frescan_servers_get_highest_prio() - get the server with highest priority
176  *
177  * @net: the network instance
178  * @id: the identificator for the server
179  * @prio: the priority of that server
180  *
181  * If "id" is returned with a value of FRESCAN_MX_IDS,
182  * there are no active servers.
183  * NOTE: id=FRESCAN_MX_IDS is the identifier for fixed priority messages
184  *
185  */
186
187 extern int frescan_servers_get_highest_prio(frescan_network_t net,
188                                             frescan_ss_t *id,
189                                             frescan_prio_t *prio);
190
191 /**
192  * frescan_servers_frame_sent() - hook to control the server budget and prio
193  *
194  * @net: the network instance
195  * @id: the identificator for the server
196  * @packet: the packet sent (with its timestamp)
197  *
198  * This function is called when a frame has been effectively sent through the
199  * CAN bus and that frame is associated to a certain server. The function
200  * decreases the capacity of the server and sets the priority to background
201  * in case the budget is exhausted.
202  *
203  * NOTE: the replenishment operation is programmed using the corresponding
204  * function at frescan_servers_replenishments module
205  */
206
207 extern int frescan_servers_frame_sent(frescan_network_t net,
208                                       frescan_ss_t id,
209                                       frescan_packet_t *packet);
210
211 #endif // _MARTE_FRESCAN_SERVERS_H_