Changeset 95 for vtcross/trunk/CR_shell/src/main_cognitive_radio.cpp
- Timestamp:
- 02/09/09 16:51:58 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
vtcross/trunk/CR_shell/src/main_cognitive_radio.cpp
r90 r95 59 59 for(i = 0; i < ce_info->numParameters; i++) { 60 60 cout << "Parameter: " << pList[i]->name << endl; 61 printf("Radio Operation Profile has been sucessfully sent.\n"); 61 62 cout << " Units: " << pList[i]->units << endl; 62 63 cout << " Min: " << pList[i]->min << endl; … … 115 116 } 116 117 ce_info->numUtilities = i; 117 cout << " Parsed " << ce_info->numUtilities << " utilities." << endl;118 cout << "Initialize:: Parsed " << ce_info->numUtilities << " utilities." << endl; 118 119 119 120 // Pull observable information from XML file. … … 157 158 } 158 159 ce_info->numObservables = i; 159 cout << " Parsed " << ce_info->numObservables << " observables." << endl;160 cout << "Initialize:: Parsed " << ce_info->numObservables << " observables." << endl; 160 161 161 162 … … 210 211 } 211 212 ce_info->numParameters = i; 212 cout << " Parsed " << ce_info->numParameters << " parameters." << endl;213 cout << "Initialize:: Parsed " << ce_info->numParameters << " parameters." << endl; 213 214 return 1; 214 215 } … … 269 270 //int total_bytes; 270 271 271 printf("Sending configuration to CE.\n");272 printf("Sending Radio Operating Profile to Cognitive Engine.\n\n"); 272 273 273 274 // utilities … … 319 320 } 320 321 321 printf("Configuration sent, waiting for ACK...\n");322 322 // Receive ACK for utils 323 323 char buffer[256]; 324 324 string message; 325 325 n = ReceiveMessage(socketfd, buffer); 326 printf("%s\n", buffer);326 //printf("%s\n", buffer); 327 327 //cout << message << endl; 328 printf("ACK received.\n");328 //printf("ACK received.\n"); 329 329 330 330 } … … 368 368 } 369 369 370 printf("experience sent\n");371 370 } 372 371 … … 389 388 float var; 390 389 391 /*// utility 392 for (i = 0; i < ce_info->numUtilities; i++){ 393 bzero(buffer,256); 394 ReceiveMessage(sockfd,buffer); 395 var = atof(buffer); 396 uList[i]->value = var; 397 printf("utility %s, value %f\n" 398 , uList[i]->name.c_str(), uList[i]->value); 399 }*/ 400 401 // paramter 390 // Send request optimization message followed by the current environment parameters. 391 /* 392 SendMessage(sockfd,"request"); 393 for (i = 0; i < ce_info->numObservables; i++){ 394 SendMessage(sockfd,..); 395 } 396 */ 397 398 // Receive optimized values from the Cognitive Engine 402 399 for (i = 0; i < ce_info->numParameters; i++){ 403 400 bzero(buffer,256); … … 405 402 var = atof(buffer); 406 403 pList[i]->value = var; 407 printf("parameter %s, value %f\n"408 , pList[i]->name.c_str(), pList[i]->value);409 404 } 410 405 411 /*// observable412 for (i = 0; i < ce_info->numObservables; i++){413 bzero(buffer,256);414 ReceiveMessage(sockfd,buffer);415 var = atof(buffer);416 oList[i]->value = var;417 printf("observable %s, value %f\n"418 , oList[i]->name.c_str(), oList[i]->value);419 }*/420 406 421 407 return 1; … … 476 462 477 463 // update ce with experience 464 printf("Sending Previous Experience to New Cognitive Engine.\n\n"); 478 465 UpdateCEExperience(socketfd, num_rows, num_cols, past_exp); 479 466 … … 484 471 // Start socket server 485 472 int sockfd, newsockfd, clilen; 473 int peer_len = sizeof(struct sockaddr); 486 474 struct sockaddr_in serv_addr, cli_addr; 475 struct sockaddr_in peer; 476 487 477 488 478 // Setup server socket connection … … 507 497 error("ERROR on accept"); 508 498 499 if(getpeername(newsockfd, (struct sockaddr *) &peer, (socklen_t*)&peer_len) == -1) { 500 perror("getpeername() failed"); 501 return -1; 502 } 503 504 printf("Received a connection from a Cognitive Engine with IP address: %s\n\n",inet_ntoa(peer.sin_addr)); 505 509 506 // Begin parsing the messages 510 507 StartMessaging(newsockfd, uList, pList, oList, ce_info); … … 541 538 } 542 539 543 cout << " Attemping to parse " << pFilename << "." << endl;540 cout << "\n\nInitialize:: Attemping to parse " << pFilename << "." << endl; 544 541 parse_ce_config( &doc , uList, pList, oList, &ce_info); 545 cout << " Configuration file parsing completed." << endl;542 cout << "Initialize:: Configuration file parsing completed.\n" << endl; 546 543 547 544 //print_current_config(uList, pList, oList, &ce_info);