Index: /trunk/FACT++/src/smartfact.cc
===================================================================
--- /trunk/FACT++/src/smartfact.cc	(revision 13642)
+++ /trunk/FACT++/src/smartfact.cc	(revision 13643)
@@ -254,14 +254,20 @@
 
         template<class T>
-            Statistics(const T &t)
-        {
-            min = *min_element(t.begin(), t.end());
-            max = *max_element(t.begin(), t.end());
-            avg =  accumulate (t.begin(), t.end(), 0.)/t.size();
+            Statistics(const T &t, size_t offset_min=0, size_t offset_max=0)
+        {
+            T copy(t);
+            sort(copy.begin(), copy.end());
+
+            if (offset_min>t.size())
+                offset_min = 0;
+            if (offset_max>t.size())
+                offset_max = 0;
+
+            min = copy[offset_min];
+            max = copy[copy.size()-1-offset_max];
+            avg = accumulate (t.begin(), t.end(), 0.)/t.size();
 
             const size_t p = t.size()/2;
 
-            T copy(t);
-            nth_element(copy.begin(), copy.begin()+p, copy.end());
             med = copy[p];
         }
@@ -489,7 +495,7 @@
 
         // Write the 160 patch values to a file
-        WriteBinary("biascontrol-current", val, 1000);
-
-        const Statistics stat(v);
+        WriteBinary("biascontrol-current", val, 500);
+
+        const Statistics stat(v, 0, 3);
 
         // Exclude the three crazy channels
@@ -503,5 +509,5 @@
 
         // write the history to a file
-        WriteBinary("biascontrol-current-hist", fBiasControlCurrentHist, 1000);
+        WriteBinary("biascontrol-current-hist", fBiasControlCurrentHist, 500);
 
         ostringstream out;
@@ -700,5 +706,5 @@
             return;
 
-        if (HandleService(curr, fDimMcpConfiguration,       &StateMachineSmartFACT::configuHandleMcpConfiguration))
+        if (HandleService(curr, fDimMcpConfiguration,       &StateMachineSmartFACT::HandleMcpConfiguration))
             return;
         if (HandleService(curr, fDimMagicWeatherData,       &StateMachineSmartFACT::HandleMagicWeatherData))
@@ -826,9 +832,9 @@
             out << col << '\t' << fMcpConfigurationName;
 
-            if (fMcpConfigurationMaxEvents>0 || fMcpConfigurationState==12)
+            if (fMcpConfigurationMaxEvents>0 || fMcpConfigurationMaxTime>0 || fMcpConfigurationState==12)
                 out << " [";
             if (fMcpConfigurationMaxEvents>0)
                 out << fMcpConfigurationMaxEvents;
-            if (fMcpConfigurationMaxEvents>0 || fMcpConfigurationState==12)
+            if (fMcpConfigurationMaxEvents>0 && (fMcpConfigurationMaxTime>0 || fMcpConfigurationState==12))
                 out << '/';
             if (fMcpConfigurationMaxTime>0)
@@ -837,5 +843,5 @@
                     out << fMcpConfigurationMaxTime-(Time()-fMcpConfigurationRunStart).total_seconds() << 's';
                 else
-                    out << fMcpConfigurationMaxTime << 's';
+                    out << "[" << fMcpConfigurationMaxTime << "s]";
             }
             else
@@ -849,5 +855,5 @@
             }
 
-            if (fMcpConfigurationMaxEvents>0 || fMcpConfigurationState==12)
+            if (fMcpConfigurationMaxEvents>0 || fMcpConfigurationMaxTime>0 || fMcpConfigurationState==12)
                 out << ']';
         }
