Changeset 232 for vtcross/trunk/src/shell/CognitiveRadioShell.cpp
- Timestamp:
- 04/07/09 10:19:43 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
vtcross/trunk/src/shell/CognitiveRadioShell.cpp
r231 r232 157 157 for(size_t i = 0; i < radio_info->numObservables; i++) { 158 158 SendMessage(socketFD, observables[i].name.c_str()); 159 159 160 160 sprintf(counter, "%i", observables[i].numAffects); 161 161 SendMessage(socketFD, counter); … … 165 165 } 166 166 } 167 167 168 168 /* Receive ACK for radio configuration */ 169 169 char buffer[256]; … … 185 185 LOG("Cognitive Radio Shell:: Sending radio experience to Cognitive Engine.\n"); 186 186 int32_t numberExp = 4; 187 187 char numberExpString[50]; 188 188 189 189 sprintf(numberExpString, "%i", numberExp); … … 462 462 uint32_t numObservables = atoi(buffer); 463 463 464 464 LOG("Cognitive Radio Shell:: Attempting to get %i observables.\n", numObservables); 465 465 Observable *o = new Observable[numObservables]; 466 466 … … 475 475 } 476 476 477 477 /* Receive Set of Current Parameters */ 478 478 memset(buffer, 0, 256); 479 479 ReadMessage(commandSocketFD,buffer); 480 480 uint32_t numCurrentParameters = atoi(buffer); 481 481 482 482 LOG("Cognitive Radio Shell:: Attempting to get %i parameters.\n",numCurrentParameters); 483 483 Parameter * cp = new Parameter[numCurrentParameters]; 484 484 … … 493 493 494 494 /* Send to Cognitive Engine 495 496 497 498 499 495 * TODO: With multiple CEs we need to make a decision about where 496 * to send this information 497 */ 498 if(!SML_present) { 499 LOG("Cognitive Radio Shell:: Passing on observables to Cognitive Engine\n"); 500 500 SendMessage(ceSocketFD,"request_optimization"); 501 501 sprintf(counter,"%i",numObservables); … … 504 504 SendMessage(ceSocketFD,o[i].name.c_str()); 505 505 sprintf(var,"%f",o[i].value); 506 506 SendMessage(ceSocketFD,var); 507 507 } 508 509 508 509 LOG("Cognitive Radio Shell:: Passing on current parameters to Cognitive Engine\n"); 510 510 sprintf(counter,"%i",numCurrentParameters); 511 511 SendMessage(ceSocketFD,counter); … … 513 513 SendMessage(ceSocketFD,cp[i].name.c_str()); 514 514 sprintf(var,"%f",cp[i].value); 515 515 SendMessage(ceSocketFD,var); 516 516 } 517 518 519 517 } 518 519 LOG("Cognitive Radio Shell:: Receiving optimized parameters from Cognitive Engine.\n"); 520 520 /* Receive Set of Parameters */ 521 521 memset(buffer, 0, 256); … … 536 536 537 537 /* Send to Application 538 539 538 */ 539 LOG("Cognitive Radio Shell:: Sending optimized parameters to Application.\n"); 540 540 memset(counter, 0, 55); 541 541 sprintf(counter, "%i", numParameters); … … 544 544 SendMessage(commandSocketFD, p[i].name.c_str()); 545 545 sprintf(var, "%f", p[i].value); 546 546 SendMessage(commandSocketFD, var); 547 547 } 548 548 … … 559 559 char buffer[256]; 560 560 561 561 /* Receive Set of Parameters */ 562 562 memset(buffer, 0, 256); 563 563 ReadMessage(commandSocketFD,buffer); … … 644 644 UpdateParameterPerformance(socketFD); 645 645 } else if(strcmp(buffer, "get_number_utilities") == 0) { 646 647 646 char numUtilities[20]; 647 sprintf(numUtilities, "%i", radio_info->numUtilities); 648 648 SendMessage(commandSocketFD, numUtilities); 649 649 } else if(strcmp(buffer, "get_number_observables") == 0) { 650 651 650 char numObservables[20]; 651 sprintf(numObservables, "%i", radio_info->numObservables); 652 652 SendMessage(commandSocketFD, numObservables); 653 653 } else if(strcmp(buffer, "get_number_parameters") == 0) { 654 655 654 char numParameters[20]; 655 sprintf(numParameters, "%i", radio_info->numParameters); 656 656 SendMessage(commandSocketFD, numParameters); 657 657 } else if(strcmp(buffer, "request_optimization") == 0) { … … 686 686 int32_t maxDescriptor; 687 687 688 689 688 if(servSock[primary] > servSock[policy]) 689 maxDescriptor = servSock[primary]; 690 690 else 691 692 693 694 691 maxDescriptor = servSock[policy]; 692 693 if(servSock[command] > maxDescriptor) 694 maxDescriptor = servSock[command]; 695 695 696 696 if(InitializeTCPServerPort(servSock[primary]) == -1)