Changeset 18606 for trunk/FACT++


Ignore:
Timestamp:
09/17/16 19:33:02 (8 years ago)
Author:
tbretz
Message:
Better handling of special cases like when the lid is closed or the drive is not moving.
File:
1 edited

Legend:

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

    r18599 r18606  
    1515
    1616#include "HeadersFTM.h"
     17#include "HeadersLid.h"
    1718#include "HeadersDrive.h"
    1819#include "HeadersRateScan.h"
     
    5657    DimDescribedState fDimFTM;
    5758    DimDescribedState fDimRS;
     59    DimDescribedState fDimLid;
    5860    DimDescribedState fDimDrive;
    5961
     
    433435        // Record only currents when the drive is tracking to avoid
    434436        // bias from the movement
    435         if (fDimDrive.state()<Drive::State::kTracking)
     437        if (fDimDrive.state()<Drive::State::kTracking || fDimLid.state()==Lid::State::kClosed)
    436438            return GetCurrentState();
    437439
     
    553555    int Calibrate()
    554556    {
    555         if (!fPhysTriggerEnabled)
    556         {
    557             Info("Physics trigger not enabled... CALIBRATE command ignored.");
    558 
    559             fTriggerOn = false;
    560             fPhysTriggerEnabled = false;
    561             return RateControl::State::kGlobalThresholdSet;
    562         }
    563 
    564557        const int32_t val[2] = { -1, fThresholdReference };
    565558        Dim::SendCommandNB("FTM_CONTROL/SET_THRESHOLD", val);
     
    584577    int CalibrateByCurrent()
    585578    {
    586         if (!fPhysTriggerEnabled)
    587         {
    588             Info("Physics trigger not enabled... CALIBRATE command ignored.");
    589 
    590             fTriggerOn = false;
    591             fPhysTriggerEnabled = false;
    592             return RateControl::State::kGlobalThresholdSet;
    593         }
    594 
    595         if (fDimDrive.state()<Drive::State::kMoving)
    596             Warn("Drive not even moving...");
    597 
    598579        fCounter = 0;
    599580        fCalibrateByCurrent = true;
     
    629610        const config &conf = it->second;
    630611
     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;
     621                return RateControl::State::kGlobalThresholdSet;
     622            }
     623
     624            if (fDimLid.state()==Lid::State::kClosed)
     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 };
     636                fDimThreshold.setQuality(3);
     637                fDimThreshold.Update(data);
     638
     639                fCalibrateByCurrent = true;
     640                fTriggerOn = false;
     641                fPhysTriggerEnabled = false;
     642                return RateControl::State::kSettingGlobalThreshold;
     643            }
     644
     645            if (fDimDrive.state()<Drive::State::kMoving)
     646                Warn("Calibration requested, but drive not even moving...");
     647        }
     648
    631649        switch (conf.fCalibrationType)
    632650        {
     
    687705        Out() << fDimFTM << endl;
    688706        Out() << fDimRS << endl;
     707        Out() << fDimLid << endl;
    689708        Out() << fDimDrive << endl;
    690709
     
    745764        fDimFTM("FTM_CONTROL"),
    746765        fDimRS("RATE_SCAN"),
     766        fDimLid("LID_CONTROL"),
    747767        fDimDrive("DRIVE_CONTROL"),
    748768        fDimThreshold("RATE_CONTROL/THRESHOLD", "S:1;D:1;D:1",
     
    762782        fDimFTM.Subscribe(*this);
    763783        fDimRS.Subscribe(*this);
     784        fDimLid.Subscribe(*this);
    764785        fDimDrive.Subscribe(*this);
    765786
Note: See TracChangeset for help on using the changeset viewer.