Changeset 203
- Timestamp:
- 03/24/09 18:03:08 (15 years ago)
- Location:
- vtcross/trunk/src
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
vtcross/trunk/src/include/vtcross/components.h
r195 r203 56 56 57 57 58 /* Wait for a command signal containing task instructions. 59 */ 60 virtual void WaitForSignal() = 0; 61 62 63 /* Completely shutdown the radio and all operations. 64 */ 65 virtual void Shutdown() = 0; 66 67 68 /* Reset the radio and reload all configuration files. 69 * 70 * TODO are we remembering experiences in CEs? 71 */ 72 virtual void Reset() = 0; 73 74 75 /* Register or deregister a component with the primary radio shell. 76 */ 77 virtual void RegisterComponent() = 0; 78 virtual void DeregisterComponent() = 0; 79 }; 80 81 82 /* Engine abstract base class from which all engine component types should 83 * inherit (e.g. cognitive and policy engines). Inherits all functions from the 84 * ABC Component publically. 85 */ 86 class Engine : public Component 87 { 88 public: 58 89 /* Connect to the remote control component, which will always be either 59 90 * the VTCROSS shell or SML. Based on the status of the SML_present … … 64 95 */ 65 96 virtual void ConnectToRemoteComponent(const char* serverName, \ 66 const char* serverPort) = 0; 67 68 /* Wait for a command signal containing task instructions. 69 */ 70 virtual void WaitForSignal() = 0; 71 72 73 /* Completely shutdown the radio and all operations. 74 */ 75 virtual void Shutdown() = 0; 76 77 78 /* Reset the radio and reload all configuration files. 79 * 80 * TODO are we remembering experiences in CEs? 81 */ 82 virtual void Reset() = 0; 83 84 85 /* Register or deregister a component with the primary radio shell. 86 */ 87 virtual void RegisterComponent() = 0; 88 virtual void DeregisterComponent() = 0; 89 }; 90 91 92 /* Engine abstract base class from which all engine component types should 93 * inherit (e.g. cognitive and policy engines). Inherits all functions from the 94 * ABC Component publically. 95 */ 96 class Engine : public Component 97 { 98 public: 97 const char* serverPort, const bool SML) = 0; 98 99 99 100 /* Register or deregister services that this engine provides with the 100 101 * service management layer. … … 115 116 ~ServiceManagementLayer(); 116 117 118 /* Overloaded constructor that creates an SML and connects it to the 119 * shell with the passed hostname and port. 120 */ 121 ServiceManagementLayer(const char* serverName, const char* serverPort); 122 123 /* Connect and register with the shell component at the passed hostname 124 * and port. 125 */ 126 void ConnectToShell(const char* serverName, \ 127 const char* serverPort); 128 117 129 void SendComponentType(); 118 void ConnectToRemoteComponent(const char* serverName, \119 const char* serverPort);120 130 void WaitForSignal(); 121 131 void Shutdown(); … … 185 195 void SendComponentType(); 186 196 void ConnectToRemoteComponent(const char* serverName, \ 187 const char* serverPort );197 const char* serverPort, const bool SML); 188 198 void WaitForSignal(); 189 199 void Shutdown(); … … 235 245 void SendComponentType(); 236 246 void ConnectToRemoteComponent(const char* serverName, \ 237 const char* serverPort );247 const char* serverPort, const bool SML); 238 248 void WaitForSignal(); 239 249 void Shutdown(); -
vtcross/trunk/src/policy_engines/PolicyEngine.cpp
r202 r203 40 40 LOG("Creating Policy Engine.\n"); 41 41 42 SML_present = SML; 43 44 ConnectToRemoteComponent(serverName, serverPort); 42 ConnectToRemoteComponent(serverName, serverPort, SML); 45 43 46 44 LoadPolicies(); … … 58 56 void 59 57 PolicyEngine::ConnectToRemoteComponent(const char* serverName, \ 60 const char* serverPort )58 const char* serverPort, const bool SML) 61 59 { 62 60 commandSocketFD = ClientSocket(serverName, serverPort); 63 61 64 if(SML_present) { 62 SML_present = SML; 63 64 if(SML) { 65 65 RegisterServices(); 66 66 LOG("Policy Engine connected to SML at %s.\n", serverName); … … 115 115 close(commandSocketFD); 116 116 117 SML_present = true; 118 119 ConnectToRemoteComponent(serverName, serverPort); 117 ConnectToRemoteComponent(serverName, serverPort, true); 120 118 } 121 119 } … … 140 138 close(commandSocketFD); 141 139 142 SML_present = false; 143 144 ConnectToRemoteComponent(serverName, serverPort); 140 ConnectToRemoteComponent(serverName, serverPort, false); 145 141 } 146 142 } … … 179 175 else 180 176 DeregisterComponent(); 181 182 SML_present = false;183 commandSocketFD = -1;184 LoadPolicies();185 177 } 186 178 … … 202 194 shutdown(commandSocketFD, 2); 203 195 close(commandSocketFD); 196 commandSocketFD = -1; 204 197 LOG("Policy Engine:: Shell socket closed.\n"); 205 198 } … … 228 221 shutdown(commandSocketFD, 2); 229 222 close(commandSocketFD); 223 commandSocketFD = -1; 230 224 LOG("Policy Engine:: SML socket closed.\n"); 231 225 }