All kinds methods to setup and test FEBs. More...
#include <FebUtil.h>
Data Structures | |
struct | RunCond |
Container for run conditions for acquireData(). More... | |
Public Types | |
enum | LoopState { kLoopStopped = 0, kLoopInterrupted, kLoopRunning } |
Public Member Functions | |
FebUtil (FebBase *feb, QuickDaq *qdaq=0) | |
Constructor with full addressing path information. | |
virtual | ~FebUtil () |
void | startLoop (double time) |
Initializes test loop context. | |
bool | testLoop () |
Iteration test in test loop. | |
void | interruptLoop () |
Terminate loop by interrupt. | |
void | stopLoop () |
Terminate loop. | |
uint64_t | getLoopCount () const |
Returns the number of test loop iterations. | |
double | getStartLoopTime () const |
Returns the time of last startLoop(). | |
double | getTestLoopTime () const |
Returns the time of last testLoop(). | |
int | getLoopState () const |
Returns loop state (kLoopStopped, kLoopInterrupted or kLoopRunning). | |
int | saveFeb (NxContext cntx[4], int domask=nxyter::kDoAll) |
Save context of all nXYTER. | |
int | restoreFeb (NxContext cntx[4], int domask=nxyter::kDoAll) |
Restore context of all nXYTER. | |
int | acquireTestTriggerData (int nxind, int npuls, DistFuncArray &dfa, bool cleardist=true) |
Acquire data for test trigger runs for a single nXYTER. | |
int | acquireTestTriggerData (int nxind, int npuls, NxDataSummary &nds) |
Aquire data for test trigger runs for a single nXYTER. | |
int | acquireTestPulserData (int nxind, const NxContext &cntx, int npuls, DistFuncArray &dfa) |
Acquire data for test pulser runs for a single nXYTER. | |
int | acquireTestPulserData (int nxind, const NxContext &cntx, int npuls, NxDataSummary &nds) |
Aquire data for test pulser runs for a single nXYTER. | |
int | testNxControlPath (int nxind, double time) |
Test nXYTER control path. | |
int | testNxRegisters (int nxind) |
Test nXYTER registers. | |
int | testMainAdcControlPath (double time) |
Test MainAdc control path. | |
int | testMainAdcDataPath (double time) |
Test MainAdc data path. | |
int | testFebControlPathCombo (double time) |
Test control path of all nXYTER of a FEB with random patterns. | |
Static Public Member Functions | |
static void | probe (base::Board *board, bool verbose=true, std::ostream &os=std::cout) |
Probes for ADC and nXYTERs and prints a report to os. | |
static double | now () |
Returns current time as a double . | |
Protected Attributes | |
FebBase * | fFeb |
FEB under test. | |
QuickDaq * | fQdaq |
QuickDaq for all DAQ. | |
int | fLoopState |
loop state | |
double | fStartLoopTime |
time of last startLoop() | |
double | fTestLoopTime |
time of last testLoop() | |
double | fTestTime |
maximal duration of test | |
uint64_t | fLoopCount |
test loop counter |
All kinds methods to setup and test FEBs.
Definition at line 22 of file FebUtil.h.
Constructor with full addressing path information.
Definition at line 31 of file FebUtil.cxx.
nxyter::FebUtil::~FebUtil | ( | ) | [virtual] |
Definition at line 44 of file FebUtil.cxx.
int nxyter::FebUtil::acquireTestPulserData | ( | int | nxind, | |
const NxContext & | cntx, | |||
int | npuls, | |||
DistFuncArray & | dfa | |||
) |
Acquire data for test pulser runs for a single nXYTER.
This method will
Only data received from the selected nXYTER will be accumulated in the distribution function array dfa.
nxind | nXYTER index of the nXYTER to be inspected | |
cntx | context of nXYTER under study with Mask part filled | |
npuls | number of test pulses to be accumulated | |
dfa | DistFuncArray object to return the data |
std::out_of_range | if nxind out of range |
Definition at line 320 of file FebUtil.cxx.
References acquireTestTriggerData(), fFeb, fQdaq, roc::I2cDevice::getRegister(), nxyter::NxChip::i2c(), nxyter::kDoMask, nxyter::kNxC1CalibSelectMask, nxyter::kNxRegConfig1, nxyter::FebBase::nx(), nxyter::NxContext::setChannelMaskBit(), nxyter::NxI2c::setContext(), and roc::I2cDevice::setRegister().
Referenced by acquireTestPulserData(), and cmd_scanvbiasf().
int nxyter::FebUtil::acquireTestPulserData | ( | int | nxind, | |
const NxContext & | cntx, | |||
int | npuls, | |||
NxDataSummary & | nds | |||
) |
Aquire data for test pulser runs for a single nXYTER.
Like acquireTestPulserData(int nxind, NxContext cntx, int npuls, DistFuncArray& dfa) but returns already reduced data in a NxDataSummary object nds.
Definition at line 363 of file FebUtil.cxx.
References acquireTestPulserData(), nxyter::NxDataSummary::analyse(), and nxyter::DistFuncArray::setMaxEntries().
int nxyter::FebUtil::acquireTestTriggerData | ( | int | nxind, | |
int | npuls, | |||
NxDataSummary & | nds | |||
) |
Aquire data for test trigger runs for a single nXYTER.
Like acquireTestTriggerData(int nxind, int npuls, DistFuncArray& dfa) but returns already reduced data in a NxDataSummary object nds.
Definition at line 291 of file FebUtil.cxx.
References acquireTestTriggerData(), nxyter::NxDataSummary::analyse(), and nxyter::DistFuncArray::setMaxEntries().
int nxyter::FebUtil::acquireTestTriggerData | ( | int | nxind, | |
int | npuls, | |||
DistFuncArray & | dfa, | |||
bool | cleardist = true | |||
) |
Acquire data for test trigger runs for a single nXYTER.
This method will
Only data received from the selected nXYTER will be accumulated in the distribution function array dfa.
nxind | nXYTER index of the nXYTER to be inspected | |
npuls | number of test pulses to be accumulated | |
dfa | DistFuncArray object to return the data | |
cleardist | if true dfa is cleared before filling |
std::out_of_range | if nxind out of range |
Definition at line 236 of file FebUtil.cxx.
References nxyter::DistFuncArray::addEntry(), nxyter::DistFuncArray::clear(), nxyter::QuickDaqStats::errorCount(), fFeb, fQdaq, base::Peripheral::getBoard(), roc::Message::getNxAdcValue(), roc::Message::getNxChNum(), roc::Message::getNxNumber(), nxyter::NxChip::getNxNumber(), roc::Message::isHitMsg(), nxyter::QuickDaqStats::kPrintError, nxyter::QuickDaq::msg(), nxyter::QuickDaq::nextRunNxMask(), nxyter::FebBase::nx(), nxyter::QuickDaqStats::print(), nxyter::QuickDaq::startRun(), nxyter::QuickDaq::stats(), and nxyter::QuickDaq::testRun().
Referenced by acquireTestPulserData(), acquireTestTriggerData(), cmd_idsigch(), cmd_scanadclat(), and get_vbiass_data().
uint64_t nxyter::FebUtil::getLoopCount | ( | ) | const [inline] |
Returns the number of test loop iterations.
true
responses of testLoop() after the last startLoop(). Definition at line 62 of file FebUtil.h.
References fLoopCount.
Referenced by print_loop_stats().
int nxyter::FebUtil::getLoopState | ( | ) | const [inline] |
Returns loop state (kLoopStopped, kLoopInterrupted or kLoopRunning).
Definition at line 74 of file FebUtil.h.
References fLoopState.
Referenced by cmd_testnxcntl(), and cmd_testnxregs().
double nxyter::FebUtil::getStartLoopTime | ( | ) | const [inline] |
Returns the time of last startLoop().
Definition at line 66 of file FebUtil.h.
References fStartLoopTime.
Referenced by print_loop_stats().
double nxyter::FebUtil::getTestLoopTime | ( | ) | const [inline] |
Returns the time of last testLoop().
Definition at line 70 of file FebUtil.h.
References fStartLoopTime.
void nxyter::FebUtil::interruptLoop | ( | ) |
Terminate loop by interrupt.
When running the loop state is kLoopRunning. A call to this method will change the loop state to kLoopInterrupted. The testLoop() method will return false
when the loop state is no longer kLoopRunning, thus causing the test loop to be terminated.
Main application for this method is to be called from a signal handler, often a SIGINT handler to catch a ^C. The code example below shows how such a SIGINT handler can be implemented.
void hdl_int(int sig, siginfo_t *info, void *cnxt) { p_to_febutil->interruptLoop(); } int main(int argc, char* argv[]) { struct sigaction act; memset (&act, '\0', sizeof(act)); act.sa_sigaction = &hdl_int; act.sa_flags = SA_SIGINFO; if (sigaction(SIGINT, &act, 0) < 0) { perror ("sigaction"); } ... }
With such a handler test loops will be gracefully terminated upon ^C.
Definition at line 105 of file FebUtil.cxx.
References fLoopState, and kLoopRunning.
Referenced by hdl_int().
double nxyter::FebUtil::now | ( | ) | [static] |
Returns current time as a double
.
Definition at line 943 of file FebUtil.cxx.
Referenced by print_loop_stats(), startLoop(), and testLoop().
void nxyter::FebUtil::probe | ( | base::Board * | board, | |
bool | verbose = true , |
|||
std::ostream & | os = std::cout | |||
) | [static] |
Probes for ADC and nXYTERs and prints a report to os.
Uses the nxyter::MainAdc::probe() and nxyter::NxI2c::probe() and FebBase::discoverFebs() methods to scan both ports of the ROC. Currently the even I2C addresses between 2 and 126 are probed, this is the range conceptually accessible in the current FEBs.
When verbose is true
, a detailed list of all probe return codes is given, it can be helpfull to determine why a device isn't probed successfully. A typical list looks like
adc 0 : rc = 8,20 -> readback verify error nx 0, 8: rc = 0,21 -> secondary bus error ... adc 1 : rc = 0, 0 -> success nx 1, 8: rc = 0, 0 -> success nx 1, 10: rc = 6,20 -> readback verify error ...
The report ends always with a summary of the form like
Full MainAdc.probe() and NxI2c::probe() scan found: port adc ----- nx i2c slave address in range 2,..,126, only even ------- 11111111111111 000011111222223333344444555556666677777888889999900000111112222 246802468024680246802468024680246802468024680246802468024680246 0 y ---y----------------------------------------------------------- 1 - --------------------------------------------------------------- Autoconfigure with FebBase::discoverFebs() found: port 0 : Feb1nxGenC port 1 : nothing
os | output stream | |
board | ROC board pointer | |
verbose | if true , the return codes of all probes are listed |
Definition at line 861 of file FebUtil.cxx.
References nxyter::FebBase::discoverFebs(), base::Board::operErrCode(), base::Board::operErrCodeName(), base::Board::operErrIndex(), nxyter::NxI2c::probe(), nxyter::MainAdc::probe(), and nxyter::FebBase::typeToString().
Referenced by cmd_discover().
int nxyter::FebUtil::restoreFeb | ( | nxyter::NxContext | cntx[4], | |
int | domask = nxyter::kDoAll | |||
) |
Restore context of all nXYTER.
The context of nXYTER of the current FEB which are not set 'offline' is restored from the context array cntx. The domask determines which parts are saved.
cntx | array of NxContext objects. cntx[i] is used to restore the context of the nXYTER with nXYTER index i. | |
domask | one or several of the mask bits nxyter::kDoMask, nxyter::kDoCore, or nxyter::kDoTrim |
Definition at line 204 of file FebUtil.cxx.
References fFeb, nxyter::FebBase::getNxOffline(), nxyter::NxChip::i2c(), nxyter::FebBase::numNx(), nxyter::FebBase::nx(), and nxyter::NxI2c::setContext().
int nxyter::FebUtil::saveFeb | ( | nxyter::NxContext | cntx[4], | |
int | domask = nxyter::kDoAll | |||
) |
Save context of all nXYTER.
The context of nXYTER of the current FEB which are not set 'offline' is saved in the context array cntx. The domask determines which parts are saved.
cntx | array of NxContext objects. cntx[i] will hold the saved context of the nXYTER with nXYTER index i. | |
domask | one or several of the mask bits nxyter::kDoMask, nxyter::kDoCore, or nxyter::kDoTrim |
Definition at line 175 of file FebUtil.cxx.
References fFeb, nxyter::NxI2c::getContext(), nxyter::FebBase::getNxOffline(), nxyter::NxChip::i2c(), nxyter::FebBase::numNx(), and nxyter::FebBase::nx().
void nxyter::FebUtil::startLoop | ( | double | time | ) |
Initializes test loop context.
The test loop logic is documented in detail under testLoop(). This method initializes the context, resets the counter and time keeping logic.
time | time in seconds the next test loop should be active. A time 0. results in indefinite execution, in this case the loop is usually terminated via ^C and an interruptLoop() call or via a stopLoop() call. |
Definition at line 60 of file FebUtil.cxx.
References fLoopCount, fLoopState, fStartLoopTime, fTestTime, and now().
Referenced by cmd_autoped(), cmd_autovbiass(), cmd_geti2c(), cmd_idsigch(), cmd_printdatadbg(), cmd_scanadclat(), cmd_scanmonadc(), cmd_scanvbiasf(), cmd_scanvbiass(), cmd_seti2c(), cmd_testnxdata(), testFebControlPathCombo(), testMainAdcControlPath(), testMainAdcDataPath(), testNxControlPath(), and testNxRegisters().
void nxyter::FebUtil::stopLoop | ( | ) |
Terminate loop.
When running the loop state is kLoopRunning. A call to this method will change the loop state to kLoopStopped. The testLoop() method will return false
when the loop state is no longer kLoopRunning, thus causing the test loop to be terminated.
By inspecting the loop state with getLoopState() it is possible to determine whether the loop ended due to an interrupt or because stopLoop() was called.
Definition at line 125 of file FebUtil.cxx.
References fLoopState, and kLoopRunning.
int nxyter::FebUtil::testFebControlPathCombo | ( | double | time | ) |
Test control path of all nXYTER of a FEB with random patterns.
time | test time in sec |
Definition at line 729 of file FebUtil.cxx.
References fFeb, nxyter::NxI2c::getContext(), nxyter::NxContext::getRegister(), nxyter::NxChip::i2c(), nxyter::kDoCore, nxyter::kDoMask, nxyter::kNxRegdelayTestTrig, nxyter::FebBase::numNx(), nxyter::FebBase::nx(), base::Board::operErrToString(), nxyter::NxI2c::setContext(), nxyter::NxContext::setRegister(), startLoop(), and testLoop().
Referenced by cmd_testfebcntl().
bool nxyter::FebUtil::testLoop | ( | ) |
Iteration test in test loop.
This is the central method of the test loop environment. It allows to implement test loops with run for a given amount of time. A call of startLoop() initializes the loop context, the testLoop() method is used as test condition of a while()
loop. Simple example
gUtil->startLoop(10.); while(gUtil->testLoop()) { int rc = i2c.setRegister(reg, val, veri); if (rc) std::cout << base::Board::operErrToString(rc) << std::endl; }
See stopLoop() of how to implement a loop abort via ^C.
Definition at line 148 of file FebUtil.cxx.
References fLoopCount, fLoopState, fStartLoopTime, fTestLoopTime, fTestTime, kLoopRunning, and now().
Referenced by cmd_autoped(), cmd_autovbiass(), cmd_geti2c(), cmd_idsigch(), cmd_printdatadbg(), cmd_scanadclat(), cmd_scanmonadc(), cmd_scanvbiasf(), cmd_scanvbiass(), cmd_seti2c(), cmd_testnxdata(), testFebControlPathCombo(), testMainAdcControlPath(), testMainAdcDataPath(), testNxControlPath(), and testNxRegisters().
int nxyter::FebUtil::testMainAdcControlPath | ( | double | time | ) |
Test MainAdc control path.
time | test time in sec |
Definition at line 640 of file FebUtil.cxx.
References nxyter::FebBase::adc(), fFeb, base::Board::operErrToString(), nxyter::MainAdc::probe(), startLoop(), and testLoop().
Referenced by cmd_testadccntl().
int nxyter::FebUtil::testMainAdcDataPath | ( | double | time | ) |
Test MainAdc data path.
time | test time in sec |
Definition at line 662 of file FebUtil.cxx.
References nxyter::FebBase::adc(), fFeb, nxyter::MainAdc::getAdcDirect(), base::Board::operErrToString(), nxyter::MainAdc::setTestMode(), nxyter::MainAdc::setUserPattern(), startLoop(), and testLoop().
Referenced by cmd_testadcdata().
int nxyter::FebUtil::testNxControlPath | ( | int | nxind, | |
double | time | |||
) |
Test nXYTER control path.
nxind | nXYTER index | |
time | test time in sec |
Definition at line 381 of file FebUtil.cxx.
References fFeb, nxyter::NxChip::i2c(), nxyter::FebBase::nx(), base::Board::operErrToString(), nxyter::NxI2c::probe(), startLoop(), and testLoop().
Referenced by cmd_testnxcntl().
int nxyter::FebUtil::testNxRegisters | ( | int | nxind | ) |
Test nXYTER registers.
nxind | nXYTER index |
Definition at line 403 of file FebUtil.cxx.
References fFeb, nxyter::NxI2c::getContext(), nxyter::NxContext::getPowerOffMaskBit(), roc::I2cDevice::getRegister(), nxyter::NxContext::getThresholdTrim(), nxyter::NxChip::i2c(), nxyter::kDoAll, nxyter::kDoTrim, nxyter::kNxRegConfig0, nxyter::FebBase::nx(), base::Board::operErrToString(), nxyter::NxContext::print(), nxyter::NxI2c::setContext(), nxyter::NxContext::setPowerOffMaskBit(), roc::I2cDevice::setRegister(), nxyter::NxContext::setThresholdTrim(), startLoop(), and testLoop().
Referenced by cmd_testnxregs().
FebBase* nxyter::FebUtil::fFeb [protected] |
FEB under test.
Definition at line 24 of file FebUtil.h.
Referenced by acquireTestPulserData(), acquireTestTriggerData(), restoreFeb(), saveFeb(), testFebControlPathCombo(), testMainAdcControlPath(), testMainAdcDataPath(), testNxControlPath(), and testNxRegisters().
uint64_t nxyter::FebUtil::fLoopCount [protected] |
test loop counter
Definition at line 30 of file FebUtil.h.
Referenced by getLoopCount(), startLoop(), and testLoop().
int nxyter::FebUtil::fLoopState [protected] |
loop state
Definition at line 26 of file FebUtil.h.
Referenced by getLoopState(), interruptLoop(), startLoop(), stopLoop(), and testLoop().
QuickDaq* nxyter::FebUtil::fQdaq [protected] |
QuickDaq for all DAQ.
Definition at line 25 of file FebUtil.h.
Referenced by acquireTestPulserData(), and acquireTestTriggerData().
double nxyter::FebUtil::fStartLoopTime [protected] |
time of last startLoop()
Definition at line 27 of file FebUtil.h.
Referenced by getStartLoopTime(), getTestLoopTime(), startLoop(), and testLoop().
double nxyter::FebUtil::fTestLoopTime [protected] |
double nxyter::FebUtil::fTestTime [protected] |
maximal duration of test
Definition at line 29 of file FebUtil.h.
Referenced by startLoop(), and testLoop().