Changeset 16776 for trunk/FACT++/src


Ignore:
Timestamp:
06/08/13 12:55:12 (11 years ago)
Author:
tbretz
Message:
Implemented SET_SELECTED_THRESHOLDS to allow setting severalö thresholds during data taking at once... this should have a slightly higher performance than requesting a static data block after each setting. Maybe the difference is small, but nevertheless.
File:
1 edited

Legend:

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

    r16771 r16776  
    719719        return true;
    720720    }
    721     /*
     721
    722722    bool SetSelectedThresholds(const int32_t *th)
    723723    {
    724724        for (int i=0; i<FTM::StaticData::kMaxPatchIdx; i++)
    725             if (th[i]<0 || th[i]>FTM::StaticData::kMaxDAC)
     725            if (th[i]>FTM::StaticData::kMaxDAC)
    726726                return false;
    727727
     
    730730        for (int i=0; i<=FTM::StaticData::kMaxPatchIdx; i++)
    731731        {
    732             if (fBufStaticData[i/4].fDac[i%4]!=th[i])
    733             {
    734 
    735                 // Calculate offset in static data block
    736                 const uint16_t addr = (uintptr_t(&fStaticData[i/4].fDAC[i%4])-uintptr_t(&fStaticData))/2;
    737 
    738                 // From CmdSetRegister
    739                 const array<uint16_t, 2> data = {{ addr, uint16_t(th[i]) }};
    740                 PostCmd(data, FTM::kCmdWrite, FTM::kCmdRegister);
    741 
    742                 reinterpret_cast<uint16_t*>(&fBufStaticData)[addr] = th[i];
    743             }
    744         }
    745 
    746         // Now execute change before the static data is requested back
    747         PostCmd(FTM::kCmdConfigFTU, (patch/40) | (((patch/4)%10)<<8));
     732            if (th[i]<0 || fBufStaticData[i/4].fDAC[i%4]==th[i])
     733                continue;
     734
     735            // Calculate offset in static data block
     736            const uint16_t addr = (uintptr_t(&fStaticData[i/4].fDAC[i%4])-uintptr_t(&fStaticData))/2;
     737
     738            reinterpret_cast<uint16_t*>(&fBufStaticData)[addr] = th[i];
     739
     740            // From CmdSetRegister
     741            const array<uint16_t, 2> arr = {{ addr, uint16_t(th[i]) }};
     742            PostCmd(arr, FTM::kCmdWrite, FTM::kCmdRegister);
     743            PostCmd(FTM::kCmdConfigFTU, (i/40) | (((i/4)%10)<<8));
     744        }
    748745
    749746        //CmdGetRegister(addr);
     
    751748
    752749        return true;
    753     }*/
    754 
     750    }
    755751
    756752    bool SetAllThresholds(const int32_t *th)
     
    16321628    }
    16331629
     1630    int SetSelectedThresholds(const EventImp &evt)
     1631    {
     1632        if (!CheckEventSize(evt.GetSize(), "SetSelectedThresholds", 160*4))
     1633            return T::kSM_FatalError;
     1634
     1635        const int32_t *data = evt.Ptr<int32_t>();
     1636        if (!fFTM.SetSelectedThresholds(data))
     1637        {
     1638            ostringstream msg;
     1639            msg << "SetAllThresholds - Value out of range, maximum 0xffff.";
     1640            T::Warn(msg);
     1641        }
     1642
     1643        return T::GetCurrentState();
     1644    }
     1645
    16341646    int SetAllThresholds(const EventImp &evt)
    16351647    {
     
    21782190             "|Threshold[counts]:Threshold to be set in binary counts");
    21792191
    2180         T::AddEvent("SET_ALL_THRESHOLDS", "I:160", FTM::State::kIdle, FTM::State::kValid, FTM::State::kConfigured, FTM::State::kTriggerOn)
     2192        T::AddEvent("SET_SELECTED_THRESHOLDS", "I:160", FTM::State::kTriggerOn)
     2193            (bind(&StateMachineFTM::SetAllThresholds, this, placeholders::_1))
     2194            ("Set the comparator thresholds. Only thresholds which are different and >=0 are sent."
     2195             "|Thresholds[counts]:Threshold to be set in binary counts");
     2196
     2197        T::AddEvent("SET_ALL_THRESHOLDS", "I:160", FTM::State::kIdle, FTM::State::kValid, FTM::State::kConfigured)
    21812198            (bind(&StateMachineFTM::SetAllThresholds, this, placeholders::_1))
    21822199            ("Set the comparator thresholds"
Note: See TracChangeset for help on using the changeset viewer.