root/vtcross/trunk/src/include/vtcross/components.h @ 183

Revision 183, 7.6 KB (checked in by bhilburn, 15 years ago)

Implemented a remote component information struct in containers that can be used
to represent either the shell or the SML.

Line 
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 */
31class 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 */
72class 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 */
87class 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/* Policy Engine class declaration.  All public functions are inherited from
137 * parent classes.
138 */
139class PolicyEngine : public Engine
140{
141    public:
142        PolicyEngine();
143        ~PolicyEngine();
144
145
146        /* Overloaded constructor that creates a policy engine object with SML
147         * information pre-defined.
148         */
149        PolicyEngine(const char* serverName, const char* portNumber);
150
151        void GetRemoteComponentType(int32_t socketFD);
152        void WaitForSignal(int32_t socketFD);
153        void Shutdown();
154        void Reset();
155        void RegisterComponent(int32_t socketFD);
156        void DeregisterComponent(int32_t socketFD);
157
158        void RegisterServices(int32_t socketFD);
159        void DeregisterServices(int32_t socketFD);
160
161    private:
162        /* Parse and load/reload policies into the policy engine.
163         */
164        void LoadPolicies();
165        void ReloadPolicies();
166
167       
168        /* Return a decision made by the policy engine regarding a certain set
169         * of transmission parameters.
170         */
171        void SendPEDecision(int32_t socketFD, struct Parameter pList[], \
172                struct CE_Info *ce_info, int32_t decision_array[]);
173
174
175        /* Validate a set of transmission parameters received from the radio.
176         */
177        void ValidateParameters(struct Parameter pList[], \
178                struct CE_Info *ce_info, int decision_array[]);
179
180
181        /* The RemoteComponent struct represents either the VTCROSS shell or the
182         * VTCROSS SML.  If 'SML_present' is false, it is the former. Otherwise,
183         * it is the latter.
184         */
185        bool SML_present;
186        struct RemoteComponent *control;
187};
188
189
190/* Cognitive Engine class declaration.  All public functions are inherited from
191 * parent classes.
192 */
193class CognitiveEngine : public Engine
194{
195    public:
196        CognitiveEngine();
197        ~CognitiveEngine();
198
199        void GetRemoteComponentType(int32_t socketFD);
200        void WaitForSignal(int32_t socketFD);
201        void Shutdown();
202        void Reset();
203        void RegisterComponent(int32_t socketFD);
204        void DeregisterComponent(int32_t socketFD);
205
206        void RegisterServices(int32_t socketFD);
207        void DeregisterServices(int32_t socketFD);
208
209    private:
210        /* Receive the transmitted radio configuration from the radio itself
211         * (the CE will not always be local to the radio).
212         */
213        void ReceiveRadioConfiguration(int32_t socketFD);
214
215
216        /* Receive an 'experience' report from the radio.
217         */
218        void ReceiveExperience(int32_t socketFD);
219
220
221        /* Find the most optimal set of transmission parameters given certain
222         * observables and possibly a service if the SML component is present
223         * and active.
224         */
225        void GetSolution(Observable *observables);
226        void GetSolution(Observable *observables, std::string service);
227
228
229        /* Receive a feedback from the radio regarding the performance of a
230         * certain set of parameters, possibly associated with a service.
231         *
232         * TODO what is the difference between experiences and feedback,
233         * exactly? we should explain that explicitly here.
234         */
235        void ReceiveFeedback(Observable *observables,\
236                Parameter *parameters, Utility *utilities);
237        void ReceiveFeedback(Observable *observables, \
238                Parameter *parameters, std::string service);
239
240
241        /* Contains information regarding the presence of a service management
242         * layer.  If this pointer is NULL, then there is no SML present in the
243         * radio system.
244         */
245        struct SML_Info *SML;
246
247};
248
249#endif
Note: See TracBrowser for help on using the browser.