Index: /trunk/FACT++/src/ratescan.cc
===================================================================
--- /trunk/FACT++/src/ratescan.cc	(revision 18047)
+++ /trunk/FACT++/src/ratescan.cc	(revision 18048)
@@ -31,4 +31,11 @@
 {
 private:
+    struct config
+    {
+        int fCounterMax;
+        float fResolution;
+    };
+    map<string, config> fTypes;
+
     DimVersion fDim;
 
@@ -226,6 +233,29 @@
     int StartRateScan(const EventImp &evt, const string &command)
     {
-        if (!CheckEventSize(evt, 12))
-            return kSM_FatalError;
+        //FIXME: check at least that size>12
+        //if (!CheckEventSize(evt, 12))
+        //    return kSM_FatalError;
+
+        string fType   = evt.Ptr<char>(12);
+
+        auto it = fTypes.find(fType);
+        if (it==fTypes.end())
+        {
+            Info("StartRateScan - Type '"+fType+"' not found... trying 'default'.");
+
+            it = fTypes.find("default");
+            if (it==fTypes.end())
+            {
+                Error("StartRateScan - Type 'default' not found.");
+                return GetCurrentState();
+            }
+        }
+        //const config &conf = it->second;
+
+        if (it!=fTypes.end())
+        {
+            fCounterMax=it->second.fCounterMax;
+            fResolution=it->second.fResolution;
+        }
 
         fCommand = "FTM_CONTROL/"+command;
@@ -287,4 +317,6 @@
         msg << "Rate scan " << now << "(" << fStartTime << ") from " << fThresholdMin << " to ";
         msg << fThresholdMax << " in steps of " << fThresholdStep;
+        msg << " with a resolution of " << fResolution ;
+        msg << " and max-wait " << fCounterMax  ;
         msg << " started.";
         Message(msg);
@@ -459,10 +491,11 @@
                      "Rate scan in progress but paused.");
 
-        AddEvent("START_THRESHOLD_SCAN", "I:3", RateScan::State::kConnected)
+        AddEvent("START_THRESHOLD_SCAN", "I:3;C", RateScan::State::kConnected)
             (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");
+             "|step[int]:Single step in DAC counts"
+             "|type[text]:Ratescan type");
 
         AddEvent("START_N_OUT_OF_4_SCAN", "I:3", RateScan::State::kConnected)
@@ -517,7 +550,37 @@
     int EvalOptions(Configuration &conf)
     {
-        fCounterMax = conf.Get<uint16_t>("max-wait");
-        fResolution = conf.Get<double>("resolution");
-
+        // ---------- Setup run types ---------
+        const vector<string> types = conf.Vec<string>("type");
+        if (types.empty())
+            Warn("No types defined.");
+        else
+            Message("Defining types");
+
+        for (auto it=types.begin(); it!=types.end(); it++)
+        {
+            Message(" -> "+ *it);
+
+            if (fTypes.count(*it)>0)
+            {
+                Error("Type "+*it+" defined twice.");
+                return 1;
+            }
+
+            config &c = fTypes[*it];
+            if (conf.HasDef("max-wait.", *it))
+                c.fCounterMax = conf.GetDef<int>("max-wait.", *it);
+            else
+            {
+                Error("Neither max-wait.default nor max-wait."+*it+" found.");
+                return 2;
+            }
+            if (conf.HasDef("resolution.", *it))
+                c.fResolution = conf.GetDef<double>("resolution.", *it);
+            else
+            {
+                Error("Neither resolution.default nor resolution."+*it+" found.");
+                return 2;
+            }
+        }
         return -1;
     }
@@ -536,11 +599,12 @@
 void SetupConfiguration(Configuration &conf)
 {
-    po::options_description control("Rate scan options");
-    control.add_options()
-        ("max-wait",   var<uint16_t>(150), "The maximum number of seconds to wait to get the anticipated resolution for a point.")
-        ("resolution", var<double>(0.05) , "The minimum resolution required for a single data point.")
-        ;
-
-    conf.AddOptions(control);
+    po::options_description type("Ratescan type configuration");
+    type.add_options()
+        ("type",           vars<string>(),  "Name of ratescan types (replace the * in the following configuration by the case-sensitive names defined here)")
+        ("max-wait.*",   var<int>(), "The maximum number of seconds to wait to get the anticipated resolution for a point.")
+        ("resolution.*", var<double>() , "The minimum resolution required for a single data point.")
+    ;
+
+    conf.AddOptions(type);
 }
 
