Changeset 18124 for trunk


Ignore:
Timestamp:
02/13/15 09:22:52 (10 years ago)
Author:
tbretz
Message:
Implemented an emergency limit in raw adc counts at which, if exceeded, the bias voltage is turned off and at which it goes to locked state. Default value is 2200.
File:
1 edited

Legend:

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

    r18116 r18124  
    6565    Time fLastConnect;
    6666
     67    int32_t  fEmergencyLimit;
     68    bool     fEmergencyShutdown;
     69
    6770protected:
    6871
     
    270273            fCurrent[id]    = status ? -(ddd==0?1:ddd) : ddd;
    271274            fPresent[board] = true;
     275
     276            if (fEmergencyLimit>0 && fCurrent[id]>fEmergencyLimit && !fEmergencyShutdown)
     277            {
     278                Info("Emergency shutdown initiated.");
     279                RampAllDacs(0);
     280                fEmergencyShutdown = true;
     281            }
    272282        }
    273283
     
    840850        fWaitingForAnswer(-1),
    841851        fCounter(8),
     852        fEmergencyLimit(0),
     853        fEmergencyShutdown(false),
    842854        fCurrent(kNumChannels),
    843855        fOperationVoltage(kNumChannels, 0),
     
    14981510        fReconnectDelay = delay;
    14991511    }
     1512
     1513    void SetEmergencyLimit(int32_t limit=0)
     1514    {
     1515        fEmergencyLimit = limit;
     1516    }
     1517
     1518    void ResetEmergencyShutdown()
     1519    {
     1520        fEmergencyShutdown = false;
     1521    }
     1522
     1523    bool IsEmergencyShutdown() const
     1524    {
     1525        return fEmergencyShutdown;
     1526    }
    15001527};
    15011528
     
    18791906        const int state = fBias.GetStatus();
    18801907
     1908        if (fBias.IsEmergencyShutdown() && state>State::kInitializing && state<State::kExpertMode)
     1909        {
     1910            fBias.RampAllDacs(0);
     1911            fBias.ResetEmergencyShutdown();
     1912            return State::kLocked;
     1913        }
     1914
    18811915        const Time now;
    18821916        if (now>fSunRise)
     
    19001934        }
    19011935
     1936        if (T::GetCurrentState()==State::kLocked)
     1937            return T::GetCurrentState();
     1938
    19021939        if (fExpertMode && state>=State::kConnected)
    19031940            return State::kExpertMode;
     
    19431980
    19441981        T::AddStateName(State::kLocked, "Locked",
    1945                         "Locked, no commands accepted except UNLOCK.");
     1982                        "Locked due to emergency shutdown, no commands accepted except UNLOCK.");
    19461983
    19471984        // Verbosity commands
     
    21212158        fBias.SetRampTime(time);
    21222159        fBias.SetUpdateInterval(conf.Get<uint32_t>("update-interval"));
     2160        fBias.SetEmergencyLimit(conf.Get<uint16_t>("emergency-limit"));
    21232161        fBias.SetSyncDelay(conf.Get<uint16_t>("sync-delay"));
    21242162
     
    22222260        ("bias-map-file",   var<string>(),       "File with nominal and offset voltages for each channel.")
    22232261        ("bias-database",   var<string>(),       "")
     2262        ("emergency-limit", var<uint16_t>(2200), "A current limit in ADC counts which, if exceeded, will initiate an emergency shutdown (0=off)")
    22242263        ;
    22252264
Note: See TracChangeset for help on using the changeset viewer.