Index: trunk/FACT++/src/ratescan.cc
===================================================================
--- trunk/FACT++/src/ratescan.cc	(revision 12653)
+++ trunk/FACT++/src/ratescan.cc	(revision 12654)
@@ -68,8 +68,8 @@
     DimDescribedService fDimProc;
 
-    int fCounter;
     int fSeconds;
-
     int fSecondsMax;
+
+    int fThreshold;
     int fThresholdMin;
     int fThresholdMax;
@@ -154,5 +154,5 @@
                 return;
 
-            if (fCounter<0/* || fStatusFTM.second!=FTM::kTakingData*/)
+            if (fThreshold<0/* || fStatusFTM.second!=FTM::kTakingData*/)
                 return;
 
@@ -176,5 +176,5 @@
             {
                 Message("Rate scan stopped due zero trigger rate.");
-                fCounter = -1;
+                fThreshold = -1;
                 return;
             }
@@ -208,5 +208,5 @@
 
             const double   time = sdata.fElapsedTime*fSeconds;
-            const uint32_t th   = fThresholdMin+fCounter*fThresholdStep;
+            const uint32_t th   = fThreshold;
 
             float data[2+3+1+40+160];
@@ -237,19 +237,17 @@
             fDimData.Update();
 
-            fCounter++;
+            fThreshold += fThresholdStep;
 
             if (fSeconds>=fSecondsMax)
             {
                 Message("Rate scan stopped due to timeout.");
-                fCounter=-1;
+                fThreshold=-1;
                 return;
             }
 
-            if (fThresholdMin+fCounter*fThresholdStep>fThresholdMax)
+            if (fThreshold>fThresholdMax)
             {
                 Message("Rate scan finished.");
-                fCounter = -1;
-
-                //DimClient::sendCommandNB("FTM_CONTROL/STOP_TRIGGER", NULL, 0);
+                fThreshold = -1;
                 return;
             }
@@ -257,5 +255,5 @@
             fSeconds = -2;  // FIXME: In principle one missed report is enough
 
-            const int32_t cmd[2] = { -1, fThresholdMin+fCounter*fThresholdStep };
+            const int32_t cmd[2] = { -1, fThreshold };
             DimClient::sendCommandNB(fCommand.c_str(), (void*)cmd, 8);
         }
@@ -324,5 +322,5 @@
         //Dim::SendCommand("FTM_CONTROL/STOP_TRIGGER");
 
-        fCounter = 0;
+        fThreshold = fThresholdMin;
         fSeconds = -2;
 
@@ -338,5 +336,5 @@
     int StopRateScan()
     {
-        fCounter = -1;
+        fThreshold = -1;
         Message("Rate scan manually stopped.");
 
@@ -431,5 +429,5 @@
         // At least one subsystem is not connected
         //        if (fStatusFTM.second>=FTM::kConnected)
-        return fCounter<0 ? kStateConnected : kStateInProgress;
+        return fThreshold<0 ? kStateConnected : kStateInProgress;
     }
 
@@ -447,5 +445,5 @@
                  "|max[DAC]:Value at which scan will end"
                  "|step[DAC]:Step size for scan"),
-        fCounter(-1), fReference(kCamera), fReferenceIdx(0)
+        fThreshold(-1), fReference(kCamera), fReferenceIdx(0)
     {
         // ba::io_service::work is a kind of keep_alive for the loop.
