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

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

Made the remotecomponent struct public since information hiding doesn't
make any sense here, removed unneeded info from it, worked on a couple
of policy engine functions to be smart about start-up connections.

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        /* The RemoteComponent struct represents either the VTCROSS shell or the
83         * VTCROSS SML.  If 'SML_present' is false, it is the former. Otherwise,
84         * it is the latter.
85         */
86        bool SML_present;
87        struct RemoteComponent *control;
88};
89
90
91/* Service Management Layer (SML) class declaration.  The functions listed here
92 * are required by the VTCROSS API for service-oriented VTCROSS radio
93 * architectures.
94 */
95class ServiceManagementLayer : public Component
96{
97    public:
98        ServiceManagementLayer();
99        ~ServiceManagementLayer();
100
101        void GetRemoteComponentType(int32_t socketFD);
102        void WaitForSignal(int32_t socketFD);
103        void Shutdown();
104        void Reset();
105        void RegisterComponent(int32_t socketFD);
106        void DeregisterComponent(int32_t socketFD);
107
108    private:
109        /* Receive the radio configuration settings from the shell and pass them
110         * on to another component.
111         */
112        void TransferRadioConfiguration();
113
114       
115        /* Receive information regarding a completed 'experience' and pass it on
116         * to the appropriate cognitive engine.
117         */
118        void TransferExperience();
119
120       
121        /* Listen for other components registering their available services with
122         * the SML. */
123        void ReceiveServices();
124
125
126        /* Change the active mission of the radio to a new one and adjust radio
127         * behavoir appropriately.
128         */
129        void SetActiveMission();
130
131
132        /* List all services provided to the radio by registered components.
133         */
134        void ListServices();
135
136
137        /* Load/Relead the XML configuration file.
138         */
139        void ReloadConfiguration();
140        void LoadConfiguration();
141};
142
143
144/* Policy Engine class declaration.  All public functions are inherited from
145 * parent classes.
146 */
147class PolicyEngine : public Engine
148{
149    public:
150        PolicyEngine();
151        ~PolicyEngine();
152
153
154        /* Overloaded constructor that creates a policy engine object and
155         * connects it to either the shell or an SML, depening on the SML bool.
156         */
157        PolicyEngine(const char* serverName, const char* portNumber, \
158                const bool SML);
159
160        void GetRemoteComponentType(int32_t socketFD);
161        void WaitForSignal(int32_t socketFD);
162        void Shutdown();
163        void Reset();
164        void RegisterComponent(int32_t socketFD);
165        void DeregisterComponent(int32_t socketFD);
166
167        void RegisterServices(int32_t socketFD);
168        void DeregisterServices(int32_t socketFD);
169
170    private:
171        /* Parse and load/reload policies into the policy engine.
172         */
173        void LoadPolicies();
174        void ReloadPolicies();
175
176       
177        /* Return a decision made by the policy engine regarding a certain set
178         * of transmission parameters.
179         */
180        void SendPEDecision(int32_t socketFD, struct Parameter pList[], \
181                struct CE_Info *ce_info, int32_t decision_array[]);
182
183
184        /* Validate a set of transmission parameters received from the radio.
185         */
186        void ValidateParameters(struct Parameter pList[], \
187                struct CE_Info *ce_info, int decision_array[]);
188};
189
190
191/* Cognitive Engine class declaration.  All public functions are inherited from
192 * parent classes.
193 */
194class CognitiveEngine : public Engine
195{
196    public:
197        CognitiveEngine();
198        ~CognitiveEngine();
199
200        void GetRemoteComponentType(int32_t socketFD);
201        void WaitForSignal(int32_t socketFD);
202        void Shutdown();
203        void Reset();
204        void RegisterComponent(int32_t socketFD);
205        void DeregisterComponent(int32_t socketFD);
206
207        void RegisterServices(int32_t socketFD);
208        void DeregisterServices(int32_t socketFD);
209
210    private:
211        /* Receive the transmitted radio configuration from the radio itself
212         * (the CE will not always be local to the radio).
213         */
214        void ReceiveRadioConfiguration(int32_t socketFD);
215
216
217        /* Receive an 'experience' report from the radio.
218         */
219        void ReceiveExperience(int32_t socketFD);
220
221
222        /* Find the most optimal set of transmission parameters given certain
223         * observables and possibly a service if the SML component is present
224         * and active.
225         */
226        void GetSolution(Observable *observables);
227        void GetSolution(Observable *observables, std::string service);
228
229
230        /* Receive a feedback from the radio regarding the performance of a
231         * certain set of parameters, possibly associated with a service.
232         *
233         * TODO what is the difference between experiences and feedback,
234         * exactly? we should explain that explicitly here.
235         */
236        void ReceiveFeedback(Observable *observables,\
237                Parameter *parameters, Utility *utilities);
238        void ReceiveFeedback(Observable *observables, \
239                Parameter *parameters, std::string service);
240
241
242        /* Contains information regarding the presence of a service management
243         * layer.  If this pointer is NULL, then there is no SML present in the
244         * radio system.
245         */
246        struct SML_Info *SML;
247};
248
249#endif
Note: See TracBrowser for help on using the browser.