Changeset 13164 for trunk/FACT++


Ignore:
Timestamp:
03/22/12 10:21:37 (13 years ago)
Author:
tbretz
Message:
Implemented new command to set all offsets individually (for current control)
File:
1 edited

Legend:

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

    r13136 r13164  
    10441044    }
    10451045
     1046    bool SetGapdVoltages(const vector<float> &offset)
     1047    {
     1048        vector<int16_t> dac(kNumChannels);
     1049        for (size_t ch=0; ch<kNumChannels; ch++)
     1050        {
     1051            if (offset[ch]<-90 || offset[ch]>90)
     1052            {
     1053                ostringstream msg;
     1054                msg << "SetGapdVoltage - Offset voltage " << offset[ch] << "V of channel " << ch << " out of range [-90V,90V].";
     1055                Error(msg);
     1056                return false;
     1057            }
     1058
     1059            dac[ch] = offset[ch]*4096/90;
     1060
     1061            if (fDacGapd[ch]+dac[ch]>kMaxDac)
     1062            {
     1063                ostringstream msg;
     1064                msg << "SetGapdVoltage - New voltage reference " << fDacGapd[ch] << "+" << dac[ch] << " out of range [0," << kMaxDac << " for channel " << ch << ".";
     1065                Error(msg);
     1066                return false;
     1067            }
     1068        }
     1069
     1070        for (size_t ch=0; ch<kNumChannels; ch++)
     1071            fDacRef[ch] = fDacGapd[ch]+dac[ch]<0 ? 0 : fDacGapd[ch]+dac[ch];
     1072
     1073        if (!fIsRamping)
     1074            fIsRamping = RampOneStep();
     1075
     1076        return true;
     1077    }
     1078
    10461079    bool SetGapdReferenceCh(uint16_t ch)
    10471080    {
     
    15331566    }
    15341567
     1568    int SetGapdVoltages(const EventImp &evt)
     1569    {
     1570        if (!CheckEventSize(evt.GetSize(), "SetGapdVoltages", 4*416))
     1571            return false;
     1572
     1573        const float *ptr = evt.Ptr<float>();
     1574        fBias.SetGapdVoltages(vector<float>(ptr, ptr+416));
     1575
     1576        return T::GetCurrentState();
     1577    }
     1578
    15351579    // --------------------------------------------------------------------
    15361580
     
    19261970            ("Set all channels to their G-APD reference voltage plus the given offset. Starts ramping if necessary."
    19271971             "|offset[V]:Offset to be added to teh G-APD reference voltage globally");
     1972
     1973        T::AddEvent("SET_ALL_CHANNELS_OFFSET", "F:416", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent)
     1974            (bind(&StateMachineBias::SetGapdVoltages, this, placeholders::_1))
     1975            ("Set all channels to their G-APD reference voltage plus the given offset. Starts ramping if necessary."
     1976             "|offset[V]:Offset to be added to teh G-APD reference voltage");
    19281977
    19291978        T::AddEvent("SET_ZERO_VOLTAGE", kConnected, kVoltageOff, kVoltageOn, kNotReferenced, kOverCurrent)
Note: See TracChangeset for help on using the changeset viewer.