Changeset 167
- Timestamp:
- 03/19/09 23:57:14 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
vtcross/trunk/src/shell/cr_shell.cpp
r166 r167 224 224 if (n < 0) 225 225 error("ERROR reading from socket"); 226 // print 32_tf("ReadMessage:%s %d\n",buffer,n);226 // printf("ReadMessage:%s %d\n",buffer,n); 227 227 228 228 return n; … … 241 241 error("Error sending to client\n"); 242 242 if(n == 0) 243 print 32_tf("Client closed the socket.\n");244 245 //print 32_tf("SendMessage:%s %d\n",message.c_str(),n);243 printtf("Client closed the socket.\n"); 244 245 //printf("SendMessage:%s %d\n",message.c_str(),n); 246 246 return n; 247 247 } … … 255 255 //int32_t total_bytes; 256 256 257 print 32_tf("Cognitive Radio:: Sending Radio Operating Profile to Cognitive Engine.\n\n");257 printtf("Cognitive Radio:: Sending Radio Operating Profile to Cognitive Engine.\n\n"); 258 258 259 259 // utilities 260 260 // Send number of utilities 261 sprint 32_tf(counter,"%d",ce_info->numUtilities);261 sprintf(counter,"%d",ce_info->numUtilities); 262 262 SendMessage(socketfd,counter); 263 263 // send utility … … 266 266 SendMessage(socketfd,uList[i]->units); 267 267 SendMessage(socketfd,uList[i]->goal); 268 sprint 32_tf(var,"%f",uList[i]->target);268 sprintf(var,"%f",uList[i]->target); 269 269 SendMessage(socketfd,var); 270 270 } 271 271 272 272 // parameters 273 sprint 32_tf(counter,"%i",ce_info->numParameters);273 sprintf(counter,"%i",ce_info->numParameters); 274 274 SendMessage(socketfd,counter); 275 275 for(i = 0; i < ce_info->numParameters; i++) { 276 276 SendMessage(socketfd,pList[i]->name); 277 277 SendMessage(socketfd,pList[i]->units); 278 sprint 32_tf(var,"%f",pList[i]->min);279 SendMessage(socketfd,var); 280 sprint 32_tf(var,"%f",pList[i]->max);281 SendMessage(socketfd,var); 282 sprint 32_tf(var,"%f",pList[i]->step);278 sprintf(var,"%f",pList[i]->min); 279 SendMessage(socketfd,var); 280 sprintf(var,"%f",pList[i]->max); 281 SendMessage(socketfd,var); 282 sprintf(var,"%f",pList[i]->step); 283 283 SendMessage(socketfd,var); 284 284 285 sprint 32_tf(counter,"%i",pList[i]->numAffects);285 sprintf(counter,"%i",pList[i]->numAffects); 286 286 SendMessage(socketfd,counter); 287 287 for(j = 0; j < pList[i]->numAffects; j++) { … … 292 292 293 293 // observables 294 sprint 32_tf(counter,"%i",ce_info->numObservables);294 sprintf(counter,"%i",ce_info->numObservables); 295 295 SendMessage(socketfd,counter); 296 296 for(i = 0; i < ce_info->numObservables; i++) { 297 297 SendMessage(socketfd,oList[i]->name); 298 298 299 sprint 32_tf(counter,"%i",oList[i]->numAffects);299 sprintf(counter,"%i",oList[i]->numAffects); 300 300 SendMessage(socketfd,counter); 301 301 for(j = 0; j < oList[i]->numAffects; j++) { … … 309 309 string message; 310 310 n = ReceiveMessage(socketfd, buffer); 311 //print 32_tf("%s\n", buffer);311 //printf("%s\n", buffer); 312 312 //cout << message << endl; 313 //print 32_tf("ACK received.\n");313 //printf("ACK received.\n"); 314 314 315 315 } … … 332 332 for (i = 0; i < num_rows; i++){ 333 333 for (j = 0; j< num_cols; j++){ 334 sprint 32_tf(var,"%f",past_exp[i][j]);335 //print 32_tf("%f, \n", past_exp[i][j]);336 //print 32_tf("%s, \n", var);334 sprintf(var,"%f",past_exp[i][j]); 335 //printf("%f, \n", past_exp[i][j]); 336 //printf("%s, \n", var); 337 337 } 338 338 } 339 339 340 340 // send the number of rows to the ce first 341 sprint 32_tf(counter,"%d",num_rows);341 sprintf(counter,"%d",num_rows); 342 342 SendMessage(socketfd,counter); 343 343 // send the number of columns to the ce 344 sprint 32_tf(counter,"%d",num_cols);344 sprintf(counter,"%d",num_cols); 345 345 SendMessage(socketfd,counter); 346 346 // update ce with experience 347 347 for (i = 0; i < num_rows; i++){ 348 348 for (j = 0; j< num_cols; j++){ 349 sprint 32_tf(var,"%f",past_exp[i][j]);349 sprintf(var,"%f",past_exp[i][j]); 350 350 SendMessage(socketfd,var); 351 351 } … … 378 378 SendMessage(socketfd,control_msg); 379 379 380 print 32_tf("Cognitive Radio:: Here. %i\n\n", socketfd);380 printf("Cognitive Radio:: Here. %i\n\n", socketfd); 381 381 382 382 // Send parameter information 383 sprint 32_tf(counter,"%i",ce_info->numParameters);383 sprintf(counter,"%i",ce_info->numParameters); 384 384 SendMessage(socketfd,counter); 385 385 for(i = 0; i < ce_info->numParameters; i++) { 386 386 SendMessage(socketfd,pList[i]->name); 387 387 SendMessage(socketfd,pList[i]->units); 388 sprint 32_tf(var,"%f",pList[i]->min);389 SendMessage(socketfd,var); 390 sprint 32_tf(var,"%f",pList[i]->max);391 SendMessage(socketfd,var); 392 sprint 32_tf(var,"%f",pList[i]->step);393 SendMessage(socketfd,var); 394 sprint 32_tf(var,"%f",pList[i]->value);388 sprintf(var,"%f",pList[i]->min); 389 SendMessage(socketfd,var); 390 sprintf(var,"%f",pList[i]->max); 391 SendMessage(socketfd,var); 392 sprintf(var,"%f",pList[i]->step); 393 SendMessage(socketfd,var); 394 sprintf(var,"%f",pList[i]->value); 395 395 SendMessage(socketfd,var); 396 396 … … 429 429 if(ce_info->policy_engine == 1) { 430 430 431 print 32_tf("Cognitive Radio:: Found Policy Engine!\n");432 print 32_tf("Cognitive Radio:: Validating parameters with Policy Engine\n\n");431 printf("Cognitive Radio:: Found Policy Engine!\n"); 432 printf("Cognitive Radio:: Validating parameters with Policy Engine\n\n"); 433 433 RequestPolicyValidation(pList,ce_info); 434 print 32_tf("Cognitive Radio:: Done\n\n");434 printf("Cognitive Radio:: Done\n\n"); 435 435 436 436 } … … 503 503 504 504 // update ce with experience 505 print 32_tf("Cognitive Radio:: Sending Previous Experience to New Cognitive Engine.\n\n");505 printf("Cognitive Radio:: Sending Previous Experience to New Cognitive Engine.\n\n"); 506 506 UpdateCEExperience(socketfd, num_rows, num_cols, past_exp); 507 507 … … 526 526 /* clntSock is connected to a client! */ 527 527 528 print 32_tf("Handling client %s\n", inet_ntoa(echoClntAddr.sin_addr));528 printf("Handling client %s\n", inet_ntoa(echoClntAddr.sin_addr)); 529 529 530 530 return clntSock; … … 552 552 /* Mark the socket so it will listen for incoming connections */ 553 553 if (listen(sock, 5) < 0) { 554 print 32_tf("listen() failed\n");554 printf("listen() failed\n"); 555 555 return 0; 556 556 } … … 567 567 ReceiveMessage(socketfd,buffer); 568 568 569 print 32_tf("Cognitive Radio:: Message Received - %s.\n\n", buffer);569 printf("Cognitive Radio:: Message Received - %s.\n\n", buffer); 570 570 571 571 if(strcmp(buffer,"c_register") == 0) … … 636 636 } 637 637 638 print 32_tf("Starting server: Hit return to shutdown\n");638 printf("Starting server: Hit return to shutdown\n"); 639 639 while (running) 640 640 { … … 655 655 rc = select(maxDescriptor + 1, &sockSet, NULL, NULL, &selTimeout); 656 656 if (rc == 0) 657 print 32_tf("No echo requests for %i secs...Server still alive\n", timeout);657 printf("No echo requests for %i secs...Server still alive\n", timeout); 658 658 else 659 659 { 660 660 if (FD_ISSET(0, &sockSet)) /* Check keyboard */ 661 661 { 662 print 32_tf("Shutting down server\n");662 printf("Shutting down server\n"); 663 663 getchar(); 664 664 running = 0; … … 670 670 if (FD_ISSET(port, &sockSet)) 671 671 { 672 print 32_tf("Request on port %d: ", port);672 printf("Request on port %d: ", port); 673 673 desc_ready -= 1; 674 674 … … 688 688 if(new_sd > maxDescriptor) 689 689 maxDescriptor = new_sd; 690 print 32_tf("New incoming connection - %i\n\n",new_sd);690 printf("New incoming connection - %i\n\n",new_sd); 691 691 } while(new_sd != -1); 692 692 } else { 693 693 694 print 32_tf("Request on already open descriptor.\n\n");694 printf("Request on already open descriptor.\n\n"); 695 695 HandleTCPClient(port, uList, pList, oList, ce_info); 696 696 … … 751 751 cout << "Initialize:: Configuration file parsing completed.\n" << endl; 752 752 753 //print 32_t_current_config(uList, pList, oList, &ce_info);753 //print_current_config(uList, pList, oList, &ce_info); 754 754 755 755 StartServers(uList, pList, oList, ce_info);