nidas v1.2.3
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
nidas::dynld::raf::SyncRecordVariable Class Reference

A Variable associated with a SyncRecord. More...

#include <SyncRecordVariable.h>

Inheritance diagram for nidas::dynld::raf::SyncRecordVariable:
Inheritance graph
[legend]

Public Types

enum  var_type {
  CONTINUOUS , COUNTER , CLOCK , OTHER ,
  WEIGHT
}
 
typedef enum nidas::core::Variable::var_type type_t
 

Public Member Functions

 SyncRecordVariable ()
 
int getSyncRecOffset () const
 Get the index into the sync record of the first value for this variable.
 
void setSyncRecOffset (int val)
 
int getLagOffset () const
 Get the index into the sync record of the lag value for this variable.
 
void setLagOffset (int val)
 
bool operator== (const Variable &x) const
 Equivalence operator for Variable, checks equivalence of their length, the variables's names without any site suffix, and their sites.
 
bool operator!= (const Variable &x) const
 
bool operator< (const Variable &x) const
 
bool closeMatch (const Variable &x) const
 A more loose check of the equivalence of two variables, This will also return a value of true if either Site is NULL.
 
void setSite (const Site *val)
 Set the Site where this variable was measured.
 
const SitegetSite () const
 Return the measurement site for this variable.
 
int getStation () const
 Station number of this variable:
 
void setStation (int val)
 
type_t getType () const
 
void setType (type_t val)
 
const SampleTaggetSampleTag () const
 What sample am I a part of?
 
void setSampleTag (const SampleTag *val)
 Set the sample tag pointer.
 
float getSampleRate () const
 Convenience routine to get the SampleTag rate.
 
void setPrefix (const std::string &val)
 Set the name prefix.
 
const std::string & getPrefix () const
 
const std::string & getSuffix () const
 Variable suffix, which is added to the name.
 
void setSuffix (const std::string &val)
 
const std::string & getSiteSuffix () const
 Site suffix, which is added to the name.
 
void setName (const std::string &val)
 Set the full name.
 
const std::string & getName () const
 
const std::string & getNameWithoutSite () const
 Get the name without the site suffix.
 
void setLongName (const std::string &val)
 Descriptive, long name, e.g.
 
const std::string & getLongName () const
 
void setA2dChannel (int val)
 The A2D channel for this variable.
 
int getA2dChannel () const
 
void setUnits (const std::string &val)
 The string discription of the units for this variable.
 
const std::string & getUnits () const
 
unsigned int getLength () const
 How many values in this variable?
 
void setLength (unsigned int val)
 
void setConverter (VariableConverter *val)
 Set the VariableConverter for this Variable.
 
const VariableConvertergetConverter () const
 
VariableConvertergetConverter ()
 
floatconvert (dsm_time_t ttag, float *values, int nvalues=0, float *results=0)
 Apply the conversions for this Variable to the floats pointed to by values, putting the results in results, up to nvalues.
 
void addParameter (Parameter *val)
 Add a parameter to this Variable.
 
const std::list< const Parameter * > & getParameters () const
 Get full list of parameters.
 
const ParametergetParameter (const std::string &name) const
 Fetch a parameter by name.
 
void setMissingValue (float val)
 
float getMissingValue () const
 
void setMinValue (float val)
 Set the minimum allowed value for this variable.
 
float getMinValue () const
 
void setMaxValue (float val)
 
float getMaxValue () const
 
void setPlotRange (float minv, float maxv)
 
void getPlotRange (float &minv, float &maxv) const
 
void setDynamic (bool val)
 A dynamic variable is one that can come and go.
 
bool isDynamic () const
 
void fromDOMElement (const xercesc::DOMElement *)
 
xercesc::DOMElement * toDOMParent (xercesc::DOMElement *parent, bool complete) const
 
xercesc::DOMElement * toDOMElement (xercesc::DOMElement *node, bool complete) const
 

Static Public Member Functions

static const XMLChgetNamespaceURI ()
 

Private Member Functions

SyncRecordVariableoperator= (const SyncRecordVariable &)
 Assignment not supported.
 
void setSiteSuffix (const std::string &val)
 

Private Attributes

int offset
 
int lagOffset
 
std::string _name
 
const Site_site
 
int _station
 
std::string _nameWithoutSite
 
std::string _prefix
 
std::string _suffix
 
std::string _siteSuffix
 
std::string _longname
 
const SampleTag_sampleTag
 
int _A2dChannel
 
std::string _units
 
type_t _type
 
unsigned int _length
 
VariableConverter_converter
 
std::list< Parameter * > _parameters
 List of pointers to Parameters.
 
std::list< const Parameter * > _constParameters
 List of const pointers to Parameters for providing via getParameters().
 
float _missingValue
 
float _minValue
 
float _maxValue
 
float _plotRange [2]
 
bool _dynamic
 

Static Private Attributes

static XMLChnamespaceURI = 0
 

Detailed Description

A Variable associated with a SyncRecord.

Member Typedef Documentation

◆ type_t

Member Enumeration Documentation

◆ var_type

Enumerator
CONTINUOUS 
COUNTER 
CLOCK 
OTHER 
WEIGHT 

Constructor & Destructor Documentation

◆ SyncRecordVariable()

nidas::dynld::raf::SyncRecordVariable::SyncRecordVariable ( )
inline

Member Function Documentation

◆ addParameter()

void nidas::core::Variable::addParameter ( Parameter * val)
inlineinherited

Add a parameter to this Variable.

Variable will then own the pointer and will delete it in its destructor.

References nidas::core::Variable::_constParameters, and nidas::core::Variable::_parameters.

Referenced by nidas::core::Variable::fromDOMElement(), nidas::core::Variable::operator=(), and nidas::core::Variable::Variable().

◆ closeMatch()

bool Variable::closeMatch ( const Variable & x) const
inherited

A more loose check of the equivalence of two variables, This will also return a value of true if either Site is NULL.

References nidas::core::Site::_name, nidas::core::Variable::_name, nidas::core::Variable::_nameWithoutSite, nidas::core::Variable::getLength(), and nidas::core::Variable::getSite().

◆ convert()

float * Variable::convert ( dsm_time_t ttag,
float * values,
int nvalues = 0,
float * results = 0 )
inherited

Apply the conversions for this Variable to the floats pointed to by values, putting the results in results, up to nvalues.

Any calibrations are looked up using time ttag. The min/max value limits of a variable are applied also, so if a variable value is converted but lies outside the min/max range, the value is set to floatNAN.

If nvalues is null, then multiple values will be converted up to the length of the Variable, otherwise only the number given in nvalues. If results is null, then the converted values will be written back into the array pointed to by values. Both values and results must point to enough memory to hold nvalues floats. Typically the results of the conversions are written over the values passed in, and values points into the memory in a DSMSensor output sample. However, if a sensor needs custom handling of the results, then the inputs and outputs can be kept separate. For example, The TRH Wisard sensor can keep the Ifan value as it was but convert T and RH to floatNAN if the Ifan result is NAN, meaning Ifan was bad or out of range. It is safe to pass results equal to values, the effect is the same as calling convert() with results=null.

Usually this conversion is the last step applied to the output sample of a sensor's process() method, and this method is called from the DSMSensor::applyConversions() method.

If this Variable has a Site (getSite() returns non-null) and the Site's getApplyVariableConversions() returns false, then no conversions are applied, not even the min/max limit filter. Otherwise the conversions are applied.

Originally, the getApplyVariableConversions() was called on DSMSensor, usually inside a sensor subclass process() method. However, that value is usually copied from the Site's applyCals attribute. So the value of the flag should be the same for both Site and DSMSensor, unless there are some uses out there which change the DSMSensor's value, such as in the sensor subclass itself. However, if a Sensor does not want to apply conversions, then it can just avoid calling any conversion methods.

The original code limit filtered values whether conversion was applied or not, and there was some inconsistency in the domain of the min/max values: Did they apply to values before or after conversion? The convention will be that min/max are in the converted space, so now no filtering happens based on min/max if conversions not applied first. It also makes sense that disabling conversions, presumably to see the more raw values, implies not limit filtering any values either. In practice this change should have little effect, since the 'applyCals' Site attribute is rarely enabled.

The return value points just past the last element in values to be converted. Note that results is not passed by reference, therefore if non-null it must be advanced after the call to convert().

References nidas::core::Variable::_site, nidas::core::floatNAN, nidas::core::Variable::getConverter(), nidas::core::Variable::getLength(), nidas::core::Variable::getMaxValue(), nidas::core::Variable::getMinValue(), nidas::core::Variable::getMissingValue(), and nidas::core::getSample().

Referenced by nidas::dynld::IEEE_Float::process(), and nidas::dynld::ModbusRTU::process().

◆ fromDOMElement()

void Variable::fromDOMElement ( const xercesc::DOMElement * node)
virtualinherited

◆ getA2dChannel()

int nidas::core::Variable::getA2dChannel ( ) const
inlineinherited

◆ getConverter() [1/2]

VariableConverter * nidas::core::Variable::getConverter ( )
inlineinherited

◆ getConverter() [2/2]

const VariableConverter * nidas::core::Variable::getConverter ( ) const
inlineinherited

◆ getLagOffset()

int nidas::dynld::raf::SyncRecordVariable::getLagOffset ( ) const
inline

Get the index into the sync record of the lag value for this variable.

The lag value is the fractional number of micro-seconds to add to the sync record time to get the time tag of the first value of this variable in the sync record. One would use it like so: float lag = sync_rec[var->getLagOffset()]; if (!isnan(lag)) tt += lag;

References lagOffset.

◆ getLength()

unsigned int nidas::core::Variable::getLength ( ) const
inlineinherited

◆ getLongName()

const std::string & nidas::core::Variable::getLongName ( ) const
inlineinherited

◆ getMaxValue()

float nidas::core::Variable::getMaxValue ( ) const
inlineinherited

◆ getMinValue()

float nidas::core::Variable::getMinValue ( ) const
inlineinherited

◆ getMissingValue()

float nidas::core::Variable::getMissingValue ( ) const
inlineinherited

◆ getName()

const std::string & nidas::core::Variable::getName ( ) const
inlineinherited

◆ getNamespaceURI()

static const XMLCh * nidas::core::DOMable::getNamespaceURI ( )
inlinestaticinherited

◆ getNameWithoutSite()

const std::string & nidas::core::Variable::getNameWithoutSite ( ) const
inlineinherited

Get the name without the site suffix.

References nidas::core::Variable::_nameWithoutSite.

Referenced by nidas::core::Variable::operator<().

◆ getParameter()

const Parameter * Variable::getParameter ( const std::string & name) const
inherited

Fetch a parameter by name.

Returns a NULL pointer if no such parameter exists.

References nidas::core::Variable::_constParameters, and nidas::core::getSample().

◆ getParameters()

const std::list< const Parameter * > & nidas::core::Variable::getParameters ( ) const
inlineinherited

Get full list of parameters.

References nidas::core::Variable::_constParameters.

Referenced by nidas::dynld::raf::A2D_Serial::validate().

◆ getPlotRange()

void nidas::core::Variable::getPlotRange ( float & minv,
float & maxv ) const
inlineinherited

◆ getPrefix()

const std::string & nidas::core::Variable::getPrefix ( ) const
inlineinherited

◆ getSampleRate()

float Variable::getSampleRate ( ) const
inherited

Convenience routine to get the SampleTag rate.

References nidas::core::Variable::_sampleTag.

◆ getSampleTag()

const SampleTag * nidas::core::Variable::getSampleTag ( ) const
inlineinherited

What sample am I a part of?

References nidas::core::Variable::_sampleTag.

Referenced by nidas::core::Variable::fromDOMElement().

◆ getSite()

const Site * nidas::core::Variable::getSite ( ) const
inlineinherited

◆ getSiteSuffix()

const std::string & nidas::core::Variable::getSiteSuffix ( ) const
inlineinherited

Site suffix, which is added to the name.

References nidas::core::Variable::_siteSuffix.

◆ getStation()

int nidas::core::Variable::getStation ( ) const
inlineinherited

Station number of this variable:

Returns
-1: not specified 0: the "non" site, or the project-wide site, 1-N: a site number

Variables can be grouped by a station number.

A measured variable is associated with a Site. A Site also has a non-negative station number. A Site may have an associated suffix, like ".bigtower".

By default, all DSMSensors at a site will be assigned the site's station number. To support the logical grouping of variables into stations, the station number of a DSMSensor can be set to a different value than the Site's number.

All variables sampled by a DSMSensor will get assigned its station number.

If the station number of a variable is 0, then the site suffix will be appended to the variable name.

Otherwise, if the station number of a variable is positive, the site suffix is not appended to its name. In this way we can have variables with a common name, like "RH.2m" at different sites, which will have different station numbers.

References nidas::core::Variable::_station.

Referenced by nidas::dynld::StatisticsCruncher::connect(), nidas::core::NearestResampler::ctorCommon(), DataPrep::run(), nidas::core::Variable::setSampleTag(), and nidas::core::Variable::setSite().

◆ getSuffix()

const std::string & nidas::core::Variable::getSuffix ( ) const
inlineinherited

Variable suffix, which is added to the name.

The full variable name is created from prefix + suffix + siteSuffix. suffix and/or siteSuffix may be empty strings. The suffix commonly comes from the DSMSensor::getFullSuffix(), containing an optional sensor suffix and a height/depth string.

References nidas::core::Variable::_suffix.

◆ getSyncRecOffset()

int nidas::dynld::raf::SyncRecordVariable::getSyncRecOffset ( ) const
inline

Get the index into the sync record of the first value for this variable.

References offset.

◆ getType()

type_t nidas::core::Variable::getType ( ) const
inlineinherited

◆ getUnits()

const std::string & nidas::core::Variable::getUnits ( ) const
inlineinherited

◆ isDynamic()

bool nidas::core::Variable::isDynamic ( ) const
inlineinherited

◆ operator!=()

bool Variable::operator!= ( const Variable & x) const
inherited

◆ operator<()

bool Variable::operator< ( const Variable & x) const
inherited

◆ operator=()

SyncRecordVariable & nidas::dynld::raf::SyncRecordVariable::operator= ( const SyncRecordVariable & )
private

Assignment not supported.

◆ operator==()

bool Variable::operator== ( const Variable & x) const
inherited

Equivalence operator for Variable, checks equivalence of their length, the variables's names without any site suffix, and their sites.

References nidas::core::Variable::_name, nidas::core::Variable::_nameWithoutSite, nidas::core::Variable::_station, nidas::core::Variable::getLength(), and nidas::core::Variable::getSite().

Referenced by nidas::core::Variable::operator!=().

◆ setA2dChannel()

void nidas::core::Variable::setA2dChannel ( int val)
inlineinherited

The A2D channel for this variable.

References nidas::core::Variable::_A2dChannel, and nidas::core::getSample().

◆ setConverter()

void nidas::core::Variable::setConverter ( VariableConverter * val)
inlineinherited

Set the VariableConverter for this Variable.

Variable will own the pointer and will delete it.

References nidas::core::Variable::_converter, and nidas::core::getSample().

Referenced by nidas::core::Variable::fromDOMElement().

◆ setDynamic()

void nidas::core::Variable::setDynamic ( bool val)
inlineinherited

A dynamic variable is one that can come and go.

The dynamic attribute is typically used by a display application which will scan all the variables for a project and create a plot for each. If a variable is dynamic, then that application should wait to create a plot for the variable until data is received for it.

References nidas::core::Variable::_dynamic, and nidas::core::getSample().

Referenced by nidas::core::Variable::fromDOMElement().

◆ setLagOffset()

void nidas::dynld::raf::SyncRecordVariable::setLagOffset ( int val)
inline

◆ setLength()

void nidas::core::Variable::setLength ( unsigned int val)
inlineinherited

◆ setLongName()

void nidas::core::Variable::setLongName ( const std::string & val)
inlineinherited

Descriptive, long name, e.g.

"Ambient air temperature".

References nidas::core::Variable::_longname, and nidas::core::getSample().

Referenced by nidas::core::Variable::fromDOMElement().

◆ setMaxValue()

void nidas::core::Variable::setMaxValue ( float val)
inlineinherited

◆ setMinValue()

void nidas::core::Variable::setMinValue ( float val)
inlineinherited

Set the minimum allowed value for this variable.

Variable values less than val will be set to NAN. Support for this check must be supported by each DSMSensor class.

References nidas::core::Variable::_minValue, nidas::core::Variable::_plotRange, and nidas::core::getSample().

Referenced by nidas::core::Variable::fromDOMElement().

◆ setMissingValue()

void nidas::core::Variable::setMissingValue ( float val)
inlineinherited

◆ setName()

void nidas::core::Variable::setName ( const std::string & val)
inlineinherited

◆ setPlotRange()

void nidas::core::Variable::setPlotRange ( float minv,
float maxv )
inlineinherited

◆ setPrefix()

void nidas::core::Variable::setPrefix ( const std::string & val)
inlineinherited

◆ setSampleTag()

void Variable::setSampleTag ( const SampleTag * val)
inherited

Set the sample tag pointer.

Variable does not own the pointer. This also copies attributes from the sample, such as site and station if they have not been set on this Variable.

References nidas::core::Variable::_sampleTag, nidas::core::getSample(), nidas::core::Variable::getSite(), nidas::core::Variable::getStation(), nidas::core::Variable::setSite(), and nidas::core::Variable::setStation().

◆ setSite()

void nidas::core::Variable::setSite ( const Site * val)
inlineinherited

◆ setSiteSuffix()

void Variable::setSiteSuffix ( const std::string & val)
privateinherited

◆ setStation()

void nidas::core::Variable::setStation ( int val)
inlineinherited

◆ setSuffix()

void nidas::core::Variable::setSuffix ( const std::string & val)
inlineinherited

◆ setSyncRecOffset()

void nidas::dynld::raf::SyncRecordVariable::setSyncRecOffset ( int val)
inline

References nidas::core::getSample(), and offset.

◆ setType()

void nidas::core::Variable::setType ( type_t val)
inlineinherited

◆ setUnits()

void nidas::core::Variable::setUnits ( const std::string & val)
inlineinherited

◆ toDOMElement()

xercesc::DOMElement * Variable::toDOMElement ( xercesc::DOMElement * node,
bool complete ) const
virtualinherited

◆ toDOMParent()

xercesc::DOMElement * Variable::toDOMParent ( xercesc::DOMElement * parent,
bool complete ) const
virtualinherited
Exceptions
xercesc::DOMException

Reimplemented from nidas::core::DOMable.

References nidas::core::DOMable::getNamespaceURI(), and nidas::core::Variable::toDOMElement().

Referenced by nidas::core::SampleTag::toDOMElement().

Member Data Documentation

◆ _A2dChannel

int nidas::core::Variable::_A2dChannel
privateinherited

◆ _constParameters

std::list<const Parameter*> nidas::core::Variable::_constParameters
privateinherited

◆ _converter

VariableConverter* nidas::core::Variable::_converter
privateinherited

◆ _dynamic

bool nidas::core::Variable::_dynamic
privateinherited

◆ _length

unsigned int nidas::core::Variable::_length
privateinherited

◆ _longname

std::string nidas::core::Variable::_longname
privateinherited

◆ _maxValue

float nidas::core::Variable::_maxValue
privateinherited

◆ _minValue

float nidas::core::Variable::_minValue
privateinherited

◆ _missingValue

float nidas::core::Variable::_missingValue
privateinherited

◆ _name

std::string nidas::core::Variable::_name
privateinherited

◆ _nameWithoutSite

std::string nidas::core::Variable::_nameWithoutSite
privateinherited

◆ _parameters

std::list<Parameter*> nidas::core::Variable::_parameters
privateinherited

◆ _plotRange

float nidas::core::Variable::_plotRange[2]
privateinherited

◆ _prefix

std::string nidas::core::Variable::_prefix
privateinherited

◆ _sampleTag

const SampleTag* nidas::core::Variable::_sampleTag
privateinherited

◆ _site

const Site* nidas::core::Variable::_site
privateinherited

◆ _siteSuffix

std::string nidas::core::Variable::_siteSuffix
privateinherited

◆ _station

int nidas::core::Variable::_station
privateinherited

◆ _suffix

std::string nidas::core::Variable::_suffix
privateinherited

◆ _type

type_t nidas::core::Variable::_type
privateinherited

◆ _units

std::string nidas::core::Variable::_units
privateinherited

◆ lagOffset

int nidas::dynld::raf::SyncRecordVariable::lagOffset
private

Referenced by getLagOffset(), and setLagOffset().

◆ namespaceURI

XMLCh * DOMable::namespaceURI = 0
staticprivateinherited

◆ offset

int nidas::dynld::raf::SyncRecordVariable::offset
private

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