Changeset 11948 for trunk/FACT++


Ignore:
Timestamp:
09/02/11 12:49:35 (13 years ago)
Author:
tbretz
Message:
Added new command to globally increase/decrease the reference voltage; Werner updated some help texts
File:
1 edited

Legend:

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

    r11943 r11948  
    756756    bool ChannelSetVolt(uint16_t ch, double volt)
    757757    {
     758        if (volt<0 || volt>90)
     759        {
     760            Error("ChannelSetVolt - Voltage out of range [0V,90V].");
     761            return false;
     762        }
     763
    758764        return ChannelSetDac(ch, volt*4096/90.);
    759765    }
     
    775781    bool GlobalSetVolt(float volt)
    776782    {
     783        if (volt<0 || volt>90)
     784        {
     785            Error("GlobalSetVolt - Voltage out of range [0V,90V].");
     786            return false;
     787        }
     788
    777789        return GlobalSetDac(volt*4096/90);
    778790    }
    779791
    780     // --------------------------------------------------------------------
    781 
    782     bool SetGapdVoltage()
     792    bool GlobalAddDac(int16_t dac)
    783793    {
    784794        for (size_t ch=0; ch<kNumChannels; ch++)
    785             if (fVoltGapd[ch]>kMaxDac)
     795        {
     796            if (fVoltRef[ch]+dac>kMaxDac)
    786797            {
    787                 Error("SetGapdVoltage - Voltage reference for G-APD channel out of range.");
     798                Error("GlobalAddDac - New voltage reference out of range.");
    788799                return false;
    789800            }
    790801
     802            if (fVoltRef[ch]+dac<0)
     803                fVoltRef[ch] = 0;
     804            else
     805                fVoltRef[ch]+= dac;
     806        }
     807
     808        if (!fIsRamping)
     809            fIsRamping = RampOneStep();
     810
     811        return true;
     812    }
     813
     814    bool GlobalAddVolt(float offset)
     815    {
     816        if (offset<-90 || offset>90)
     817        {
     818            Error("GlobalAddVolt - Offset out of range [-90V,90V].");
     819            return false;
     820        }
     821
     822        return GlobalAddDac(offset*4096/90);
     823    }
     824
     825    // --------------------------------------------------------------------
     826
     827    bool SetGapdVoltage(float offset)
     828    {
     829        if (offset<-90 || offset>90)
     830        {
     831            Error("SetGapdVoltage - Offset out of range [-90V,90V].");
     832            return false;
     833        }
     834
     835        const int16_t dac = offset*4096/90;
     836
    791837        for (size_t ch=0; ch<kNumChannels; ch++)
    792             fVoltRef[ch] = fVoltGapd[ch];
     838            if (fVoltGapd[ch]+dac>kMaxDac)
     839            {
     840                Error("SetGapdVoltage - New voltage reference out of range.");
     841                return false;
     842            }
     843
     844        for (size_t ch=0; ch<kNumChannels; ch++)
     845            fVoltRef[ch] = fVoltGapd[ch]+dac<0 ? 0 : fVoltGapd[ch]+dac;
    793846
    794847        if (!fIsRamping)
     
    11921245    // --------------------------------------------------------------------
    11931246
     1247    int SetGapdVoltage(const EventImp &evt)
     1248    {
     1249        if (!CheckEventSize(evt.GetSize(), "SetGapdVoltage", 4))
     1250            return false;
     1251
     1252        fBias.SetGapdVoltage(evt.GetFloat());
     1253
     1254        return T::GetCurrentState();
     1255    }
     1256
     1257    // --------------------------------------------------------------------
     1258
    11941259    int SetGlobalVolt(const EventImp &evt)
    11951260    {
     
    11971262            return false;
    11981263
    1199         if (!fBias.GlobalSetVolt(evt.GetFloat()))
    1200             T::Error("Supplied voltage out of range (0-90)");
     1264        fBias.GlobalSetVolt(evt.GetFloat());
    12011265
    12021266        return T::GetCurrentState();
     
    12081272            return false;
    12091273
    1210         if (!fBias.GlobalSetDac(evt.GetUShort()))
    1211             T::Error("Supplied voltage out of range (0-90)");
     1274        fBias.GlobalSetDac(evt.GetUShort());
    12121275
    12131276        return T::GetCurrentState();
    12141277    }
    12151278
     1279    int IncGlobalVolt(const EventImp &evt)
     1280    {
     1281        if (!CheckEventSize(evt.GetSize(), "IncGlobalVolt", 4))
     1282            return false;
     1283
     1284        fBias.GlobalAddVolt(evt.GetFloat());
     1285
     1286        return T::GetCurrentState();
     1287    }
     1288
     1289    int IncGlobalDac(const EventImp &evt)
     1290    {
     1291        if (!CheckEventSize(evt.GetSize(), "IncGlobalDac", 2))
     1292            return false;
     1293
     1294        fBias.GlobalAddDac(evt.GetShort());
     1295
     1296        return T::GetCurrentState();
     1297    }
     1298
     1299    int DecGlobalVolt(const EventImp &evt)
     1300    {
     1301        if (!CheckEventSize(evt.GetSize(), "DecGlobalVolt", 4))
     1302            return false;
     1303
     1304        fBias.GlobalAddVolt(-evt.GetFloat());
     1305
     1306        return T::GetCurrentState();
     1307    }
     1308
     1309    int DecGlobalDac(const EventImp &evt)
     1310    {
     1311        if (!CheckEventSize(evt.GetSize(), "DecGlobalDac", 2))
     1312            return false;
     1313
     1314        fBias.GlobalAddDac(-evt.GetShort());
     1315
     1316        return T::GetCurrentState();
     1317    }
     1318
    12161319    int SetChannelVolt(const EventImp &evt)
    12171320    {
     
    12191322            return false;
    12201323
    1221         if (!fBias.ChannelSetVolt(evt.GetUShort(), evt.Get<float>(2)))
    1222             T::Error("Value out of range");
     1324        fBias.ChannelSetVolt(evt.GetUShort(), evt.Get<float>(2));
    12231325
    12241326        return T::GetCurrentState();
     
    12301332            return false;
    12311333
    1232         if (!fBias.ChannelSetDac(evt.Get<uint16_t>(), evt.Get<uint16_t>(2)))
    1233             T::Error("Value out of range");
     1334        fBias.ChannelSetDac(evt.Get<uint16_t>(), evt.Get<uint16_t>(2));
    12341335
    12351336        return T::GetCurrentState();
     
    12431344            return false;
    12441345
    1245         if (!fBias.ExpertGlobalSetVolt(evt.GetFloat()))
    1246             T::Error("Supplied voltage out of range (0-90)");
     1346        fBias.ExpertGlobalSetVolt(evt.GetFloat());
    12471347
    12481348        return T::GetCurrentState();
     
    12541354            return false;
    12551355
    1256         if (!fBias.ExpertGlobalSetDac(evt.GetUShort()))
    1257             T::Error("Supplied voltage out of range (0-90)");
     1356        fBias.ExpertGlobalSetDac(evt.GetUShort());
    12581357
    12591358        return T::GetCurrentState();
     
    12651364            return false;
    12661365
    1267         if (!fBias.ExpertChannelSetVolt(evt.GetUShort(), evt.Get<float>(2)))
    1268             T::Error("Value out of range");
     1366        fBias.ExpertChannelSetVolt(evt.GetUShort(), evt.Get<float>(2));
    12691367
    12701368        return T::GetCurrentState();
     
    12761374            return false;
    12771375
    1278         if (!fBias.ExpertChannelSetDac(evt.Get<uint16_t>(), evt.Get<uint16_t>(2)))
    1279             T::Error("Value out of range");
     1376        fBias.ExpertChannelSetDac(evt.Get<uint16_t>(), evt.Get<uint16_t>(2));
    12801377
    12811378        return T::GetCurrentState();
     
    14251522            ("Set all channels to a new DAC reference. Starts ramping if necessary. (This command is not realized with the GLOBAL SET command.)");
    14261523
     1524        T::AddEvent("INCREASE_GLOBAL_VOLTAGE", "F:1", kConnected, kAtReference, kOverCurrent)
     1525            (bind(&StateMachineBias::IncGlobalVolt, this, placeholders::_1))
     1526            ("Set all channels to a new reference voltage. Starts ramping if necessary. (This command is not realized with the GLOBAL SET command.)");
     1527
     1528        T::AddEvent("INCREASE_GLOBAL_DAC", "S:1", kConnected, kAtReference, kOverCurrent)
     1529            (bind(&StateMachineBias::IncGlobalDac, this, placeholders::_1))
     1530            ("Set all channels to a new DAC reference. Starts ramping if necessary. (This command is not realized with the GLOBAL SET command.)");
     1531
     1532        T::AddEvent("DECREASE_GLOBAL_VOLTAGE", "F:1", kConnected, kAtReference, kOverCurrent)
     1533            (bind(&StateMachineBias::DecGlobalVolt, this, placeholders::_1))
     1534            ("Set all channels to a new reference voltage. Starts ramping if necessary. (This command is not realized with the GLOBAL SET command.)");
     1535
     1536        T::AddEvent("DECREASE_GLOBAL_DAC", "S:1", kConnected, kAtReference, kOverCurrent)
     1537            (bind(&StateMachineBias::DecGlobalDac, this, placeholders::_1))
     1538            ("Set all channels to a new DAC reference. Starts ramping if necessary. (This command is not realized with the GLOBAL SET command.)");
     1539
    14271540        T::AddEvent("SET_CHANNEL_VOLTAGE", "S:1;F:1", kConnected, kAtReference, kOverCurrent)
    14281541            (bind(&StateMachineBias::SetChannelVolt, this, placeholders::_1))
     
    14341547
    14351548        T::AddEvent("SET_GAPD_REFERENCE_VOLTAGE", kConnected, kAtReference, kOverCurrent)
    1436             (Wrapper(bind(&ConnectionBias::SetGapdVoltage, &fBias)))
     1549            (Wrapper(bind(&ConnectionBias::SetGapdVoltage, &fBias, 0.)))
    14371550            ("Set all channels to their G-APD reference voltage. Starts ramping if necessary.");
     1551
     1552        T::AddEvent("SET_GAPD_REFERENCE_OFFSET", "F:1", kConnected, kAtReference, kOverCurrent)
     1553            (bind(&StateMachineBias::SetGapdVoltage, this, placeholders::_1))
     1554            ("Set all channels to their G-APD reference voltage plus the given offset. Starts ramping if necessary.");
    14381555
    14391556        T::AddEvent("SET_ZERO_VOLTAGE", kConnected, kAtReference, kOverCurrent)
     
    16061723        ("dev",             var<string>("FTE00FOH"),  "Device address of USB port to bias-power supply")
    16071724        ("quiet,q",         po_bool(),           "Disable printing contents of all received messages (except dynamic data) in clear text.")
    1608         ("ramp-time",       var<uint16_t>(15),   "Delay between the answer of one ramping steps and sending the next ramp command to all channels in milliseconds.")
     1725        ("ramp-time",       var<uint16_t>(15),   "Delay between the answer of one ramping step and sending the next ramp command to all channels in milliseconds.")
    16091726        ("ramp-step",       var<uint16_t>(46),   "Maximum step in DAC counts during ramping (Volt = DAC*90/4096)")
    16101727        ("update-interval", var<uint16_t>(3000), "Interval between two current requests in milliseconds")
     
    16301747{
    16311748    cout <<
    1632         "The biasctrl controls the bias-power supply boards.\n"
     1749        "The biasctrl program controls the bias-power supply boards.\n"
    16331750        "\n"
    1634         "The default is that the program is started without user intercation. "
    1635         "All actions are supposed to arrive as DimCommands. Using the -c "
    1636         "option, a local shell can be initialized. With h or help a short "
    1637         "help message about the usuage can be brought to the screen.\n"
     1751        "Note: At default the program is started without a command line (user) "
     1752        "interface. In this case Actions/Commands are available via Dim "
     1753        "exclusively.\n"
     1754        "Use the -c option to start the program with a command line interface.\n"
     1755        "\n"
     1756        "In the running application:\n"
     1757        "Use h or help to print a short help message about its usage.\n"
    16381758        "\n"
    16391759        "Usage: biasctrl [-c type] [OPTIONS]\n"
Note: See TracChangeset for help on using the changeset viewer.