Index: /vtcross/trunk/src/service_management_layer/ServiceManagementLayer.cpp
===================================================================
--- /vtcross/trunk/src/service_management_layer/ServiceManagementLayer.cpp	(revision 290)
+++ /vtcross/trunk/src/service_management_layer/ServiceManagementLayer.cpp	(revision 291)
@@ -708,5 +708,5 @@
 
 
-
+    //If this is a service command and not a shell command...
     //Transmission starting messages
     SendMessage(miss[activeMission].services[sourceID].socketFD, "request_optimization_service");
@@ -879,25 +879,15 @@
  * When they complete, the output path is found and the data is transfered as it becomes available
  * Presumably at this point the second function has all of it's paramaters, so it begins to compute, and the cycle repeats
- * If the generated output is an overall output, it is sent on to the shell
- * "if" and "while" statements are handled by setting up a faux service that has a true input, a false input, and a boolean flag
- * If the true input is non-NULL and the flag is true, the statements execute
- * Likewise, if the false input is non-NULL and the flag is false, the statements execute
- * These flags are set during execution any time one of these faux services' inputs appear in an output statement  
  *  
  * 
  * Rules for active missions (currently)
- * -Three inputs/outputs per service and per mission
- * -Inputs simply define a path, so multiple variables can be transmitted over the same input
- * -Each component that sends data must include the "output_finished" statement after each output is finished sending it's data
+ * -Five inputs/outputs per service and per mission
  * -All ordering constraints have been relaxed in this version; all data is stored locally and only sent when requested
- * -If support fully implemented
- * -Conditions must be boolean flags
- * -Flags are set by putting either the character string "true" or "false" on the buffer
+ * -If support fully implemented - up to three levels
+ * -While support still a work in progress
  * -IMPORTANT: DB uses '@' to seperate individual statements; using '@' in the data stream will result in incorrect behavior
  */
 
 //IF-IF-IF
-//IF-IF-WHILE
-//IF-WHILE
 //WHILE
 void
@@ -920,5 +910,5 @@
 
     int32_t t = atoi(buffer);
-   // printf("****%d****\n", t);
+    /* Receive Set of Observables */
     for(int32_t m = 0; m < t; m++) {
 	//printf("data=%s\n", data_obsv.c_str());
@@ -941,20 +931,4 @@
     }
 
-
-    /*printf("\n\n\n");
-    // generate commandi
-    strcpy(_data_DB->command, "select ");
-    strcat(_data_DB->command, _data_DB->tablename);
-    strcat(_data_DB->command, ".* from ");
-    strcat(_data_DB->command, _data_DB->tablename);
-    strcat(_data_DB->command, ";");
-
-    // execute print (select all)  command  
-    rc = sqlite3_exec(_data_DB->db, _data_DB->command, callback, 0, &errorMsg);
-    if( rc!=SQLITE_OK && rc!=101 )
-        fprintf(stderr, "SQL error: %s\n", errorMsg);
-    printf("database %s, table %s:\n", _data_DB->filename, _data_DB->tablename);
-    printf("\n\n\n");*/
-
     /* Receive Set of Parameters */
     memset(buffer, 0, 256);
@@ -974,6 +948,5 @@
         memset(buffer, 0, 256);
         ReadMessage(shellSocketFD, buffer);
-	sprintf(_data_DB->command, "%s values('%s', '1@%s@%s", _data_DB->command, buffer1, buffer1, buffer);
-	strcat(_data_DB->command, "');");
+	sprintf(_data_DB->command, "%s values('%s', '1@%s@%s');", _data_DB->command, buffer1, buffer1, buffer);
    	rc = sqlite3_exec(_data_DB->db, _data_DB->command, callback, 0, &errorMsg);
    	if( rc!=SQLITE_OK && rc!=101 )
@@ -982,4 +955,46 @@
 
 
+
+
+
+    while(i < 5 && !miss[activeMission].input[i].empty()){
+	    //New data being added to DB
+	//printf("inserting data from shell\n");
+	memset(buffer1, 0, 256);
+	ReadMessage(shellSocketFD, buffer1);
+        t=atoi(buffer1);
+	//printf("t=%d\n", t);
+        for(int m = 0; m < t; m++) {
+	    data.append("@");
+	    memset(buffer, 0, 256);
+	    ReadMessage(shellSocketFD, buffer);
+	    data.append(buffer);
+	    data.append("@");
+	    memset(buffer, 0, 256);
+	    ReadMessage(shellSocketFD, buffer);
+	    data.append(buffer);
+	}
+	//printf("here %s\n", data.c_str());
+	strcpy(_data_DB->command, "insert into ");
+    	strcat(_data_DB->command, _data_DB->tablename); 
+      	strcat(_data_DB->command, " (");
+    	strcat(_data_DB->command, cols[0]);
+    	strcat(_data_DB->command, ", ");
+	strcat(_data_DB->command, cols[1]);
+	strcat(_data_DB->command, ") ");
+	strcat(_data_DB->command, " values('");
+	strcat(_data_DB->command, miss[activeMission].input[i].c_str());
+	sprintf(_data_DB->command, "%s', '%s%s');", _data_DB->command, buffer1, data.c_str());
+    	char *errorMsg;
+   	rc = sqlite3_exec(_data_DB->db, _data_DB->command, callback, 0, &errorMsg);
+   	if( rc!=SQLITE_OK && rc!=101 )
+   	    fprintf(stderr, "SQL error: %s\n", errorMsg);
+        //printf("SML: finished adding data from shell on input %d\n", i);
+        i++;
+	data.clear();
+    }
+
+
+    //Useful for spotchecking what's in the database
     /*printf("\n\n\n");
     // generate commandi
@@ -1003,5 +1018,4 @@
     i=0; 
     int32_t numstatements[3] = {0,0,0};
-    data.clear();
     while(i < miss[activeMission].numServices)
     {
@@ -1378,8 +1392,7 @@
  *
  * DESCRIPTION: IMPORTANT - See formatting instructions for correct parsing of data
- * Can currently handle 3 inputs and 3 outputs per service, but easily expandable
- * Also, can handle one layer of nested conditional statements, but could
- * be expanded to meet additional needs.  Only support now is for straight bool flags,
- * but support could be added for more complex conditionals later.
+ * Can currently handle 5 inputs and 5 outputs per service, but easily expandable
+ * Also, can handle two layer of nested conditional statements, but could
+ * be expanded to meet additional needs.
  * 
  * Components assigned to mission during "set active mission" stage so that
