Changeset 209

Show
Ignore:
Timestamp:
03/26/09 12:53:27 (15 years ago)
Author:
bhilburn
Message:

Simply whitespace fixes.

Location:
vtcross/trunk/src
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • vtcross/trunk/src/include/vtcross/components.h

    r208 r209  
    4949        } 
    5050 
    51          
    5251        /* Send an indentfying string for this object's component type in 
    5352         * response to a GetRemoteComponentType query. 
     
    5554        virtual void SendComponentType() = 0; 
    5655 
    57  
    5856        /* Wait for a command signal containing task instructions. 
    5957         */ 
    6058        virtual void WaitForSignal() = 0; 
    6159 
    62  
    6360        /* Completely shutdown the radio and all operations. 
    6461         */ 
    6562        virtual void Shutdown() = 0; 
    66  
    6763 
    6864        /* Reset the radio and reload all configuration files. 
     
    7167         */ 
    7268        virtual void Reset() = 0; 
    73  
    7469 
    7570        /* Register or deregister a component with the primary radio shell. 
     
    9792                const char* serverPort, const bool SML) = 0; 
    9893 
    99  
    10094        /* Register or deregister services that this engine provides with the 
    10195         * service management layer. 
     
    140134        void TransferRadioConfiguration(); 
    141135 
    142          
    143136        /* Receive information regarding a completed 'experience' and pass it on 
    144137         * to the appropriate cognitive engine. 
    145138         */ 
    146139        void TransferExperience(); 
    147  
    148140         
    149141        /* Listen for other components registering their available services with 
     
    152144        void ReceiveServices(); 
    153145 
    154  
    155146        /* Change the active mission of the radio to a new one and adjust radio 
    156147         * behavoir appropriately. 
     
    158149        void SetActiveMission(); 
    159150 
    160  
    161151        /* List all services provided to the radio by registered components. 
    162152         */ 
    163153        void ListServices(); 
    164  
    165154 
    166155        /* Load/Relead the XML configuration file.  
     
    169158        void LoadConfiguration(); 
    170159 
    171  
    172160        /* The socket file descriptor information for the shell which this SML 
    173161         * is connected to. 
     
    185173        PolicyEngine(); 
    186174        ~PolicyEngine(); 
    187  
    188175 
    189176        /* Overloaded constructor that creates a policy engine object and 
     
    211198        void ReloadPolicies(); 
    212199 
    213          
    214200        /* Return a decision made by the policy engine regarding a certain set 
    215201         * of transmission parameters. 
     
    218204                int32_t decision_array[]); 
    219205 
    220  
    221206        /* Validate a set of transmission parameters received from the radio. 
    222207         */ 
    223208        void ValidateParameters(); 
    224  
    225209 
    226210        /* The SML_present bool reflects whether or not the remote component 
     
    261245        void ReceiveRadioConfiguration(); 
    262246 
    263  
    264247        /* Receive an 'experience' report from the radio. 
    265248         */ 
    266249        void ReceiveExperience(); 
    267  
    268250 
    269251        /* Find the most optimal set of transmission parameters given certain 
     
    273255        void GetSolution(Observable *observables); 
    274256        void GetSolution(Observable *observables, std::string service); 
    275  
    276257 
    277258        /* Receive a feedback from the radio regarding the performance of a 
     
    303284        ~CognitiveRadioShell(); 
    304285 
    305  
    306         /* Overloaded constructor that creates a CR Shell object */  
     286        /* Overloaded constructor that creates a CR Shell object and loads the 
     287         * passed radio configuration XML file. 
     288         */ 
    307289        CognitiveRadioShell(const char* radioConfig, int16_t primaryPort, \ 
    308290            int16_t policyPort, int16_t commandPort); 
     
    314296        /* Start all the socket servers */ 
    315297        void StartShellServer(); 
     298 
    316299        int32_t LoadRadioConfiguration(const char* radioConfig, Parameter* &pList, \ 
    317300            Utility* &uList, Observable* &oList, Radio_Info* radioInfo); 
     
    322305        void ReloadPolicies(); 
    323306 
    324         /* Register and Deregister the different components */ 
     307        /* Register and Deregister the different components. 
     308         */ 
    325309        void RegisterCognitiveEngine(int32_t socketFD); 
    326310        void DeregisterCognitiveEngine(int32_t socketFD); 
     
    330314        void DeregisterSML(int32_t socketFD); 
    331315 
    332         /* Handle a message that is received from a component */ 
     316        /* Handle a message that is received from a component. 
     317         */ 
    333318        void HandleMessage(int32_t socketFD); 
    334319        
    335         /* Send optimization request to primary port FD*/ 
     320        /* Send optimization request to primary port FD. 
     321         */ 
    336322        void GetOptimalParameters(int32_t socketFD); 
    337323 
  • vtcross/trunk/src/shell/CognitiveRadioShell.cpp

    r208 r209  
    6262    radio_info = new Radio_Info; 
    6363 
    64  
    6564    LoadRadioConfiguration(radioConfig,p,u,o,radio_info); 
    6665 
     
    7877} 
    7978 
     79 
    8080void  
    8181CognitiveRadioShell::Shutdown() 
     
    9898} 
    9999 
     100 
    100101void 
    101102CognitiveRadioShell::SendRadioExperience(int32_t socketFD) 
     
    104105    LOG("Cognitive Radio Shell:: Sending radio experience to Cognitive Engine.\n"); 
    105106} 
     107 
    106108 
    107109void 
     
    117119} 
    118120 
     121 
    119122void  
    120123CognitiveRadioShell::DeregisterCognitiveEngine(int32_t socketFD) 
     
    124127    numberOfCognitiveEngines--; 
    125128    if(numberOfCognitiveEngines == 0) 
    126     CE_present = false; 
     129        CE_present = false; 
    127130 
    128131    SendMessage(socketFD, "deregister_ack"); 
     
    132135} 
    133136 
     137 
    134138void 
    135139CognitiveRadioShell::RegisterPolicyEngine(int32_t socketFD) 
     
    138142    PE_present = true; 
    139143} 
     144 
    140145 
    141146void  
     
    152157} 
    153158 
     159 
    154160void 
    155161CognitiveRadioShell::RegisterSML(int32_t socketFD) 
     
    159165    SML_present = true; 
    160166} 
     167 
    161168 
    162169void  
     
    173180} 
    174181 
     182 
    175183int32_t  
    176 CognitiveRadioShell::LoadRadioConfiguration(const char* radioConfig, Parameter* &pList, \ 
    177     Utility* &uList, Observable* &oList, Radio_Info * radioInfo) 
     184CognitiveRadioShell::LoadRadioConfiguration(const char* radioConfig, \ 
     185        Parameter* &pList, Utility* &uList, Observable* &oList, \ 
     186        Radio_Info* radioInfo) 
    178187{ 
    179188    TiXmlElement *pElem; 
     
    193202    TiXmlDocument doc( radioConfig ); 
    194203    bool loadOkay = doc.LoadFile(); 
    195     if(!loadOkay) 
    196     { 
     204    if(!loadOkay) { 
    197205        ERROR(1,"Loading radio configuration failed: %s\n", radioConfig); 
    198206        return -1; 
     
    212220 
    213221    for(pChild = pChild1->FirstChildElement("utility"); pChild; \ 
    214         pChild = pChild->NextSiblingElement())  
    215     { 
     222        pChild = pChild->NextSiblingElement()) { 
     223 
    216224        const char *uName = pChild->Attribute("name"); 
    217225        if(uName) 
     
    240248 
    241249    for(pChild = pChild1->FirstChildElement("observable"); pChild; \ 
    242         pChild = pChild->NextSiblingElement())  
    243     { 
     250        pChild = pChild->NextSiblingElement()) { 
     251 
    244252        const char *oName = pChild->Attribute("name"); 
    245253        if(oName)  
     
    248256        affect_count = 0; 
    249257        for(pSecondChild = pChild->FirstChildElement("affect"); pSecondChild; \ 
    250             pSecondChild = pSecondChild->NextSiblingElement())  
    251         { 
     258            pSecondChild = pSecondChild->NextSiblingElement()) { 
     259 
    252260            const char *oUtilName = pSecondChild->Attribute("utility"); 
    253             if(oUtilName)  
    254             { 
    255                 for(attribute_count = 0; attribute_count < radio_info->numUtilities; attribute_count++ )  
    256                 { 
    257                     if(uList[attribute_count].name == oUtilName)  
    258                     { 
     261            if(oUtilName) { 
     262                for(attribute_count = 0; attribute_count < radio_info->numUtilities; attribute_count++ ) { 
     263                    if(uList[attribute_count].name == oUtilName) { 
     264 
    259265                        oList[item_count].affection_list[affect_count].u = &uList[attribute_count]; 
    260266                        const char *oRelate = pSecondChild->Attribute("relationship"); 
    261267                        if(oRelate)  
    262268                            oList[item_count].affection_list[affect_count].relation = oRelate; 
     269 
    263270                        affect_count++; 
    264271                        match_found = true; 
     
    287294    item_count = 0; 
    288295    for(pChild = pChild1->FirstChildElement("parameter"); pChild; \ 
    289         pChild = pChild->NextSiblingElement())  
    290     { 
     296        pChild = pChild->NextSiblingElement()) { 
     297 
    291298        const char *pName = pChild->Attribute("name"); 
    292299        if(pName)  
     
    308315        affect_count = 0; 
    309316        for(pSecondChild = pChild->FirstChildElement("affect"); pSecondChild; \ 
    310             pSecondChild = pSecondChild->NextSiblingElement())  
    311         { 
     317 
     318            pSecondChild = pSecondChild->NextSiblingElement()) { 
    312319            const char *pUtilName = pSecondChild->Attribute("utility"); 
    313             if(pUtilName)  
    314             { 
    315                 for(attribute_count = 0; attribute_count < radio_info->numUtilities; attribute_count++)  
    316                 { 
    317                     if(uList[attribute_count].name == pUtilName)  
    318                     { 
     320            if(pUtilName) { 
     321                for(attribute_count = 0; attribute_count < radio_info->numUtilities; attribute_count++) { 
     322                    if(uList[attribute_count].name == pUtilName) { 
    319323                        pList[item_count].affection_list[affect_count].u = &uList[attribute_count];     
    320324 
     
    332336            } 
    333337 
    334             if(!match_found)  
    335             { 
     338            if(!match_found) { 
    336339                ERROR(1, "Error: %s: %s is not a valid utility.\n", \ 
    337340                    pList[item_count].name.c_str(), pUtilName); 
     
    352355} 
    353356 
     357 
    354358void 
    355359CognitiveRadioShell::GetOptimalParameters(int32_t socketFD) 
    356360{ 
    357  
    358  
    359 } 
     361} 
     362 
    360363 
    361364void 
     
    384387} 
    385388 
     389 
    386390void 
    387391CognitiveRadioShell::StartShellServer() 
     
    421425    } 
    422426 
    423     while (running) 
    424     { 
     427    while (running) { 
    425428        /* Zero socket descriptor vector and set for server sockets */ 
    426429        /* This must be reset every time select() is called */ 
     
    437440        /* Suspend program until descriptor is ready or timeout */ 
    438441        rc = select(maxDescriptor + 1, &sockSet, NULL, NULL, &selTimeout);  
    439         if (rc == 0) 
     442        if(rc == 0) 
    440443            LOG("No echo requests for %i secs...Server still alive\n", timeout); 
    441         else  
    442         { 
     444        else { 
    443445            desc_ready = rc; 
    444446 
    445             for (port = 0; port <= maxDescriptor && desc_ready > 0; port++) { 
    446                 if (FD_ISSET(port, &sockSet)) 
    447                 { 
    448                 desc_ready -= 1; 
     447            for(port = 0; port <= maxDescriptor && desc_ready > 0; port++) { 
     448                if(FD_ISSET(port, &sockSet)) { 
     449                    desc_ready -= 1; 
    449450 
    450451                    /* Check if request is new or on an existing open descriptor */ 
    451                     if( (port == servSock[primary]) || (port == servSock[policy]) || (port == servSock[command])) {  
    452                         do 
    453                         {  
     452                    if((port == servSock[primary]) || (port == servSock[policy]) || (port == servSock[command])) {  
     453                        do { 
    454454                            new_sd = AcceptTCPConnection(port); 
    455455                            if(new_sd < 0)  
    456                             { 
    457456                                break; 
    458                             } 
    459457                             
    460458                            HandleMessage(new_sd); 
     
    464462                            //LOG("New incoming connection - %i\n\n",new_sd); 
    465463                        } while(new_sd != -1); 
    466                     } else { 
    467                          
     464                    }  
     465                    else { 
    468466                        //LOG("Request on already open descriptor.\n\n"); 
    469467                        HandleMessage(port);