DUECA/DUSIME
Loading...
Searching...
No Matches
dueca::InputCalibratorRanging< T, R > Class Template Reference

Class that performs calibration and scaling of an incoming integer value from an A/D converter or other input device. More...

#include <InputCalibratorRanging.hxx>

Public Types

typedef T::data_type data_type
 Converted datatype.

Public Member Functions

 InputCalibratorRanging (const R in_min, const R in_max, const T &c, const data_type out_min, const data_type out_max, unsigned int idx=0, const double range_tolerance=0.01)
 Constructor.
 ~InputCalibratorRanging ()
 Destructor.
 operator double () const
 Obtain the converted value.
R raw () const
 Obtain the raw integer value.
void newConversion (const R i)
 Insert a new converted value into the calibrator.
R bitDifference (const double r) const
 Return the difference between the given value and the measured value in bit domain.
unsigned int index () const
 The index is a variable for user convenience, e.g.
bool lockOffset ()
 Determine the calibration offset.
RangingLockReason< T, R > lockReason () const
 Print calibration offset reasoning.
void resetHoming ()
 Reset for a new homing movement.
std::ostream & print (std::ostream &os) const
 Print to stream, for debugging purposes.

Friends

class RangingLockReason< T, R >

Detailed Description

template<class T, class R = int>
class dueca::InputCalibratorRanging< T, R >

Class that performs calibration and scaling of an incoming integer value from an A/D converter or other input device.

It is a templated class, and the template parameter must be a class capable of scaling the incoming values.

Constructor & Destructor Documentation

◆ InputCalibratorRanging()

template<class T, class R>
dueca::InputCalibratorRanging< T, R >::InputCalibratorRanging ( const R in_min,
const R in_max,
const T & c,
const data_type out_min,
const data_type out_max,
unsigned int idx = 0,
const double range_tolerance = 0.01 )

Constructor.

Takes a converter as argument.

Parameters
in_minMinimum integer value
in_maxMaximum integer value
cConverter of (template) type T, the operation operator() (const double x) should exist for values between in_min and in_max, and should produce the required converted/scaled value.
out_minMinimum output value
out_maxMaximum output value
idxOptional index to be stored with the calibrator
range_toleranceRelative tolerance for the error between the out_min..out_max range and the range detected in homing.

Member Function Documentation

◆ bitDifference()

template<class T, class R>
R dueca::InputCalibratorRanging< T, R >::bitDifference ( const double r) const

Return the difference between the given value and the measured value in bit domain.

Parameters
rValue for comparison
Returns
  • 0 if the difference is 1 bit or less
  • 1 if the value is two bits larger
  • -1 if the value is two bits smaller
  • 2 respectively -2 if the value is three bits or more larger or smaller.

◆ index()

template<class T, class R = int>
unsigned int dueca::InputCalibratorRanging< T, R >::index ( ) const
inline

The index is a variable for user convenience, e.g.

to remember where in an array of raw data the input value is stored.

◆ lockOffset()

template<class T, class R>
bool dueca::InputCalibratorRanging< T, R >::lockOffset ( )

Determine the calibration offset.

Checks found maximum and minimum values, verifies that their range is within the tolerance of expected max and min, and if so locks the offset

Returns
true if the range within tolerance

The documentation for this class was generated from the following file:
  • /home/abuild/rpmbuild/BUILD/dueca-4.3.3-build/dueca-4.3.3/extra/InputCalibratorRanging.hxx