Changeset 16445 for trunk/FACT++/src


Ignore:
Timestamp:
05/30/13 00:23:28 (11 years ago)
Author:
tbretz
Message:
Added time to output; Require the physics trigger be enables and switched on to go to InProgress; leave InProgress if one of the two conditions is not fullfilled anymore; print a message when stop was received.
File:
1 edited

Legend:

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

    r16282 r16445  
    4848    PixelMap fMap;
    4949
     50    bool fPhysTriggerEnabled;
    5051    bool fTriggerOn;
    5152
     
    100101        //    return;
    101102
    102         if (!fThresholds.empty())
     103        if (fThresholds.empty())
    103104            return;
    104105
     
    360361
    361362        const FTM::DimStaticData &sdata = *static_cast<const FTM::DimStaticData*>(evt.GetData());
    362         fTriggerOn = sdata.HasTrigger();
    363 
     363        fPhysTriggerEnabled = sdata.HasTrigger();
     364        fTriggerOn = (evt.GetQoS()&FTM::kFtmStates)==FTM::kFtmRunning;
     365
     366        Out() << "\n" << evt.GetTime() << ": " << (bool)fTriggerOn << " " << (bool)fPhysTriggerEnabled << endl;
    364367        PrintThresholds(sdata);
    365368
     
    371374    int HandleTriggerRates(const EventImp &evt)
    372375    {
     376        fTriggerOn = (evt.GetQoS()&FTM::kFtmStates)==FTM::kFtmRunning;
     377
    373378        if (fThresholds.empty())
    374379            return GetCurrentState();
     
    523528    int Calibrate()
    524529    {
    525         if (!fTriggerOn)
     530        if (!fPhysTriggerEnabled)
    526531        {
    527532            Info("Physics trigger not enabled... CALIBRATE command ignored.");
     
    551556    int CalibrateByCurrent()
    552557    {
    553         if (!fTriggerOn)
     558        if (!fPhysTriggerEnabled)
    554559        {
    555560            Info("Physics trigger not enabled... CALIBRATE command ignored.");
     
    596601            Info("No calibration requested.");
    597602            return RateControl::State::kGlobalThresholdSet;
     603            break;
    598604
    599605        case 1:
     
    615621    int StopRC()
    616622    {
     623        Info("Stop received.");
    617624        return RateControl::State::kConnected;
    618625    }
     
    669676            return RateControl::State::kDisconnected;
    670677
    671         const bool inprog = fTriggerOn && fDimRS.state()<RateScan::State::kConfiguring;
     678        // Do not allow any action while a ratescan is configured or in progress
     679        if (fDimRS.state()>=RateScan::State::kConfiguring)
     680            return RateControl::State::kConnected;
    672681
    673682        switch (GetCurrentState())
     
    677686
    678687        case RateControl::State::kGlobalThresholdSet:
    679             if (!inprog)
    680                 return RateControl::State::kGlobalThresholdSet;
     688
     689            // Wait for the trigger to get switched on before starting control loop
     690            if (fTriggerOn && fPhysTriggerEnabled)
     691                return RateControl::State::kInProgress;
     692
     693            return RateControl::State::kGlobalThresholdSet;
    681694
    682695        case RateControl::State::kInProgress:
    683             if (inprog)
    684                 return RateControl::State::kInProgress;
     696
     697            // Go back to connected when the trigger has been switched off
     698            if (!fTriggerOn || !fPhysTriggerEnabled)
     699                return RateControl::State::kConnected;
     700
     701            return RateControl::State::kInProgress;
    685702        }
    686703
     
    690707public:
    691708    StateMachineRateControl(ostream &out=cout) : StateMachineDim(out, "RATE_CONTROL"),
    692         fTriggerOn(false), fBlock(40),
     709        fPhysTriggerEnabled(false), fTriggerOn(false), fBlock(40),
    693710        fDimFTM("FTM_CONTROL"),
    694711        fDimRS("RATE_SCAN"),
     
    748765        AddEvent("CALIBRATE_RUN", "C")
    749766            (bind(&StateMachineRateControl::CalibrateRun, this, placeholders::_1))
    750             ("Start a threshold calibration as defined in the setup for this run-type");
     767            ("Start a threshold calibration as defined in the setup for this run-type, state change to InProgress is delayed until trigger enabled");
    751768
    752769        AddEvent("STOP", RateControl::State::kSettingGlobalThreshold, RateControl::State::kGlobalThresholdSet, RateControl::State::kInProgress)
Note: See TracChangeset for help on using the changeset viewer.