1 | /* Virginia Tech Cognitive Radio Open Source Systems |
---|
2 | * Virginia Tech, 2009 |
---|
3 | * |
---|
4 | * LICENSE INFORMATION GOES HERE |
---|
5 | */ |
---|
6 | |
---|
7 | /* This header exports the declarations for all VT-CROSS radio components. It |
---|
8 | * contains two pure abstract base classes, Component and Engine; Engine derives |
---|
9 | * from Component. All functions contained within the abstract base classes are |
---|
10 | * dynamically linked and pure, and all child non-abstract classes derive using |
---|
11 | * private inheritence. Class functions of the abstract base classes are public |
---|
12 | * for two reasons: (1) To allow for public/protected inheritence in other |
---|
13 | * implementations, (2) So that symbolic debuggers can navigate the call tree |
---|
14 | * for typecasted objects of derivative classes. |
---|
15 | */ |
---|
16 | |
---|
17 | #ifndef COMPONENTS_H |
---|
18 | #define COMPONENTS_H |
---|
19 | |
---|
20 | |
---|
21 | #include <stdint.h> |
---|
22 | #include <string> |
---|
23 | |
---|
24 | #include "containers.h" |
---|
25 | |
---|
26 | |
---|
27 | /* Component abstract base class that all component classes should inherit from, |
---|
28 | * including cognitive and policy engines, and the service management layer. |
---|
29 | * Defines only functions required by all component types. |
---|
30 | */ |
---|
31 | class Component |
---|
32 | { |
---|
33 | public: |
---|
34 | /* Asks the component at the passed socket FD for its component type |
---|
35 | * string. |
---|
36 | */ |
---|
37 | virtual void GetRemoteComponentType(int32_t socketFD) = 0; |
---|
38 | |
---|
39 | |
---|
40 | /* Wait for a command signal containing task instructions. |
---|
41 | */ |
---|
42 | virtual void WaitForSignal(int32_t socketFD) = 0; |
---|
43 | |
---|
44 | |
---|
45 | /* Completely shutdown the radio and all operations. |
---|
46 | */ |
---|
47 | virtual void Shutdown() = 0; |
---|
48 | |
---|
49 | |
---|
50 | /* Reset the radio and reload all configuration files. |
---|
51 | * |
---|
52 | * TODO are we remembering experiences in CEs? |
---|
53 | */ |
---|
54 | virtual void Reset() = 0; |
---|
55 | |
---|
56 | |
---|
57 | /* Register or deregister a component with the primary radio shell. |
---|
58 | */ |
---|
59 | virtual void RegisterComponent(int32_t socketFD) = 0; |
---|
60 | virtual void DeregisterComponent(int32_t socketFD) = 0; |
---|
61 | }; |
---|
62 | |
---|
63 | |
---|
64 | /* Engine abstract base class from which all engine component types should |
---|
65 | * inherit (e.g. cognitive and policy engines). Inherits all functions from the |
---|
66 | * ABC Component publically. |
---|
67 | * |
---|
68 | * TODO perhaps this shouldn't be an abstract base class? Some functions, like |
---|
69 | * GetRemoteComponentType, are going to be the same for all child classes |
---|
70 | * anyways... |
---|
71 | */ |
---|
72 | class Engine : public Component |
---|
73 | { |
---|
74 | public: |
---|
75 | /* Register or deregister services that this engine provides with the |
---|
76 | * service management layer. |
---|
77 | */ |
---|
78 | virtual void RegisterServices(int32_t socketFD) = 0; |
---|
79 | virtual void DeregisterServices(int32_t socketFD) = 0; |
---|
80 | }; |
---|
81 | |
---|
82 | |
---|
83 | /* Service Management Layer (SML) class declaration. The functions listed here |
---|
84 | * are required by the VTCROSS API for service-oriented VTCROSS radio |
---|
85 | * architectures. |
---|
86 | */ |
---|
87 | class ServiceManagementLayer : public Component |
---|
88 | { |
---|
89 | public: |
---|
90 | ServiceManagementLayer(); |
---|
91 | ~ServiceManagementLayer(); |
---|
92 | |
---|
93 | void GetRemoteComponentType(int32_t socketFD); |
---|
94 | void WaitForSignal(int32_t socketFD); |
---|
95 | void Shutdown(); |
---|
96 | void Reset(); |
---|
97 | void RegisterComponent(int32_t socketFD); |
---|
98 | void DeregisterComponent(int32_t socketFD); |
---|
99 | |
---|
100 | private: |
---|
101 | /* Receive the radio configuration settings from the shell and pass them |
---|
102 | * on to another component. |
---|
103 | */ |
---|
104 | void TransferRadioConfiguration(); |
---|
105 | |
---|
106 | |
---|
107 | /* Receive information regarding a completed 'experience' and pass it on |
---|
108 | * to the appropriate cognitive engine. |
---|
109 | */ |
---|
110 | void TransferExperience(); |
---|
111 | |
---|
112 | |
---|
113 | /* Listen for other components registering their available services with |
---|
114 | * the SML. */ |
---|
115 | void ReceiveServices(); |
---|
116 | |
---|
117 | |
---|
118 | /* Change the active mission of the radio to a new one and adjust radio |
---|
119 | * behavoir appropriately. |
---|
120 | */ |
---|
121 | void SetActiveMission(); |
---|
122 | |
---|
123 | |
---|
124 | /* List all services provided to the radio by registered components. |
---|
125 | */ |
---|
126 | void ListServices(); |
---|
127 | |
---|
128 | |
---|
129 | /* Load/Relead the XML configuration file. |
---|
130 | */ |
---|
131 | void ReloadConfiguration(); |
---|
132 | void LoadConfiguration(); |
---|
133 | }; |
---|
134 | |
---|
135 | |
---|
136 | /* Contains information regarding the SML in a VTCROSS system. Note that if |
---|
137 | * there is no SML present, the engine should have no instantiation of this |
---|
138 | * struct. |
---|
139 | */ |
---|
140 | struct SML_Info { |
---|
141 | std::string hostname; |
---|
142 | std::string port; |
---|
143 | int32_t socketFD; |
---|
144 | }; |
---|
145 | |
---|
146 | |
---|
147 | /* Policy Engine class declaration. All public functions are inherited from |
---|
148 | * parent classes. |
---|
149 | */ |
---|
150 | class PolicyEngine : public Engine |
---|
151 | { |
---|
152 | public: |
---|
153 | PolicyEngine(); |
---|
154 | ~PolicyEngine(); |
---|
155 | |
---|
156 | |
---|
157 | /* Overloaded constructor that creates a policy engine object with SML |
---|
158 | * information pre-defined. |
---|
159 | */ |
---|
160 | PolicyEngine(const char* serverName, const char* portNumber); |
---|
161 | |
---|
162 | void GetRemoteComponentType(int32_t socketFD); |
---|
163 | void WaitForSignal(int32_t socketFD); |
---|
164 | void Shutdown(); |
---|
165 | void Reset(); |
---|
166 | void RegisterComponent(int32_t socketFD); |
---|
167 | void DeregisterComponent(int32_t socketFD); |
---|
168 | |
---|
169 | void RegisterServices(int32_t socketFD); |
---|
170 | void DeregisterServices(int32_t socketFD); |
---|
171 | |
---|
172 | private: |
---|
173 | /* Parse and load/reload policies into the policy engine. |
---|
174 | */ |
---|
175 | void LoadPolicies(); |
---|
176 | void ReloadPolicies(); |
---|
177 | |
---|
178 | |
---|
179 | /* Return a decision made by the policy engine regarding a certain set |
---|
180 | * of transmission parameters. |
---|
181 | */ |
---|
182 | void SendPEDecision(int32_t socketFD, struct Parameter pList[], \ |
---|
183 | struct CE_Info *ce_info, int32_t decision_array[]); |
---|
184 | |
---|
185 | |
---|
186 | /* Validate a set of transmission parameters received from the radio. |
---|
187 | */ |
---|
188 | void ValidateParameters(struct Parameter pList[], \ |
---|
189 | struct CE_Info *ce_info, int decision_array[]); |
---|
190 | |
---|
191 | |
---|
192 | /* Contains information regarding the presence of a service management |
---|
193 | * layer. If this pointer is NULL, then there is no SML present in the |
---|
194 | * radio system. |
---|
195 | */ |
---|
196 | struct SML_Info *SML; |
---|
197 | }; |
---|
198 | |
---|
199 | |
---|
200 | /* Cognitive Engine class declaration. All public functions are inherited from |
---|
201 | * parent classes. |
---|
202 | */ |
---|
203 | class CognitiveEngine : public Engine |
---|
204 | { |
---|
205 | public: |
---|
206 | CognitiveEngine(); |
---|
207 | ~CognitiveEngine(); |
---|
208 | |
---|
209 | void GetRemoteComponentType(int32_t socketFD); |
---|
210 | void WaitForSignal(int32_t socketFD); |
---|
211 | void Shutdown(); |
---|
212 | void Reset(); |
---|
213 | void RegisterComponent(int32_t socketFD); |
---|
214 | void DeregisterComponent(int32_t socketFD); |
---|
215 | |
---|
216 | void RegisterServices(int32_t socketFD); |
---|
217 | void DeregisterServices(int32_t socketFD); |
---|
218 | |
---|
219 | private: |
---|
220 | /* Receive the transmitted radio configuration from the radio itself |
---|
221 | * (the CE will not always be local to the radio). |
---|
222 | */ |
---|
223 | void ReceiveRadioConfiguration(int32_t socketFD); |
---|
224 | |
---|
225 | |
---|
226 | /* Receive an 'experience' report from the radio. |
---|
227 | */ |
---|
228 | void ReceiveExperience(int32_t socketFD); |
---|
229 | |
---|
230 | |
---|
231 | /* Find the most optimal set of transmission parameters given certain |
---|
232 | * observables and possibly a service if the SML component is present |
---|
233 | * and active. |
---|
234 | */ |
---|
235 | void GetSolution(Observable *observables); |
---|
236 | void GetSolution(Observable *observables, std::string service); |
---|
237 | |
---|
238 | |
---|
239 | /* Receive a feedback from the radio regarding the performance of a |
---|
240 | * certain set of parameters, possibly associated with a service. |
---|
241 | * |
---|
242 | * TODO what is the difference between experiences and feedback, |
---|
243 | * exactly? we should explain that explicitly here. |
---|
244 | */ |
---|
245 | void ReceiveFeedback(Observable *observables,\ |
---|
246 | Parameter *parameters, Utility *utilities); |
---|
247 | void ReceiveFeedback(Observable *observables, \ |
---|
248 | Parameter *parameters, std::string service); |
---|
249 | |
---|
250 | |
---|
251 | /* Contains information regarding the presence of a service management |
---|
252 | * layer. If this pointer is NULL, then there is no SML present in the |
---|
253 | * radio system. |
---|
254 | */ |
---|
255 | struct SML_Info *SML; |
---|
256 | |
---|
257 | }; |
---|
258 | |
---|
259 | #endif |
---|