Index: /vtcross/branches/trnewman/CR_shell/src/main_cognitive_radio.cpp
===================================================================
--- /vtcross/branches/trnewman/CR_shell/src/main_cognitive_radio.cpp	(revision 78)
+++ /vtcross/branches/trnewman/CR_shell/src/main_cognitive_radio.cpp	(revision 80)
@@ -22,4 +22,5 @@
 	string goal;
 	float target;
+    float value;
 };
 struct Affect {
@@ -35,4 +36,5 @@
 	float max;
 	float step;
+    float value;
 };
 
@@ -41,4 +43,5 @@
 	Affect affection_list[10];
 	int numAffects;
+    float value;
 };
 
@@ -53,5 +56,4 @@
 		cout << "     Target: " << uList[i]->target << endl;
 	}
-
 
 	for(i = 0; i < ce_info->numParameters; i++) {
@@ -65,5 +67,6 @@
 		}
 	}
-	for(i = 0; i < ce_info->numObservables; i++) {
+	
+    for(i = 0; i < ce_info->numObservables; i++) {
 		cout << "Observable:  " << oList[i]->name << endl;
 		for(j = 0; j < oList[i]->numAffects; j++) {
@@ -270,10 +273,10 @@
 	printf("Sending configuration to CE.\n");
  
+ 	// utilities
 	// Send number of utilities
 	sprintf(counter,"%d",ce_info->numUtilities);
 	SendMessage(socketfd,counter);
-		
- 	// utilities
-        for(i = 0; i < ce_info->numUtilities; i++) {
+	// send utility	
+    for(i = 0; i < ce_info->numUtilities; i++) {
 		SendMessage(socketfd,uList[i]->name);
 		SendMessage(socketfd,uList[i]->units);
@@ -284,5 +287,5 @@
 
 	// parameters
-        sprintf(counter,"%i",ce_info->numParameters);
+    sprintf(counter,"%i",ce_info->numParameters);
 	SendMessage(socketfd,counter);
 	for(i = 0; i < ce_info->numParameters; i++) {
@@ -304,5 +307,5 @@
 	}
 
-        // observables
+    // observables
 	sprintf(counter,"%i",ce_info->numObservables);
 	SendMessage(socketfd,counter);
@@ -351,5 +354,70 @@
 }
 
-void RunSimulator(int socketfd,Utility * uList[], Parameter * pList[], Observable * oList[], CE_Info * ce_info) {
+int UpdateRadioSettings(int sockfd, Utility *uList[], 
+        Parameter *pList[], Observable *oList[],
+        CE_Info *ce_info)
+{
+    char buffer[256];
+    string message;
+    int i;
+    float var;
+
+    // utility
+    // numUtilities
+    bzero(buffer,256);
+    message.erase();
+    ReceiveMessage(sockfd,message);
+    ce_info->numUtilities = atoi(message.c_str());
+    printf("number of utilities: %d\n", ce_info->numUtilities);
+    for (i = 0; i < ce_info->numUtilities; i++){
+        bzero(buffer,256);
+        message.erase();
+        ReceiveMessage(sockfd,message);
+        var = atof(message.c_str());
+        uList[i]->value = var;
+        printf("utility %s, value: %f\n", 
+                uList[i]->name, uList[i]->value);
+    }
+    
+    // paramter
+    // numparameters
+    /*bzero(buffer,256);*/
+    message.erase();
+    ReceiveMessage(sockfd,message);
+    ce_info->numParameters = atoi(message.c_str());
+    printf("number of parameters: %d\n", ce_info->numParameters);
+    for (i = 0; i < ce_info->numParameters; i++){
+        /*bzero(buffer,256);*/
+        message.erase();
+        ReceiveMessage(sockfd,message);
+        var = atof(message.c_str());
+        pList[i]->value = var;
+        printf("parameter %s, value: %f\n", 
+                pList[i]->name, pList[i]->value);
+    }
+
+    // observable
+    // numObservables
+    /*bzero(buffer,256);
+    ReceiveMessage(sockfd,buffer);*/
+    message.erase();
+    ReceiveMessage(sockfd,message);
+    ce_info->numObservables = atoi(message.c_str());
+    printf("number of observables: %d\n", ce_info->numObservables);
+    for (i = 0; i < ce_info->numObservables; i++){
+        /*bzero(buffer,256);
+        ReceiveMessage(sockfd,buffer);*/
+        message.erase();
+        ReceiveMessage(sockfd,message);
+        var = atof(message.c_str());
+        oList[i]->value = var;
+        printf("observable %s, value: %f\n", 
+                oList[i]->name, oList[i]->value);
+    }
+}
+
+void RunSimulator(int socketfd, Utility * uList[], 
+        Parameter * pList[], Observable * oList[], 
+        CE_Info * ce_info) {
 
 	// Set fake past environment -  
@@ -360,5 +428,5 @@
 
 	// Act like we are updating the hardware tranmission settings
-	UpdateRadioSettings();
+	UpdateRadioSettings(socketfd, uList, pList, oList, ce_info);
 
 	// Send back fake utility values
@@ -366,9 +434,9 @@
 }
 
-void StartMessaging(int socketfd,Utility * uList[], Parameter * pList[], Observable * oList[], CE_Info * ce_info) {
-
-	LoadCEConfiguration(socketfd,uList, pList, oList, ce_info);
-
-	RunSimulator(socketfd,uList, pList, oList, ce_info);
+void StartMessaging(int socketfd, Utility * uList[], Parameter * pList[], Observable * oList[], CE_Info * ce_info) {
+
+	LoadCEConfiguration(socketfd, uList, pList, oList, ce_info);
+
+	RunSimulator(socketfd, uList, pList, oList, ce_info);
 }
 
@@ -400,5 +468,5 @@
 
 		// Begin parsing the messages
-		StartMessaging(newsockfd,uList, pList, oList, ce_info);
+		StartMessaging(newsockfd, uList, pList, oList, ce_info);
 	//}
 	return 0;
