Changeset 11777 for trunk


Ignore:
Timestamp:
08/04/11 20:07:06 (13 years ago)
Author:
tbretz
Message:
Added options to set N/4 threshold; renamed options for thresholds.
File:
1 edited

Legend:

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

    r11763 r11777  
    708708
    709709        /*
     710          if (data[patch/4].fDAC[patch%4] == value)
     711             return true;
     712          */
     713 
     714        // Calculate offset in static data block
     715        const uint16_t addr = (uintptr_t(&fStaticData[patch/4].fDAC[patch%4])-uintptr_t(&fStaticData))/2;
     716
     717        // From CmdSetRegister
     718        const array<uint16_t, 2> data = {{ addr, uint16_t(value) }};
     719        PostCmd(data, FTM::kCmdWrite, FTM::kCmdRegister);
     720
     721        reinterpret_cast<uint16_t*>(&fBufStaticData)[addr] = value;
     722
     723        // Now execute change before the static data is requested back
     724        PostCmd(FTM::kCmdConfigFTU, (patch/40) | (((patch/4)%10)<<8));
     725
     726        //CmdGetRegister(addr);
     727        CmdReqStatDat();
     728
     729        return true;
     730    }
     731
     732    bool SetNoutof4(int32_t patch, int32_t value)
     733    {
     734        if (patch>=FTM::StaticData::kMaxMultiplicity)
     735            return false;
     736
     737        if (value<0 || value>FTM::StaticData::kMaxDAC)
     738            return false;
     739
     740        if (patch<0)
     741        {
     742            FTM::StaticData data(fStaticData);
     743
     744            bool ident = true;
     745            for (int i=0; i<FTM::StaticData::kMaxMultiplicity; i++)
     746                if (data[i].fDAC[4] != value)
     747                {
     748                    ident = false;
     749                    break;
     750                }
     751
     752            if (ident)
     753                return true;
     754
     755            for (int i=0; i<=FTM::StaticData::kMaxMultiplicity; i++)
     756                data[i].fDAC[4] = value;
     757
     758            // Maybe move to a "COMMIT" command?
     759            CmdSendStatDat(data);
     760
     761            return true;
     762        }
     763
     764        /*
    710765         if (data[patch/4].fDAC[patch%4] == value)
    711766            return true;
     
    718773
    719774        // Calculate offset in static data block
    720         const uint16_t addr = (uintptr_t(&fStaticData[patch/4].fDAC[patch%4])-uintptr_t(&fStaticData))/2;
     775        const uint16_t addr = (uintptr_t(&fStaticData[patch].fDAC[4])-uintptr_t(&fStaticData))/2;
    721776
    722777        // From CmdSetRegister
     
    14251480    }
    14261481
     1482    int SetNoutof4(const EventImp &evt)
     1483    {
     1484        if (!CheckEventSize(evt.GetSize(), "SetNoutof4", 8))
     1485            return T::kSM_FatalError;
     1486
     1487        const int32_t *data = evt.Ptr<int32_t>();
     1488
     1489        if (!fFTM.SetNoutof4(data[0], data[1]))
     1490            T::Warn("SetNoutof4 - Maximum allowed board number 39, valid value range 0-0xffff");
     1491
     1492        return T::GetCurrentState();
     1493    }
     1494
    14271495    int EnableFTU(const EventImp &evt)
    14281496    {
     
    19211989             "|status[bool]:disable or enable that the FTM sends rate reports (yes/no)");
    19221990
    1923        T::AddEvent("SET_THRESHOLD", "I:2", FTM::kIdle, FTM::kTakingData)
     1991        T::AddEvent("SET_THRESHOLD", "I:2", FTM::kIdle, FTM::kTakingData)
    19241992            (bind(&StateMachineFTM::SetThreshold, this, placeholders::_1))
    19251993            ("Set the comparator threshold"
    19261994             "|Patch[idx]:Index of the patch (0-159), -1 for all"
     1995             "|Threshold[counts]:Threshold to be set in binary counts");
     1996
     1997        T::AddEvent("SET_N_OUT_OF_4", "I:2", FTM::kIdle, FTM::kTakingData)
     1998            (bind(&StateMachineFTM::SetNoutof4, this, placeholders::_1))
     1999            ("Set the comparator threshold"
     2000             "|Board[idx]:Index of the board (0-39), -1 for all"
    19272001             "|Threshold[counts]:Threshold to be set in binary counts");
    19282002
     
    20652139        // A new configure will first stop the FTM this means
    20662140        // we can allow it in idle _and_ taking data
    2067         T::AddEvent("CONFIGURE", "C", FTM::kIdle, FTM::kTakingData)
     2141        T::AddEvent("CONFIGURE", "C", FTM::kIdle, FTM::kConfiguring1, FTM::kConfiguring2, FTM::kConfigured, FTM::kTakingData)
    20682142            (bind(&StateMachineFTM::ConfigureFTM, this, placeholders::_1))
    20692143            ("");
     
    22622336                !CheckConfigVal<uint16_t>(conf, data.kMaxIntensity,       "light-pulser.external.intensity.",     *it) ||
    22632337                !CheckConfigVal<uint16_t>(conf, data.kMaxIntensity,       "light-pulser.internal.intensity.",     *it) ||
    2264                 !CheckConfigVal<uint16_t>(conf, data.kMaxDAC,             "trigger.threshold.pixel.",             *it) ||
    2265                 !CheckConfigVal<uint16_t>(conf, data.kMaxDAC,             "trigger.threshold.patch.",            *it) ||
     2338                !CheckConfigVal<uint16_t>(conf, data.kMaxDAC,             "trigger.threshold.patch.",             *it) ||
     2339                !CheckConfigVal<uint16_t>(conf, data.kMaxDAC,             "trigger.threshold.logic.",             *it) ||
    22662340                0)
    22672341                return 2;
     
    23362410            }
    23372411
    2338             const uint16_t th0 = conf.GetDef<uint16_t>("trigger.threshold.pixel.", *it);
    2339             const uint16_t th1 = conf.GetDef<uint16_t>("trigger.threshold.patch.", *it);
     2412            const uint16_t th0 = conf.GetDef<uint16_t>("trigger.threshold.patch.", *it);
     2413            const uint16_t th1 = conf.GetDef<uint16_t>("trigger.threshold.logic.", *it);
    23402414
    23412415            for (int i=0; i<40; i++)
     
    24332507        ("trigger.disable-pixel.*",              vars<uint16_t>(), "")
    24342508        ("trigger.disable-patch.*",              vars<uint16_t>(), "")
    2435         ("trigger.threshold.pixel.*",            var<uint16_t>(),  "")
    24362509        ("trigger.threshold.patch.*",            var<uint16_t>(),  "")
     2510        ("trigger.threshold.logic.*",            var<uint16_t>(),  "")
    24372511        ("ftu-report-interval.*",                var<uint16_t>(),  "")
    24382512        ("light-pulser.external.enable-group1.*", var<bool>(),     "Enable LED group 1 of external light pulser")
Note: See TracChangeset for help on using the changeset viewer.