FACT++  1.0
StateMachineRateControl::StateMachineRateControl ( ostream &  out = cout)
inline

Definition at line 762 of file ratecontrol.cc.

References Calibrate(), CalibrateByCurrent(), CalibrateRun(), HandleCalibratedCurrents(), HandleStaticData(), HandleTriggerRates(), RateControl::State::kConnected, RateControl::State::kDimNetworkNA, RateControl::State::kDisconnected, RateControl::State::kGlobalThresholdSet, RateControl::State::kInProgress, RateControl::State::kSettingGlobalThreshold, Print(), SetMinThreshold(), SetTargetRate(), SetVerbosity(), StopRC(), DimState::Subscribe(), and DimDescribedState::Subscribe().

762  : StateMachineDim(out, "RATE_CONTROL"),
763  fPhysTriggerEnabled(false), fTriggerOn(false), fBlock(40),
764  fDimFTM("FTM_CONTROL"),
765  fDimRS("RATE_SCAN"),
766  fDimLid("LID_CONTROL"),
767  fDimDrive("DRIVE_CONTROL"),
768  fDimThreshold("RATE_CONTROL/THRESHOLD", "S:1;D:1;D:1",
769  "Resulting threshold after calibration"
770  "|threshold[dac]:Resulting threshold from calibration"
771  "|begin[mjd]:Start time of calibration"
772  "|end[mjd]:End time of calibration")
773  {
774  // ba::io_service::work is a kind of keep_alive for the loop.
775  // It prevents the io_service to go to stopped state, which
776  // would prevent any consecutive calls to run()
777  // or poll() to do nothing. reset() could also revoke to the
778  // previous state but this might introduce some overhead of
779  // deletion and creation of threads and more.
780 
781  fDim.Subscribe(*this);
782  fDimFTM.Subscribe(*this);
783  fDimRS.Subscribe(*this);
784  fDimLid.Subscribe(*this);
785  fDimDrive.Subscribe(*this);
786 
787  Subscribe("FTM_CONTROL/TRIGGER_RATES")
788  (bind(&StateMachineRateControl::HandleTriggerRates, this, placeholders::_1));
789  Subscribe("FTM_CONTROL/STATIC_DATA")
790  (bind(&StateMachineRateControl::HandleStaticData, this, placeholders::_1));
791  Subscribe("FEEDBACK/CALIBRATED_CURRENTS")
792  (bind(&StateMachineRateControl::HandleCalibratedCurrents, this, placeholders::_1));
793 
794  // State names
795  AddStateName(RateControl::State::kDimNetworkNA, "DimNetworkNotAvailable",
796  "The Dim DNS is not reachable.");
797 
799  "The Dim DNS is reachable, but the required subsystems are not available.");
800 
802  "All needed subsystems are connected to their hardware, no action is performed.");
803 
805  "A global minimum threshold is currently determined.");
806 
808  "A global threshold has ben set, waiting for the trigger to be switched on.");
809 
811  "Rate control in progress.");
812 
813  AddEvent("CALIBRATE")
815  ("Start a search for a reasonable minimum global threshold");
816 
817  AddEvent("CALIBRATE_BY_CURRENT")
819  ("Set the global threshold from the median current");
820 
821  AddEvent("CALIBRATE_RUN", "C")
822  (bind(&StateMachineRateControl::CalibrateRun, this, placeholders::_1))
823  ("Start a threshold calibration as defined in the setup for this run-type, state change to InProgress is delayed until trigger enabled");
824 
826  (bind(&StateMachineRateControl::StopRC, this))
827  ("Stop a calibration or ratescan in progress");
828 
829  AddEvent("SET_MIN_THRESHOLD", "I:1")
830  (bind(&StateMachineRateControl::SetMinThreshold, this, placeholders::_1))
831  ("Set a minimum threshold at which th rate control starts calibrating");
832 
833  AddEvent("SET_TARGET_RATE", "F:1")
834  (bind(&StateMachineRateControl::SetTargetRate, this, placeholders::_1))
835  ("Set a target trigger rate for the calibration");
836 
837  AddEvent("PRINT")
838  (bind(&StateMachineRateControl::Print, this))
839  ("Print current status");
840 
841  AddEvent("SET_VERBOSE", "B")
842  (bind(&StateMachineRateControl::SetVerbosity, this, placeholders::_1))
843  ("set verbosity state"
844  "|verbosity[bool]:disable or enable verbosity for received data (yes/no), except dynamic data");
845 
846  }
int CalibrateRun(const EventImp &evt)
Definition: ratecontrol.cc:593
EventImp & AddEvent(const std::string &name, const std::string &states, const std::string &fmt)
int SetMinThreshold(const EventImp &evt)
Definition: ratecontrol.cc:680
virtual void Subscribe(StateMachineImp &imp)
Definition: DimState.h:134
int HandleStaticData(const EventImp &evt)
Definition: ratecontrol.cc:376
int HandleTriggerRates(const EventImp &evt)
Definition: ratecontrol.cc:404
StateMachineDim(std::ostream &out=std::cout, const std::string &name="DEFAULT")
int HandleCalibratedCurrents(const EventImp &evt)
Definition: ratecontrol.cc:429
vector< bool > fBlock
Definition: ratecontrol.cc:54
int SetVerbosity(const EventImp &evt)
Definition: ratecontrol.cc:713
int SetTargetRate(const EventImp &evt)
Definition: ratecontrol.cc:692
DimDescribedState fDimDrive
Definition: ratecontrol.cc:60
DimDescribedService fDimThreshold
Definition: ratecontrol.cc:62
DimDescribedState fDimFTM
Definition: ratecontrol.cc:57
virtual void Subscribe(StateMachineImp &imp)
Definition: DimState.h:68
EventImp & Subscribe(const std::string &name)
DimDescribedState fDimLid
Definition: ratecontrol.cc:59
DimDescribedState fDimRS
Definition: ratecontrol.cc:58
bool AddStateName(const int state, const std::string &name, const std::string &doc="")

+ Here is the call graph for this function: