Index: vtcross/branches/engineTreeFix/src/cognitive_engines/Makefile.am
===================================================================
--- vtcross/branches/engineTreeFix/src/cognitive_engines/Makefile.am	(revision 526)
+++ vtcross/branches/engineTreeFix/src/cognitive_engines/Makefile.am	(revision 527)
@@ -22,3 +22,3 @@
 libce_a_SOURCES = CognitiveEngine.cpp
 
-SUBDIRS = . CBR_CE DSA_CE #OSSIE_DEMO_CE
+SUBDIRS = . CBR_CE DSA_CE OSSIE_DEMO_CE
Index: vtcross/branches/engineTreeFix/src/cognitive_engines/CBR_CE/CBR_CE.cpp
===================================================================
--- vtcross/branches/engineTreeFix/src/cognitive_engines/CBR_CE/CBR_CE.cpp	(revision 525)
+++ vtcross/branches/engineTreeFix/src/cognitive_engines/CBR_CE/CBR_CE.cpp	(revision 527)
@@ -41,5 +41,5 @@
     public:
         /*! Default constructor. */
-        CBR_CE(){};
+        CBR_CE() : CognitiveEngine(){};
 
         /*! Default destructor. */
Index: vtcross/branches/engineTreeFix/src/cognitive_engines/OSSIE_DEMO_CE/OSSIE_Demo.cpp
===================================================================
--- vtcross/branches/engineTreeFix/src/cognitive_engines/OSSIE_DEMO_CE/OSSIE_Demo.cpp	(revision 465)
+++ vtcross/branches/engineTreeFix/src/cognitive_engines/OSSIE_DEMO_CE/OSSIE_Demo.cpp	(revision 527)
@@ -31,5 +31,5 @@
        ERROR(1, "Usage: %s hostname port\n", argv[0]);
     
-    CognitiveEngine cognitiveEngine(argv[1], argv[2], false);
+    CognitiveEngine cognitiveEngine(argv[1], argv[2], 10, false);
 
     LOG("Waiting for signal...\n");
Index: vtcross/branches/engineTreeFix/src/cognitive_engines/OSSIE_DEMO_CE/Makefile.am
===================================================================
--- vtcross/branches/engineTreeFix/src/cognitive_engines/OSSIE_DEMO_CE/Makefile.am	(revision 470)
+++ vtcross/branches/engineTreeFix/src/cognitive_engines/OSSIE_DEMO_CE/Makefile.am	(revision 527)
@@ -1,2 +1,16 @@
+# Copyright 2009 Virginia Polytechnic Institute and State University  
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); 
+# you may not use this file except in compliance with the License. 
+# You may obtain a copy of the License at 
+# 
+# http://www.apache.org/licenses/LICENSE-2.0 
+#
+# Unless required by applicable law or agreed to in writing, software 
+# distributed under the License is distributed on an "AS IS" BASIS, 
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+# See the License for the specific language governing permissions and 
+# limitations under the License. 
+
 include $(top_srcdir)/Makefile.common
 
@@ -8,4 +22,5 @@
 
 OSSIE_Demo_SOURCES = OSSIE_CE.cpp OSSIE_Demo.cpp
-OSSIE_Demo_LDADD = -lsqlite3 $(CROSS_SOCKETCOMM_LA) 
+OSSIE_Demo_DEPENDENCIES = ../libce.a
+OSSIE_Demo_LDADD = -lsqlite3 ../libce.a $(CROSS_SOCKETCOMM_LA) 
 
Index: vtcross/branches/engineTreeFix/src/cognitive_engines/OSSIE_DEMO_CE/OSSIE_CE.cpp
===================================================================
--- vtcross/branches/engineTreeFix/src/cognitive_engines/OSSIE_DEMO_CE/OSSIE_CE.cpp	(revision 521)
+++ vtcross/branches/engineTreeFix/src/cognitive_engines/OSSIE_DEMO_CE/OSSIE_CE.cpp	(revision 527)
@@ -166,16 +166,84 @@
 
 
-static ossieCBR *myCBR;
-
-
-CognitiveEngine::CognitiveEngine()
-{
-    LOG("Creating Cognitive Engine.\n");
-    SML_present = false;
-    commandSocketFD = -1;
-}
-
-
-CognitiveEngine::~CognitiveEngine()
+class OSSIE_CE : public CognitiveEngine
+{
+    public:
+        /*! Default constructor. */
+        OSSIE_CE() : CognitiveEngine(){};
+
+        /*! Default destructor. */
+        ~OSSIE_CE();
+
+        /*! \brief Preferred constructor.
+         *
+         * Overloaded constructor that creates a cognitive engine object and
+         * connects it to either the shell or an SML, depening on the SML bool.
+         *
+         * The 'numFields' parameter sets how large the parameter, observable,
+         * and utility arrays should be upon instantiation.
+         */
+        OSSIE_CE(const char* serverName, const char* serverPort, \
+                const int32_t numFields, const bool SML) \
+            : CognitiveEngine(serverName, serverPort, numFields, SML){}
+
+
+        void RegisterServices();
+        void DeregisterServices();
+
+        /*! \brief Request that the CE optimize a set of parameters. 
+         *
+         * Find the most optimal set of transmission parameters given certain
+         * observables and possibly a service if the SML component is present
+         * and active. */
+        Parameter *GetSolution(Observable *observables, \
+                Parameter *currentParameters);
+        Parameter *GetSolution(Observable *observables, \
+                Parameter *currentParameters, std::string service);
+
+        /*! \brief Receive feedback from the radio 
+         *
+         * Receive a feedback from the radio regarding the performance of a
+         * certain set of parameters, possibly associated with a service.
+         *
+         * Feedback is a single set of performance statistics that is achieved
+         * corresponding to a specific set of transmission parameters.  Feedback
+         * helps a Cognitive Engine make better future decisions based upon 
+         * more accurate performance statistics. 
+         */
+        void ReceiveFeedback(Observable *observables,Parameter *parameters);
+        void ReceiveFeedback(Observable *observables, Parameter *parameters, \
+                std::string service);
+
+
+        /*! \brief Initialize the CE and prepare it for operation. 
+         *
+         * BuildCognitiveEngine performs the CE implementation specific work
+         * that defines the internals of a CE.  For example, a CBR CE engine
+         * would build the case-base reasoner or create the database, a neural
+         * network based CE may perform the initial training, a GA based CE
+         * may build the chromosome structure.
+         */
+        void BuildCognitiveEngine();
+
+        /*! \brief Each of these functions responds to a specific command.
+         *
+         * These functions are left principally un-implemented. It is the duty
+         * of child classes to implement these functions, as they define the
+         * cognitive engine's functionality.
+         */
+        void PerformUpdatePerformance();
+        void PerformRequestOptimizationService();
+        void PerformRequestOptimization();
+        void PerformQueryComponentType();
+        void PerformConnectSML();
+        void PerformDisconnectSML();
+        void PerformResetEngineCognitive();
+        void PerformShutdownEngineCognitive();
+
+        ossieCBR *myCBR;
+};
+
+
+OSSIE_CE::~OSSIE_CE()
 {
     delete myCBR;
@@ -187,56 +255,7 @@
 }
 
-
-CognitiveEngine::CognitiveEngine(const char *serverName, const char *serverPort, \
-        const bool SML)
-{
-    LOG("Creating Cognitive Engine.\n");
-
-    pList = new Parameter[10];
-    oList = new Observable[10];
-    uList = new Utility[10];
-    radioInfo = new Radio_Info;
-
-    ConnectToRemoteComponent(serverName, serverPort, SML);
-}
-
-
-void
-CognitiveEngine::SendComponentType()
-{
-    SendMessage(commandSocketFD, "response_engine_cognitive");
-    LOG("Cognitive Engine responded to GetRemoteComponentType query.\n");
-}
-
-
-void
-CognitiveEngine::ConnectToRemoteComponent(const char *serverName, \
-        const char *serverPort, const bool SML)
-{
-    commandSocketFD = ClientSocket(serverName, serverPort);
-
-    SML_present = SML;
-
-    if(SML) {
-        
-        RegisterComponent();
-        LOG("Cognitive Engine connected to SML at %s.\n", serverName);
-        ReceiveRadioConfiguration();
-        ReceiveExperience();
-        
-        RegisterServices();
-    }
-    else {
-        RegisterComponent();
-        LOG("Cognitive Engine connected to shell at %s.\n", serverName);
-        ReceiveRadioConfiguration();
-        ReceiveExperience();
-    }
-}
-
 // This function needs serious help and is very confusing
-
 void 
-CognitiveEngine::ReceiveFeedback(Observable *observables, Parameter *parameters)
+OSSIE_CE::ReceiveFeedback(Observable *observables, Parameter *parameters)
 { 
    LOG("Cognitive Engine:: Receiving feedback.\n");
@@ -292,309 +311,13 @@
 
 void 
-CognitiveEngine::WaitForSignal()
-{
-    char buffer[256];
-
-    while(true) {
-        memset(buffer, 0, 256);
-       
-        ReadMessage(commandSocketFD, buffer);
-
-        // TODO this is ugly... is there a better way? Doesn't strcmp compare the
-        // whole string?  We only need to compare until we find a single different
-        // byte...
-        //
-        // If we send integer op codes rather than strings, this process will be
-        // MUCH faster since instead of donig string compares we can simply
-        // switch on the integer value...
-        if(strcmp(buffer, "update_performance") == 0) {
-            
-            /* Receive Set of current Parameters */
-            memset(buffer, 0, 256);
-            ReadMessage(commandSocketFD, buffer);
-            uint32_t numParameters = atoi(buffer);
-   
-            Parameter *p = new Parameter[numParameters];
- 
-            for(size_t i = 0; i < numParameters; i++) {
-                memset(buffer, 0, 256);
-                ReadMessage(commandSocketFD, buffer);
-                p[i].name = std::string(buffer);
-    
-                memset(buffer, 0, 256);
-                ReadMessage(commandSocketFD, buffer);
-                p[i].value = atof(buffer);
-            } 
-
-            /* Receive Set of Observables */
-            memset(buffer, 0, 256);
-            ReadMessage(commandSocketFD, buffer);
-            uint32_t numObservables = atoi(buffer);
-   
-            Observable *o = new Observable[numObservables];
- 
-            for(size_t i = 0; i < numObservables; i++) {
-                memset(buffer, 0, 256);
-                ReadMessage(commandSocketFD, buffer);
-                o[i].name = std::string(buffer);
-    
-                memset(buffer, 0, 256);
-                ReadMessage(commandSocketFD, buffer);
-                o[i].value = atof(buffer);
-            }  
-
-            ReceiveFeedback(o,p);
-
-            delete [] o;
-            delete [] p;
-        } 
-        else if(strcmp(buffer, "request_optimization_service") == 0) {
-	    // THIS IS CURRENTLY IN DEMO MODE            
-
-
-            /* Receive Set of Observables */
-            LOG("\nCognitive Engine:: Receiving service name\n");
-
-            memset(buffer, 0, 256);
-            ReadMessage(commandSocketFD,buffer);
-            LOG("\nCognitive Engine:: Got service name, %s\n", buffer);
-
-            /* Receive Set of Observables */
-            LOG("\nCognitive Engine:: Receiving Observable Parameters\n");
-
-            memset(buffer, 0, 256);
-            ReadMessage(commandSocketFD,buffer);
-            uint32_t numObservables = atoi(buffer);
-   
-            Observable *o = new Observable[numObservables];
- 
-            for(size_t i = 0; i < numObservables; i++) {
-                memset(buffer, 0, 256);
-                ReadMessage(commandSocketFD, buffer);
-                o[i].name = std::string(buffer);
-    
-                memset(buffer, 0, 256);
-                ReadMessage(commandSocketFD, buffer);
-                o[i].value = atof(buffer);
-            }  
-
-            /* Receive Set of current Parameters */
-            LOG("Cognitive Engine:: Receiving Current Transmission Parameters\n");
-
-            memset(buffer, 0, 256);
-            ReadMessage(commandSocketFD, buffer);
-            uint32_t numCurrentParameters = atoi(buffer);
-   
-            Parameter *cp = new Parameter[numCurrentParameters];
- 
-            for(size_t i = 0; i < numCurrentParameters; i++) {
-                memset(buffer, 0, 256);
-                ReadMessage(commandSocketFD, buffer);
-                cp[i].name = std::string(buffer);
-    
-                memset(buffer, 0, 256);
-                ReadMessage(commandSocketFD, buffer);
-                cp[i].value = atof(buffer);
-            }  
-            LOG("Cognitive Engine:: Processing parameters....\n");
-
-            //Parameter *solutionSet;
-            
-            //solutionSet = GetSolution(o,cp);
-
-            // TODO need to actually do something with the observables here
-           
-            LOG("Cognitive Engine:: Sending Optimal Parameters to Application.\n");
-            char numParametersChar[10];
-            //char solutionValue[50];
-            sprintf(numParametersChar, "%i", radioInfo->numParameters);
-            SendMessage(commandSocketFD, numParametersChar);
-            for(size_t i = 0; i < radioInfo->numParameters; i++) {
-                //SendMessage(commandSocketFD, solutionSet[i].name.c_str());
-		SendMessage(commandSocketFD, "test");
-                //memset(solutionValue, 0, 50);
-                //sprintf(solutionValue, "%f", solutionSet[i].value);
-                //SendMessage(commandSocketFD, solutionValue);
-		SendMessage(commandSocketFD, "00");
-            }
-
-            delete [] o;
-            delete [] cp;
-        }
-        else if(strcmp(buffer, "request_optimization") == 0) {
-            
-            /* Receive Set of Observables */
-            LOG("\nCognitive Engine:: Receiving Observable Parameters\n");
-
-            memset(buffer, 0, 256);
-            ReadMessage(commandSocketFD,buffer);
-            uint32_t numObservables = atoi(buffer);
-   
-            Observable *o = new Observable[numObservables];
- 
-            for(size_t i = 0; i < numObservables; i++) {
-                memset(buffer, 0, 256);
-                ReadMessage(commandSocketFD, buffer);
-                o[i].name = std::string(buffer);
-    
-                memset(buffer, 0, 256);
-                ReadMessage(commandSocketFD, buffer);
-                o[i].value = atof(buffer);
-            }  
-
-            /* Receive Set of current Parameters */
-            LOG("Cognitive Engine:: Receiving Current Transmission Parameters\n");
-
-            memset(buffer, 0, 256);
-            ReadMessage(commandSocketFD, buffer);
-            uint32_t numCurrentParameters = atoi(buffer);
-   
-            Parameter *cp = new Parameter[numCurrentParameters];
- 
-            for(size_t i = 0; i < numCurrentParameters; i++) {
-                memset(buffer, 0, 256);
-                ReadMessage(commandSocketFD, buffer);
-                cp[i].name = std::string(buffer);
-    
-                memset(buffer, 0, 256);
-                ReadMessage(commandSocketFD, buffer);
-                cp[i].value = atof(buffer);
-            }  
-            LOG("Cognitive Engine:: Processing parameters....\n");
-
-            Parameter *solutionSet;
-            
-            solutionSet = GetSolution(o,cp);
-
-            // TODO need to actually do something with the observables here
-           
-            LOG("Cognitive Engine:: Sending Optimal Parameters to Application.\n");
-            char numParametersChar[10];
-            char solutionValue[50];
-            sprintf(numParametersChar, "%i", radioInfo->numParameters);
-            SendMessage(commandSocketFD, numParametersChar);
-            for(size_t i = 0; i < radioInfo->numParameters; i++) {
-                SendMessage(commandSocketFD, solutionSet[i].name.c_str());
-                memset(solutionValue, 0, 50);
-                sprintf(solutionValue, "%f", solutionSet[i].value);
-                SendMessage(commandSocketFD, solutionValue);
-            }
-
-            delete [] o;
-            delete [] cp;
-        }
-        else if(strcmp(buffer, "query_component_type") == 0) {
-            SendComponentType();
-        }
-        else if(strcmp(buffer, "connect_sml") == 0) {
-            /* This command implies that we are disconnecting from the shell and
-             * connecting to a SML component. */
-            char serverName[256];
-            char serverPort[256];
-            // TODO is this going to end up being too slow?
-            memset(serverName, 0, 256);
-            memset(serverPort, 0, 256);
-
-            ReadMessage(commandSocketFD, serverName);
-            ReadMessage(commandSocketFD, serverPort);
-
-            /* Only continue if we are currently connected to a shell. */
-            if(!SML_present) {
-                DeregisterComponent();
-
-                shutdown(commandSocketFD, 2);
-                close(commandSocketFD);
-
-                ConnectToRemoteComponent(serverName, serverPort, true);
-            }
-        }
-        else if(strcmp(buffer, "disconnect_sml") == 0) {
-            /* This command implies that we are disconnecting from the SML and
-             * connecting to a shell component. */
-            char serverName[256];
-            char serverPort[256];
-            // TODO is this going to end up being too slow?
-            memset(serverName, 0, 256);
-            memset(serverPort, 0, 256);
-
-            ReadMessage(commandSocketFD, serverName);
-            ReadMessage(commandSocketFD, serverPort);
-
-            /* We only want to do this if we are actually connected to an SML
-             * currently. */
-            if(SML_present) {
-                DeregisterServices();
-
-                shutdown(commandSocketFD, 2);
-                close(commandSocketFD);
-
-                ConnectToRemoteComponent(serverName, serverPort, false);
-            }
-        }
-        else if(strcmp(buffer, "reset_engine_cognitive") == 0) {
-            Reset();
-        }
-        else if(strcmp(buffer, "shutdown_engine_cognitive") == 0) {
-            Shutdown();
-        }
-    }
+OSSIE_CE::ReceiveFeedback(Observable *observables, Parameter *parameters, \
+    std::string service)
+{
+    LOG("Cognitive Engine:: Receiving feedback.\n");
 }
 
 
 void 
-CognitiveEngine::Shutdown()
-{
-    if(SML_present) {
-        //DeregisterServices();
-        DeregisterComponent();
-    } 
-    else {
-        DeregisterComponent();
-    }
-    // TODO should something else be happening here?
-}
-
-
-void
-CognitiveEngine::Reset()
-{
-    LOG("Resetting Cognitive Engine.\n");
-
-    if(SML_present) {
-        DeregisterServices();
-        DeregisterComponent();
-    } 
-    else {
-        DeregisterComponent();
-    }
-}
-
-
-void
-CognitiveEngine::RegisterComponent()
-{
-    char buffer[256];
-    SendMessage(commandSocketFD, "register_engine_cognitive");
-    LOG("Cognitive Engine:: Registration message sent to shell.\n");
-
-    memset(buffer, 0, 256);
-    ReadMessage(commandSocketFD, buffer);
-}
-
-void 
-CognitiveEngine::DeregisterComponent()
-{
-    SendMessage(commandSocketFD, "deregister_engine_cognitive");
-    LOG("Cognitive Engine:: Deregistration message sent.\n");
-
-    shutdown(commandSocketFD, 2);
-    close(commandSocketFD);
-    commandSocketFD = -1;
-    LOG("Cognitive Engine:: Shell socket closed.\n");
-}
-
-
-void 
-CognitiveEngine::RegisterServices()
+OSSIE_CE::RegisterServices()
 {
     LOG("Cognitive Engine:: Registering services.\n");
@@ -614,7 +337,7 @@
 }
 
-//Combined with deregister component since those two things must happen togeather
+
 void 
-CognitiveEngine::DeregisterServices()
+OSSIE_CE::DeregisterServices()
 {
     LOG("Cognitive Engine:: Deregistering services.\n");
@@ -634,136 +357,7 @@
 }
 
-void 
-CognitiveEngine::ReceiveRadioConfiguration()
-{
-    LOG("Cognitive Engine:: Receiving Radio Configuration.\n");
-    
-    char buffer[256];
- 
-    /* Receive Set of Utilities */
-    memset(buffer, 0, 256);
-    ReadMessage(commandSocketFD, buffer);
-    radioInfo->numUtilities = atoi(buffer);
-
-    for(size_t i = 0; i < radioInfo->numUtilities; i++) {
-        memset(buffer, 0, 256);
-        ReadMessage(commandSocketFD, buffer);
-        uList[i].name = std::string(buffer);
-   
-        memset(buffer, 0, 256);
-        ReadMessage(commandSocketFD, buffer);
-        uList[i].units = std::string(buffer);
-
-        memset(buffer, 0, 256);
-        ReadMessage(commandSocketFD, buffer);
-        uList[i].goal = std::string(buffer);
-    
-        memset(buffer, 0, 256);
-        ReadMessage(commandSocketFD, buffer);
-        uList[i].target = atof(buffer);
-    }
-
-    /* Receive Set of Parameters */
-    memset(buffer, 0, 256);
-    ReadMessage(commandSocketFD, buffer);
-    radioInfo->numParameters = atoi(buffer);
-    
-    for(size_t i = 0; i < radioInfo->numParameters; i++) {
-        memset(buffer, 0, 256);
-        ReadMessage(commandSocketFD, buffer);
-        pList[i].name = std::string(buffer);
-    
-        memset(buffer, 0, 256);
-        ReadMessage(commandSocketFD, buffer);
-        pList[i].units = std::string(buffer);
-
-        memset(buffer, 0, 256);
-        ReadMessage(commandSocketFD, buffer);
-        pList[i].min = atof(buffer);
-    
-        memset(buffer, 0, 256);
-        ReadMessage(commandSocketFD, buffer);
-        pList[i].max = atof(buffer);
-    
-        memset(buffer, 0, 256);
-        ReadMessage(commandSocketFD, buffer);
-        pList[i].step = atof(buffer);
-    
-        memset(buffer, 0, 256);
-        ReadMessage(commandSocketFD,buffer);
-        pList[i].numAffects = atoi(buffer);
-    
-        for(size_t j = 0; j < pList[i].numAffects; j++) {
-            memset(buffer, 0, 256);
-            ReadMessage(commandSocketFD,buffer);
-            // TODO for + if{break} = while?
-            for(size_t k = 0; k < radioInfo->numUtilities; k++) {
-                if(uList[k].name == std::string(buffer)) {    
-                    pList[i].affection_list[j].u = &uList[k];   
-                    break;
-                }
-            }
-
-            memset(buffer, 0, 256);
-            ReadMessage(commandSocketFD, buffer);
-            pList[i].affection_list[j].relation = std::string(buffer);   
-        }
-    }   
-
-    /* Receive Set of Observables */
-    memset(buffer, 0, 256);
-    ReadMessage(commandSocketFD, buffer);
-    radioInfo->numObservables = atoi(buffer);
-    
-    for(size_t i = 0; i < radioInfo->numObservables; i++) {
-        memset(buffer, 0, 256);
-        ReadMessage(commandSocketFD, buffer);
-        oList[i].name = std::string(buffer);
-    
-        memset(buffer, 0, 256);
-        ReadMessage(commandSocketFD, buffer);
-        oList[i].numAffects = atoi(buffer);
-    
-        for(size_t j = 0; j < oList[i].numAffects; j++) {
-            memset(buffer, 0, 256);
-            ReadMessage(commandSocketFD, buffer);
-            // TODO for + if{break} = while?
-            for(size_t k = 0; k < radioInfo->numUtilities; k++) {
-                if(uList[k].name == std::string(buffer)){    
-                    oList[i].affection_list[j].u = &uList[k];   
-                    break;
-                }
-            }
- 
-            memset(buffer, 0, 256);
-            ReadMessage(commandSocketFD, buffer);
-            oList[i].affection_list[j].relation = std::string(buffer);   
-        }
-    }
-
-    SendMessage(commandSocketFD, "receive_config_ack");
-
-    BuildCognitiveEngine();
-}
-
-void 
-CognitiveEngine::ReceiveExperience()
-{
-    LOG("Cognitive Engine:: Receiving Experience Report.\n");
-    char buffer[256];
-    uint32_t numberExp;
-    
-    /* Receive number of experience entries */
-    memset(buffer, 0, 256);
-    ReadMessage(commandSocketFD, buffer);
-    numberExp = atoi(buffer);
-
-    LOG("Cognitive Engine:: Waiting for %i number of entries.\n", numberExp);
- 
-    SendMessage(commandSocketFD, "receive_exp_ack");
-}
 
 Parameter* 
-CognitiveEngine::GetSolution(Observable *observables, Parameter *currentParameters)
+OSSIE_CE::GetSolution(Observable *observables, Parameter *currentParameters)
 {
     LOG("Cognitive Engine:: Generating solution.\n");
@@ -873,5 +467,5 @@
 
 Parameter* 
-CognitiveEngine::GetSolution(Observable *observables, \
+OSSIE_CE::GetSolution(Observable *observables, \
         Parameter *currentParameters, std::string service)
 {
@@ -882,14 +476,6 @@
 
 
-void 
-CognitiveEngine::ReceiveFeedback(Observable *observables, Parameter *parameters, \
-    std::string service)
-{
-    LOG("Cognitive Engine:: Receiving feedback.\n");
-}
-
-
 void
-CognitiveEngine::BuildCognitiveEngine()
+OSSIE_CE::BuildCognitiveEngine()
 {
     string filename = "ex1";
@@ -919,2 +505,261 @@
 }
 
+void 
+OSSIE_CE::PerformUpdatePerformance()
+{
+    /* Receive Set of current Parameters */
+    char buffer[256];
+    memset(buffer, 0, 256);
+    ReadMessage(commandSocketFD, buffer);
+    uint32_t numParameters = atoi(buffer);
+
+    Parameter *p = new Parameter[numParameters];
+
+    for(size_t i = 0; i < numParameters; i++) {
+        memset(buffer, 0, 256);
+        ReadMessage(commandSocketFD, buffer);
+        p[i].name = std::string(buffer);
+
+        memset(buffer, 0, 256);
+        ReadMessage(commandSocketFD, buffer);
+        p[i].value = atof(buffer);
+    } 
+
+    /* Receive Set of Observables */
+    memset(buffer, 0, 256);
+    ReadMessage(commandSocketFD, buffer);
+    uint32_t numObservables = atoi(buffer);
+
+    Observable *o = new Observable[numObservables];
+
+    for(size_t i = 0; i < numObservables; i++) {
+        memset(buffer, 0, 256);
+        ReadMessage(commandSocketFD, buffer);
+        o[i].name = std::string(buffer);
+
+        memset(buffer, 0, 256);
+        ReadMessage(commandSocketFD, buffer);
+        o[i].value = atof(buffer);
+    }  
+
+    ReceiveFeedback(o,p);
+
+    delete [] o;
+    delete [] p;
+}
+
+
+void
+OSSIE_CE::PerformRequestOptimizationService()
+{
+    /* Receive Set of Observables */
+    LOG("\nCognitive Engine:: Receiving service name\n");
+
+    char buffer[256];
+    memset(buffer, 0, 256);
+    ReadMessage(commandSocketFD,buffer);
+    LOG("\nCognitive Engine:: Got service name, %s\n", buffer);
+
+    /* Receive Set of Observables */
+    LOG("\nCognitive Engine:: Receiving Observable Parameters\n");
+
+    memset(buffer, 0, 256);
+    ReadMessage(commandSocketFD,buffer);
+    uint32_t numObservables = atoi(buffer);
+
+    Observable *o = new Observable[numObservables];
+
+    for(size_t i = 0; i < numObservables; i++) {
+        memset(buffer, 0, 256);
+        ReadMessage(commandSocketFD, buffer);
+        o[i].name = std::string(buffer);
+
+        memset(buffer, 0, 256);
+        ReadMessage(commandSocketFD, buffer);
+        o[i].value = atof(buffer);
+    }  
+
+    /* Receive Set of current Parameters */
+    LOG("Cognitive Engine:: Receiving Current Transmission Parameters\n");
+
+    memset(buffer, 0, 256);
+    ReadMessage(commandSocketFD, buffer);
+    uint32_t numCurrentParameters = atoi(buffer);
+
+    Parameter *cp = new Parameter[numCurrentParameters];
+
+    for(size_t i = 0; i < numCurrentParameters; i++) {
+        memset(buffer, 0, 256);
+        ReadMessage(commandSocketFD, buffer);
+        cp[i].name = std::string(buffer);
+
+        memset(buffer, 0, 256);
+        ReadMessage(commandSocketFD, buffer);
+        cp[i].value = atof(buffer);
+    }  
+    LOG("Cognitive Engine:: Processing parameters....\n");
+
+    //Parameter *solutionSet;
+    
+    //solutionSet = GetSolution(o,cp);
+
+    // TODO need to actually do something with the observables here
+   
+    LOG("Cognitive Engine:: Sending Optimal Parameters to Application.\n");
+    char numParametersChar[10];
+    //char solutionValue[50];
+    sprintf(numParametersChar, "%i", radioInfo->numParameters);
+    SendMessage(commandSocketFD, numParametersChar);
+    for(size_t i = 0; i < radioInfo->numParameters; i++) {
+        //SendMessage(commandSocketFD, solutionSet[i].name.c_str());
+        SendMessage(commandSocketFD, "test");
+        //memset(solutionValue, 0, 50);
+        //sprintf(solutionValue, "%f", solutionSet[i].value);
+        //SendMessage(commandSocketFD, solutionValue);
+        SendMessage(commandSocketFD, "00");
+    }
+
+    delete [] o;
+    delete [] cp;
+}
+
+
+void
+OSSIE_CE::PerformRequestOptimization()
+{
+    /* Receive Set of Observables */
+    LOG("\nCognitive Engine:: Receiving Observable Parameters\n");
+
+    char buffer[256];
+    memset(buffer, 0, 256);
+    ReadMessage(commandSocketFD,buffer);
+    uint32_t numObservables = atoi(buffer);
+
+    Observable *o = new Observable[numObservables];
+
+    for(size_t i = 0; i < numObservables; i++) {
+        memset(buffer, 0, 256);
+        ReadMessage(commandSocketFD, buffer);
+        o[i].name = std::string(buffer);
+
+        memset(buffer, 0, 256);
+        ReadMessage(commandSocketFD, buffer);
+        o[i].value = atof(buffer);
+    }  
+
+    /* Receive Set of current Parameters */
+    LOG("Cognitive Engine:: Receiving Current Transmission Parameters\n");
+
+    memset(buffer, 0, 256);
+    ReadMessage(commandSocketFD, buffer);
+    uint32_t numCurrentParameters = atoi(buffer);
+
+    Parameter *cp = new Parameter[numCurrentParameters];
+
+    for(size_t i = 0; i < numCurrentParameters; i++) {
+        memset(buffer, 0, 256);
+        ReadMessage(commandSocketFD, buffer);
+        cp[i].name = std::string(buffer);
+
+        memset(buffer, 0, 256);
+        ReadMessage(commandSocketFD, buffer);
+        cp[i].value = atof(buffer);
+    }  
+    LOG("Cognitive Engine:: Processing parameters....\n");
+
+    Parameter *solutionSet;
+    
+    solutionSet = GetSolution(o,cp);
+
+    // TODO need to actually do something with the observables here
+   
+    LOG("Cognitive Engine:: Sending Optimal Parameters to Application.\n");
+    char numParametersChar[10];
+    char solutionValue[50];
+    sprintf(numParametersChar, "%i", radioInfo->numParameters);
+    SendMessage(commandSocketFD, numParametersChar);
+    for(size_t i = 0; i < radioInfo->numParameters; i++) {
+        SendMessage(commandSocketFD, solutionSet[i].name.c_str());
+        memset(solutionValue, 0, 50);
+        sprintf(solutionValue, "%f", solutionSet[i].value);
+        SendMessage(commandSocketFD, solutionValue);
+    }
+
+    delete [] o;
+    delete [] cp;
+}
+
+
+void
+OSSIE_CE::PerformQueryComponentType()
+{
+    SendComponentType();
+}
+
+
+void
+OSSIE_CE::PerformConnectSML()
+{
+    /* This command implies that we are disconnecting from the shell and
+     * connecting to a SML component. */
+    char serverName[256];
+    char serverPort[256];
+    // TODO is this going to end up being too slow?
+    memset(serverName, 0, 256);
+    memset(serverPort, 0, 256);
+
+    ReadMessage(commandSocketFD, serverName);
+    ReadMessage(commandSocketFD, serverPort);
+
+    /* Only continue if we are currently connected to a shell. */
+    if(!SML_present) {
+        DeregisterComponent();
+
+        shutdown(commandSocketFD, 2);
+        close(commandSocketFD);
+
+        ConnectToRemoteComponent(serverName, serverPort, true);
+    }
+}
+
+
+void
+OSSIE_CE::PerformDisconnectSML()
+{
+    /* This command implies that we are disconnecting from the SML and
+     * connecting to a shell component. */
+    char serverName[256];
+    char serverPort[256];
+    // TODO is this going to end up being too slow?
+    memset(serverName, 0, 256);
+    memset(serverPort, 0, 256);
+
+    ReadMessage(commandSocketFD, serverName);
+    ReadMessage(commandSocketFD, serverPort);
+
+    /* We only want to do this if we are actually connected to an SML
+     * currently. */
+    if(SML_present) {
+        DeregisterServices();
+
+        shutdown(commandSocketFD, 2);
+        close(commandSocketFD);
+
+        ConnectToRemoteComponent(serverName, serverPort, false);
+    }
+}
+
+
+void
+OSSIE_CE::PerformResetEngineCognitive()
+{
+    Reset();
+}
+
+
+void
+OSSIE_CE::PerformShutdownEngineCognitive()
+{
+    Shutdown();
+}
+ 
