nidas v1.2.3
Public Member Functions | Protected Attributes | Private Member Functions | List of all members
nidas::core::A2DConverter Class Referenceabstract

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>

Inheritance diagram for nidas::core::A2DConverter:
Inheritance graph
[legend]

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.
 
A2DConverteroperator= (const A2DConverter &x)
 No assign.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ A2DConverter() [1/2]

A2DConverter::A2DConverter ( int nchan,
int ncoefs )

◆ ~A2DConverter()

A2DConverter::~A2DConverter ( )
virtual

References _bipolar, and _gain.

◆ A2DConverter() [2/2]

nidas::core::A2DConverter::A2DConverter ( const A2DConverter & x)
private

No copy.

Member Function Documentation

◆ convert()

virtual float nidas::core::A2DConverter::convert ( int ichan,
float counts ) const
pure virtual

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().

◆ get()

virtual void nidas::core::A2DConverter::get ( int ichan,
float * d,
int nd ) const
pure virtual

◆ getBipolar()

int A2DConverter::getBipolar ( int ichan) const

◆ getGain()

int A2DConverter::getGain ( int ichan) const

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().

◆ getMaxNumChannels()

int nidas::core::A2DConverter::getMaxNumChannels ( ) const
inline

Maximum possible number of channels.

References _maxNumChannels.

◆ getNumConfigChannels()

int nidas::core::A2DConverter::getNumConfigChannels ( ) const
inline

One plus the index of the last active channel.

An active channel has a gain > 0.

References _numConfigChannels.

Referenced by readCalFile().

◆ operator=()

A2DConverter & nidas::core::A2DConverter::operator= ( const A2DConverter & x)
private

No assign.

◆ readCalFile()

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.

Exceptions

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()

virtual void nidas::core::A2DConverter::set ( int ichan,
const float * d,
int nd )
pure virtual

◆ setBipolar()

void A2DConverter::setBipolar ( int ichan,
int val )

◆ setGain()

void A2DConverter::setGain ( int ichan,
int val )

◆ setNAN() [1/2]

virtual void nidas::core::A2DConverter::setNAN ( )
pure virtual

◆ setNAN() [2/2]

virtual void nidas::core::A2DConverter::setNAN ( int ichan)
pure virtual

Member Data Documentation

◆ _bipolar

int* nidas::core::A2DConverter::_bipolar
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().

◆ _gain

int* nidas::core::A2DConverter::_gain
protected

Gain setting of each channel.

0 for an unused channel.

Referenced by A2DConverter(), getGain(), readCalFile(), setGain(), and ~A2DConverter().

◆ _maxNumChannels

int nidas::core::A2DConverter::_maxNumChannels
protected

◆ _ncoefs

int nidas::core::A2DConverter::_ncoefs
protected

◆ _numConfigChannels

int nidas::core::A2DConverter::_numConfigChannels
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().


The documentation for this class was generated from the following files: