Index: fact/Evidence/History.cc
===================================================================
--- fact/Evidence/History.cc	(revision 12894)
+++ fact/Evidence/History.cc	(revision 12909)
@@ -23,4 +23,5 @@
 #include <math.h>
 #include <float.h>
+#include <limits>
 #include <sys/stat.h>
 #include <sys/time.h>
@@ -44,4 +45,5 @@
 	  double LastValue;
 	  double MinAbsChange;
+	  pair <unsigned int, unsigned int> Range;
 	  string Format;
 	  time_t LastSave;
@@ -51,5 +53,4 @@
 	DimInfo *ServerList;
 	char *Directory;
-	string Change;
 
     void infoHandler();
@@ -73,5 +74,5 @@
 
   // Get/initialize configuration
-  Change = GetConfig("minchange", " ");
+  GetConfig("minchange", " ");
   GetConfig("maxsize_kb", DEFAULT_MAX_SIZE_KB);
   GetConfig("numentries", DEFAULT_NUM_ENTRIES);
@@ -161,16 +162,21 @@
   }
 
-  // If data is number of single type, check minumum change before adding to history
-  if (strcmp(I->getFormat(), "C") != 0) {
-	// Calculate sum of all number in array
-	istringstream Text(EvidenceServer::ToString(I->getFormat(), I->getData(), I->getSize()));
-	double Num, Sum = 0;
-	while (Text.good()) {
-	  Text >> Num;
-	  Sum += fabs(Num);
-	}
-
-	// Minimum change?
-	if (fabs(Sum-Map[Service].LastValue) < fabs(Map[Service].MinAbsChange)) return;
+  // Check minumum change before adding to history
+  if (Map[Service].MinAbsChange != 0) {
+	double Sum = 0;
+	unsigned int Count = 0;
+
+	// Add values within given range	
+	vector<string> Values = Tokenize(EvidenceServer::ToString(I->getFormat(), I->getData(), I->getSize()));
+
+	for (unsigned int i=0; i<Values.size(); i++) {
+	  if ((i < Map[Service].Range.first) || (i > Map[Service].Range.second)) continue;
+
+	  Sum += atof(Values[i].c_str());
+	  Count++;
+	}
+
+	// Minimum change of average value?	
+	if (Count>0 && (fabs(Sum-Map[Service].LastValue)/Count < fabs(Map[Service].MinAbsChange))) return;
 	Map[Service].LastValue = Sum;
   }
@@ -276,10 +282,27 @@
   Map[Name].Format = Format;
   Map[Name].MinAbsChange = 0.0;
+  Map[Name].Range = pair <unsigned int, unsigned int> (0, numeric_limits<unsigned int>::max());
   Map[Name].LastSave = 0.0;
   
   // Set minimum required change if given in configuratrion
+  string Change = GetConfig("minchange");
   size_t Pos = Change.find(Name+":");
-  if (Pos != string::npos) Map[Name].MinAbsChange = atof(Change.c_str() + Pos + Name.size() + 1);
-
+  
+  if (Pos != string::npos) {
+	vector<string> Parts = Tokenize(Change.substr(Pos, Change.find(' ', Pos)-Pos), ":");
+
+	// Check if index range is given as well  
+    if (Parts.size() == 2) Map[Name].MinAbsChange = atof(Parts[1].c_str());
+    else if (Parts.size() == 3) {
+	  Map[Name].MinAbsChange = atof(Parts[2].c_str());
+
+	  vector<string> Range = Tokenize(Parts[1], "-");
+	  if (Range.size() == 1) Map[Name].Range = pair <unsigned int, unsigned int> (atoi(Range[0].c_str()), atoi(Range[0].c_str()));
+	  else if (Range.size() == 2) Map[Name].Range = pair <unsigned int, unsigned int> (atoi(Range[0].c_str()), atoi(Range[1].c_str()));
+	}	
+  }
+
+  SendToLog("Subscribing to service '%s': MinAbsChange %f, Index range %u-%u\n", Name.c_str(),   Map[Name].MinAbsChange, Map[Name].Range.first, Map[Name].Range.second);
+  
   // Load history buffer from file if existing
   FILE *File = OpenFile(Name, "rb");
@@ -326,4 +349,6 @@
   if (Map.count(Name) == 0) return;
 
+  SendToLog("Unsubscribing service '%s'", Name.c_str());
+
   // Delete subscription first so handler and not called anymore
   delete Map[Name].DataItem;
Index: fact/Evidence/readme.txt
===================================================================
--- fact/Evidence/readme.txt	(revision 12894)
+++ fact/Evidence/readme.txt	(revision 12909)
@@ -54,4 +54,8 @@
 6/7/2011	Missing pthread_mutexattr_init() in Evidence constructor caused spurious errors when
 			locking mutex
-2/8/2011	Used inCallback() method of DIM version v19r23 to decide between blocking or non-blocking config request.
-			Updated EvidenceServer::ToString() for B and V formats.
+2/8/2011	Used inCallback() method of DIM version v19r23 to decide between blocking or
+			non-blocking config request. Updated EvidenceServer::ToString() for B and V formats.
+16/2/2012	EvidenceServer::ToString() handles more complex single-type formats (e.g. "F:1;F:4;F"
+18/2/2012	History server detection for minimum change takes an index range given in the configuration
+			into account (e.g. Service:a-b:0.4 requires an minimum absolute change of 0.4 for the average
+			value of indices a to b)
