Index: vtcross/trunk/INSTALL
===================================================================
--- vtcross/trunk/INSTALL	(revision 161)
+++ vtcross/trunk/INSTALL	(revision 285)
@@ -1,1 +1,1 @@
-link /usr/share/automake-1.10/INSTALL
+link /usr/share/automake-1.9/INSTALL
Index: vtcross/trunk/src/cognitive_engines/cbr_demo.cpp
===================================================================
--- vtcross/trunk/src/cognitive_engines/cbr_demo.cpp	(revision 222)
+++ vtcross/trunk/src/cognitive_engines/cbr_demo.cpp	(revision 285)
@@ -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], true);
 
     LOG("Waiting for signal...\n");
Index: vtcross/trunk/src/cognitive_engines/CognitiveEngine.cpp
===================================================================
--- vtcross/trunk/src/cognitive_engines/CognitiveEngine.cpp	(revision 278)
+++ vtcross/trunk/src/cognitive_engines/CognitiveEngine.cpp	(revision 285)
@@ -81,9 +81,11 @@
 
     if(SML) {
-        RegisterServices();
+        
         RegisterComponent();
         LOG("Cognitive Engine connected to SML at %s.\n", serverName);
         ReceiveRadioConfiguration();
         ReceiveExperience();
+        
+        RegisterServices();
     }
     else {
@@ -215,4 +217,77 @@
             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) {
             
@@ -367,6 +442,10 @@
 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);
 }
 
@@ -390,14 +469,15 @@
 
     SendMessage(commandSocketFD, "register_service");
-    SendMessage(commandSocketFD, "jam_wifi");
+    SendMessage(commandSocketFD, "test_srv");
 
     SendMessage(commandSocketFD, "register_service");
-    SendMessage(commandSocketFD, "signal_detection");
+    SendMessage(commandSocketFD, "test_srv1");
 
     SendMessage(commandSocketFD, "register_service");
-    SendMessage(commandSocketFD, "max_throughput");
+    SendMessage(commandSocketFD, "test_srv2");
 
     SendMessage(commandSocketFD, "register_service");
-    SendMessage(commandSocketFD, "jam_bluetooth");
+    SendMessage(commandSocketFD, "test_srv3");
+
 }
 
@@ -409,14 +489,14 @@
 
     SendMessage(commandSocketFD, "deregister_service");
-    SendMessage(commandSocketFD, "jam_wifi");
+    SendMessage(commandSocketFD, "test_srv");
 
     SendMessage(commandSocketFD, "deregister_service");
-    SendMessage(commandSocketFD, "signal_detection");
+    SendMessage(commandSocketFD, "test_srv1");
 
     SendMessage(commandSocketFD, "deregister_service");
-    SendMessage(commandSocketFD, "max_throughput");
+    SendMessage(commandSocketFD, "test_srv2");
 
     SendMessage(commandSocketFD, "deregister_service");
-    SendMessage(commandSocketFD, "jam_bluetooth");
+    SendMessage(commandSocketFD, "test_srv3");
 
 }
@@ -433,5 +513,7 @@
     ReadMessage(commandSocketFD, buffer);
     radioInfo->numUtilities = atoi(buffer);
-    
+    LOG("Cognitive Engine:: Receiving Radio Configuration. %s\n",buffer);
+
+
     for(size_t i = 0; i < radioInfo->numUtilities; i++) {
         memset(buffer, 0, 256);
Index: vtcross/trunk/src/include/vtcross/components.h
===================================================================
--- vtcross/trunk/src/include/vtcross/components.h	(revision 281)
+++ vtcross/trunk/src/include/vtcross/components.h	(revision 285)
@@ -114,5 +114,5 @@
          * shell with the passed hostname and port.
          */
-        ServiceManagementLayer(const char* SML_Config, const char* serverName, const char* serverPort);
+        ServiceManagementLayer(const char* SML_Config, const char* serverName, const char* serverPort, int16_t clientPort);
 
         /* Connect and register with the shell component at the passed hostname
@@ -187,4 +187,6 @@
 	bool CE_Present;
         int32_t activeMission;
+
+        int16_t SMLport;
 };
 
Index: vtcross/trunk/src/shell/CognitiveRadioShell.cpp
===================================================================
--- vtcross/trunk/src/shell/CognitiveRadioShell.cpp	(revision 281)
+++ vtcross/trunk/src/shell/CognitiveRadioShell.cpp	(revision 285)
@@ -123,4 +123,5 @@
     sprintf(counter, "%d", radio_info->numUtilities);
     SendMessage(socketFD, counter);
+    LOG("Cognitive Radio Shell:: Sending radio configuration to Cognitive Engine. %s\n",counter);
     for(size_t i = 0; i < radio_info->numUtilities; i++) {
         SendMessage(socketFD, utils[i].name.c_str());
@@ -187,6 +188,6 @@
     char numberExpString[50];
 
-    sprintf(numberExpString, "%i", numberExp);
-    SendMessage(socketFD, numberExpString); 
+    sprintf(numberExpString, "%d", numberExp);
+    SendMessage(socketFD, "test");  //TODO modified
 
     char buffer[256];
@@ -198,5 +199,5 @@
         return 0;
     }
-
+    //printf("done sending exp \n");
     return 1;
 }
@@ -646,5 +647,5 @@
 {
     char buffer[256];
-
+    //printf("here\n");
     ReadMessage(socketFD, buffer);
 
@@ -729,5 +730,5 @@
         /* Zero socket descriptor vector and set for server sockets */
         /* This must be reset every time select() is called */
-        FD_ZERO(&sockSet);
+        //FD_ZERO(&sockSet);
         FD_SET(servSock[primary], &sockSet);
         FD_SET(servSock[policy], &sockSet);
@@ -749,5 +750,4 @@
                 if(FD_ISSET(port, &sockSet)) {
                     desc_ready -= 1;
-
                     /* Check if request is new or on an existing open descriptor */
                     if((port == servSock[primary]) || (port == servSock[policy]) || (port == servSock[command])) { 
@@ -763,4 +763,5 @@
                             if(port == servSock[policy])
                                 policySocketFD = new_sd;
+ 			    //printf("%d %d %d :: %d\n", ceSocketFD, commandSocketFD, policySocketFD, new_sd);
 
                             HandleMessage(new_sd);
Index: vtcross/trunk/src/service_management_layer/sml_demo.cpp
===================================================================
--- vtcross/trunk/src/service_management_layer/sml_demo.cpp	(revision 279)
+++ vtcross/trunk/src/service_management_layer/sml_demo.cpp	(revision 285)
@@ -50,8 +50,8 @@
 {  
 
-    if(argc < 3)
-       ERROR(1, "Usage: %s config hostname port\n", argv[0]);
+    if(argc < 5)
+       ERROR(1, "Usage: %s config hostname shell_port client_port\n", argv[0]);
  
-    ServiceManagementLayer SML(argv[1], argv[2], argv[3]);
+    ServiceManagementLayer SML(argv[1], argv[2], argv[3], atoi(argv[4]));
     SML.StartSMLServer();     
 }
Index: vtcross/trunk/src/service_management_layer/ServiceManagementLayer.cpp
===================================================================
--- vtcross/trunk/src/service_management_layer/ServiceManagementLayer.cpp	(revision 282)
+++ vtcross/trunk/src/service_management_layer/ServiceManagementLayer.cpp	(revision 285)
@@ -133,8 +133,9 @@
 //Also, their sizes are hardcoded into the code in various places; a fix for a future version.
 ServiceManagementLayer::ServiceManagementLayer(const char* SML_Config, \
-	const char* serverName, const char* serverPort)
+	const char* serverName, const char* serverPort, int16_t clientPort)
 {
     LOG("Creating Service Management Layer.\n");
     _SML_Config = SML_Config;
+    SMLport = clientPort;
 
     ConnectToShell(serverName, serverPort);
@@ -588,4 +589,6 @@
 	    break;
     }
+
+    LOG("ServiceManagementLayer:: Received Set Active Mission command: %i\n",missID);
     //For each service in the mission
     for(int i = 0; i < miss[activeMission].numServices; i++)
@@ -620,5 +623,6 @@
 	//Nothing to be done for conditionals at this stage
     }
-
+ 
+    SendMessage(shellSocketFD, "ack");
 
     //printf("\nhere ---%d, %d---\n", miss[activeMission].services[0].componentID, miss[activeMission].services[1].componentID);
@@ -1278,5 +1282,5 @@
     fd_set sockSet, shellSet;
 
-    cogEngSrv = CreateTCPServerSocket(2044);
+    cogEngSrv = CreateTCPServerSocket(SMLport);
     int32_t maxDescriptor = cogEngSrv;
 
Index: vtcross/trunk/src/libvtcross/libvtcross_demo_sml.cpp
===================================================================
--- vtcross/trunk/src/libvtcross/libvtcross_demo_sml.cpp	(revision 283)
+++ vtcross/trunk/src/libvtcross/libvtcross_demo_sml.cpp	(revision 285)
@@ -30,5 +30,5 @@
     uint32_t numObservables = 2;
 
-    for(size_t i = 0; i < 10; i++) {
+    //for(size_t i = 0; i < 10; i++) {
         
         Observable *o = new Observable[2];
@@ -41,13 +41,13 @@
         o[1].value = 12.00;
 
-        if(i == 0) {
+        //if(i == 0) {
             currentParameters[0].name = "bandwidth";
             currentParameters[0].value = 300.0;
             currentParameters[1].name = "tx_power";
             currentParameters[1].value = 10.0;
-        } else {
-            currentParameters[0].value = p[0].value;
-            currentParameters[1].value = p[1].value;
-        }
+       // } else {
+       //     currentParameters[0].value = p[0].value;
+       //     currentParameters[1].value = p[1].value;
+       // }
 
 
@@ -55,15 +55,15 @@
     	// Note: mission name must match a mission 
 	// in the SML xml file
-        ret = SetActiveMission("test1");
+        SetActiveMission("0");
 
         // Send a request to the system for a new set of 
         //  parameters.
-        //p = GetOptimalParameters(o,numObservables,currentParameters,numParameters);
+        p = GetOptimalParameters(o,numObservables,currentParameters,numParameters);
         
-        //LOG("Application:: Received the following parameters.\n");
+        LOG("Application:: Received the following parameters.\n");
         
-        //for(size_t i = 0; i < numParameters; i++) {
-        //    LOG("%s:: %f\n", p[i].name.c_str(), p[i].value);
-        //}
+        for(size_t i = 0; i < numParameters; i++) {
+            LOG("%s:: %f\n", p[i].name.c_str(), p[i].value);
+        }
 
         // Simulate the REAL observable values after the
@@ -79,5 +79,5 @@
         delete [] p; 
         delete [] o; 
-    }
+    //}
 
     return 0;
Index: vtcross/trunk/src/libvtcross/libvtcross.cpp
===================================================================
--- vtcross/trunk/src/libvtcross/libvtcross.cpp	(revision 280)
+++ vtcross/trunk/src/libvtcross/libvtcross.cpp	(revision 285)
@@ -67,9 +67,8 @@
     SendMessage(socketfd, activeMission);
 
-    memset(buffer, 0, 256);
-    ReadMessage(socketfd, buffer);
-    uint32_t ret = atoi(buffer);
+    //memset(buffer, 0, 256);
+    //ReadMessage(socketfd, buffer);
 
-    return ret;
+    return 1;
 }
 
Index: vtcross/trunk/COPYING
===================================================================
--- vtcross/trunk/COPYING	(revision 161)
+++ vtcross/trunk/COPYING	(revision 285)
@@ -1,1 +1,1 @@
-link /usr/share/automake-1.10/COPYING
+link /usr/share/automake-1.9/COPYING
