- Timestamp:
- 01/03/15 05:42:11 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/ratescan.cc
r17645 r18048 31 31 { 32 32 private: 33 struct config 34 { 35 int fCounterMax; 36 float fResolution; 37 }; 38 map<string, config> fTypes; 39 33 40 DimVersion fDim; 34 41 … … 226 233 int StartRateScan(const EventImp &evt, const string &command) 227 234 { 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 } 230 260 231 261 fCommand = "FTM_CONTROL/"+command; … … 287 317 msg << "Rate scan " << now << "(" << fStartTime << ") from " << fThresholdMin << " to "; 288 318 msg << fThresholdMax << " in steps of " << fThresholdStep; 319 msg << " with a resolution of " << fResolution ; 320 msg << " and max-wait " << fCounterMax ; 289 321 msg << " started."; 290 322 Message(msg); … … 459 491 "Rate scan in progress but paused."); 460 492 461 AddEvent("START_THRESHOLD_SCAN", "I:3 ", RateScan::State::kConnected)493 AddEvent("START_THRESHOLD_SCAN", "I:3;C", RateScan::State::kConnected) 462 494 (bind(&StateMachineRateScan::StartRateScan, this, placeholders::_1, "SET_THRESHOLD")) 463 495 ("Start rate scan for the threshold in the defined range" 464 496 "|min[int]:Start value in DAC counts" 465 497 "|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"); 467 500 468 501 AddEvent("START_N_OUT_OF_4_SCAN", "I:3", RateScan::State::kConnected) … … 517 550 int EvalOptions(Configuration &conf) 518 551 { 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 } 522 585 return -1; 523 586 } … … 536 599 void SetupConfiguration(Configuration &conf) 537 600 { 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); 545 609 } 546 610
Note:
See TracChangeset
for help on using the changeset viewer.