]> rtime.felk.cvut.cz Git - frescor/fna.git/blob - src_frescan/frescan_servers.h
047225dd3762a51fa76550c5efe1bb4231f01cad
[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  * See MaRTE OS license
22  *
23  */
24
25 #ifndef _MARTE_FRESCAN_SERVERS_H_
26 #define _MARTE_FRESCAN_SERVERS_H_
27
28 #include "frescan.h"         // frescan_prio_t, frescan_ss_t
29 #include "frescan_packets.h" // frescan_packet_t
30 #include <time.h>            // struct timespec
31 #include "frescan_data.h"
32
33 /**
34  * frescan_servers_init() - initialize server structures
35  *
36  * @net: the network instance
37  */
38
39 extern int frescan_servers_init(frescan_network_t net);
40
41 /**
42  * frescan_servers_create() - create a sporadic server
43  *
44  * @net: the network instance
45  * @params: the parameters for the server
46  * @id: the identificator for the server as a return value
47  *
48  */
49
50 extern int frescan_servers_create(frescan_network_t net,
51                                   const frescan_server_params_t *params,
52                                   frescan_ss_t *id);
53
54 /**
55  * frescan_servers_update() - update a sporadic server data
56  *
57  * @net: the network instance
58  * @params: the parameters for the server
59  * @id: the identificator for the server
60  *
61  */
62
63 extern int frescan_servers_update(frescan_network_t net,
64                                   const frescan_server_params_t *params,
65                                   frescan_ss_t id);
66
67 /**
68  * frescan_servers_destroy() - delete a sporadic server
69  *
70  * @net: the network instance
71  * @id: the identificator for the server
72  *
73  */
74
75 extern int frescan_servers_destroy(frescan_network_t net, frescan_ss_t id);
76
77 /**
78  * frescan_servers_get_data() - get a sporadic server data
79  *
80  * @net: the network instance
81  * @params: the parameters of the server
82  * @id: the identificator for the server
83  *
84  */
85
86 extern  int frescan_servers_get_data(frescan_network_t net,
87                                      frescan_server_params_t *params,
88                                      frescan_ss_t id);
89
90 /**
91  * frescan_servers_get_current_budget() - get the current sporadic server budget
92  *
93  * @net: the network instance
94  * @id: the identificator for the server
95  * @current_budget: the current budget of the server
96  *
97  */
98
99 extern int frescan_servers_get_current_budget(frescan_network_t net,
100                                               frescan_ss_t id,
101                                               frescan_budget_t *current_budget);
102
103 /**
104  * frescan_servers_get_highest_prio() - get the server with highest priority
105  *
106  * @net: the network instance
107  * @id: the identificator for the server
108  * @prio: the priority of that server
109  *
110  * If "id" is returned with a value of FRESCAN_MX_IDS,
111  * there are no active servers.
112  * NOTE: id=FRESCAN_MX_IDS is the identifier for fixed priority messages
113  *
114  */
115
116 extern int frescan_servers_get_highest_prio(frescan_network_t net,
117                                             frescan_ss_t *id,
118                                             frescan_prio_t *prio);
119
120 /**
121  * frescan_servers_frame_sent() - hook to control the server budget and prio
122  *
123  * @net: the network instance
124  * @id: the identificator for the server
125  *
126  * This function is called when a frame has been effectively sent through the
127  * CAN bus and that frame is associated to a certain server. The function
128  * decreases the capacity of the server and sets the priority to background
129  * in case the budget is exhausted.
130  *
131  * NOTE: the replenishment operation is programmed using the corresponding
132  * function at frescan_servers_replenishments module
133  */
134
135 extern int frescan_servers_frame_sent(frescan_network_t net, frescan_ss_t id);
136
137 #endif // _MARTE_FRESCAN_SERVERS_H_