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

Revision 192, 7.8 KB (checked in by bhilburn, 15 years ago)

Removed older declerations for the GetRemoteComponentType? function.

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#include "socketcomm.h"
26
27
28/* Component abstract base class that all component classes should inherit from,
29 * including cognitive and policy engines, and the service management layer.
30 * Defines only functions required by all component types.
31 */
32class Component
33{
34    public:
35        /* Asks the component at the passed socket FD for its component type
36         * string.  Note that this implementation is global for all component
37         * types, so is implemented here.  Should a component need to override
38         * it, that is possible via dynamic binding or overloading.
39         */
40        virtual std::string GetRemoteComponentType(int32_t componentSocketFD)
41        {
42            SendMessage(componentSocketFD, "request_component_type");
43
44            char buffer[256];
45            memset(buffer, 0, 256);
46            ReadMessage(componentSocketFD, buffer);
47
48            return std::string(buffer);
49        }
50
51
52        /* Wait for a command signal containing task instructions.
53         */
54        virtual void WaitForSignal() = 0;
55
56
57        /* Completely shutdown the radio and all operations.
58         */
59        virtual void Shutdown() = 0;
60
61
62        /* Reset the radio and reload all configuration files.
63         *
64         * TODO are we remembering experiences in CEs?
65         */
66        virtual void Reset() = 0;
67
68
69        /* Register or deregister a component with the primary radio shell.
70         */
71        virtual void RegisterComponent() = 0;
72        virtual void DeregisterComponent() = 0;
73};
74
75
76/* Engine abstract base class from which all engine component types should
77 * inherit (e.g. cognitive and policy engines). Inherits all functions from the
78 * ABC Component publically.
79 */
80class Engine : public Component
81{
82    public:
83        /* Register or deregister services that this engine provides with the
84         * service management layer.
85         */
86        virtual void RegisterServices() = 0;
87        virtual void DeregisterServices() = 0;
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 WaitForSignal();
102        void Shutdown();
103        void Reset();
104        void RegisterComponent();
105        void DeregisterComponent();
106
107    private:
108        /* Receive the radio configuration settings from the shell and pass them
109         * on to another component.
110         */
111        void TransferRadioConfiguration();
112
113       
114        /* Receive information regarding a completed 'experience' and pass it on
115         * to the appropriate cognitive engine.
116         */
117        void TransferExperience();
118
119       
120        /* Listen for other components registering their available services with
121         * the SML. */
122        void ReceiveServices();
123
124
125        /* Change the active mission of the radio to a new one and adjust radio
126         * behavoir appropriately.
127         */
128        void SetActiveMission();
129
130
131        /* List all services provided to the radio by registered components.
132         */
133        void ListServices();
134
135
136        /* Load/Relead the XML configuration file.
137         */
138        void ReloadConfiguration();
139        void LoadConfiguration();
140
141
142        /* The socket file descriptor information for the shell which this SML
143         * is connected to.
144         */
145        int32_t shellSocketFD;
146};
147
148
149/* Policy Engine class declaration.  All public functions are inherited from
150 * parent classes.
151 */
152class PolicyEngine : public Engine
153{
154    public:
155        PolicyEngine();
156        ~PolicyEngine();
157
158
159        /* Overloaded constructor that creates a policy engine object and
160         * connects it to either the shell or an SML, depening on the SML bool.
161         */
162        PolicyEngine(const char* serverName, const char* portNumber, \
163                const bool SML);
164
165        void WaitForSignal();
166        void Shutdown();
167        void Reset();
168        void RegisterComponent();
169        void DeregisterComponent();
170
171        void RegisterServices();
172        void DeregisterServices();
173
174    private:
175        /* Parse and load/reload policies into the policy engine.
176         */
177        void LoadPolicies();
178        void ReloadPolicies();
179
180       
181        /* Return a decision made by the policy engine regarding a certain set
182         * of transmission parameters.
183         */
184        void SendPEDecision(struct Parameter pList[], struct CE_Info *ce_info, \
185                int32_t decision_array[]);
186
187
188        /* Validate a set of transmission parameters received from the radio.
189         */
190        void ValidateParameters(struct Parameter pList[], \
191                struct CE_Info *ce_info, int decision_array[]);
192
193
194        /* The SML_present bool reflects whether or not the remote component
195         * this object is connected to is an SML.  If it isn't, then it must be
196         * a shell.  The socketFD stores the socket file descriptor for this
197         * connection.
198         */
199        bool SML_present;
200        int32_t commandSocketFD;
201};
202
203
204/* Cognitive Engine class declaration.  All public functions are inherited from
205 * parent classes.
206 */
207class CognitiveEngine : public Engine
208{
209    public:
210        CognitiveEngine();
211        ~CognitiveEngine();
212
213        void WaitForSignal();
214        void Shutdown();
215        void Reset();
216        void RegisterComponent();
217        void DeregisterComponent();
218
219        void RegisterServices();
220        void DeregisterServices();
221
222    private:
223        /* Receive the transmitted radio configuration from the radio itself
224         * (the CE will not always be local to the radio).
225         */
226        void ReceiveRadioConfiguration();
227
228
229        /* Receive an 'experience' report from the radio.
230         */
231        void ReceiveExperience();
232
233
234        /* Find the most optimal set of transmission parameters given certain
235         * observables and possibly a service if the SML component is present
236         * and active.
237         */
238        void GetSolution(Observable *observables);
239        void GetSolution(Observable *observables, std::string service);
240
241
242        /* Receive a feedback from the radio regarding the performance of a
243         * certain set of parameters, possibly associated with a service.
244         *
245         * TODO what is the difference between experiences and feedback,
246         * exactly? we should explain that explicitly here.
247         */
248        void ReceiveFeedback(Observable *observables,\
249                Parameter *parameters, Utility *utilities);
250        void ReceiveFeedback(Observable *observables, \
251                Parameter *parameters, std::string service);
252
253        /* The SML_present bool reflects whether or not the remote component
254         * this object is connected to is an SML.  If it isn't, then it must be
255         * a shell.  The socketFD stores the socket file descriptor for this
256         * connection.
257         */
258        bool SML_present;
259        int32_t commandSocketFD;
260};
261
262#endif
Note: See TracBrowser for help on using the browser.