Index: vtcross/trunk/src/service_management_layer/ServiceManagementLayer.cpp
===================================================================
--- vtcross/trunk/src/service_management_layer/ServiceManagementLayer.cpp	(revision 293)
+++ vtcross/trunk/src/service_management_layer/ServiceManagementLayer.cpp	(revision 294)
@@ -16,9 +16,4 @@
  */
 
-//TODO Add nested conditional support
-//TODO Verify update functionality
-//TODO Better shutdown
-//TODO Verify Deregister services
-//TODO printf's 
 
 #include <stdlib.h>
@@ -145,5 +140,5 @@
     miss = new Mission[10];
     for(int i = 0; i < 10; i++)
-    	miss[i].services = new Service[20];
+    	miss[i].services = new Service[30];
 
     Current_ID = 0;
@@ -467,4 +462,5 @@
 
 //Modified to check the incoming message buffer rather than the outgoing message buffer to avoid a portion of the delay
+//May change this again to handle data more inteligently, taking advantage of it's properties.
 void 
 ServiceManagementLayer::TransferRadioConfiguration(int32_t ID)
@@ -505,4 +501,5 @@
 
 //Modified to check the incoming message buffer rather than the outgoing message buffer to avoid a portion of the delay
+//May change this again to handle data more inteligently, taking advantage of it's properties.
 void 
 ServiceManagementLayer::TransferExperience(int32_t ID)
@@ -653,7 +650,5 @@
     char* cols[] = {(char *)"Tag", (char *)"Data"};
     int i = 0;
-    fd_set sockSet;
     char *token;
-    struct timeval selTimeout;
 
    //Send a message directly to the shell
@@ -661,5 +656,4 @@
    if(miss[activeMission].services[sourceID].name.find("shell")!=string::npos)
    {
-	//printf("caught shell\n");
 	//If the name on the output doesn't start with "~", search the DB to find the output that should be returned
 	if(miss[activeMission].services[sourceID].output[0].find("~") == string::npos){
@@ -679,12 +673,10 @@
                 else {
 		    //TODO could do shell output here if not in DB
-	    	data.append("1@");
-	    	data.append(miss[activeMission].services[sourceID].output[0]);
-	    	data.append("@");
+	    	data.append("1@output1@");
 	    	data.append(miss[activeMission].services[sourceID].output[0]);
 	    	data.append("@");
 		//printf("data = %s\n", data.c_str());
 	    	
-	            printf("data_DB:: Data not yet in DB.\n");
+	            //printf("2222data_DB:: Data not yet in DB.\n");
 		    rc=31337;
 	        }
@@ -707,12 +699,20 @@
    } 
 
-
     //If this is a service command and not a shell command...
     //Transmission starting messages
     SendMessage(miss[activeMission].services[sourceID].socketFD, "request_optimization_service");
     SendMessage(miss[activeMission].services[sourceID].socketFD, miss[activeMission].services[sourceID].name.c_str());
-    //Find and load the input data
+
+   //If the service takes a paramater, feed that paramater in
+   if(!miss[activeMission].services[sourceID].paramater.empty()){
+	//printf("sending parameter!\n");
+	SendMessage(miss[activeMission].services[sourceID].socketFD, "1");
+	SendMessage(miss[activeMission].services[sourceID].socketFD, "parameter");
+	SendMessage(miss[activeMission].services[sourceID].socketFD, miss[activeMission].services[sourceID].paramater.c_str());
+    }
+
+
+    //Load and transmit the input data
     while(i < 5 && !miss[activeMission].services[sourceID].input[i].empty()){
-	//printf("pulling input data out of DB for ID#=%d\n", sourceID);
         strcpy(_data_DB->command, "select ");
    	strcat(_data_DB->command, _data_DB->tablename);
@@ -720,8 +720,5 @@
     	strcat(_data_DB->command, _data_DB->tablename);
     	strcat(_data_DB->command, " where Tag==");
-	char temp[100];
-	strcpy(temp, miss[activeMission].services[sourceID].input[i].c_str());
-	char *temp2 = strtok(temp, "+");
-	sprintf(_data_DB->command, "%s'%s';", _data_DB->command, temp2);
+	sprintf(_data_DB->command, "%s'%s';", _data_DB->command, miss[activeMission].services[sourceID].input[i].c_str());
         sqlite3_stmt * pStatement;
         int rc = sqlite3_prepare_v2(_data_DB->db, _data_DB->command, -1, &pStatement, NULL);
@@ -738,93 +735,35 @@
         }
         sqlite3_finalize(pStatement);
-	char *data_ch = (char *) data.c_str();
-	int32_t numStatements = 0;
-	temp2 = strtok(NULL, "+");
-	while(temp2){
-	    numStatements++;
-	    temp2 = strtok(NULL, "+");
-	}
-	//printf("here1%d\n", numStatements);
-	char temp4[10];
-	memset(temp4, 0, 10);
-	sprintf(temp4, "%d", numStatements);
-	//Tokenize the data and pass it along
-	//printf("here2 %s\n", temp4);
-	if(strstr(miss[activeMission].services[sourceID].input[i].c_str(), "+")){
-	    SendMessage(miss[activeMission].services[sourceID].socketFD, temp4);
-	    token = strtok(data_ch, "@");
-	}
-	else{
-	    token = strtok(data_ch, "@");
+
+	    token = strtok((char *)data.c_str(), "@");
+	while(token){
 	    SendMessage(miss[activeMission].services[sourceID].socketFD, token);
-	}
-	token = strtok(NULL, "@");
-
-
-	//Either have to send whole block of memory or just one piece
-	while(token){
-	    if(strstr(miss[activeMission].services[sourceID].input[i].c_str(), token))
-	    {
-		//printf("1tokenizing %s %s!\n", miss[activeMission].services[sourceID].input[i].c_str(), token);
-	        SendMessage(miss[activeMission].services[sourceID].socketFD, token);
-	        token = strtok(NULL, "@");
-	        SendMessage(miss[activeMission].services[sourceID].socketFD, token);
-	    }
-	    else if(!strstr(miss[activeMission].services[sourceID].input[i].c_str(), "+"))
-	    {
-		//printf("t not detected tokenizing %s %s!\n", miss[activeMission].services[sourceID].input[i].c_str(), token);
-	        SendMessage(miss[activeMission].services[sourceID].socketFD, token);
-	        token = strtok(NULL, "@");
-	        SendMessage(miss[activeMission].services[sourceID].socketFD, token);
-	    }
-	    else{
-		//printf("3tokenizing %s %s!\n", miss[activeMission].services[sourceID].input[i].c_str(), token);
-	        token = strtok(NULL, "@");}
 	    token = strtok(NULL, "@");
 	}
-	//printf("done\n");
-	//printf("done pulling input data out of DB for ID#=%d\n", sourceID);
 	i++;
 	data.clear();
     }
     int32_t j = 0;
-    FD_ZERO(&sockSet);
-    FD_SET(miss[activeMission].services[sourceID].socketFD, &sockSet);
-    //TODO neccessary?
-    selTimeout.tv_sec = 5;
-    selTimeout.tv_usec = 0;
-    //Use select command to force wait for processing to finish
-    select(miss[activeMission].services[sourceID].socketFD + 1, &sockSet, NULL, NULL, &selTimeout);
-	//printf("done\n");
-   //TODO rewrite part of data on output?
-   //TODO true false format?
+    
+    //Receive and store the output data
     while(j < 5 && !miss[activeMission].services[sourceID].output[j].empty()){
 	int rc;
 	memset(buffer, 0, 256);
+	//Read the number of datapairs for this output
 	ReadMessage(miss[activeMission].services[sourceID].socketFD, buffer);
-       // printf("waiting\n");	    
 	data.append(buffer);
 	data.append("@");
 	int t = atoi(buffer);
-	//printf("%d\n", t);
 	for(int k = 0; k < t; k++){
-	    //Read the data incrementally and deliminate it with the "@" symbol
+	    //Read the datapairs incrementally and deliminate it with the "@" symbol
 	    memset(buffer, 0, 256);
 	    ReadMessage(miss[activeMission].services[sourceID].socketFD, buffer);
-	    if(!strcmp(buffer, "TF")){
-		ReadMessage(miss[activeMission].services[sourceID].socketFD, buffer);
-	        data.append(buffer);
-	        data.append("@");
-	    }
-	    else{
-	        data.append(buffer);
-	        data.append("@");
-	        memset(buffer, 0, 256);
-	        ReadMessage(miss[activeMission].services[sourceID].socketFD, buffer);
-	        data.append(buffer);
-	        data.append("@");
-	    }
+	    data.append(buffer);
+	    data.append("@");
+	    memset(buffer, 0, 256);
+	    ReadMessage(miss[activeMission].services[sourceID].socketFD, buffer);
+	    data.append(buffer);
+	    data.append("@");
 	}
-	//printf("SML: putting output data into DB for ID#=%d\n", sourceID);
 
 	strcpy(_data_DB->command, "insert or replace into ");
@@ -884,10 +823,9 @@
  * -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 - up to three levels
- * -While support still a work in progress
+ * -If and while support fully implemented - up to three levels (if's can be nested, but dowhiles cannot)
+ * -For dowhiles, assumes loop condition determined on next to last line (last line is a shell statement to keep the application updated)
  * -IMPORTANT: DB uses '@' to seperate individual statements; using '@' in the data stream will result in incorrect behavior
  */
 
-//IF-IF-IF
 //WHILE
 void
@@ -908,5 +846,5 @@
     ReadMessage(shellSocketFD, buffer);
     LOG("ServiceManagementLayer:: Received PerformActiveMission command.\n");
-
+    //TODO this whole section needs to be reworked depending on how relevent data is actually transmitted from the app to the shell to the SML
     int32_t t = atoi(buffer);
     /* Receive Set of Observables */
@@ -957,5 +895,5 @@
 
 
-
+    //Receive any other defined inputs
     while(i < 5 && !miss[activeMission].input[i].empty()){
 	    //New data being added to DB
@@ -1054,4 +992,5 @@
 		    token = strtok(NULL, "@");
 		    //printf("data=%s\n", token);
+		data.clear();
 		    break;
 		}
@@ -1059,5 +998,41 @@
 	    //printf("L0:--- %s  %s---\n", miss[activeMission].services[i].output[t].c_str(), token);
 	    //TODO change to strstr
-	    if(strstr(miss[activeMission].services[i].output[t].c_str(), token)){
+
+	    bool doit = false;
+	    if(miss[activeMission].services[i].output[t].find(">") != string::npos){
+		//printf("foundit!\n");
+		    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, " where Tag==");
+		    miss[activeMission].services[i].output[t].erase(0, 1);
+	    //printf("here! %s\n", miss[activeMission].services[i].output[t].c_str());
+		    sprintf(_data_DB->command, "%s'%s';", _data_DB->command, miss[activeMission].services[i].output[t].c_str());
+		    sqlite3_stmt * pStatement;
+		    rc = sqlite3_prepare_v2(_data_DB->db, _data_DB->command, -1, &pStatement, NULL);
+		    if (rc == SQLITE_OK){ 
+			if (sqlite3_step(pStatement) == SQLITE_ROW)
+			     data = (const char *) sqlite3_column_text(pStatement, 1); 
+			else {
+				printf("1 data_DB:: Data not yet in DB.\n");
+				rc=31337;
+			}
+		    } else {
+			printf("data_DB:: Error executing SQL statement. rc = %i\n%s\n",rc,_data_DB->command);
+		    }
+		   	    sqlite3_finalize(pStatement);
+		    token = strtok((char *)data.c_str(), "@");
+		    token = strtok(NULL, "@");
+		    token = strtok(NULL, "@");
+		    if(atof(buffer) > atof(token))
+			doit=true;
+		    //printf("%s %s\n", buffer, token);
+		data.clear();
+	    }
+	    else if (strstr(miss[activeMission].services[i].output[t].c_str(), token))
+    	        doit=true;
+	    if(doit){
+	    //if(strstr(miss[activeMission].services[i].output[t].c_str(), token)){
 		//printf("L0:if taken\n");
 		for(uint16_t k = i+1; k <= i+miss[activeMission].services[i].num_conds; k++){ 
@@ -1096,4 +1071,5 @@
 				    token = strtok(NULL, "@");
 				    //printf("data=%s\n", token);
+				    data.clear();
 				    break;
 				}
@@ -1101,5 +1077,37 @@
 			    //printf("L1:--- %s  %s---\n", miss[activeMission].services[k].output[t].c_str(), token);
 			    //TODO change to strstr
-			    if(strstr(miss[activeMission].services[k].output[t].c_str(), token)){
+			    bool doit = false;
+				//printf("here! %s\n", miss[activeMission].services[k].output[t].c_str());
+			    if(miss[activeMission].services[k].output[t].find(">") != string::npos){
+				    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, " where Tag==");
+				    miss[activeMission].services[k].output[t].erase(0, 1);
+				    sprintf(_data_DB->command, "%s'%s';", _data_DB->command, miss[activeMission].services[k].output[t].c_str());
+				    sqlite3_stmt * pStatement;
+				    rc = sqlite3_prepare_v2(_data_DB->db, _data_DB->command, -1, &pStatement, NULL);
+				    if (rc == SQLITE_OK){ 
+					if (sqlite3_step(pStatement) == SQLITE_ROW)
+					     data = (const char *) sqlite3_column_text(pStatement, 1); 
+					else {
+						printf("1 data_DB:: Data not yet in DB.\n");
+						rc=31337;
+					}
+				    } else {
+					printf("data_DB:: Error executing SQL statement. rc = %i\n%s\n",rc,_data_DB->command);
+				    }
+			    	    sqlite3_finalize(pStatement);
+				    token = strtok((char *)data.c_str(), "@");
+				    token = strtok(NULL, "@");
+				    token = strtok(NULL, "@");
+			        if(atof(buffer) > atof(token))
+				    doit=true;
+				data.clear();
+			    }
+			    else if (strstr(miss[activeMission].services[k].output[t].c_str(), token))
+				doit=true;
+			    if(doit){
 				//printf("L1:if taken\n");
 				for(uint16_t j = k+1; j <= k+miss[activeMission].services[k].num_conds; j++){ 
@@ -1138,4 +1146,5 @@
 						    token = strtok(NULL, "@");
 						    //printf("data=%s\n", token);
+						    data.clear();
 						    break;
 						}
@@ -1143,5 +1152,37 @@
 					    //printf("L2:--- %s  %s---\n", miss[activeMission].services[j].output[t].c_str(), token);
 					    //TODO change to strstr
-					    if(strstr(miss[activeMission].services[j].output[t].c_str(), token)){
+					    bool doit = false;
+						//printf("here! %s\n", miss[activeMission].services[j].output[t].c_str());
+					    if(miss[activeMission].services[j].output[t].find(">") != string::npos){
+						    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, " where Tag==");
+						    miss[activeMission].services[k].output[t].erase(0, 1);
+					sprintf(_data_DB->command, "%s'%s';", _data_DB->command, miss[activeMission].services[j].output[t].c_str());
+						    sqlite3_stmt * pStatement;
+						    rc = sqlite3_prepare_v2(_data_DB->db, _data_DB->command, -1, &pStatement, NULL);
+						    if (rc == SQLITE_OK){ 
+							if (sqlite3_step(pStatement) == SQLITE_ROW)
+							     data = (const char *) sqlite3_column_text(pStatement, 1); 
+							else {
+								printf("1 data_DB:: Data not yet in DB.\n");
+								rc=31337;
+							}
+						    } else {
+							printf("data_DB:: Error executing SQL statement. rc = %i\n%s\n",rc,_data_DB->command);
+						    }
+					    	    sqlite3_finalize(pStatement);
+						    token = strtok((char *)data.c_str(), "@");
+						    token = strtok(NULL, "@");
+						    token = strtok(NULL, "@");
+						if(atof(buffer) > atof(token))
+						    doit=true;
+						data.clear();
+					    }
+					    else if (strstr(miss[activeMission].services[k].output[t].c_str(), token))
+						doit=true;
+					    if(doit){
 						//printf("L1:if taken\n");
 						for(uint16_t l = j+1; l <= j+miss[activeMission].services[j].num_conds; l++){ 
@@ -1155,4 +1196,59 @@
 						j+=miss[activeMission].services[j].num_conds;
 					    //printf("doneif %d, %d, %d\n", numstatements, miss[activeMission].services[i].num_conds, i);
+					}else if(miss[activeMission].services[j].name.compare("dowhile")==0){
+					    numstatements[0]=0;
+					    printf("L2 while detected\n");
+					    while(true){
+						uint16_t l;
+						    for(l = j+1; l <= j+miss[activeMission].services[j].num_conds; l++){ 
+							TransactData(l);
+							printf("l=%d\n", l);
+						    }
+						    data.clear();
+						    //printf("L0:while detected %d, %d\n", k, miss[activeMission].services[i].num_conds);
+						    input.clear();
+						    check.clear();
+						    int t;
+						    for(t = 0; t < 5; t++){
+							if(!miss[activeMission].services[j].output[t].empty()){
+							    input=miss[activeMission].services[l-2].output[t];
+							    //printf("input=%s\n", input.c_str());
+							    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, " where Tag==");
+							    sprintf(_data_DB->command, "%s'%s';", _data_DB->command, input.c_str());
+							    sqlite3_stmt * pStatement;
+							    rc = sqlite3_prepare_v2(_data_DB->db, _data_DB->command, -1, &pStatement, NULL);
+							    if (rc == SQLITE_OK){ 
+								if (sqlite3_step(pStatement) == SQLITE_ROW)
+								     data = (const char *) sqlite3_column_text(pStatement, 1); 
+								else {
+									printf("1 data_DB:: Data not yet in DB.\n");
+									rc=31337;
+								}
+							    } else {
+								printf("data_DB:: Error executing SQL statement. rc = %i\n%s\n",rc,_data_DB->command);
+							    }
+						    	    sqlite3_finalize(pStatement);
+							    //printf("data=%s\n", data.c_str());
+							    token = strtok((char *)data.c_str(), "@");
+							    token = strtok(NULL, "@");
+							    token = strtok(NULL, "@");
+							    //printf("data=%s\n", token);
+							    break;
+							}
+						    }
+						    //printf("L2:--- %s  %s---\n", miss[activeMission].services[j].output[t].c_str(), token);
+						    if(strstr(miss[activeMission].services[j].output[t].c_str(), token)){
+							//printf("L2:while taken again!\n");
+						    }
+						    else {
+							//printf("no more while\n");
+							break;}
+					    }
+					    j+=miss[activeMission].services[j].num_conds;
+					    //printf("doneif\n");
 					}
 					else{
@@ -1168,20 +1264,21 @@
 			        k+=miss[activeMission].services[k].num_conds;
 			    //printf("doneif %d, %d, %d\n", numstatements, miss[activeMission].services[i].num_conds, i);
-			} else if(miss[activeMission].services[k].name.compare("dowhile")==0){
-			    //printf("while detected\n");
+			}else if(miss[activeMission].services[k].name.compare("dowhile")==0){
+			    numstatements[0]=0;
+			    //printf("L1 while detected\n");
 			    while(true){
-				uint16_t m;
-				for(uint16_t m = k+1; m <= k+miss[activeMission].services[k].num_conds; m++){ 
-				    TransactData(m);
-				    printf("transact! %d\n", m);
-				}
+				uint16_t j;
+				    for(j = k+1; j <= k+miss[activeMission].services[k].num_conds; j++){ 
+					TransactData(j);
+				    }
 				    data.clear();
-				    printf("L1:while detected %d, %d\n", miss[activeMission].services[k].num_conds, k);
+				    //printf("L0:while detected %d, %d\n", k, miss[activeMission].services[i].num_conds);
 				    input.clear();
 				    check.clear();
 				    int t;
 				    for(t = 0; t < 5; t++){
-					if(!miss[activeMission].services[k-1].output[t].empty()){
-					    input=miss[activeMission].services[m].output[t];
+					if(!miss[activeMission].services[k].output[t].empty()){
+					    input=miss[activeMission].services[j-2].output[t];
+					    //printf("input=%s\n", input.c_str());
 					    strcpy(_data_DB->command, "SELECT ");
 					    strcat(_data_DB->command, _data_DB->tablename);
@@ -1203,5 +1300,5 @@
 					    }
 				    	    sqlite3_finalize(pStatement);
-					    //printf("data=%s\n", data.c_str());
+					   // printf("data=%s\n", data.c_str());
 					    token = strtok((char *)data.c_str(), "@");
 					    token = strtok(NULL, "@");
@@ -1211,13 +1308,14 @@
 					}
 				    }
-				    printf("L1:--- %s  %s---\n", miss[activeMission].services[k].output[t].c_str(), token);
+				    //printf("L1:--- %s  %s---\n", miss[activeMission].services[k].output[t].c_str(), token);
 				    if(strstr(miss[activeMission].services[k].output[t].c_str(), token)){
-					printf("L1:do it again!\n");
+					//printf("L1:while taken again!\n");
 				    }
-				    else
-					break;
+				    else {
+					//printf("no more while\n");
+					break;}
 			    }
 			    k+=miss[activeMission].services[k].num_conds;
-			    //printf("donewhile\n");
+			    //printf("doneif\n");
 			}
 			else{
@@ -1241,5 +1339,5 @@
 	{
 	    numstatements[0]=0;
-	    //printf("while detected\n");
+	    //printf("L0 while detected\n");
 	    while(true){
 		uint16_t k;
@@ -1254,5 +1352,5 @@
 		    for(t = 0; t < 5; t++){
 			if(!miss[activeMission].services[i].output[t].empty()){
-			    input=miss[activeMission].services[k-1].output[t];
+			    input=miss[activeMission].services[k-2].output[t];
 			    //printf("input=%s\n", input.c_str());
 			    strcpy(_data_DB->command, "SELECT ");
@@ -1287,6 +1385,7 @@
 			//printf("L0:while taken again!\n");
 		    }
-		    else
-			break;
+		    else {
+			//printf("no more while\n");
+			break;}
 	    }
 	    i+=miss[activeMission].services[i].num_conds;
@@ -1317,5 +1416,5 @@
 	         data.append((const char*) sqlite3_column_text(pStatement, 1)); 
             else {
-	            printf("data_DB:: Data not yet in DB.\n");
+	            printf("1data_DB:: Data not yet in DB.\n");
 		    rc=31337;
 	    }
@@ -1341,6 +1440,6 @@
         data.clear();
     }
-    LOG("ServiceManagementLayer:: Done sending output data to shell from PerformActiveMission.\n");
-    /*strcpy(_data_DB->command, "select ");
+    /*LOG("ServiceManagementLayer:: Done sending output data to shell from PerformActiveMission.\n");
+    strcpy(_data_DB->command, "select ");
     strcat(_data_DB->command, _data_DB->tablename);
     strcat(_data_DB->command, ".* from ");
@@ -1394,5 +1493,5 @@
     miss = new Mission[10];
     for(int i = 0; i < 10; i++)
-    	miss[i].services = new Service[20];
+    	miss[i].services = new Service[30];
     LoadConfiguration(_SML_Config, miss);
 }
@@ -1444,5 +1543,5 @@
 	//memset(cond_array, 0, 2);
 	
-    	for(pChild1  = pChild0->FirstChildElement(); pChild1; \
+    	for(pChild1  = (pChild0->FirstChildElement())->FirstChildElement(); pChild1; \
       	    pChild1  = pChild1->NextSiblingElement()) 
     	{
@@ -1487,4 +1586,6 @@
 		            if(pChild4->Attribute("output5"))
 				mList[mission_num].services[service_num].output[4] = pChild4->Attribute("output5");
+			    if(pChild4->Attribute("parameter"))
+				mList[mission_num].services[service_num].paramater = pChild4->Attribute("parameter");
 			    cond_array[2]++;
 			}
@@ -1515,4 +1616,6 @@
 		            if(pChild3->Attribute("output5"))
 				mList[mission_num].services[conditional_2].output[4] = pChild3->Attribute("output5");
+			    if(pChild3->Attribute("parameter"))
+				mList[mission_num].services[conditional_2].paramater = pChild3->Attribute("parameter");
 			mList[mission_num].services[conditional_2].num_conds = cond_array[2];
 			cond_array[1]+=cond_array[2]+1;
@@ -1548,4 +1651,6 @@
                     if(pChild2->Attribute("output5"))
 			mList[mission_num].services[conditional_1].output[4] = pChild2->Attribute("output5");
+		    if(pChild2->Attribute("parameter"))
+			mList[mission_num].services[conditional_1].paramater = pChild2->Attribute("parameter");
 
 		mList[mission_num].services[conditional_1].num_conds = cond_array[1];
@@ -1581,5 +1686,7 @@
 		    mList[mission_num].services[conditional_0].output[3] = pChild1->Attribute("output4");
                 if(pChild1->Attribute("output5"))
-		    mList[mission_num].services[service_num].output[4] = pChild1->Attribute("output4");
+		    mList[mission_num].services[conditional_0].output[4] = pChild1->Attribute("output5");
+		if(pChild1->Attribute("parameter"))
+		    mList[mission_num].services[conditional_0].paramater = pChild1->Attribute("parameter");
 	    mList[mission_num].services[conditional_0].num_conds = cond_array[0];
             cond_array[0] = 0;
@@ -1587,5 +1694,5 @@
 	}
 	//for(int i = 0; i < service_num; i++)
-	 //printf("ttt%d\n", mList[mission_num].services[i].num_conds);
+	// printf("ttt%s\n",mList[mission_num].services[i].name.c_str());
 	
 	mList[mission_num].numServices = service_num;
