Changeset 99

Show
Ignore:
Timestamp:
02/16/09 17:03:33 (15 years ago)
Author:
anonymous
Message:

Modded code to fit new protocols

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • vtcross/trunk/CR_engines/CBR/src/main_cognitive_engine.c

    r95 r99  
    7373    if (n < 0)  
    7474         error("ERROR reading from socket"); 
    75 //    printf("ReadMessage:%s %d\n",buffer,n); 
     75    //printf("ReadMessage:%s %d\n",buffer,n); 
    7676} 
    7777 
     
    398398    "log10_ber", "mod_scheme", "tx_power", "SNR", "utility"};*/ 
    399399    //char cols[num_cols][50]; 
    400      
     400    
     401 
    401402    char **cols; 
    402403    cols = (char **)malloc(sizeof(char)*num_cols); 
     
    423424    cols[j] = "utility"; 
    424425     
    425     printf("column names:"); 
    426     for (i = 0; i<num_cols; i++){ 
    427         printf(" %s",cols[i]); 
    428     } 
    429     printf("\n"); 
     426    //printf("column names:"); 
     427    //for (i = 0; i<num_cols; i++){ 
     428    //    printf(" %s",cols[i]); 
     429    //} 
     430    //printf("\n"); 
    430431 
    431432    int rc; 
     
    530531} 
    531532 
     533int RegisterCE(int sockfd, struct Utility uList[], struct Parameter pList[],  
     534        struct Observable oList[], struct CE_Info *ce_info) 
     535{ 
     536    // Send register message to cognitive radio 
     537    SendMessage(sockfd, "c_register"); 
     538    return 1; 
     539     
     540     
     541     
     542    return 1; 
     543} 
    532544 
    533545// main client socket 
     
    538550    struct Observable oList[10]; 
    539551    struct CE_Info ce_info; 
     552    char buffer[256]; 
    540553 
    541554    // setup client socket connection 
    542555    int sockfd; 
    543556    sockfd = ClientSocket(argc, argv); 
    544      
     557 
     558    RegisterCE(sockfd,uList,pList,oList,&ce_info); 
    545559    // get xml info from server 
    546560    GetXMLFromServer(sockfd, uList, pList, oList, &ce_info); 
     
    548562    //print_current_config(uList, pList, oList, &ce_info);  
    549563     
    550      
    551564    // get experience size from server 
    552565    int num_rows, num_cols; 
    553566    GetExperienceSize(sockfd, &num_rows, &num_cols); 
    554      
     567 
    555568    // get experience 
    556569    int i, j; 
     
    558571    GetExperience(sockfd, num_rows, num_cols, past_exp); 
    559572    printf("Received Previous Radio Experience from Server Successfully.\n\n"); 
    560      
    561     // calculate utility 
    562  
    563573    // cbr operation 
    564574    //unsigned int num_cols; 
     
    567577    num_cols = num_cols + ce_info.numObservables; 
    568578    num_cols = num_cols + 1;    // overall utility 
    569     
    570579    //while(1) { 
    571580         
     
    574583        //GetRequest(sockfd); 
    575584        //printf("Received optimization request from server\n\n"); 
    576         RunCBREngine(uList, pList, oList, &ce_info, num_cols, num_rows,  
    577             past_exp);     
     585        RunCBREngine(uList, pList, oList, &ce_info, num_cols, num_rows, past_exp);     
    578586    
    579587        printf("Sending optimization results to server.\n\n"); 
    580588        // send results back to server 
    581589        SendCEResults(sockfd, uList, pList, oList, &ce_info); 
     590         
    582591    //} 
    583592