Container for complete I2C register context of a nXYTER. More...
#include <NxContext.h>
Public Member Functions | |
NxContext () | |
Constructor, clears all values. | |
virtual | ~NxContext () |
void | setRegister (int reg, uint8_t val) |
Set value of register reg to val. | |
uint8_t | getRegister (int reg) const |
Return value of register reg. | |
void | setTrimRegister (int channel, uint8_t val) |
Set value of shift register slot channel to val. | |
uint8_t | getTrimRegister (int channel) const |
Return value of shift register slot channel. | |
void | setChannelMaskBit (int channel, bool isoff) |
Set the channel mask bit for channel channel to isoff. | |
void | setChannelMaskBit (int chbeg, int chend, bool isoff, int chstep=1) |
Set the channel mask bit isoff for channels chbeg to chend. | |
bool | getChannelMaskBit (int channel) const |
Return the channel mask bit for channel channel. | |
void | setThresholdTrim (int channel, uint8_t val) |
Set the threshold trim value channel to val. | |
void | setThresholdTrim (int chbeg, int chend, uint8_t val, int chstep=1) |
Set the threshold trim value to val for channels chbeg to chend. | |
uint8_t | getThresholdTrim (int channel) const |
Return the threshold trim value channel. | |
void | setPowerOffMaskBit (int channel, bool isoff) |
Set the power off mask bit for channel to isoff. | |
void | setPowerOffMaskBit (int chbeg, int chend, bool isoff, int chstep=1) |
Set the power off mask bit to isoff for channels chbeg to chend. | |
bool | getPowerOffMaskBit (int channel) const |
Return the power off mask bit for channel. | |
void | setToDefault (bool ispos=false, int maskon=128, int poweron=128) |
Set nXYTER context to default values. | |
bool | getConfigurationBit (int n) |
Return configuration bit from regs 32-33. | |
void | setConfigurationBit (int n, bool on) |
Set configuration bit from regs 32-33. | |
bool | equal (const NxContext &rhs, int domask=kDoAll) const |
Compare this contet with context rhs. | |
void | print (std::ostream &os, int domask=kDoAll) const |
Print context to stream os. | |
uint8_t * | dataRegisterMain () |
Returns pointer to normal register data array. | |
uint8_t * | dataRegisterTrim () |
Returns pointer to trim-daq register (register 42) data array. | |
bool | fillCmdFile (FILE *f, int nx) |
Print context as rocutil command file. | |
bool | operator== (const NxContext &rhs) const |
Compare equal operator. | |
bool | operator!= (const NxContext &rhs) const |
Compare non-equal operator. | |
Static Public Attributes | |
static const int | dimRegMain = 46 |
to cover all I2C registers | |
static const int | dimRegTrim = 129 |
128+1 locations of shift reg | |
Protected Attributes | |
uint8_t | fRegMain [dimRegMain] |
holds data for normal registers | |
uint8_t | fRegTrim [dimRegTrim] |
holds register 42 data | |
Related Functions | |
(Note that these are not member functions.) | |
std::ostream & | operator<< (std::ostream &os, const nxyter::NxContext &obj) |
ostream insertion for nxyter::NxContext |
Container for complete I2C register context of a nXYTER.
This class holds the information of all implemented registers of the the nXYTER, with the exception of the two error counters (overflow and token miss). Several methods allow convenient access to individual fields of the data. The nxyter::NxI2c class has methods to write/read a full context to/from an xXYTER (see nxyter::NxI2c::setContext() and nxyter::NxI2c::getContext()).
Definition at line 24 of file NxContext.h.
nxyter::NxContext::NxContext | ( | ) |
Constructor, clears all values.
Definition at line 29 of file NxContext.cxx.
References dimRegMain, dimRegTrim, fRegMain, and fRegTrim.
nxyter::NxContext::~NxContext | ( | ) | [virtual] |
Definition at line 37 of file NxContext.cxx.
uint8_t* nxyter::NxContext::dataRegisterMain | ( | ) | [inline] |
Returns pointer to normal register data array.
Definition at line 70 of file NxContext.h.
References fRegMain.
Referenced by nxyter::NxI2c::getContext(), and nxyter::NxI2c::setContext().
uint8_t* nxyter::NxContext::dataRegisterTrim | ( | ) | [inline] |
Returns pointer to trim-daq register (register 42) data array.
Definition at line 73 of file NxContext.h.
References fRegTrim.
Referenced by nxyter::NxI2c::getContext(), and nxyter::NxI2c::setContext().
Compare this
contet with context rhs.
The compare can be enabled separately for mask, core and trim part of the context with the domask when the bits kDoMask, kDoCore, or kDoTrim are set. The whole context is compared when all three are true
, which is the default.
rhs | second context to compare against | |
domask | one or several of the mask bits kDoMask, kDoCore, or kDoTrim |
false
if any enabled compare fails, true
otherwise Definition at line 401 of file NxContext.cxx.
References dimRegMain, dimRegTrim, fRegMain, fRegTrim, nxyter::kDoCore, nxyter::kDoMask, and nxyter::kDoTrim.
Referenced by operator!=(), operator==(), and nxyter::NxI2c::setContext().
bool nxyter::NxContext::fillCmdFile | ( | FILE * | f, | |
int | nx | |||
) |
Print context as rocutil command file.
Produces set of commands to set all regeisters of nxyter.
Definition at line 531 of file NxContext.cxx.
References getChannelMaskBit(), getPowerOffMaskBit(), getRegister(), and getThresholdTrim().
Referenced by NxyterWidget::fillCmdFile().
bool nxyter::NxContext::getChannelMaskBit | ( | int | channel | ) | const |
Return the channel mask bit for channel channel.
channel | nx channel number |
throw | std::out_of_range if channel not in range |
Definition at line 166 of file NxContext.cxx.
References fRegMain.
Referenced by cmd_autotrim(), fillCmdFile(), NxyterWidget::maskRowColumn(), and NxyterWidget::showMask().
bool nxyter::NxContext::getConfigurationBit | ( | int | n | ) |
Return configuration bit from regs 32-33.
n | from range 0-11 |
Definition at line 295 of file NxContext.cxx.
References fRegMain.
Referenced by NxyterWidget::showContext().
bool nxyter::NxContext::getPowerOffMaskBit | ( | int | channel | ) | const |
Return the power off mask bit for channel.
channel | nx channel number (range 0-128, 128 is test channel) |
throw | std::out_of_range if channel not in range |
Definition at line 280 of file NxContext.cxx.
References dimRegTrim, and fRegTrim.
Referenced by fillCmdFile(), print(), NxyterWidget::showThreshold(), nxyter::FebUtil::testNxRegisters(), and NxyterWidget::thresholdRowColumn().
uint8_t nxyter::NxContext::getRegister | ( | int | reg | ) | const |
Return value of register reg.
In many cases it is more convenient to use getChannelMaskBit(int channel) to access the channel masks in registers 0 to 15.
throw | std::out_of_range if reg not in range |
Definition at line 70 of file NxContext.cxx.
References dimRegMain, and fRegMain.
Referenced by cmd_printstatus(), cmd_scanadclat(), fillCmdFile(), setToDefault(), NxyterWidget::showContext(), and nxyter::FebUtil::testFebControlPathCombo().
uint8_t nxyter::NxContext::getThresholdTrim | ( | int | channel | ) | const |
Return the threshold trim value channel.
channel | nx channel number (range 0-128, 128 is test channel) |
throw | std::out_of_range if channel not in range |
Definition at line 223 of file NxContext.cxx.
References dimRegTrim, and fRegTrim.
Referenced by autotrim_print_trim(), autotrim_print_trim_dbg(), cmd_autotrim(), fillCmdFile(), print(), NxyterWidget::showThreshold(), nxyter::FebUtil::testNxRegisters(), and NxyterWidget::thresholdRowColumn().
uint8_t nxyter::NxContext::getTrimRegister | ( | int | channel | ) | const |
Return value of shift register slot channel.
Gives access to all bits of trim-daq register data. In many cases it is more convenient to use getThresholdTrim() and getPowerOffMaskBit() to access the components individually.
channel | nx channel number (range 0-128, 128 is test channel) |
throw | std::out_of_range if channel not in range |
Definition at line 109 of file NxContext.cxx.
References dimRegTrim, and fRegTrim.
bool nxyter::NxContext::operator!= | ( | const NxContext & | rhs | ) | const [inline] |
Compare non-equal operator.
Definition at line 83 of file NxContext.h.
References equal().
bool nxyter::NxContext::operator== | ( | const NxContext & | rhs | ) | const [inline] |
Compare equal operator.
Definition at line 80 of file NxContext.h.
References equal().
void nxyter::NxContext::print | ( | std::ostream & | os, | |
int | domask = kDoAll | |||
) | const |
Print context to stream os.
Produces a nicely formatted listing of all or part of the nXYTER settings. The print can be enabled separately for mask, core and trim part of the context with the domask when the bits kDoMask, kDoCore, or kDoTrim are set.
The output has the form (here full listing with kDoAll):
Reg( 0) mask_000_007 : 0xff 255 : ch 7- 0: o o o o o o o o o=active Reg( 1) mask_008_015 : 0xff 15 : ch 15- 8: o o o o d d d d d=inactive ... Reg(15) mask_120_127 : 0x00 0 : ch 127-120: o o o o o o o o Reg(16) Vcg : 0xa0 160 Reg(17) Icgfoll : 0xff 255 ... Reg(28) iPDH : 0x5c 92 Reg(29) iTWC : 0x45 69 Reg(32) Config0 : 0x00 0 : bit(0) = 0 : test pulse enable : bit(1) = 0 : test pulse synchronize : bit(2) = 0 : test pulse polarity : bit(3) = 0 : test trigger enable : bit(4) = 0 : test trigger synchronize : bit(5) = 0 : disable 32MHz clock : bit(6) = 0 : disable 128 MHz clock : bit(7) = 0 : TS LSB clock select Reg(33) Config1 : 0x0b 11 : bit(0) = 1 : calibration select bit 0 : bit(1) = 1 : calibration select bit 1 : bit(2) = 0 : front-end polarity : bit(3) = 1 : readout clock select Reg(38) delayTestPuls : 0x00 0 : delay= 0 ... Reg(45) delayClock3 : 0x00 0 : delay= 0 Reg(42) TrimDAQ-Power : ch 0: u 16 u 16 u 16 u 16 u 16 u 16 u 16 u 16 Reg(42) TrimDAQ-Power : ch 8: u 16 u 16 u 16 u 16 u 16 u 16 u 16 u 16 ... Reg(42) TrimDAQ-Power : ch 120: d 16 d 16 d 16 d 16 d 16 d 16 d 16 d 16 Reg(42) TrimDAQ-Power : ch 128: u 16
Definition at line 470 of file NxContext.cxx.
References nxyter::NxI2c::configurationBitName(), fRegMain, getPowerOffMaskBit(), getThresholdTrim(), nxyter::kDoCore, nxyter::kDoMask, nxyter::kDoTrim, nxyter::NxI2c::registerName(), and nxyter::NxI2c::settingToDelay().
Referenced by operator<<(), nxyter::NxI2c::printRegisters(), and nxyter::FebUtil::testNxRegisters().
void nxyter::NxContext::setChannelMaskBit | ( | int | channel, | |
bool | isoff | |||
) |
Set the channel mask bit for channel channel to isoff.
channel | nx channel number | |
isoff | new channel-off flag (0 is channel-on, 1 is channel-off) |
throw | std::out_of_range if channel not in range |
Definition at line 125 of file NxContext.cxx.
References fRegMain.
Referenced by nxyter::FebUtil::acquireTestPulserData(), cmd_autosettrh(), cmd_scanadclat(), cmd_setnxmask(), NxyterWidget::maskRowColumn(), setChannelMaskBit(), and setToDefault().
void nxyter::NxContext::setChannelMaskBit | ( | int | chbeg, | |
int | chend, | |||
bool | isoff, | |||
int | chstep = 1 | |||
) |
Set the channel mask bit isoff for channels chbeg to chend.
chbeg | begin of channel range | |
chend | end of channel range | |
isoff | new channel-off flag (0 is channel-on, 1 is channel-off) | |
chstep | increment for channel stepping. e.g. 2 will set every 2nd channel, convenient when all odd or even channels are to be touched. |
throw | std::out_of_range if channel not in range |
Definition at line 151 of file NxContext.cxx.
References setChannelMaskBit().
void nxyter::NxContext::setConfigurationBit | ( | int | n, | |
bool | on | |||
) |
Set configuration bit from regs 32-33.
n | from range 0-11 |
Definition at line 308 of file NxContext.cxx.
References fRegMain.
Referenced by NxyterWidget::configBitChanged().
void nxyter::NxContext::setPowerOffMaskBit | ( | int | chbeg, | |
int | chend, | |||
bool | isoff, | |||
int | chstep = 1 | |||
) |
Set the power off mask bit to isoff for channels chbeg to chend.
The allowed channel range is 0 to 128, 128 is the test channel.
chbeg | begin of channel range | |
chend | end of channel range | |
isoff | new power-down flag (0 is power-on, 1 is power-off) | |
chstep | increment for channel stepping. e.g. 2 will set every 2nd channel, convenient when all odd or even channels are to be touched. |
throw | std::out_of_range if a non-existing channel is touched |
Definition at line 265 of file NxContext.cxx.
References setPowerOffMaskBit().
void nxyter::NxContext::setPowerOffMaskBit | ( | int | channel, | |
bool | isoff | |||
) |
Set the power off mask bit for channel to isoff.
channel | nx channel number (range 0-128, 128 is test channel) | |
isoff | new power-down flag (0 is power-on, 1 is power-off) |
throw | std::out_of_range if channel not in range |
Definition at line 240 of file NxContext.cxx.
References dimRegTrim, and fRegTrim.
Referenced by cmd_setnxpower(), setPowerOffMaskBit(), setToDefault(), nxyter::FebUtil::testNxRegisters(), and NxyterWidget::thresholdRowColumn().
void nxyter::NxContext::setRegister | ( | int | reg, | |
uint8_t | val | |||
) |
Set value of register reg to val.
In many cases it is more convenient to use setChannelMaskBit(int channel, bool isoff) to access the channel masks in registers 0 to 15.
throw | std::out_of_range if reg not in range |
Definition at line 52 of file NxContext.cxx.
References dimRegMain, and fRegMain.
Referenced by NxyterWidget::biasRegChanged(), cmd_scanadclat(), NxyterWidget::otherRegsChanged(), setToDefault(), and nxyter::FebUtil::testFebControlPathCombo().
void nxyter::NxContext::setThresholdTrim | ( | int | chbeg, | |
int | chend, | |||
uint8_t | val, | |||
int | chstep = 1 | |||
) |
Set the threshold trim value to val for channels chbeg to chend.
The allowed channel range is 0 to 128, 128 is the test channel.
chbeg | begin of channel range | |
chend | end of channel range | |
val | new value for threshold trim (5bit, range 0-31) | |
chstep | increment for channel stepping. e.g. 2 will set every 2nd channel, convenient when all odd or even channels are to be touched. |
throw | std::out_of_range if channel not in range |
Definition at line 208 of file NxContext.cxx.
References setThresholdTrim().
void nxyter::NxContext::setThresholdTrim | ( | int | channel, | |
uint8_t | val | |||
) |
Set the threshold trim value channel to val.
channel | nx channel number (range 0-128, 128 is test channel) | |
val | new value for threshold trim (5bit, range 0-31) |
throw | std::out_of_range if channel not in range |
Definition at line 186 of file NxContext.cxx.
References dimRegTrim, and fRegTrim.
Referenced by cmd_autotrim(), cmd_setnxtrim(), setThresholdTrim(), setToDefault(), nxyter::FebUtil::testNxRegisters(), and NxyterWidget::thresholdRowColumn().
void nxyter::NxContext::setToDefault | ( | bool | ispos = false , |
|
int | maskon = 128 , |
|||
int | poweron = 128 | |||
) |
Set nXYTER context to default values.
All registers are initialized with default values
ispos | if false setup for negative pulses, if true , for positive pulses. | |
maskon | channels with a number less or equal maskon will be enable in the channel mask (mask bit = 0), the rest disabled. | |
poweron | channels with a number less or equal poweron will be powered, the rest has the power-down flag set. |
Definition at line 344 of file NxContext.cxx.
References dimRegMain, dimRegTrim, fRegMain, fRegTrim, getRegister(), nxyter::kNxC0TestPulsPolarity, nxyter::kNxC1FrontEndPolarity, nxyter::kNxC1ReadClockSelect, nxyter::kNxRegcal, nxyter::kNxRegConfig0, nxyter::kNxRegConfig1, nxyter::kNxRegIcgfoll, nxyter::kNxRegiCOMP, nxyter::kNxRegiDUR, nxyter::kNxRegiINV, nxyter::kNxRegiPDH, nxyter::kNxRegiTWC, nxyter::kNxRegVbfb, nxyter::kNxRegVbiasF, nxyter::kNxRegVbiasS, nxyter::kNxRegVbiasS2, nxyter::kNxRegVcg, nxyter::kNxRegVcm, nxyter::kNxRegVth, setChannelMaskBit(), setPowerOffMaskBit(), setRegister(), and setThresholdTrim().
Referenced by cmd_scanadclat(), NxyterWidget::setSubToDefault(), and nxyter::NxI2c::setToDefault().
void nxyter::NxContext::setTrimRegister | ( | int | channel, | |
uint8_t | val | |||
) |
Set value of shift register slot channel to val.
Gives access to all bits of trim-daq register data. In many cases it is more convenient to use setThresholdTrim() and setPowerOffMaskBit() to access the components individually.
channel | nx channel number (range 0-128, 128 is test channel) | |
val | new value (6 bit, MSB is power-down flag, 5LSB trim daq value) |
throw | std::out_of_range if channel not in range |
Definition at line 90 of file NxContext.cxx.
References dimRegTrim, and fRegTrim.
std::ostream & operator<< | ( | std::ostream & | os, | |
const nxyter::NxContext & | obj | |||
) | [related] |
ostream insertion for nxyter::NxContext
Just calls nxyter::NxContext::print()
Definition at line 94 of file NxContext.h.
References print().
const int nxyter::NxContext::dimRegMain = 46 [static] |
to cover all I2C registers
Definition at line 27 of file NxContext.h.
Referenced by equal(), getRegister(), NxContext(), setRegister(), and setToDefault().
const int nxyter::NxContext::dimRegTrim = 129 [static] |
128+1 locations of shift reg
Definition at line 28 of file NxContext.h.
Referenced by equal(), getPowerOffMaskBit(), getThresholdTrim(), getTrimRegister(), NxContext(), setPowerOffMaskBit(), setThresholdTrim(), setToDefault(), and setTrimRegister().
uint8_t nxyter::NxContext::fRegMain[dimRegMain] [protected] |
holds data for normal registers
Definition at line 31 of file NxContext.h.
Referenced by dataRegisterMain(), equal(), getChannelMaskBit(), getConfigurationBit(), getRegister(), NxContext(), print(), setChannelMaskBit(), setConfigurationBit(), setRegister(), and setToDefault().
uint8_t nxyter::NxContext::fRegTrim[dimRegTrim] [protected] |
holds register 42 data
Definition at line 32 of file NxContext.h.
Referenced by dataRegisterTrim(), equal(), getPowerOffMaskBit(), getThresholdTrim(), getTrimRegister(), NxContext(), setPowerOffMaskBit(), setThresholdTrim(), setToDefault(), and setTrimRegister().