Changeset 291

Show
Ignore:
Timestamp:
06/19/09 09:09:01 (15 years ago)
Author:
wrodgers
Message:

Added non-observ/param inputs for missions

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • vtcross/trunk/src/service_management_layer/ServiceManagementLayer.cpp

    r290 r291  
    708708 
    709709 
    710  
     710    //If this is a service command and not a shell command... 
    711711    //Transmission starting messages 
    712712    SendMessage(miss[activeMission].services[sourceID].socketFD, "request_optimization_service"); 
     
    879879 * When they complete, the output path is found and the data is transfered as it becomes available 
    880880 * Presumably at this point the second function has all of it's paramaters, so it begins to compute, and the cycle repeats 
    881  * If the generated output is an overall output, it is sent on to the shell 
    882  * "if" and "while" statements are handled by setting up a faux service that has a true input, a false input, and a boolean flag 
    883  * If the true input is non-NULL and the flag is true, the statements execute 
    884  * Likewise, if the false input is non-NULL and the flag is false, the statements execute 
    885  * These flags are set during execution any time one of these faux services' inputs appear in an output statement   
    886881 *   
    887882 *  
    888883 * Rules for active missions (currently) 
    889  * -Three inputs/outputs per service and per mission 
    890  * -Inputs simply define a path, so multiple variables can be transmitted over the same input 
    891  * -Each component that sends data must include the "output_finished" statement after each output is finished sending it's data 
     884 * -Five inputs/outputs per service and per mission 
    892885 * -All ordering constraints have been relaxed in this version; all data is stored locally and only sent when requested 
    893  * -If support fully implemented 
    894  * -Conditions must be boolean flags 
    895  * -Flags are set by putting either the character string "true" or "false" on the buffer 
     886 * -If support fully implemented - up to three levels 
     887 * -While support still a work in progress 
    896888 * -IMPORTANT: DB uses '@' to seperate individual statements; using '@' in the data stream will result in incorrect behavior 
    897889 */ 
    898890 
    899891//IF-IF-IF 
    900 //IF-IF-WHILE 
    901 //IF-WHILE 
    902892//WHILE 
    903893void 
     
    920910 
    921911    int32_t t = atoi(buffer); 
    922    // printf("****%d****\n", t); 
     912    /* Receive Set of Observables */ 
    923913    for(int32_t m = 0; m < t; m++) { 
    924914        //printf("data=%s\n", data_obsv.c_str()); 
     
    941931    } 
    942932 
    943  
    944     /*printf("\n\n\n"); 
    945     // generate commandi 
    946     strcpy(_data_DB->command, "select "); 
    947     strcat(_data_DB->command, _data_DB->tablename); 
    948     strcat(_data_DB->command, ".* from "); 
    949     strcat(_data_DB->command, _data_DB->tablename); 
    950     strcat(_data_DB->command, ";"); 
    951  
    952     // execute print (select all)  command   
    953     rc = sqlite3_exec(_data_DB->db, _data_DB->command, callback, 0, &errorMsg); 
    954     if( rc!=SQLITE_OK && rc!=101 ) 
    955         fprintf(stderr, "SQL error: %s\n", errorMsg); 
    956     printf("database %s, table %s:\n", _data_DB->filename, _data_DB->tablename); 
    957     printf("\n\n\n");*/ 
    958  
    959933    /* Receive Set of Parameters */ 
    960934    memset(buffer, 0, 256); 
     
    974948        memset(buffer, 0, 256); 
    975949        ReadMessage(shellSocketFD, buffer); 
    976         sprintf(_data_DB->command, "%s values('%s', '1@%s@%s", _data_DB->command, buffer1, buffer1, buffer); 
    977         strcat(_data_DB->command, "');"); 
     950        sprintf(_data_DB->command, "%s values('%s', '1@%s@%s');", _data_DB->command, buffer1, buffer1, buffer); 
    978951        rc = sqlite3_exec(_data_DB->db, _data_DB->command, callback, 0, &errorMsg); 
    979952        if( rc!=SQLITE_OK && rc!=101 ) 
     
    982955 
    983956 
     957 
     958 
     959 
     960    while(i < 5 && !miss[activeMission].input[i].empty()){ 
     961            //New data being added to DB 
     962        //printf("inserting data from shell\n"); 
     963        memset(buffer1, 0, 256); 
     964        ReadMessage(shellSocketFD, buffer1); 
     965        t=atoi(buffer1); 
     966        //printf("t=%d\n", t); 
     967        for(int m = 0; m < t; m++) { 
     968            data.append("@"); 
     969            memset(buffer, 0, 256); 
     970            ReadMessage(shellSocketFD, buffer); 
     971            data.append(buffer); 
     972            data.append("@"); 
     973            memset(buffer, 0, 256); 
     974            ReadMessage(shellSocketFD, buffer); 
     975            data.append(buffer); 
     976        } 
     977        //printf("here %s\n", data.c_str()); 
     978        strcpy(_data_DB->command, "insert into "); 
     979        strcat(_data_DB->command, _data_DB->tablename);  
     980        strcat(_data_DB->command, " ("); 
     981        strcat(_data_DB->command, cols[0]); 
     982        strcat(_data_DB->command, ", "); 
     983        strcat(_data_DB->command, cols[1]); 
     984        strcat(_data_DB->command, ") "); 
     985        strcat(_data_DB->command, " values('"); 
     986        strcat(_data_DB->command, miss[activeMission].input[i].c_str()); 
     987        sprintf(_data_DB->command, "%s', '%s%s');", _data_DB->command, buffer1, data.c_str()); 
     988        char *errorMsg; 
     989        rc = sqlite3_exec(_data_DB->db, _data_DB->command, callback, 0, &errorMsg); 
     990        if( rc!=SQLITE_OK && rc!=101 ) 
     991            fprintf(stderr, "SQL error: %s\n", errorMsg); 
     992        //printf("SML: finished adding data from shell on input %d\n", i); 
     993        i++; 
     994        data.clear(); 
     995    } 
     996 
     997 
     998    //Useful for spotchecking what's in the database 
    984999    /*printf("\n\n\n"); 
    9851000    // generate commandi 
     
    10031018    i=0;  
    10041019    int32_t numstatements[3] = {0,0,0}; 
    1005     data.clear(); 
    10061020    while(i < miss[activeMission].numServices) 
    10071021    { 
     
    13781392 * 
    13791393 * DESCRIPTION: IMPORTANT - See formatting instructions for correct parsing of data 
    1380  * Can currently handle 3 inputs and 3 outputs per service, but easily expandable 
    1381  * Also, can handle one layer of nested conditional statements, but could 
    1382  * be expanded to meet additional needs.  Only support now is for straight bool flags, 
    1383  * but support could be added for more complex conditionals later. 
     1394 * Can currently handle 5 inputs and 5 outputs per service, but easily expandable 
     1395 * Also, can handle two layer of nested conditional statements, but could 
     1396 * be expanded to meet additional needs. 
    13841397 *  
    13851398 * Components assigned to mission during "set active mission" stage so that