Changeset 86

Show
Ignore:
Timestamp:
11/25/08 14:31:00 (16 years ago)
Author:
trnewman
Message:

fixed some error handling issues

Location:
vtcross/branches/trnewman/CR_shell
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • vtcross/branches/trnewman/CR_shell/example.ce.xml

    r85 r86  
    88    <!-- utilities : QoS metrics --> 
    99    <utilities> 
    10         <utility name="throughput" units="kbps" goal="max" target="125000" /> 
     10        <utility name="throughput" units="kbps" goal="max" target="125000" />  
    1111        <utility name="spectral_efficiency" units="b/s/Hz" goal="max" /> 
    12         <utility name="log10_ber" units="none" goal="min" target="-3" /> 
     12        <!-- <utility name="log10_ber" units="none" goal="min" target="-3" /> --> 
    1313        <!-- <utility name="latency" units="ms" goal="min" target=100 /> --> 
    1414    </utilities> 
  • vtcross/branches/trnewman/CR_shell/src/main_cognitive_radio.cpp

    r85 r86  
    9090        int j = 0; 
    9191        int k = 0; 
     92        int match_found = 0; 
    9293 
    9394        pElem = hDoc.FirstChildElement().Element(); 
     
    137138                        if(oUtilName) { 
    138139                                // Search for correct utility 
    139                                 for(k=0;k<10;k++){ 
     140                                for( k=0 ; u[k]!=NULL ; k++ ){ 
    140141                                        if(u[k]->name == oUtilName) { 
    141142                                                o[i]->affection_list[j].u = u[k]; 
     143                                                // Set relationship 
     144                                                const char *oRelate = pSecondChild->Attribute("relationship"); 
     145                                                if(oRelate) o[i]->affection_list[j].relation = oRelate; 
     146                                                j++; 
     147                                                match_found = 1; 
    142148                                                break; 
    143149                                        } 
    144150                                } 
    145151                        } 
    146                          
    147                         // Set relationship 
    148                         const char *oRelate = pSecondChild->Attribute("relationship"); 
    149                         if(oRelate) o[i]->affection_list[j].relation = oRelate; 
    150                         j++; 
     152                        if(!match_found) cout << "Error: " << o[i]->name << ": " << oUtilName << " not a valid utility: Affect not added." << endl;      
     153                        match_found = 0;         
    151154                } 
    152155                o[i]->numAffects = j;  
     
    185188                                for( k=0 ; u[k]!=NULL ; k++ ){ 
    186189                                        if(u[k]->name == pUtilName) { 
     190                                                // If match found, assign it to this index 
    187191                                                p[i]->affection_list[j].u = u[k];        
     192                                                const char *pRelate = pSecondChild->Attribute("relationship"); 
     193                                                if(pRelate) { 
     194                                                        p[i]->affection_list[j].relation = pRelate; 
     195                                                } else { 
     196                                                        cout << "Error: No relation found." << endl; 
     197                                                } 
     198                                                match_found = 1; 
     199                                                j++; 
    188200                                                break; 
    189201                                        } 
    190202                                } 
    191203                        } 
    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                  
     204                        if(!match_found) cout << "Error: " << p[i]->name << ": " << pUtilName << " not a valid utility: Affect not added." << endl;      
     205                        match_found = 0;         
    202206                } 
    203207                p[i]->numAffects = j;