Index: trunk/FACT++/src/ratescan.cc
===================================================================
--- trunk/FACT++/src/ratescan.cc	(revision 12237)
+++ trunk/FACT++/src/ratescan.cc	(revision 12238)
@@ -169,5 +169,5 @@
                 reference = fTriggersPatch[fReferenceIdx];
 
-            if (sqrt(reference)>fResolution*reference && fSeconds<fSecondsMax)
+            if ((reference==0 || sqrt(reference)>fResolution*reference) && fSeconds<fSecondsMax)
             {
                 ostringstream out;
@@ -176,4 +176,5 @@
                     out << " (" << sqrt(reference)/reference << ")";
                 Info(out);
+
                 return;
             }
@@ -238,6 +239,13 @@
     }
 
-    int StartRateScan()
-    {
+    int StartRateScan(const EventImp &evt)
+    {
+        if (!CheckEventSize(evt.GetSize(), "StartRateScan", 12))
+            return kSM_FatalError;
+
+        fThresholdMin   = evt.Get<uint32_t>();
+        fThresholdMax   = evt.Get<uint32_t>(4);
+        fThresholdStep = evt.Get<uint32_t>(8);
+
         ofstream fout("ratescan.txt", ios::app);
         fout << "# ----- " << Time() << " -----" << endl;
@@ -257,5 +265,5 @@
 
         Message("Starting Trigger (FTM)");
-        Dim::SendCommand("FTM_CONTROL/SET_PRESCALING", int32_t(20));
+        //Dim::SendCommand("FTM_CONTROL/SET_PRESCALING", int32_t(20));
         Dim::SendCommand("FTM_CONTROL/SET_THRESHOLD", data);
         //Dim::SendCommand("FTM_CONTROL/STOP_RUN");
@@ -371,11 +379,10 @@
                      "Rate scan in progress.");
 
-        AddEvent("START", kStateConnected)
-            (bind(&StateMachineRateScan::StartRateScan, this))
-            ("");
-
-        AddEvent("START", kStateConnected)
-            (bind(&StateMachineRateScan::StartRateScan, this))
-            ("");
+        AddEvent("START", "I:3", kStateConnected)
+            (bind(&StateMachineRateScan::StartRateScan, this, placeholders::_1))
+            ("Start rate scan for the defined range"
+             "|min[int]:Start value in DAC counts"
+             "|max[int]:Limiting value in DAC counts"
+             "|step[int]:Single step in DAC counts");
 
         AddEvent("STOP", kStateInProgress)
@@ -428,4 +435,12 @@
 //             "|verbosity[bool]:disable or enable verbosity for received data (yes/no), except dynamic data");
 */
+/*
+        AddEvent("SET_RANGE", "I:3")
+            (bind(&StateMachineRateScan::SetRange, this, placeholders::_1))
+            ("Set raneg for ratescane"
+             "|min[int]:Start value in DAC counts"
+             "|max[int]:Limiting value in DAC counts"
+             "|step[int]:Single step in DAC counts");
+*/
         AddEvent("PRINT")
             (bind(&StateMachineRateScan::Print, this))
@@ -441,8 +456,4 @@
             return 1;
         }*/
-
-        fThresholdMin  = 0;
-        fThresholdMax  = 100;
-        fThresholdStep = 1;
 
         fSecondsMax    = 150;
