Index: /trunk/FACT++/src/ratescan.cc
===================================================================
--- /trunk/FACT++/src/ratescan.cc	(revision 12240)
+++ /trunk/FACT++/src/ratescan.cc	(revision 12241)
@@ -91,4 +91,6 @@
     uint16_t    fReferenceIdx;
 
+    string fCommand;
+
     pair<Time, int> GetNewState(DimStampedInfo &info) const
     {
@@ -219,5 +221,5 @@
 
             const int32_t data[2] = { -1, fThresholdMin+fCounter*fThresholdStep };
-            DimClient::sendCommandNB("FTM_CONTROL/SET_THRESHOLD", (void*)data, 8);
+            DimClient::sendCommandNB(fCommand.c_str(), (void*)data, 8);
         }
     }
@@ -247,15 +249,19 @@
     }
 
-    int StartRateScan(const EventImp &evt)
+    int StartRateScan(const EventImp &evt, const string &command)
     {
         if (!CheckEventSize(evt.GetSize(), "StartRateScan", 12))
             return kSM_FatalError;
 
-        fThresholdMin   = evt.Get<uint32_t>();
-        fThresholdMax   = evt.Get<uint32_t>(4);
+        fCommand = "FTM_CONTROL/"+command;
+
+        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;
+        fout << "# ----- " << Time() << " -----\n";
+        fout << "# Command: " << fCommand << '\n';
         fout << "# Reference: ";
         switch (fReference)
@@ -274,5 +280,5 @@
         //Message("Starting Trigger (FTM)");
         //Dim::SendCommand("FTM_CONTROL/SET_PRESCALING", int32_t(20));
-        Dim::SendCommand("FTM_CONTROL/SET_THRESHOLD", data);
+        Dim::SendCommand(fCommand, data);
         //Dim::SendCommand("FTM_CONTROL/STOP_RUN");
 
@@ -372,5 +378,5 @@
         fFTM("FTM_CONTROL/STATE",       (void*)NULL, 0, this),
         fRates("FTM_CONTROL/TRIGGER_RATES", (void*)NULL, 0, this),
-        fCounter(-1)
+        fCounter(-1), fReference(kCamera), fReferenceIdx(0)
     {
         // ba::io_service::work is a kind of keep_alive for the loop.
@@ -394,7 +400,14 @@
                      "Rate scan in progress.");
 
-        AddEvent("START", "I:3", kStateConnected)
-            (bind(&StateMachineRateScan::StartRateScan, this, placeholders::_1))
-            ("Start rate scan for the defined range"
+        AddEvent("START_THRESHOLD_SCAN", "I:3", kStateConnected)
+            (bind(&StateMachineRateScan::StartRateScan, this, placeholders::_1, "SET_THRESHOLD"))
+            ("Start rate scan for the threshold in 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("START_N_OUT_OF_4_SCAN", "I:3", kStateConnected)
+            (bind(&StateMachineRateScan::StartRateScan, this, placeholders::_1, "SET_N_OUT_OF_4"))
+            ("Start rate scan for N-out-of-4 in the defined range"
              "|min[int]:Start value in DAC counts"
              "|max[int]:Limiting value in DAC counts"
