Index: /vtcross/trunk/src/service_management_layer/ServiceManagementLayer.cpp
===================================================================
--- /vtcross/trunk/src/service_management_layer/ServiceManagementLayer.cpp	(revision 288)
+++ /vtcross/trunk/src/service_management_layer/ServiceManagementLayer.cpp	(revision 289)
@@ -678,4 +678,5 @@
 	            data.append((const char*) sqlite3_column_text(pStatement, 1)); 
                 else {
+		    //TODO could do shell output here if not in DB
 	            printf("data_DB:: Data not yet in DB.\n");
 		    rc=31337;
@@ -910,4 +911,5 @@
     char buffer[256];
     char buffer1[256];
+    char *token;
     int rc;
     char *errorMsg;
@@ -918,7 +920,7 @@
     LOG("ServiceManagementLayer:: Received PerformActiveMission command.\n");
 
-    int t = atoi(buffer);
+    int32_t t = atoi(buffer);
    // printf("****%d****\n", t);
-    for(int k = 0; k < t; k++) {
+    for(int32_t m = 0; m < t; m++) {
 	//printf("data=%s\n", data_obsv.c_str());
         memset(buffer1, 0, 256);
@@ -1001,4 +1003,5 @@
    // printf("done\n");
     i=0;
+    int32_t numstatements = 0;
     data.clear();
     while(i < miss[activeMission].numServices)
@@ -1006,64 +1009,69 @@
 	if(miss[activeMission].services[i].name.compare("if")==0)
 	{
-	   // printf("L0:if detected\n");
+	   //printf("L0:if detected\n");
 	    input.clear();
 	    check.clear();
-	    if(!miss[activeMission].services[i].input[0].empty()){
-		input=miss[activeMission].services[i].input[0];
-		check = "1@true@";
+	    int t;
+	    for(t = 0; t < 5; t++){
+		if(!miss[activeMission].services[i].output[t].empty()){
+		    //printf("i-numstmts = %d\n", i-numstatements-1);
+		    input=miss[activeMission].services[i-numstatements-1].output[t];
+		    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;
+		}
 	    }
-	    else{
-		input=miss[activeMission].services[i].input[1];
-		check = "1@false@";
+	    //printf("L0:--- %s  %s---\n", miss[activeMission].services[i].output[t].c_str(), token);
+	    if(!miss[activeMission].services[i].output[t].compare(token)){
+		//printf("L0:if taken\n");
+		for(uint16_t k = i+1; k <= i+miss[activeMission].services[i].num_conds; k++){ 
+		    //printf("transacting data for k=%d\n", k);
+		    TransactData(k);
+		}
 	    }
-            //printf("L0: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. %d\n", i);
-		        rc=31337;
-	        }
-            } else {
-	        printf("data_DB:: Error executing SQL statement. rc = %i\n%s\n",rc,_data_DB->command);
-            }
-
-    	    sqlite3_finalize(pStatement);
-	   // printf("L0:data=%s, check=%s\n", data.c_str(), check.c_str());
-	   // printf("L0:--- %d  %d---\n", miss[activeMission].services[i].num_conds, i);
-	    if(data.compare(check)==0){
-		//printf("L0:if taken\n");
-		
-		for(int k = i + 1; k <= i + miss[activeMission].services[i].num_conds; k++){
-			//printf("k=%d\n", k);
-			if(miss[activeMission].services[k].name.compare("if")==0)
-			{
-			    //printf("L1:if detected\n");
-			    input.clear();
-			    check.clear();
-			    if(!miss[activeMission].services[k].input[0].empty()){
-				input=miss[activeMission].services[k].input[0];
-				check = "1@true@";
-			    }
-			    else{
-				input=miss[activeMission].services[k].input[1];
-				check = "1@false@";
-			    }
-			    //printf("input=%s\n", input.c_str());
-
+            numstatements +=miss[activeMission].services[i].num_conds+1;
+	    i+=miss[activeMission].services[i].num_conds;
+	    //printf("doneif %d, %d, %d\n", numstatements, miss[activeMission].services[i].num_conds, i);
+	}
+	else if(miss[activeMission].services[i].name.compare("while")==0)
+	{
+	    numstatements=0;
+	    //printf("while detected\n");
+	    while(true){
+		    data.clear();
+		    printf("L0:if detected\n");
+		    input.clear();
+		    check.clear();
+		    int t;
+		    for(t = 0; t < 5; t++){
+			if(!miss[activeMission].services[i].output[t].empty()){
+			    input=miss[activeMission].services[i-1].output[t];
 			    strcpy(_data_DB->command, "SELECT ");
-		   	    strcat(_data_DB->command, _data_DB->tablename);
+			    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==");
+			    strcat(_data_DB->command, " where Tag==");
 			    sprintf(_data_DB->command, "%s'%s';", _data_DB->command, input.c_str());
 			    sqlite3_stmt * pStatement;
@@ -1073,5 +1081,5 @@
 				     data = (const char *) sqlite3_column_text(pStatement, 1); 
 				else {
-					printf("1 data_DB:: Data not yet in DB. %d\n", k);
+					printf("1 data_DB:: Data not yet in DB.\n");
 					rc=31337;
 				}
@@ -1079,228 +1087,29 @@
 				printf("data_DB:: Error executing SQL statement. rc = %i\n%s\n",rc,_data_DB->command);
 			    }
-
 		    	    sqlite3_finalize(pStatement);
-			    //printf("L1:data=%s, check=%s\n", data.c_str(), check.c_str());
-			    //printf("L1:--- %d  %d---\n", miss[activeMission].services[i].num_conds, k);
-			    if(data.compare(check)==0){
-				//printf("L1:if taken\n");
-				for(int j = k + 1; j <= k + miss[activeMission].services[k].num_conds; j++){
-				   // printf("j=%d\n", k);
-				    //printf("name!!!! = %s\n", miss[activeMission].services[j].name.c_str());
-				    if(miss[activeMission].services[j].name.compare("if")==0)
-				    {
-					   // printf("L2:if detected\n");
-					    input.clear();
-					    check.clear();
-					    if(!miss[activeMission].services[j].input[0].empty()){
-						input=miss[activeMission].services[j].input[0];
-						check = "1@true@";
-					    }
-					    else{
-						input=miss[activeMission].services[j].input[1];
-						check = "1@false@";
-					    }
-					    //printf("L2: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. %d\n", k);
-							rc=31337;
-						}
-					    } else {
-						printf("data_DB:: Error executing SQL statement. rc = %i\n%s\n",rc,_data_DB->command);
-					    }
-
-				    	    sqlite3_finalize(pStatement);
-					   // printf("L2:data=%s, check=%s\n", data.c_str(), check.c_str());
-					   // printf("L2:--- %d  %d---\n", miss[activeMission].services[i].num_conds, k);
-					    if(data.compare(check)==0){
-						//printf("L2:if taken\n");
-						for(int p = j + 1; p <= j + miss[activeMission].services[j].num_conds; p++)
-						    TransactData(p);
-					    }
-					    else{
-						//printf("L2:if not taken %d\n", miss[activeMission].services[j].num_conds);
-					    }
-				   	j+=miss[activeMission].services[j].num_conds;
-				    }
-
-				    else if(miss[activeMission].services[j].name.compare("while")==0)
-				    {
-			    		//printf("while detected\n");
-					while(true){
-					    data.clear();
-					    input.clear();
-					    check.clear();
-					    if(!miss[activeMission].services[j].input[0].empty()){
-						input=miss[activeMission].services[j].input[0];
-						check = "1@true@";
-					    }
-					    else{
-						input=miss[activeMission].services[j].input[1];
-						check = "1@false@";
-					    }
-					    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. %d\n", i);
-					    } 
-					    else {
-						printf("data_DB:: Error executing SQL statement. rc = %i\n%s\n",rc,_data_DB->command);
-					    }
-
-				    	    sqlite3_finalize(pStatement);
-					    printf("data=%s, check=%s\n", data.c_str(), check.c_str());
-					    if(data.compare(check)==0){
-						printf("while taken\n");
-						for(int p = j + 1; p <= j + miss[activeMission].services[j].num_conds; p++)
-						    TransactData(p);
-					    }
-					    else{
-						printf("while not taken %d\n", miss[activeMission].services[k].num_conds);
-				   		 j+=miss[activeMission].services[j].num_conds;
-						break;
-					    }
-					}
-				    }
-				    else{
-					printf("L2: nocond transact\n");
-				  	TransactData(j);}
-				    j++;
-				}
-			    }
-			    else{
-				//printf("if not taken %d\n", miss[activeMission].services[k].num_conds);
-			    }
-			    k+=miss[activeMission].services[k].num_conds;
+			    //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;
 			}
-			else if(miss[activeMission].services[k].name.compare("while")==0)
-			{
-			    //printf("while detected\n");
-			    while(true){
-				    data.clear();
-				    input.clear();
-				    check.clear();
-				    if(!miss[activeMission].services[k].input[0].empty()){
-					input=miss[activeMission].services[k].input[0];
-					check = "1@true@";
-				    }
-				    else{
-					input=miss[activeMission].services[k].input[1];
-					check = "1@false@";
-				    }
-				    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. %d\n", i);
-				    } 
-				    else {
-					printf("data_DB:: Error executing SQL statement. rc = %i\n%s\n",rc,_data_DB->command);
-				    }
-
-			    	    sqlite3_finalize(pStatement);
-				    printf("data=%s, check=%s\n", data.c_str(), check.c_str());
-				    if(data.compare(check)==0){
-					printf("while taken\n");
-					for(int k = i + 1; k <= i + miss[activeMission].services[i].num_conds; k++)
-					    TransactData(k);
-				    }
-				    else{
-					printf("while not taken %d\n", miss[activeMission].services[k].num_conds);
-				        k+=miss[activeMission].services[k].num_conds;
-					break;
-				    }
-			    }
+		    }
+		    printf("L0:--- %s  %s---\n", miss[activeMission].services[i].output[t].c_str(), token);
+		    if(!miss[activeMission].services[i].output[t].compare(token)){
+			printf("L0:if taken\n");
+			for(uint16_t k = i+i; k <= i+miss[activeMission].services[i].num_conds; k++){ 
+			    TransactData(k);
 			}
-			else{
-			    //printf("L1: nocond transact\n");
-			    TransactData(k);}
-			k++;
-		}
+		    }
+		    else
+			break;
 	    }
-	    else{
-		printf("La2 if not taken %d\n", miss[activeMission].services[i].num_conds);
-	    }
-	    //printf("i=%d\n", i);
 	    i+=miss[activeMission].services[i].num_conds;
-	    //printf("i=%d\n", i);
-	}
-	else if(miss[activeMission].services[i].name.compare("while")==0)
-	{
-	    //printf("while detected\n");
-	    while(true){
-		    data.clear();
-	            input.clear();
-	            check.clear();
-		    if(!miss[activeMission].services[i].input[0].empty()){
-			input=miss[activeMission].services[i].input[0];
-			check = "1@true@";
-		    }
-		    else{
-			input=miss[activeMission].services[i].input[1];
-			check = "1@false@";
-		    }
-		    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. %d\n", i);
-		    } 
-		    else {
-			printf("data_DB:: Error executing SQL statement. rc = %i\n%s\n",rc,_data_DB->command);
-		    }
-
-	    	    sqlite3_finalize(pStatement);
-		    //printf("data=%s, check=%s\n", data.c_str(), check.c_str());
-		    if(data.compare(check)==0){
-			printf("while taken\n");
-			for(int k = i + 1; k <= i + miss[activeMission].services[i].num_conds; k++)
-			    TransactData(k);
-		    }
-		    else{
-			printf("while not taken %d\n", miss[activeMission].services[i].num_conds);
-			i+=miss[activeMission].services[i].num_conds;
-			break;
-		    }
-	    }
+	    //printf("doneif\n");
 	}
 	else{
-	   // printf("L0 nocond transact\n");
+	    numstatements=0;
+	    //printf("L0 Neither if nor while\n");
 	    TransactData(i);}
 	i++;
@@ -1481,39 +1290,30 @@
 			    cond_array[2]++;
 			}
-			if(!strcmp(pChild3->Value(), "shell")) {
+			if(!strcmp(pChild3->Value(), "shell") || conditional_2 != service_num) {
 			    mList[mission_num].services[conditional_2].name = pChild3->Value();
-			    mList[mission_num].services[conditional_2].output[0] = pChild3->Attribute("output1");
-		//printf("2shell detected\n");
-			}
-			else if(conditional_2 != service_num){
-			    mList[mission_num].services[conditional_2].name = pChild3->Value();
-		            if(pChild3->Attribute("input_t"))
-				mList[mission_num].services[conditional_2].input[0] = pChild3->Attribute("input_t");
-		            if(pChild3->Attribute("input_f"))
-				mList[mission_num].services[conditional_2].input[1] = pChild3->Attribute("input_f");
 			}
 			else{
 			    mList[mission_num].services[service_num].name = pChild3->Attribute("name");
+			}
 		            if(pChild3->Attribute("input1"))
-				mList[mission_num].services[service_num].input[0] = pChild3->Attribute("input1");
+				mList[mission_num].services[conditional_2].input[0] = pChild3->Attribute("input1");
 		            if(pChild3->Attribute("input2"))
-				mList[mission_num].services[service_num].input[1] = pChild3->Attribute("input2");
+				mList[mission_num].services[conditional_2].input[1] = pChild3->Attribute("input2");
 		            if(pChild3->Attribute("input3"))
-				mList[mission_num].services[service_num].input[2] = pChild3->Attribute("input3");
+				mList[mission_num].services[conditional_2].input[2] = pChild3->Attribute("input3");
 		            if(pChild3->Attribute("input4"))
-				mList[mission_num].services[service_num].input[3] = pChild3->Attribute("input4");
+				mList[mission_num].services[conditional_2].input[3] = pChild3->Attribute("input4");
 		            if(pChild3->Attribute("input5"))
-				mList[mission_num].services[service_num].input[4] = pChild3->Attribute("input5");
+				mList[mission_num].services[conditional_2].input[4] = pChild3->Attribute("input5");
 		            if(pChild3->Attribute("output1"))
-				mList[mission_num].services[service_num].output[0] = pChild3->Attribute("output1");
+				mList[mission_num].services[conditional_2].output[0] = pChild3->Attribute("output1");
 		            if(pChild3->Attribute("output2"))
-				mList[mission_num].services[service_num].output[1] = pChild3->Attribute("output2");
+				mList[mission_num].services[conditional_2].output[1] = pChild3->Attribute("output2");
 		            if(pChild3->Attribute("output3"))
-				mList[mission_num].services[service_num].output[2] = pChild3->Attribute("output3");
+				mList[mission_num].services[conditional_2].output[2] = pChild3->Attribute("output3");
 			    if(pChild3->Attribute("output4"))
-				mList[mission_num].services[service_num].output[3] = pChild3->Attribute("output4");
+				mList[mission_num].services[conditional_2].output[3] = pChild3->Attribute("output4");
 		            if(pChild3->Attribute("output5"))
-				mList[mission_num].services[service_num].output[4] = pChild3->Attribute("output5");
-			}
+				mList[mission_num].services[conditional_2].output[4] = pChild3->Attribute("output5");
 			mList[mission_num].services[conditional_2].num_conds = cond_array[2];
 			cond_array[1]+=cond_array[2]+1;
@@ -1524,39 +1324,31 @@
 		}
 		//printf("here\n");
-		if(!strcmp(pChild2->Value(), "shell")) {
+		if(!strcmp(pChild2->Value(), "shell") || conditional_1 != service_num) {
 		    mList[mission_num].services[conditional_1].name = pChild2->Value();
-		    mList[mission_num].services[conditional_1].output[0] = pChild2->Attribute("output1");
-		//printf("1shell detected\n");
-		}
-		else if(conditional_1 != service_num){
-		    mList[mission_num].services[conditional_1].name = pChild2->Value();
-                    if(pChild2->Attribute("input_t"))
-			mList[mission_num].services[conditional_1].input[0] = pChild2->Attribute("input_t");
-                    if(pChild2->Attribute("input_f"))
-			mList[mission_num].services[conditional_1].input[1] = pChild2->Attribute("input_f");
 		}
 		else{
 		    mList[mission_num].services[service_num].name = pChild2->Attribute("name");
-                    if(pChild2->Attribute("input1"))
-			mList[mission_num].services[service_num].input[0] = pChild2->Attribute("input1");
-                    if(pChild2->Attribute("input2"))
-			mList[mission_num].services[service_num].input[1] = pChild2->Attribute("input2");
+		}
+                if(pChild2->Attribute("input1"))
+		    mList[mission_num].services[conditional_1].input[0] = pChild2->Attribute("input1");
+                if(pChild2->Attribute("input2"))
+		    mList[mission_num].services[conditional_1].input[1] = pChild2->Attribute("input2");
                     if(pChild2->Attribute("input3"))
-			mList[mission_num].services[service_num].input[2] = pChild2->Attribute("input3");
+			mList[mission_num].services[conditional_1].input[2] = pChild2->Attribute("input3");
                     if(pChild2->Attribute("input4"))
-			mList[mission_num].services[service_num].input[3] = pChild2->Attribute("input4");
+			mList[mission_num].services[conditional_1].input[3] = pChild2->Attribute("input4");
                     if(pChild2->Attribute("input5"))
-			mList[mission_num].services[service_num].input[4] = pChild2->Attribute("input5");
+			mList[mission_num].services[conditional_1].input[4] = pChild2->Attribute("input5");
                     if(pChild2->Attribute("output1"))
-			mList[mission_num].services[service_num].output[0] = pChild2->Attribute("output1");
+			mList[mission_num].services[conditional_1].output[0] = pChild2->Attribute("output1");
                     if(pChild2->Attribute("output2"))
-			mList[mission_num].services[service_num].output[1] = pChild2->Attribute("output2");
+			mList[mission_num].services[conditional_1].output[1] = pChild2->Attribute("output2");
                     if(pChild2->Attribute("output3"))
-			mList[mission_num].services[service_num].output[2] = pChild2->Attribute("output3");
+			mList[mission_num].services[conditional_1].output[2] = pChild2->Attribute("output3");
 		    if(pChild2->Attribute("output4"))
-			mList[mission_num].services[service_num].output[3] = pChild2->Attribute("output4");
+			mList[mission_num].services[conditional_1].output[3] = pChild2->Attribute("output4");
                     if(pChild2->Attribute("output5"))
-			mList[mission_num].services[service_num].output[4] = pChild2->Attribute("output5");
-		}
+			mList[mission_num].services[conditional_1].output[4] = pChild2->Attribute("output5");
+	    //printf("2%s %s\n", mList[mission_num].services[conditional_1].output[0].c_str(), mList[mission_num].services[conditional_1].output[1].c_str());
 
 		mList[mission_num].services[conditional_1].num_conds = cond_array[1];
@@ -1566,42 +1358,32 @@
 	    }
 	    
-	    if(!strcmp(pChild1->Value(), "shell")) {
-		//printf("shell detected\n");
+	    if(!strcmp(pChild1->Value(), "shell") || conditional_0 != service_num) {
 	        mList[mission_num].services[conditional_0].name = pChild1->Value();
-	        mList[mission_num].services[conditional_0].output[0] = pChild1->Attribute("output1");
-	    }
-	    else if(conditional_0 != service_num){
-		mList[mission_num].services[conditional_0].name = pChild1->Value();
-                    if(pChild1->Attribute("input_t"))
-			mList[mission_num].services[conditional_0].input[0] = pChild1->Attribute("input_t");
-                    if(pChild1->Attribute("input_f"))
-			mList[mission_num].services[conditional_0].input[1] = pChild1->Attribute("input_f");
-		//printf("---input_t=%s\n", mList[mission_num].services[conditional_0].input[0].c_str());
 	    }
 	    else{
 		mList[mission_num].services[conditional_0].name = pChild1->Attribute("name");
+	    }
 		//printf("name=%s\n", mList[mission_num].services[conditional_0].name.c_str());
                 if(pChild1->Attribute("input1"))
-	            mList[mission_num].services[service_num].input[0] = pChild1->Attribute("input1");
+	            mList[mission_num].services[conditional_0].input[0] = pChild1->Attribute("input1");
                 if(pChild1->Attribute("input2"))
-		    mList[mission_num].services[service_num].input[1] = pChild1->Attribute("input2");
+		    mList[mission_num].services[conditional_0].input[1] = pChild1->Attribute("input2");
                 if(pChild1->Attribute("input3"))
-		    mList[mission_num].services[service_num].input[2] = pChild1->Attribute("input3");
+		    mList[mission_num].services[conditional_0].input[2] = pChild1->Attribute("input3");
                 if(pChild1->Attribute("input4"))
-		    mList[mission_num].services[service_num].input[3] = pChild1->Attribute("input4");
+		    mList[mission_num].services[conditional_0].input[3] = pChild1->Attribute("input4");
                 if(pChild1->Attribute("input5"))
-		    mList[mission_num].services[service_num].input[4] = pChild1->Attribute("input5");
+		    mList[mission_num].services[conditional_0].input[4] = pChild1->Attribute("input5");
                 if(pChild1->Attribute("output1"))
-		    mList[mission_num].services[service_num].output[0] = pChild1->Attribute("output1");
+		    mList[mission_num].services[conditional_0].output[0] = pChild1->Attribute("output1");
                 if(pChild1->Attribute("output2"))
-		    mList[mission_num].services[service_num].output[1] = pChild1->Attribute("output2");
+		    mList[mission_num].services[conditional_0].output[1] = pChild1->Attribute("output2");
                 if(pChild1->Attribute("output3"))
-		    mList[mission_num].services[service_num].output[2] = pChild1->Attribute("output3");
+		    mList[mission_num].services[conditional_0].output[2] = pChild1->Attribute("output3");
                 if(pChild1->Attribute("output4"))
-		    mList[mission_num].services[service_num].output[3] = pChild1->Attribute("output4");
+		    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");
-	    }
-
+	    //printf("1%s %s\n", mList[mission_num].services[conditional_0].output[0].c_str(), mList[mission_num].services[conditional_0].output[1].c_str());
 	    mList[mission_num].services[conditional_0].num_conds = cond_array[0];
             cond_array[0] = 0;
