FACT++  1.0
int StateMachineRateControl::CalibrateRun ( const EventImp evt)
inlineprivate

Definition at line 593 of file ratecontrol.cc.

References data, Error(), StateMachineRateControl::config::fAverageTime, StateMachineRateControl::config::fCalibrationType, StateMachineRateControl::config::fMinThreshold, StateMachineRateControl::config::fRequiredEvents, StateMachineRateControl::config::fTargetRate, EventImp::GetText(), Lid::State::kClosed, RateControl::State::kGlobalThresholdSet, Drive::State::kMoving, RateControl::State::kSettingGlobalThreshold, Time::Mjd(), Dim::SendCommandNB(), DimService::setQuality(), DimState::state(), and DimDescribedService::Update().

Referenced by StateMachineRateControl().

594  {
595  const string name = evt.GetText();
596 
597  auto it = fRunTypes.find(name);
598  if (it==fRunTypes.end())
599  {
600  Info("CalibrateRun - Run-type '"+name+"' not found... trying 'default'.");
601 
602  it = fRunTypes.find("default");
603  if (it==fRunTypes.end())
604  {
605  Error("CalibrateRun - Run-type 'default' not found.");
606  return GetCurrentState();
607  }
608  }
609 
610  const config &conf = it->second;
611 
612  if (conf.fCalibrationType!=0)
613  {
614 
615  if (!fPhysTriggerEnabled)
616  {
617  Info("Calibration requested, but physics trigger not enabled... CALIBRATE command ignored.");
618 
619  fTriggerOn = false;
620  fPhysTriggerEnabled = false;
622  }
623 
625  {
626  Info("Calibration requested, but lid closed... setting all thresholds to "+to_string(conf.fMinThreshold)+".");
627 
628  const int32_t val[2] = { -1, conf.fMinThreshold };
629  Dim::SendCommandNB("FTM_CONTROL/SET_THRESHOLD", val);
630 
631  fThresholds.assign(160, conf.fMinThreshold);
632 
633  const double mjd = Time().Mjd();
634 
635  const RateControl::DimThreshold data = { conf.fMinThreshold, mjd, mjd };
637  fDimThreshold.Update(data);
638 
639  fCalibrateByCurrent = true;
640  fTriggerOn = false;
641  fPhysTriggerEnabled = false;
643  }
644 
646  Warn("Calibration requested, but drive not even moving...");
647  }
648 
649  switch (conf.fCalibrationType)
650  {
651  case 0:
652  Info("No calibration requested.");
653  fTriggerOn = false;
654  fPhysTriggerEnabled = false;
656  break;
657 
658  case 1:
659  fThresholdReference = conf.fMinThreshold;
660  fTargetRate = conf.fTargetRate;
661  return Calibrate();
662 
663  case 2:
664  fThresholdReference = conf.fMinThreshold;
665  fAverageTime = conf.fAverageTime;
666  fRequiredEvents = conf.fRequiredEvents;
667  return CalibrateByCurrent();
668  }
669 
670  Error("CalibrateRun - Calibration type "+to_string(conf.fCalibrationType)+" unknown.");
671  return GetCurrentState();
672  }
int GetCurrentState() const
return the current state of the machine
const char * GetText() const
Definition: EventImp.h:88
void setQuality(int quality)
Definition: discpp.cxx:1256
Adds some functionality to boost::posix_time::ptime for our needs.
Definition: Time.h:30
const int32_t & state() const
Definition: DimState.h:80
void Mjd(double mjd)
Definition: Time.cc:145
map< string, config > fRunTypes
Definition: ratecontrol.cc:47
int Error(const std::string &str)
Definition: MessageImp.h:49
DimDescribedState fDimDrive
Definition: ratecontrol.cc:60
void SendCommandNB(const std::string &command)
Definition: Dim.h:30
int Warn(const std::string &str)
Definition: MessageImp.h:48
DimDescribedService fDimThreshold
Definition: ratecontrol.cc:62
float data[4 *1440]
DimDescribedState fDimLid
Definition: ratecontrol.cc:59
int Info(const std::string &str)
Definition: MessageImp.h:47
vector< uint32_t > fThresholds
Definition: ratecontrol.cc:98

+ Here is the call graph for this function:

+ Here is the caller graph for this function: