Changeset 18048 for trunk


Ignore:
Timestamp:
01/03/15 05:42:11 (10 years ago)
Author:
Daniela Dorner
Message:
added ratescan type
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/ratescan.cc

    r17645 r18048  
    3131{
    3232private:
     33    struct config
     34    {
     35        int fCounterMax;
     36        float fResolution;
     37    };
     38    map<string, config> fTypes;
     39
    3340    DimVersion fDim;
    3441
     
    226233    int StartRateScan(const EventImp &evt, const string &command)
    227234    {
    228         if (!CheckEventSize(evt, 12))
    229             return kSM_FatalError;
     235        //FIXME: check at least that size>12
     236        //if (!CheckEventSize(evt, 12))
     237        //    return kSM_FatalError;
     238
     239        string fType   = evt.Ptr<char>(12);
     240
     241        auto it = fTypes.find(fType);
     242        if (it==fTypes.end())
     243        {
     244            Info("StartRateScan - Type '"+fType+"' not found... trying 'default'.");
     245
     246            it = fTypes.find("default");
     247            if (it==fTypes.end())
     248            {
     249                Error("StartRateScan - Type 'default' not found.");
     250                return GetCurrentState();
     251            }
     252        }
     253        //const config &conf = it->second;
     254
     255        if (it!=fTypes.end())
     256        {
     257            fCounterMax=it->second.fCounterMax;
     258            fResolution=it->second.fResolution;
     259        }
    230260
    231261        fCommand = "FTM_CONTROL/"+command;
     
    287317        msg << "Rate scan " << now << "(" << fStartTime << ") from " << fThresholdMin << " to ";
    288318        msg << fThresholdMax << " in steps of " << fThresholdStep;
     319        msg << " with a resolution of " << fResolution ;
     320        msg << " and max-wait " << fCounterMax  ;
    289321        msg << " started.";
    290322        Message(msg);
     
    459491                     "Rate scan in progress but paused.");
    460492
    461         AddEvent("START_THRESHOLD_SCAN", "I:3", RateScan::State::kConnected)
     493        AddEvent("START_THRESHOLD_SCAN", "I:3;C", RateScan::State::kConnected)
    462494            (bind(&StateMachineRateScan::StartRateScan, this, placeholders::_1, "SET_THRESHOLD"))
    463495            ("Start rate scan for the threshold in the defined range"
    464496             "|min[int]:Start value in DAC counts"
    465497             "|max[int]:Limiting value in DAC counts"
    466              "|step[int]:Single step in DAC counts");
     498             "|step[int]:Single step in DAC counts"
     499             "|type[text]:Ratescan type");
    467500
    468501        AddEvent("START_N_OUT_OF_4_SCAN", "I:3", RateScan::State::kConnected)
     
    517550    int EvalOptions(Configuration &conf)
    518551    {
    519         fCounterMax = conf.Get<uint16_t>("max-wait");
    520         fResolution = conf.Get<double>("resolution");
    521 
     552        // ---------- Setup run types ---------
     553        const vector<string> types = conf.Vec<string>("type");
     554        if (types.empty())
     555            Warn("No types defined.");
     556        else
     557            Message("Defining types");
     558
     559        for (auto it=types.begin(); it!=types.end(); it++)
     560        {
     561            Message(" -> "+ *it);
     562
     563            if (fTypes.count(*it)>0)
     564            {
     565                Error("Type "+*it+" defined twice.");
     566                return 1;
     567            }
     568
     569            config &c = fTypes[*it];
     570            if (conf.HasDef("max-wait.", *it))
     571                c.fCounterMax = conf.GetDef<int>("max-wait.", *it);
     572            else
     573            {
     574                Error("Neither max-wait.default nor max-wait."+*it+" found.");
     575                return 2;
     576            }
     577            if (conf.HasDef("resolution.", *it))
     578                c.fResolution = conf.GetDef<double>("resolution.", *it);
     579            else
     580            {
     581                Error("Neither resolution.default nor resolution."+*it+" found.");
     582                return 2;
     583            }
     584        }
    522585        return -1;
    523586    }
     
    536599void SetupConfiguration(Configuration &conf)
    537600{
    538     po::options_description control("Rate scan options");
    539     control.add_options()
    540         ("max-wait",   var<uint16_t>(150), "The maximum number of seconds to wait to get the anticipated resolution for a point.")
    541         ("resolution", var<double>(0.05) , "The minimum resolution required for a single data point.")
    542         ;
    543 
    544     conf.AddOptions(control);
     601    po::options_description type("Ratescan type configuration");
     602    type.add_options()
     603        ("type",           vars<string>(),  "Name of ratescan types (replace the * in the following configuration by the case-sensitive names defined here)")
     604        ("max-wait.*",   var<int>(), "The maximum number of seconds to wait to get the anticipated resolution for a point.")
     605        ("resolution.*", var<double>() , "The minimum resolution required for a single data point.")
     606    ;
     607
     608    conf.AddOptions(type);
    545609}
    546610
Note: See TracChangeset for help on using the changeset viewer.