Index: vtcross/branches/trnewman/CR_shell/src/main_cognitive_engine.cpp
===================================================================
--- vtcross/branches/trnewman/CR_shell/src/main_cognitive_engine.cpp	(revision 38)
+++ 	(revision )
@@ -1,310 +1,0 @@
-#include <iostream>
-#include "tinyxml.h"
-#include "tinystr.h"
-#include "socket/ServerSocket.h"
-#include "socket/SocketException.h"
-#include "socket/ClientSocket.h"
-
-using namespace std;
-
-#define SERVER_PORT 30000
-
-struct CE_Info {
-	int numUtilities;
-	int numParameters;
-	int numObservables;
-};
-
-
-
-struct Utility {
-	string name;
-	string units;
-	string goal;
-	float target;
-};
-struct Affect {
-	Utility * u;
-	string relation;
-};
-struct Parameter {
-	string name;
-	string units;
-	float min;
-	int numAffects;
-	Affect affection_list[10];
-	float max;
-	float step;
-};
-
-struct Observable {
-	string name;
-	Affect affection_list[10];
-	int numAffects;
-};
-
-void print_current_config(Utility * uList[], Parameter * pList[10], Observable * oList[], CE_Info * ce_info) {
-	int i = 0;
-	int j = 0;
-
-	for(i = 0; i < ce_info->numUtilities ; i++) {
-		cout << "Utility:  " << uList[i]->name << endl;
-		cout << "     Units:  " << uList[i]->units << endl;
-		cout << "     Goal:   " << uList[i]->goal << endl;
-		cout << "     Target: " << uList[i]->target << endl;
-	}
-
-
-	for(i = 0; i < ce_info->numParameters; i++) {
-		cout << "Parameter:  " << pList[i]->name << endl;
-		cout << "       Units:   " << pList[i]->units << endl;
-		cout << "       Min:     " << pList[i]->min << endl;
-		cout << "       Max:     " << pList[i]->max << endl;
-		cout << "       Step:    " << pList[i]->step << endl;
-		for(j = 0; j < pList[i]->numAffects; j++) {
-			cout << "       Affect: " << pList[i]->affection_list[j].u->name << " -> " << pList[i]->affection_list[j].relation << endl;
-		}
-	}
-	for(i = 0; i < ce_info->numObservables; i++) {
-		cout << "Observable:  " << oList[i]->name << endl;
-		for(j = 0; j < oList[i]->numAffects; j++) {
-			cout << "       Affect: " << oList[i]->affection_list[j].u->name << " -> " << oList[i]->affection_list[j].relation << endl;
-		}
-	}
-}
-
-
-int parse_ce_config( TiXmlDocument * doc , Utility * u[], Parameter * p[], Observable * o[], CE_Info * ce_info) {
-
-	TiXmlElement* pElem;	//!current element
-	TiXmlElement* pChild;	//!current child of pElem
-	TiXmlElement* pChild1;	//!current child of pElem
-	TiXmlElement* pSecondChild;	//!current child of pElem
-	TiXmlHandle hDoc(doc);	//!handle to xml document
-	TiXmlHandle hRoot(0); //! handle to root element 
-
-	int count = 0;
-	int i = 0;
-	int j = 0;
-	int k = 0;
-
-	pElem = hDoc.FirstChildElement().Element();
-	if(!pElem) { cout << "no valid root! quit-ing function!" << endl; return 0; }
-	hRoot = TiXmlHandle(pElem);
-
-	// Pull utility information from XML file.
-
-	pElem = hRoot.FirstChild("utilities").Element();
-	pChild1 = hRoot.Child("utilities",count).Element();
-
-
-	for(pChild = pChild1->FirstChildElement("utility"); pChild; pChild = pChild->NextSiblingElement())
-     	{
-		u[i] = new Utility;
-   		const char *uName = pChild->Attribute("name");
-   		if(uName) u[i]->name = uName;	
-		const char *uUnits = pChild->Attribute("units");
-   		if(uUnits) u[i]->units = uUnits;
-   		const char *uGoal = pChild->Attribute("goal");
-   		if(uGoal) u[i]->goal = uGoal;
-   		if(pChild->QueryFloatAttribute("target",&u[i]->target) != TIXML_SUCCESS) u[i]->target = -1;
-		i++;
-	}
-	ce_info->numUtilities = i;	
-	cout << "Parsed " << ce_info->numUtilities << " utilities." << endl;
-
-	// Pull observable information from XML file.
-	i = 0;
-	pElem = hRoot.FirstChild("observables").Element();
-	pChild1 = hRoot.Child("observables",count).Element();
-	
-	for(pChild = pChild1->FirstChildElement("observable"); pChild; pChild = pChild->NextSiblingElement())
-     	{
-
-   		const char *oName = pChild->Attribute("name");
-		o[i] = new Observable;
-
-   		if(oName) o[i]->name = oName;
-		
-		j = 0;
-		for(pSecondChild = pChild->FirstChildElement("affect"); pSecondChild; pSecondChild = pSecondChild->NextSiblingElement())
-		{
-   			const char *oUtilName = pSecondChild->Attribute("utility");
-
-   			// If a utility affects this parameter find the utility object and assign it
-			if(oUtilName) {
-				// Search for correct utility
-				for(k=0;k<10;k++){
-					if(u[k]->name == oUtilName) {
-						o[i]->affection_list[j].u = u[k];
-				 		break;
-					}
-				}
-			}
-			
-			// Set relationship
-			const char *oRelate = pSecondChild->Attribute("relationship");
-   			if(oRelate) o[i]->affection_list[j].relation = oRelate;
-			j++;
-		}
-		o[i]->numAffects = j; 
-		i++;
-	}
-	ce_info->numObservables = i;	
-	cout << "Parsed " << ce_info->numObservables << " observables." << endl;
-	
-
-	// Pull parameter information from XML file.
-	pElem = hRoot.FirstChild("parameters").Element();
-	pChild1 = hRoot.Child("parameters",count).Element();
-	
-	i = 0;
-	for(pChild = pChild1->FirstChildElement("parameter"); pChild; pChild = pChild->NextSiblingElement())
-     	{
-		p[i] = new Parameter;
-
-		const char *pName = pChild->Attribute("name");
-   		if(pName) p[i]->name = pName;	
-		const char *pUnits = pChild->Attribute("units");
-   		if(pUnits) p[i]->units = pUnits;
-
-   		if(pChild->QueryFloatAttribute("min",&p[i]->min) != TIXML_SUCCESS) p[i]->min = -1;
-   		if(pChild->QueryFloatAttribute("max",&p[i]->max) != TIXML_SUCCESS) p[i]->max = -1;
-   		if(pChild->QueryFloatAttribute("step",&p[i]->step) != TIXML_SUCCESS) p[i]->step = -1;
-		
-		j = 0;
-		for(pSecondChild = pChild->FirstChildElement("affect"); pSecondChild; pSecondChild = pSecondChild->NextSiblingElement())
-		{
-   			const char *pUtilName = pSecondChild->Attribute("utility");
-   			
-			// If a utility affects this parameter find the utility object and assign it
-			if(pUtilName) {
-				// Search for correct utility
-				for( k=0 ; u[k]!=NULL ; k++ ){
-					if(u[k]->name == pUtilName) {
-						p[i]->affection_list[j].u = u[k];	
-						break;
-					}
-				}
-			}
-			
-			// Set relationship
-			const char *pRelate = pSecondChild->Attribute("relationship");
-   			if(pRelate) {
-				p[i]->affection_list[j].relation = pRelate;
-			} else {
-				cout << "Error: No relation found." << endl;
-			}
-			j++;
-		
-		}
-		p[i]->numAffects = j; 
-		i++;
-
-	}
-	ce_info->numParameters = i;	
-	cout << "Parsed " << ce_info->numParameters << " parameters." << endl;
-	return 1;
-}
-
-
-int StartShell() {
-   // Start socket server
-
-
-   try
-   {
-      //Create the socket
-      ServerSocket server ( SERVER_PORT );
-      ServerSocket server_1 ( 30001 );
-
-      cout << "Waiting for Cognitive Engine to connect: port " << SERVER_PORT << endl;;
-      while ( true )
-      {
-         ServerSocket new_sock;
-       	 server.accept ( new_sock );
-
-       	 try
-       	 {
-       	    while ( true ) {
-       	       string data;
-       	       new_sock >> data;
-       	       new_sock << data;
-       	    }
-       	 }
-         catch ( SocketException& ) {}
-
-      }
-   }
-   catch ( SocketException& e )
-   {
-      cout << "Exception was caught:" << e.description() << "\nExiting.\n";
-   } 
-
-   return 0;
-}
-
-int StartClient()
-{
-    // start clinet
-    //
-    try { 
-        ClientSocket client_socket ( "localhost", 30000 );
-    
-        std::string reply;
-                 
-        try {
-            client_socket << "Test message.";
-            client_socket >> reply;
-        }
-        catch ( SocketException& ) {}
-                        
-    std::cout << "We received this response from the server:\n\"" << reply << "\"\n";
-                                      
-    }
-    catch ( SocketException& e ){
-        std::cout << "Exception was caught:" << e.description() << "\n";
-    }
-                                  
-    return 0;
-
-}
-
-
-int main(int argc, char* argv[]) {
-
-
-	// CognitiveEngine CE;
-	// CognitiveEngineShell Shell;
-	/*string pFilename; 
-
-	Utility * uList[10];
-	Parameter * pList[10];
-	Observable * oList[10];
-	CE_Info ce_info;
-
-	if(argc < 2) { 
-		cout << "Warning no XML file specific using default: example.xml" << endl;
-		pFilename = "example.xml";
-	} else {  
-		pFilename = argv[1];
-	}
-
-	TiXmlDocument doc( pFilename.c_str() );
-	bool loadOkay = doc.LoadFile();
-	if (!loadOkay)
-	{
-		cout << "Loading " << pFilename << " failed." << endl;
-		return 0;
-	}
-
-	cout << "Attemping to parse " << pFilename << "." << endl;
-	parse_ce_config( &doc , uList, pList, oList, &ce_info);
-	cout << "Configuration file parsing completed." << endl;
-
-	StartShell();*/
-
-    StartClient();
-
-   return 1;
-} 
