[35] | 1 | #include <iostream> |
---|
[63] | 2 | #include <sys/types.h> |
---|
| 3 | #include <sys/wait.h> |
---|
[35] | 4 | #include "tinyxml.h" |
---|
| 5 | #include "tinystr.h" |
---|
| 6 | #include "socket/ServerSocket.h" |
---|
| 7 | #include "socket/SocketException.h" |
---|
| 8 | |
---|
| 9 | using namespace std; |
---|
| 10 | |
---|
| 11 | #define SERVER_PORT 30000 |
---|
| 12 | |
---|
| 13 | struct CE_Info { |
---|
| 14 | int numUtilities; |
---|
| 15 | int numParameters; |
---|
| 16 | int numObservables; |
---|
| 17 | }; |
---|
| 18 | |
---|
| 19 | struct Utility { |
---|
| 20 | string name; |
---|
| 21 | string units; |
---|
| 22 | string goal; |
---|
| 23 | float target; |
---|
[80] | 24 | float value; |
---|
[35] | 25 | }; |
---|
| 26 | struct Affect { |
---|
| 27 | Utility * u; |
---|
| 28 | string relation; |
---|
| 29 | }; |
---|
| 30 | struct Parameter { |
---|
| 31 | string name; |
---|
| 32 | string units; |
---|
| 33 | float min; |
---|
| 34 | int numAffects; |
---|
| 35 | Affect affection_list[10]; |
---|
| 36 | float max; |
---|
| 37 | float step; |
---|
[80] | 38 | float value; |
---|
[35] | 39 | }; |
---|
| 40 | |
---|
| 41 | struct Observable { |
---|
| 42 | string name; |
---|
| 43 | Affect affection_list[10]; |
---|
| 44 | int numAffects; |
---|
[80] | 45 | float value; |
---|
[35] | 46 | }; |
---|
| 47 | |
---|
[65] | 48 | void print_current_config(Utility * uList[], Parameter * pList[], Observable * oList[], CE_Info * ce_info) { |
---|
[35] | 49 | int i = 0; |
---|
| 50 | int j = 0; |
---|
| 51 | |
---|
| 52 | for(i = 0; i < ce_info->numUtilities ; i++) { |
---|
| 53 | cout << "Utility: " << uList[i]->name << endl; |
---|
| 54 | cout << " Units: " << uList[i]->units << endl; |
---|
| 55 | cout << " Goal: " << uList[i]->goal << endl; |
---|
| 56 | cout << " Target: " << uList[i]->target << endl; |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | for(i = 0; i < ce_info->numParameters; i++) { |
---|
| 60 | cout << "Parameter: " << pList[i]->name << endl; |
---|
| 61 | cout << " Units: " << pList[i]->units << endl; |
---|
| 62 | cout << " Min: " << pList[i]->min << endl; |
---|
| 63 | cout << " Max: " << pList[i]->max << endl; |
---|
| 64 | cout << " Step: " << pList[i]->step << endl; |
---|
| 65 | for(j = 0; j < pList[i]->numAffects; j++) { |
---|
| 66 | cout << " Affect: " << pList[i]->affection_list[j].u->name << " -> " << pList[i]->affection_list[j].relation << endl; |
---|
| 67 | } |
---|
| 68 | } |
---|
[80] | 69 | |
---|
| 70 | for(i = 0; i < ce_info->numObservables; i++) { |
---|
[35] | 71 | cout << "Observable: " << oList[i]->name << endl; |
---|
| 72 | for(j = 0; j < oList[i]->numAffects; j++) { |
---|
| 73 | cout << " Affect: " << oList[i]->affection_list[j].u->name << " -> " << oList[i]->affection_list[j].relation << endl; |
---|
| 74 | } |
---|
| 75 | } |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | |
---|
| 79 | int parse_ce_config( TiXmlDocument * doc , Utility * u[], Parameter * p[], Observable * o[], CE_Info * ce_info) { |
---|
| 80 | |
---|
| 81 | TiXmlElement* pElem; //!current element |
---|
| 82 | TiXmlElement* pChild; //!current child of pElem |
---|
| 83 | TiXmlElement* pChild1; //!current child of pElem |
---|
| 84 | TiXmlElement* pSecondChild; //!current child of pElem |
---|
| 85 | TiXmlHandle hDoc(doc); //!handle to xml document |
---|
| 86 | TiXmlHandle hRoot(0); //! handle to root element |
---|
| 87 | |
---|
| 88 | int count = 0; |
---|
| 89 | int i = 0; |
---|
| 90 | int j = 0; |
---|
| 91 | int k = 0; |
---|
| 92 | |
---|
| 93 | pElem = hDoc.FirstChildElement().Element(); |
---|
| 94 | if(!pElem) { cout << "no valid root! quit-ing function!" << endl; return 0; } |
---|
| 95 | hRoot = TiXmlHandle(pElem); |
---|
| 96 | |
---|
| 97 | // Pull utility information from XML file. |
---|
| 98 | |
---|
| 99 | pElem = hRoot.FirstChild("utilities").Element(); |
---|
| 100 | pChild1 = hRoot.Child("utilities",count).Element(); |
---|
| 101 | |
---|
| 102 | |
---|
| 103 | for(pChild = pChild1->FirstChildElement("utility"); pChild; pChild = pChild->NextSiblingElement()) |
---|
| 104 | { |
---|
| 105 | u[i] = new Utility; |
---|
| 106 | const char *uName = pChild->Attribute("name"); |
---|
| 107 | if(uName) u[i]->name = uName; |
---|
| 108 | const char *uUnits = pChild->Attribute("units"); |
---|
| 109 | if(uUnits) u[i]->units = uUnits; |
---|
| 110 | const char *uGoal = pChild->Attribute("goal"); |
---|
| 111 | if(uGoal) u[i]->goal = uGoal; |
---|
| 112 | if(pChild->QueryFloatAttribute("target",&u[i]->target) != TIXML_SUCCESS) u[i]->target = -1; |
---|
| 113 | i++; |
---|
| 114 | } |
---|
| 115 | ce_info->numUtilities = i; |
---|
| 116 | cout << "Parsed " << ce_info->numUtilities << " utilities." << endl; |
---|
| 117 | |
---|
| 118 | // Pull observable information from XML file. |
---|
| 119 | i = 0; |
---|
| 120 | pElem = hRoot.FirstChild("observables").Element(); |
---|
| 121 | pChild1 = hRoot.Child("observables",count).Element(); |
---|
| 122 | |
---|
| 123 | for(pChild = pChild1->FirstChildElement("observable"); pChild; pChild = pChild->NextSiblingElement()) |
---|
| 124 | { |
---|
| 125 | |
---|
| 126 | const char *oName = pChild->Attribute("name"); |
---|
| 127 | o[i] = new Observable; |
---|
| 128 | |
---|
| 129 | if(oName) o[i]->name = oName; |
---|
| 130 | |
---|
| 131 | j = 0; |
---|
| 132 | for(pSecondChild = pChild->FirstChildElement("affect"); pSecondChild; pSecondChild = pSecondChild->NextSiblingElement()) |
---|
| 133 | { |
---|
| 134 | const char *oUtilName = pSecondChild->Attribute("utility"); |
---|
| 135 | |
---|
| 136 | // If a utility affects this parameter find the utility object and assign it |
---|
| 137 | if(oUtilName) { |
---|
| 138 | // Search for correct utility |
---|
| 139 | for(k=0;k<10;k++){ |
---|
| 140 | if(u[k]->name == oUtilName) { |
---|
| 141 | o[i]->affection_list[j].u = u[k]; |
---|
| 142 | break; |
---|
| 143 | } |
---|
| 144 | } |
---|
| 145 | } |
---|
| 146 | |
---|
| 147 | // Set relationship |
---|
| 148 | const char *oRelate = pSecondChild->Attribute("relationship"); |
---|
| 149 | if(oRelate) o[i]->affection_list[j].relation = oRelate; |
---|
| 150 | j++; |
---|
| 151 | } |
---|
| 152 | o[i]->numAffects = j; |
---|
| 153 | i++; |
---|
| 154 | } |
---|
| 155 | ce_info->numObservables = i; |
---|
| 156 | cout << "Parsed " << ce_info->numObservables << " observables." << endl; |
---|
| 157 | |
---|
| 158 | |
---|
| 159 | // Pull parameter information from XML file. |
---|
| 160 | pElem = hRoot.FirstChild("parameters").Element(); |
---|
| 161 | pChild1 = hRoot.Child("parameters",count).Element(); |
---|
| 162 | |
---|
| 163 | i = 0; |
---|
| 164 | for(pChild = pChild1->FirstChildElement("parameter"); pChild; pChild = pChild->NextSiblingElement()) |
---|
| 165 | { |
---|
| 166 | p[i] = new Parameter; |
---|
| 167 | |
---|
| 168 | const char *pName = pChild->Attribute("name"); |
---|
| 169 | if(pName) p[i]->name = pName; |
---|
| 170 | const char *pUnits = pChild->Attribute("units"); |
---|
| 171 | if(pUnits) p[i]->units = pUnits; |
---|
| 172 | |
---|
| 173 | if(pChild->QueryFloatAttribute("min",&p[i]->min) != TIXML_SUCCESS) p[i]->min = -1; |
---|
| 174 | if(pChild->QueryFloatAttribute("max",&p[i]->max) != TIXML_SUCCESS) p[i]->max = -1; |
---|
| 175 | if(pChild->QueryFloatAttribute("step",&p[i]->step) != TIXML_SUCCESS) p[i]->step = -1; |
---|
| 176 | |
---|
| 177 | j = 0; |
---|
| 178 | for(pSecondChild = pChild->FirstChildElement("affect"); pSecondChild; pSecondChild = pSecondChild->NextSiblingElement()) |
---|
| 179 | { |
---|
| 180 | const char *pUtilName = pSecondChild->Attribute("utility"); |
---|
| 181 | |
---|
| 182 | // If a utility affects this parameter find the utility object and assign it |
---|
| 183 | if(pUtilName) { |
---|
| 184 | // Search for correct utility |
---|
| 185 | for( k=0 ; u[k]!=NULL ; k++ ){ |
---|
| 186 | if(u[k]->name == pUtilName) { |
---|
| 187 | p[i]->affection_list[j].u = u[k]; |
---|
| 188 | break; |
---|
| 189 | } |
---|
| 190 | } |
---|
| 191 | } |
---|
| 192 | |
---|
| 193 | // Set relationship |
---|
| 194 | const char *pRelate = pSecondChild->Attribute("relationship"); |
---|
| 195 | if(pRelate) { |
---|
| 196 | p[i]->affection_list[j].relation = pRelate; |
---|
| 197 | } else { |
---|
| 198 | cout << "Error: No relation found." << endl; |
---|
| 199 | } |
---|
| 200 | j++; |
---|
| 201 | |
---|
| 202 | } |
---|
| 203 | p[i]->numAffects = j; |
---|
| 204 | i++; |
---|
| 205 | |
---|
| 206 | } |
---|
| 207 | ce_info->numParameters = i; |
---|
| 208 | cout << "Parsed " << ce_info->numParameters << " parameters." << endl; |
---|
| 209 | return 1; |
---|
| 210 | } |
---|
| 211 | |
---|
| 212 | |
---|
[63] | 213 | void error(char *msg) |
---|
| 214 | { |
---|
| 215 | perror(msg); |
---|
| 216 | exit(1); |
---|
| 217 | } |
---|
[35] | 218 | |
---|
| 219 | |
---|
[81] | 220 | int ReceiveMessage(int socket,char * buffer) |
---|
| 221 | { |
---|
| 222 | int i,n; |
---|
[65] | 223 | |
---|
[81] | 224 | n = recv(socket,buffer,256,MSG_PEEK); |
---|
| 225 | for(i=0;i<256;i++){ |
---|
| 226 | if(strcmp(&buffer[i],"\0") == 0) break; |
---|
| 227 | } |
---|
| 228 | n = recv(socket,buffer,i+1,0); |
---|
| 229 | if (n < 0) |
---|
| 230 | error("ERROR reading from socket"); |
---|
| 231 | // printf("ReadMessage:%s %d\n",buffer,n); |
---|
| 232 | |
---|
| 233 | return n; |
---|
[65] | 234 | } |
---|
| 235 | |
---|
[81] | 236 | |
---|
[65] | 237 | int SendMessage(int socketfd, string message) { |
---|
| 238 | int n; |
---|
| 239 | |
---|
[70] | 240 | message.append("\0000"); |
---|
[65] | 241 | // Write message back to client |
---|
[70] | 242 | n = write(socketfd,message.c_str(),(message.size()+1)); |
---|
| 243 | if (n<0) |
---|
| 244 | error("Error sending to client\n"); |
---|
[72] | 245 | if(n == 0) |
---|
| 246 | printf("Client closed the socket.\n"); |
---|
[66] | 247 | |
---|
[70] | 248 | return n; |
---|
[65] | 249 | } |
---|
| 250 | |
---|
[72] | 251 | void GetEnvironment() { |
---|
| 252 | |
---|
| 253 | } |
---|
| 254 | |
---|
| 255 | void Policy_ValidateSettings() { |
---|
| 256 | |
---|
| 257 | } |
---|
| 258 | |
---|
| 259 | |
---|
| 260 | void LoadCEConfiguration(int socketfd,Utility * uList[], Parameter * pList[], Observable * oList[], CE_Info * ce_info){ |
---|
[65] | 261 | int n,i,j; |
---|
| 262 | char counter[55]; |
---|
| 263 | char var[50]; |
---|
[82] | 264 | //int total_bytes; |
---|
[72] | 265 | |
---|
| 266 | printf("Sending configuration to CE.\n"); |
---|
| 267 | |
---|
[80] | 268 | // utilities |
---|
[72] | 269 | // Send number of utilities |
---|
| 270 | sprintf(counter,"%d",ce_info->numUtilities); |
---|
| 271 | SendMessage(socketfd,counter); |
---|
[80] | 272 | // send utility |
---|
| 273 | for(i = 0; i < ce_info->numUtilities; i++) { |
---|
[72] | 274 | SendMessage(socketfd,uList[i]->name); |
---|
| 275 | SendMessage(socketfd,uList[i]->units); |
---|
| 276 | SendMessage(socketfd,uList[i]->goal); |
---|
| 277 | sprintf(var,"%f",uList[i]->target); |
---|
| 278 | SendMessage(socketfd,var); |
---|
| 279 | } |
---|
[66] | 280 | |
---|
[72] | 281 | // parameters |
---|
[80] | 282 | sprintf(counter,"%i",ce_info->numParameters); |
---|
[72] | 283 | SendMessage(socketfd,counter); |
---|
| 284 | for(i = 0; i < ce_info->numParameters; i++) { |
---|
| 285 | SendMessage(socketfd,pList[i]->name); |
---|
| 286 | SendMessage(socketfd,pList[i]->units); |
---|
| 287 | sprintf(var,"%f",pList[i]->min); |
---|
| 288 | SendMessage(socketfd,var); |
---|
| 289 | sprintf(var,"%f",pList[i]->max); |
---|
| 290 | SendMessage(socketfd,var); |
---|
| 291 | sprintf(var,"%f",pList[i]->step); |
---|
| 292 | SendMessage(socketfd,var); |
---|
| 293 | |
---|
| 294 | sprintf(counter,"%i",pList[i]->numAffects); |
---|
[65] | 295 | SendMessage(socketfd,counter); |
---|
[72] | 296 | for(j = 0; j < pList[i]->numAffects; j++) { |
---|
| 297 | SendMessage(socketfd,pList[i]->affection_list[j].u->name); |
---|
| 298 | SendMessage(socketfd,pList[i]->affection_list[j].relation); |
---|
[65] | 299 | } |
---|
[72] | 300 | } |
---|
[66] | 301 | |
---|
[80] | 302 | // observables |
---|
[72] | 303 | sprintf(counter,"%i",ce_info->numObservables); |
---|
| 304 | SendMessage(socketfd,counter); |
---|
| 305 | for(i = 0; i < ce_info->numObservables; i++) { |
---|
| 306 | SendMessage(socketfd,oList[i]->name); |
---|
| 307 | |
---|
| 308 | sprintf(counter,"%i",oList[i]->numAffects); |
---|
[65] | 309 | SendMessage(socketfd,counter); |
---|
[72] | 310 | for(j = 0; j < oList[i]->numAffects; j++) { |
---|
| 311 | SendMessage(socketfd,oList[i]->affection_list[j].u->name); |
---|
| 312 | SendMessage(socketfd,oList[i]->affection_list[j].relation); |
---|
[71] | 313 | } |
---|
[72] | 314 | } |
---|
[66] | 315 | |
---|
[72] | 316 | printf("Configuration sent, waiting for ACK...\n"); |
---|
| 317 | // Receive ACK for utils |
---|
[81] | 318 | char buffer[256]; |
---|
[66] | 319 | string message; |
---|
[81] | 320 | n = ReceiveMessage(socketfd, buffer); |
---|
| 321 | printf("%s\n", buffer); |
---|
| 322 | //cout << message << endl; |
---|
[72] | 323 | printf("ACK received.\n"); |
---|
[66] | 324 | |
---|
[72] | 325 | } |
---|
[66] | 326 | |
---|
[72] | 327 | void UpdateCEConfiguration() { |
---|
| 328 | |
---|
| 329 | } |
---|
| 330 | |
---|
| 331 | void ResetCEConfiguration(){ |
---|
| 332 | |
---|
| 333 | } |
---|
| 334 | |
---|
| 335 | void LoadCEExperience(){ |
---|
| 336 | |
---|
| 337 | } |
---|
| 338 | |
---|
| 339 | void UpdateCEExperience() { |
---|
| 340 | |
---|
| 341 | } |
---|
| 342 | |
---|
| 343 | void ResetCEExperience() { |
---|
| 344 | |
---|
| 345 | } |
---|
| 346 | |
---|
[82] | 347 | // Update operating settings |
---|
| 348 | // This function will interact with the hardware "drivers" |
---|
| 349 | void UpdateRadioSettings() { |
---|
[72] | 350 | |
---|
| 351 | } |
---|
| 352 | |
---|
[82] | 353 | int RequestCEOptimization(int sockfd, Utility *uList[], |
---|
[80] | 354 | Parameter *pList[], Observable *oList[], |
---|
| 355 | CE_Info *ce_info) |
---|
| 356 | { |
---|
| 357 | string message; |
---|
[81] | 358 | char buffer[256]; |
---|
[80] | 359 | int i; |
---|
| 360 | float var; |
---|
[72] | 361 | |
---|
[82] | 362 | /*// utility |
---|
[80] | 363 | for (i = 0; i < ce_info->numUtilities; i++){ |
---|
| 364 | bzero(buffer,256); |
---|
[81] | 365 | ReceiveMessage(sockfd,buffer); |
---|
| 366 | var = atof(buffer); |
---|
[80] | 367 | uList[i]->value = var; |
---|
[81] | 368 | printf("utility %s, value %f\n" |
---|
| 369 | , uList[i]->name.c_str(), uList[i]->value); |
---|
[82] | 370 | }*/ |
---|
[80] | 371 | |
---|
| 372 | // paramter |
---|
| 373 | for (i = 0; i < ce_info->numParameters; i++){ |
---|
[81] | 374 | bzero(buffer,256); |
---|
| 375 | ReceiveMessage(sockfd,buffer); |
---|
| 376 | var = atof(buffer); |
---|
[80] | 377 | pList[i]->value = var; |
---|
[81] | 378 | printf("parameter %s, value %f\n" |
---|
| 379 | , pList[i]->name.c_str(), pList[i]->value); |
---|
[80] | 380 | } |
---|
| 381 | |
---|
[82] | 382 | /*// observable |
---|
[80] | 383 | for (i = 0; i < ce_info->numObservables; i++){ |
---|
[81] | 384 | bzero(buffer,256); |
---|
| 385 | ReceiveMessage(sockfd,buffer); |
---|
| 386 | var = atof(buffer); |
---|
[80] | 387 | oList[i]->value = var; |
---|
[81] | 388 | printf("observable %s, value %f\n" |
---|
| 389 | , oList[i]->name.c_str(), oList[i]->value); |
---|
[82] | 390 | }*/ |
---|
| 391 | |
---|
[81] | 392 | return 1; |
---|
[80] | 393 | } |
---|
| 394 | |
---|
| 395 | void RunSimulator(int socketfd, Utility * uList[], |
---|
| 396 | Parameter * pList[], Observable * oList[], |
---|
| 397 | CE_Info * ce_info) { |
---|
| 398 | |
---|
[78] | 399 | // Set fake past environment - |
---|
[72] | 400 | LoadCEExperience(); |
---|
[66] | 401 | |
---|
[78] | 402 | // Set fake current environment params = current environment |
---|
[82] | 403 | //RequestCEOptimization(); |
---|
| 404 | RequestCEOptimization(socketfd, uList, pList, oList, ce_info); |
---|
[72] | 405 | |
---|
| 406 | // Act like we are updating the hardware tranmission settings |
---|
[82] | 407 | //UpdateRadioSettings(socketfd, uList, pList, oList, ce_info); |
---|
| 408 | UpdateRadioSettings(); |
---|
[72] | 409 | |
---|
| 410 | // Send back fake utility values |
---|
| 411 | UpdateCEExperience(); |
---|
[63] | 412 | } |
---|
[35] | 413 | |
---|
[80] | 414 | void StartMessaging(int socketfd, Utility * uList[], Parameter * pList[], Observable * oList[], CE_Info * ce_info) { |
---|
[72] | 415 | |
---|
[80] | 416 | LoadCEConfiguration(socketfd, uList, pList, oList, ce_info); |
---|
[72] | 417 | |
---|
[80] | 418 | RunSimulator(socketfd, uList, pList, oList, ce_info); |
---|
[72] | 419 | } |
---|
| 420 | |
---|
[65] | 421 | int StartShell(int port,Utility * uList[], Parameter * pList[], Observable * oList[], CE_Info * ce_info) { |
---|
[63] | 422 | // Start socket server |
---|
| 423 | int sockfd, newsockfd, clilen; |
---|
| 424 | struct sockaddr_in serv_addr, cli_addr; |
---|
[35] | 425 | |
---|
[73] | 426 | // Setup server socket connection |
---|
| 427 | sockfd = socket(AF_INET, SOCK_STREAM, 0); |
---|
[63] | 428 | if (sockfd < 0) |
---|
| 429 | error("ERROR opening socket"); |
---|
| 430 | bzero((char *) &serv_addr, sizeof(serv_addr)); |
---|
| 431 | serv_addr.sin_family = AF_INET; |
---|
| 432 | serv_addr.sin_port = htons(port); |
---|
[73] | 433 | serv_addr.sin_addr.s_addr = INADDR_ANY; |
---|
[63] | 434 | if (bind(sockfd, (struct sockaddr *) &serv_addr, |
---|
| 435 | sizeof(serv_addr)) < 0) |
---|
| 436 | error("ERROR on binding"); |
---|
| 437 | listen(sockfd,5); |
---|
| 438 | clilen = sizeof(cli_addr); |
---|
[35] | 439 | |
---|
[66] | 440 | //while(1) { |
---|
[64] | 441 | newsockfd = accept(sockfd, |
---|
| 442 | (struct sockaddr *) &cli_addr, |
---|
| 443 | (socklen_t*)&clilen); |
---|
| 444 | if (newsockfd < 0) |
---|
| 445 | error("ERROR on accept"); |
---|
[63] | 446 | |
---|
[64] | 447 | // Begin parsing the messages |
---|
[80] | 448 | StartMessaging(newsockfd, uList, pList, oList, ce_info); |
---|
[66] | 449 | //} |
---|
[63] | 450 | return 0; |
---|
[35] | 451 | } |
---|
| 452 | |
---|
| 453 | int main(int argc, char* argv[]) { |
---|
| 454 | |
---|
| 455 | |
---|
| 456 | // CognitiveEngine CE; |
---|
| 457 | // CognitiveEngineShell Shell; |
---|
| 458 | string pFilename; |
---|
[64] | 459 | int pid; |
---|
[35] | 460 | |
---|
| 461 | Utility * uList[10]; |
---|
| 462 | Parameter * pList[10]; |
---|
| 463 | Observable * oList[10]; |
---|
| 464 | CE_Info ce_info; |
---|
| 465 | |
---|
| 466 | if(argc < 2) { |
---|
| 467 | cout << "Warning no XML file specific using default: example.xml" << endl; |
---|
| 468 | pFilename = "example.xml"; |
---|
| 469 | } else { |
---|
| 470 | pFilename = argv[1]; |
---|
| 471 | } |
---|
| 472 | |
---|
| 473 | TiXmlDocument doc( pFilename.c_str() ); |
---|
| 474 | bool loadOkay = doc.LoadFile(); |
---|
| 475 | if (!loadOkay) |
---|
| 476 | { |
---|
| 477 | cout << "Loading " << pFilename << " failed." << endl; |
---|
| 478 | return 0; |
---|
| 479 | } |
---|
| 480 | |
---|
| 481 | cout << "Attemping to parse " << pFilename << "." << endl; |
---|
| 482 | parse_ce_config( &doc , uList, pList, oList, &ce_info); |
---|
| 483 | cout << "Configuration file parsing completed." << endl; |
---|
| 484 | |
---|
[72] | 485 | //print_current_config(uList, pList, oList, &ce_info); |
---|
[69] | 486 | |
---|
| 487 | pid = fork(); |
---|
[64] | 488 | if(pid == 0) { |
---|
| 489 | // In child process - open policy engine port. |
---|
[71] | 490 | // StartShell(30000,uList, pList, oList, &ce_info); |
---|
[64] | 491 | } else { |
---|
| 492 | // In parent process - open cognitive engine port. |
---|
[82] | 493 | StartShell(30001,uList, pList, oList, &ce_info); |
---|
[64] | 494 | } |
---|
| 495 | |
---|
[35] | 496 | |
---|
| 497 | return 1; |
---|
[71] | 498 | } |
---|