nidas v1.2.3
|
Virtual class with methods for performing conversions from integer A2D counts to floating point voltages for each channel of an A2D. More...
#include <A2DConverter.h>
Public Member Functions | |
A2DConverter (int nchan, int ncoefs) | |
virtual | ~A2DConverter () |
int | getMaxNumChannels () const |
Maximum possible number of channels. | |
int | getNumConfigChannels () const |
One plus the index of the last active channel. | |
int | getGain (int ichan) const |
Gain of each channel. | |
void | setGain (int ichan, int val) |
int | getBipolar (int ichan) const |
void | setBipolar (int ichan, int val) |
virtual float | convert (int ichan, float counts) const =0 |
Convert a count to a floating point value. | |
virtual void | set (int ichan, const float *d, int nd)=0 |
Set the initial conversion for a channel. | |
virtual void | get (int ichan, float *d, int nd) const =0 |
virtual void | setNAN (int ichan)=0 |
virtual void | setNAN ()=0 |
void | readCalFile (CalFile *cf, dsm_time_t tt) |
Read records from a CalFile for calibration coefficients with time tags less than or equal to tt, assuming they are in increasingg order in the file. | |
Protected Attributes | |
int | _maxNumChannels |
How many channels on the A2D. | |
int | _numConfigChannels |
A configured channel has a gain > 0. | |
int | _ncoefs |
Number of coefficients in the conversion. | |
int * | _gain |
Gain setting of each channel. | |
int * | _bipolar |
Polarity setting, 1=bi-polar. | |
Private Member Functions | |
A2DConverter (const A2DConverter &x) | |
No copy. | |
A2DConverter & | operator= (const A2DConverter &x) |
No assign. | |
Virtual class with methods for performing conversions from integer A2D counts to floating point voltages for each channel of an A2D.
Two subclasses are defined, LinearA2DConverter and PolyA2DConverter. A2D sensor classes instantiate whichever type they want to use.
The gain and bipolar value for each channel in the A2DConverter are set by the A2D sensor, typically at configuration time in the validate() method. A gain of 0 indicates that a channel is not used.
Our A2Ds (DSMAnalogSensor, DSC_A2DSensor, A2D_Serial) typically instantiate two converters. A LinearA2DConverter is used to convert counts to approximate voltages using the known voltage transformations of the A2D, at a given gain and bipolar value for each channel.
A second converter, often a 3rd order PolyA2DConverter, then applies corrections to obtain a calibrated voltage.
If an A2D CalFile has been configured for the sensor, the readCalFile() method of the second converter can be called to read the conversion coefficients from the file. See the doc for the readCalFile() method for information about the number of expected values in the calibration file.
References _bipolar, _gain, and nidas::core::getSample().
|
private |
No copy.
Convert a count to a floating point value.
Implemented in nidas::core::LinearA2DConverter, and nidas::core::PolyA2DConverter.
Referenced by nidas::dynld::raf::A2D_Serial::process().
Implemented in nidas::core::LinearA2DConverter, and nidas::core::PolyA2DConverter.
Referenced by nidas::dynld::raf::A2D_Serial::dumpConfig().
References _bipolar, _maxNumChannels, and nidas::core::getSample().
Referenced by nidas::dynld::raf::A2D_Serial::getBipolar().
Gain of each channel.
An A2DConverter needs to know the gain and bipolarity because it reads the cal file and there are typically cal records for each gain and polarity.
References _gain, _maxNumChannels, and nidas::core::getSample().
Referenced by nidas::dynld::raf::A2D_Serial::getGain().
|
inline |
Maximum possible number of channels.
References _maxNumChannels.
|
inline |
One plus the index of the last active channel.
An active channel has a gain > 0.
References _numConfigChannels.
Referenced by readCalFile().
|
private |
No assign.
void A2DConverter::readCalFile | ( | CalFile * | cf, |
dsm_time_t | tt ) |
Read records from a CalFile for calibration coefficients with time tags less than or equal to tt, assuming they are in increasingg order in the file.
Each record has a gain and bipolar value after the time, followed by coefficients for each channel.
A calibration record is used for a channel if its gain and bipolar fields match the values for the configured channel. A gain value of -1 in the file is a wildcard, matching any configured gain for a channel, and likewise for the bipolar value.
readCalFile() expects there to be getNumConfigChannels() X _ncoefs number of coefficients after the time, gain and bipolar fields in each CalFile record. If there are less than the expected number, a warning is logged, and missing coefficients are set to floatNAN.
EOFException, IOException, ParseException
References _bipolar, _gain, _ncoefs, getNumConfigChannels(), nidas::core::getSample(), LOG_WARNING, set(), and setNAN().
Referenced by nidas::dynld::raf::A2D_Serial::process().
Set the initial conversion for a channel.
Implemented in nidas::core::LinearA2DConverter, and nidas::core::PolyA2DConverter.
Referenced by readCalFile(), nidas::dynld::DSC_A2DSensor::validate(), nidas::dynld::raf::A2D_Serial::validate(), and nidas::dynld::raf::DSMAnalogSensor::validate().
References _bipolar, _maxNumChannels, and nidas::core::getSample().
Referenced by nidas::dynld::DSC_A2DSensor::validate(), nidas::dynld::raf::A2D_Serial::validate(), and nidas::dynld::raf::DSMAnalogSensor::validate().
Implemented in nidas::core::LinearA2DConverter, and nidas::core::PolyA2DConverter.
Referenced by readCalFile().
Implemented in nidas::core::LinearA2DConverter, and nidas::core::PolyA2DConverter.
Referenced by nidas::dynld::raf::A2D_Serial::process().
|
protected |
Polarity setting, 1=bi-polar.
e.g -5 to 5V, 0=unipolar, e.g. 0 to 5V, -1 for an unused channel.
Referenced by A2DConverter(), getBipolar(), readCalFile(), setBipolar(), and ~A2DConverter().
|
protected |
Gain setting of each channel.
0 for an unused channel.
Referenced by A2DConverter(), getGain(), readCalFile(), setGain(), and ~A2DConverter().
|
protected |
How many channels on the A2D.
Set in constructor.
Referenced by nidas::core::LinearA2DConverter::convert(), nidas::core::LinearA2DConverter::get(), nidas::core::PolyA2DConverter::get(), getBipolar(), getGain(), getMaxNumChannels(), nidas::core::PolyA2DConverter::PolyA2DConverter(), nidas::core::LinearA2DConverter::set(), nidas::core::PolyA2DConverter::set(), setBipolar(), setGain(), nidas::core::LinearA2DConverter::setNAN(), nidas::core::PolyA2DConverter::setNAN(), and nidas::core::PolyA2DConverter::~PolyA2DConverter().
|
protected |
Number of coefficients in the conversion.
Referenced by nidas::core::PolyA2DConverter::convert(), nidas::core::PolyA2DConverter::get(), nidas::core::PolyA2DConverter::PolyA2DConverter(), readCalFile(), nidas::core::PolyA2DConverter::set(), and nidas::core::PolyA2DConverter::setNAN().
|
protected |
A configured channel has a gain > 0.
The number of configured channels is the index of the last configured channel plus one.
Referenced by getNumConfigChannels(), and setGain().