Index: trunk/FACT++/src/ratescan.cc
===================================================================
--- trunk/FACT++/src/ratescan.cc	(revision 12209)
+++ trunk/FACT++/src/ratescan.cc	(revision 12210)
@@ -128,10 +128,10 @@
                 return;
 
-            if (fCounter<0 || fStatusFTM.second!=FTM::kTakingData)
+            if (fCounter<0/* || fStatusFTM.second!=FTM::kTakingData*/)
                 return;
 
             const FTM::DimTriggerRates &sdata = *static_cast<FTM::DimTriggerRates*>(curr->getData());
 
-            if (fSeconds++<0)
+            if (++fSeconds<0)
                 return;
 
@@ -168,5 +168,5 @@
                 sout2 << float(fTriggersPatch[i])/fSeconds << " ";
             sout3 << fSeconds << " ";
-            sout3 << float(sdata.fOnTimeCounter-fOnTimeStart)/fSeconds;
+            sout3 << float(sdata.fOnTimeCounter-fOnTimeStart)/fSeconds/1000000;
 
             cout << sout1.str() << sout3.str() << endl;
@@ -178,12 +178,14 @@
 
             fCounter++;
-            fSeconds = -2;
-
-            if (fThresholdMin+fCounter*fThresholdStep>fThresholdMax)
+
+            if (fSeconds>=fSecondsMax || fThresholdMin+fCounter*fThresholdStep>fThresholdMax)
             {
                 fCounter = -1;
-                DimClient::sendCommandNB("FTM_CONTROL/STOP_RUN", NULL, 0);
+                cout << "The END" << endl;
+                //DimClient::sendCommandNB("FTM_CONTROL/STOP_RUN", NULL, 0);
                 return;
             }
+
+            fSeconds = -2;  // FIXME: In principle one missed report is enough
 
             const int32_t data[2] = { -1, fThresholdMin+fCounter*fThresholdStep };
@@ -223,7 +225,7 @@
 
         Message("Starting Trigger (FTM)");
-        Dim::SendCommand("FTM_CONTROL/SET_PRESCALING", int32_t(0));
+        Dim::SendCommand("FTM_CONTROL/SET_PRESCALING", int32_t(20));
         Dim::SendCommand("FTM_CONTROL/SET_THRESHOLD", data);
-        Dim::SendCommand("FTM_CONTROL/START_RUN");
+        //Dim::SendCommand("FTM_CONTROL/STOP_RUN");
 
         fCounter = 0;
@@ -237,8 +239,8 @@
         fCounter = -1;
 
-        if (fStatusFTM.second==FTM::kTakingData)
+        //if (fStatusFTM.second==FTM::kTakingData)
 	{
             Message("Stopping FTM");
-	    Dim::SendCommand("FTM_CONTROL/STOP_RUN");
+	    //Dim::SendCommand("FTM_CONTROL/STOP_RUN");
         }
 
@@ -273,5 +275,6 @@
         fDim("DIS_DNS/VERSION_NUMBER",  (void*)NULL, 0, this),
         fFTM("FTM_CONTROL/STATE",       (void*)NULL, 0, this),
-        fRates("FTM_CONTROL/TRIGGER_RATES", (void*)NULL, 0, this)
+        fRates("FTM_CONTROL/TRIGGER_RATES", (void*)NULL, 0, this),
+        fCounter(-1)
     {
         // ba::io_service::work is a kind of keep_alive for the loop.
@@ -355,7 +358,8 @@
         }*/
 
-        fThresholdMin  = 100;
-        fThresholdMax  = 1000;
-        fThresholdStep = 25;
+        fThresholdMin  = 0;
+        fThresholdMax  = 100;
+        fThresholdStep = 1;
+
         fSecondsMax    = 150;
         fResolution    = 0.05;
