Changeset 281

Show
Ignore:
Timestamp:
06/16/09 14:21:14 (15 years ago)
Author:
trnewman
Message:

Adding set active mission functionality in the shell

Location:
vtcross/trunk/src
Files:
4 modified

Legend:

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

    r278 r281  
    367367        void RegisterSML(int32_t socketFD); 
    368368        void DeregisterSML(int32_t socketFD); 
     369         
     370        void SetActiveMission(int32_t socketFD); 
    369371 
    370372        /* Handle a message that is received from a component. 
  • vtcross/trunk/src/libvtcross/Makefile.am

    r222 r281  
    22 
    33lib_LTLIBRARIES = libvtcross.la 
    4 bin_PROGRAMS = libvtcross_demo 
     4bin_PROGRAMS = libvtcross_demo libvtcross_demo_sml 
    55 
    66libvtcross_la_SOURCES = libvtcross.cpp 
     
    1010libvtcross_demo_SOURCES = libvtcross_demo.cpp 
    1111libvtcross_demo_LDADD = libvtcross.la 
     12 
     13libvtcross_demo_sml_SOURCES = libvtcross_demo_sml.cpp 
     14libvtcross_demo_sml_LDADD = libvtcross.la 
  • vtcross/trunk/src/service_management_layer/Makefile.am

    r279 r281  
    33AM_CXXFLAGS = -Wall -g 
    44 
    5 bin_PROGRAMS = sml_demo ce_test_demo 
     5bin_PROGRAMS = sml_demo 
    66 
    77sml_demo_SOURCES = ServiceManagementLayer.cpp sml_demo.cpp 
    88sml_demo_LDADD = -ldl -lpthread -lsqlite3  ../lib/tinyxml/libtinyxml.a ../lib/socketcomm/libsocketcomm.a 
    9  
    10 ce_test_demo_SOURCES = ce_test_demo.cpp 
    11 ce_test_demo_LDADD = -ldl -lpthread ../lib/socketcomm/libsocketcomm.a 
  • vtcross/trunk/src/shell/CognitiveRadioShell.cpp

    r279 r281  
    277277} 
    278278 
     279void  
     280CognitiveRadioShell::SetActiveMission(int32_t socketFD) 
     281{ 
     282    char buffer[256]; 
     283 
     284    LOG("Cognitive Radio Shell:: Received Set Active Mission command from host.\n"); 
     285    
     286    // Read the name of the active mission to be set from the host.  
     287    memset(buffer, 0, 256); 
     288    ReadMessage(commandSocketFD, buffer); 
     289 
     290    // Send command to SML 
     291    SendMessage(ceSocketFD, "set_active_mission"); 
     292    SendMessage(ceSocketFD, buffer); 
     293 
     294    // Get ack from SML saying the mission was set properly 
     295    memset(buffer, 0, 256); 
     296    ReadMessage(ceSocketFD, buffer); 
     297 
     298    // Forward ack to host 
     299    SendMessage(commandSocketFD, buffer); 
     300} 
    279301 
    280302int32_t  
     
    497519     * to send this information 
    498520     */ 
    499     if(!SML_present) {  
    500         LOG("Cognitive Radio Shell:: Passing on observables to Cognitive Engine\n"); 
    501         SendMessage(ceSocketFD,"request_optimization"); 
    502         sprintf(counter,"%i",numObservables); 
    503         SendMessage(ceSocketFD,counter); 
    504         for(size_t i = 0; i < numObservables; i++) { 
    505             SendMessage(ceSocketFD,o[i].name.c_str()); 
    506             sprintf(var,"%f",o[i].value); 
    507             SendMessage(ceSocketFD,var); 
    508         } 
     521    LOG("Cognitive Radio Shell:: Passing on observables.\n"); 
     522    SendMessage(ceSocketFD,"request_optimization"); 
     523    sprintf(counter,"%i",numObservables); 
     524    SendMessage(ceSocketFD,counter); 
     525    for(size_t i = 0; i < numObservables; i++) { 
     526        SendMessage(ceSocketFD,o[i].name.c_str()); 
     527        sprintf(var,"%f",o[i].value); 
     528        SendMessage(ceSocketFD,var); 
     529    } 
    509530         
    510         LOG("Cognitive Radio Shell:: Passing on current parameters to Cognitive Engine\n"); 
    511         sprintf(counter,"%i",numCurrentParameters); 
    512         SendMessage(ceSocketFD,counter); 
    513         for(size_t i = 0; i < numCurrentParameters; i++) { 
    514             SendMessage(ceSocketFD,cp[i].name.c_str()); 
    515             sprintf(var,"%f",cp[i].value); 
    516             SendMessage(ceSocketFD,var); 
    517         } 
    518     } 
    519  
    520     LOG("Cognitive Radio Shell:: Receiving optimized parameters from Cognitive Engine.\n"); 
     531    LOG("Cognitive Radio Shell:: Passing on current parameters.\n"); 
     532    sprintf(counter,"%i",numCurrentParameters); 
     533    SendMessage(ceSocketFD,counter); 
     534    for(size_t i = 0; i < numCurrentParameters; i++) { 
     535        SendMessage(ceSocketFD,cp[i].name.c_str()); 
     536        sprintf(var,"%f",cp[i].value); 
     537        SendMessage(ceSocketFD,var); 
     538    } 
     539 
     540    LOG("Cognitive Radio Shell:: Receiving optimized parameters.\n"); 
    521541    /* Receive Set of Parameters */ 
    522542    memset(buffer, 0, 256); 
     
    659679        /* Receive optimization request and current environment */ 
    660680        GetOptimalParameters(socketFD);   
     681    } else if(strcmp(buffer, "set_active_mission") == 0) { 
     682        SetActiveMission(socketFD);   
    661683    } else if(strcmp(buffer, "request_optimization_service") == 0) { 
    662684        /* Receive optimization request and current environment */