1 | /* |
---|
2 | Copyright 2009 Virginia Polytechnic Institute and State University |
---|
3 | |
---|
4 | Licensed under the Apache License, Version 2.0 (the "License"); |
---|
5 | you may not use this file except in compliance with the License. |
---|
6 | You may obtain a copy of the License at |
---|
7 | |
---|
8 | http://www.apache.org/licenses/LICENSE-2.0 |
---|
9 | |
---|
10 | Unless required by applicable law or agreed to in writing, software |
---|
11 | distributed under the License is distributed on an "AS IS" BASIS, |
---|
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
13 | See the License for the specific language governing permissions and |
---|
14 | limitations under the License. |
---|
15 | */ |
---|
16 | |
---|
17 | /*! This header exports the declaration for the CROSS Shell component, which is |
---|
18 | * a critical part of every CROSS system. |
---|
19 | */ |
---|
20 | |
---|
21 | #ifndef CROSS_SHELL_H |
---|
22 | #define CROSS_SHELL_H |
---|
23 | |
---|
24 | |
---|
25 | #include "components.h" |
---|
26 | |
---|
27 | |
---|
28 | /*! \brief Cognitive Radio Shell class declaration. |
---|
29 | * |
---|
30 | * The CROSS Cognitive Radio Shell (CRS) is the central control component of |
---|
31 | * most CROSS radios. It is a requirement for any CROSS radio, regardless of |
---|
32 | * the presence or lack thereof of the SML. |
---|
33 | */ |
---|
34 | class CognitiveRadioShell |
---|
35 | { |
---|
36 | public: |
---|
37 | /*! \brief Default CRS costructor. */ |
---|
38 | CognitiveRadioShell(); |
---|
39 | |
---|
40 | /*! \brief Default CRS destructor. */ |
---|
41 | ~CognitiveRadioShell(); |
---|
42 | |
---|
43 | /*! \brief Preferred CRS constructor. |
---|
44 | * |
---|
45 | * Overloaded constructor that creates a CR Shell object and loads the |
---|
46 | * passed radio configuration XML file. |
---|
47 | */ |
---|
48 | CognitiveRadioShell(const char* radioConfig, int16_t primaryPort, \ |
---|
49 | int16_t policyPort, int16_t commandPort); |
---|
50 | |
---|
51 | /*! \brief Request the component type of a remote component. */ |
---|
52 | std::string GetRemoteComponentType(int32_t socketFD); |
---|
53 | |
---|
54 | /*! \brief Respond to a request to identify component type. */ |
---|
55 | void SendComponentType(int32_t socketFD); |
---|
56 | |
---|
57 | /*! \brief Shutdown the CRS. |
---|
58 | * |
---|
59 | * Since the CRS is the central control component of the CROSS radio, |
---|
60 | * shutting down the CRS will shutdown the entire radio. |
---|
61 | */ |
---|
62 | void Shutdown(); |
---|
63 | |
---|
64 | /*! \brief Restart the CRS. |
---|
65 | * |
---|
66 | * Restart the CRS component - reloads configuration files, and |
---|
67 | * re-initializes the CRS component. |
---|
68 | */ |
---|
69 | void Reset(); |
---|
70 | |
---|
71 | /*! \brief Start the CRS's socket server. |
---|
72 | * |
---|
73 | * This function will make the CRS create a socket server and begin |
---|
74 | * listening for incoming connections from other components. |
---|
75 | */ |
---|
76 | void StartShellServer(); |
---|
77 | |
---|
78 | /*! \brief Load the radio configuration. |
---|
79 | * |
---|
80 | * This function reads in the radio's XML configuration file, which is |
---|
81 | * typically located on the same system as the CRS, although it can also |
---|
82 | * be passed to the CRS from the radio host platform if necessary. |
---|
83 | */ |
---|
84 | int32_t LoadRadioConfiguration(const char* radioConfig, Parameter* &pList, \ |
---|
85 | Utility* &uList, Observable* &oList, Radio_Info* radioInfo); |
---|
86 | private: |
---|
87 | /*! \brief Handle component registration activities. |
---|
88 | * |
---|
89 | * Register and Deregister the different components. |
---|
90 | * TODO Are multiple functions really necessary? They are all basically |
---|
91 | * doing the same thing... |
---|
92 | */ |
---|
93 | void RegisterCognitiveEngine(int32_t socketFD); |
---|
94 | void DeregisterCognitiveEngine(int32_t socketFD); |
---|
95 | void RegisterPolicyEngine(int32_t socketFD); |
---|
96 | void DeregisterPolicyEngine(int32_t socketFD); |
---|
97 | void RegisterSML(int32_t socketFD); |
---|
98 | void DeregisterSML(int32_t socketFD); |
---|
99 | |
---|
100 | /*! \brief Set the active mission. |
---|
101 | * |
---|
102 | * This function handles a request by the radio host platform to set or |
---|
103 | * change the current active mission in the service management layer. |
---|
104 | * This command is basically passed through the CRS to the SML. |
---|
105 | */ |
---|
106 | void SetActiveMission(int32_t socketFD); |
---|
107 | |
---|
108 | /* Handle a message that is received from a component. |
---|
109 | */ |
---|
110 | int32_t HandleMessage(int32_t socketFD); |
---|
111 | |
---|
112 | /*! \brief Send optimization request to CE. |
---|
113 | * |
---|
114 | * The host application requested that parameters be optimized - pass |
---|
115 | * the parameters and command to the CE. |
---|
116 | * |
---|
117 | * TODO How is the CE being selected if multiple CEs are available? |
---|
118 | */ |
---|
119 | void GetOptimalParameters(int32_t socketFD); |
---|
120 | |
---|
121 | /*! TODO |
---|
122 | */ |
---|
123 | bool SendRadioConfiguration(int32_t socketFD); |
---|
124 | bool SendRadioExperience(int32_t socketFD); |
---|
125 | |
---|
126 | /*! TODO |
---|
127 | */ |
---|
128 | bool UpdateParameterPerformance(int32_t socketFD); |
---|
129 | |
---|
130 | /*! TODO |
---|
131 | */ |
---|
132 | bool SML_present; |
---|
133 | bool PE_present; |
---|
134 | bool CE_present; |
---|
135 | |
---|
136 | /*! TODO |
---|
137 | */ |
---|
138 | int32_t numberOfCognitiveEngines; |
---|
139 | |
---|
140 | /*! TODO |
---|
141 | */ |
---|
142 | int16_t primaryPort; |
---|
143 | int16_t policyPort; |
---|
144 | int16_t commandPort; |
---|
145 | |
---|
146 | /*! TODO |
---|
147 | * |
---|
148 | * I'm confused as to what exactly these are for... there can be |
---|
149 | * multiple CEs and PEs, and the CRS _IS_ the command component. |
---|
150 | * --BCH |
---|
151 | */ |
---|
152 | int32_t ceSocketFD; |
---|
153 | int32_t commandSocketFD; |
---|
154 | int32_t policySocketFD; |
---|
155 | |
---|
156 | /*! TODO |
---|
157 | */ |
---|
158 | Utility *utils; |
---|
159 | Parameter *params; |
---|
160 | Observable *observables; |
---|
161 | |
---|
162 | /*! TODO |
---|
163 | */ |
---|
164 | struct Radio_Info *radio_info; |
---|
165 | }; |
---|
166 | |
---|
167 | #endif |
---|