nidas  v1.2-1520
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
nidas::core::Variable Class Reference

Class describing a sampled variable. More...

#include <Variable.h>

Inheritance diagram for nidas::core::Variable:
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

 Variable ()
 Create a variable. More...
 
 Variable (const Variable &)
 Copy constructor. More...
 
Variableoperator= (const Variable &)
 Assignment. More...
 
virtual ~Variable ()
 
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. More...
 
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. More...
 
void setSite (const Site *val)
 Set the Site where this variable was measured. More...
 
const SitegetSite () const
 Return the measurement site for this variable. More...
 
int getStation () const
 Station number of this variable: More...
 
void setStation (int val)
 
type_t getType () const
 
void setType (type_t val)
 
const SampleTaggetSampleTag () const
 What sample am I a part of? More...
 
void setSampleTag (const SampleTag *val)
 Set the sample tag pointer. More...
 
float getSampleRate () const
 Convenience routine to get the SampleTag rate. More...
 
void setPrefix (const std::string &val)
 Set the name prefix. More...
 
const std::string & getPrefix () const
 
const std::string & getSuffix () const
 Variable suffix, which is added to the name. More...
 
void setSuffix (const std::string &val)
 
const std::string & getSiteSuffix () const
 Site suffix, which is added to the name. More...
 
void setName (const std::string &val)
 Set the full name. More...
 
const std::string & getName () const
 
const std::string & getNameWithoutSite () const
 Get the name without the site suffix. More...
 
void setLongName (const std::string &val)
 Descriptive, long name, e.g. More...
 
const std::string & getLongName () const
 
void setA2dChannel (int val)
 The A2D channel for this variable. More...
 
int getA2dChannel () const
 
void setUnits (const std::string &val)
 The string discription of the units for this variable. More...
 
const std::string & getUnits () const
 
unsigned int getLength () const
 How many values in this variable? More...
 
void setLength (unsigned int val)
 
void setConverter (VariableConverter *val)
 Set the VariableConverter for this Variable. More...
 
const VariableConvertergetConverter () const
 
VariableConvertergetConverter ()
 
float * convert (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. More...
 
void addParameter (Parameter *val)
 Add a parameter to this Variable. More...
 
const std::list< const
Parameter * > & 
getParameters () const
 Get full list of parameters. More...
 
const ParametergetParameter (const std::string &name) const
 Fetch a parameter by name. More...
 
void setMissingValue (float val)
 
float getMissingValue () const
 
void setMinValue (float val)
 Set the minimum allowed value for this variable. More...
 
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. More...
 
bool isDynamic () const
 
void fromDOMElement (const xercesc::DOMElement *) throw (nidas::util::InvalidParameterException)
 Initialize myself from a xercesc::DOMElement. More...
 
xercesc::DOMElement * toDOMParent (xercesc::DOMElement *parent, bool complete) const throw (xercesc::DOMException)
 Create a DOMElement and append it to the parent. More...
 
xercesc::DOMElement * toDOMElement (xercesc::DOMElement *node, bool complete) const throw (xercesc::DOMException)
 Add my content into a DOMElement. More...
 

Static Public Member Functions

static const XMLCh * getNamespaceURI ()
 

Private Member Functions

void setSiteSuffix (const std::string &val)
 

Private Attributes

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. More...
 
std::list< const Parameter * > _constParameters
 List of const pointers to Parameters for providing via getParameters(). More...
 
float _missingValue
 
float _minValue
 
float _maxValue
 
float _plotRange [2]
 
bool _dynamic
 

Detailed Description

Class describing a sampled variable.

Member Typedef Documentation

Member Enumeration Documentation

Enumerator
CONTINUOUS 
COUNTER 
CLOCK 
OTHER 
WEIGHT 

Constructor & Destructor Documentation

Variable::Variable ( )

Create a variable.

References _plotRange, and nidas::core::floatNAN.

Variable::Variable ( const Variable x)
Variable::~Variable ( )
virtual

References _converter, and _parameters.

Member Function Documentation

void nidas::core::Variable::addParameter ( Parameter val)
inline

Add a parameter to this Variable.

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

References _constParameters, and _parameters.

Referenced by main(), operator=(), and Variable().

bool Variable::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.

References _name, _nameWithoutSite, getLength(), and getSite().

Referenced by nidas::dynld::StatisticsProcessor::connectSource(), and DataPrep::matchVariables().

float * Variable::convert ( 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.

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 _site, nidas::core::VariableConverter::convert(), nidas::core::floatNAN, nidas::core::Site::getApplyVariableConversions(), getConverter(), getLength(), getMaxValue(), getMinValue(), and getMissingValue().

Referenced by nidas::core::DSMSensor::applyConversions(), nidas::dynld::isff::NCAR_TRH::convertVariable(), nidas::dynld::isff::CSI_IRGA_Sonic::process(), and nidas::dynld::IEEE_Float::process().

void Variable::fromDOMElement ( const xercesc::DOMElement *  )
throw (nidas::util::InvalidParameterException
)
virtual
int nidas::core::Variable::getA2dChannel ( ) const
inline

References _A2dChannel.

Referenced by parseAnalog().

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

References _converter.

unsigned int nidas::core::Variable::getLength ( ) const
inline
const std::string& nidas::core::Variable::getLongName ( ) const
inline
float nidas::core::Variable::getMaxValue ( ) const
inline
float nidas::core::Variable::getMinValue ( ) const
inline
float nidas::core::Variable::getMissingValue ( ) const
inline

References _missingValue.

Referenced by convert().

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

References _name.

Referenced by nidas::dynld::isff::GOESOutput::addSourceSampleTag(), nidas::dynld::StatisticsCruncher::attach(), nidas::dynld::isff::Wind3D::checkSampleTags(), SampleCounter::collectMetadata(), nidas::core::NearestResampler::connect(), nidas::core::SampleAverager::connect(), nidas::dynld::StatisticsCruncher::connect(), nidas::core::NearestResamplerAtRate::connect(), nidas::dynld::isff::GOESOutput::connected(), nidas::dynld::StatisticsProcessor::connectSource(), nidas::dynld::StatisticsCruncher::createCombinations(), nidas::dynld::raf::SyncRecordSource::createHeader(), nidas::dynld::isff::WisardMote::createSampleTag(), nidas::dynld::psql::PSQLSampleOutput::createTables(), nidas::core::NearestResampler::ctorCommon(), nidas::core::NearestResamplerAtRate::ctorCommon(), nidas::core::DSMSensor::findVariableIndex(), nidas::core::DSMSensor::fromDOMElement(), nidas::dynld::WxtSensor::init(), nidas::dynld::raf::TwoD_USB::init(), nidas::dynld::raf::TwoD64_USB::init_parameters(), nidas::dynld::raf::TwoD64_USB_v3::init_parameters(), nidas::dynld::StatisticsCruncher::initStats(), StatsProcess::listOutputSamples(), PConfig::loadVariables(), DataPrep::matchVariables(), nidas::dynld::raf::DSMArincSensor::open(), parseAnalog(), parseOther(), nidas::dynld::raf::SyncRecordSource::preLoadCalibrations(), DumpClient::printHeader(), nidas::core::SampleTag::removeVariable(), SyncDumper::run(), DataPrep::run(), nidas::dynld::raf::SyncRecordReader::scanHeader(), nidas::dynld::WxtSensor::scanSample(), PConfig::showAll(), PConfig::showCalFiles(), nidas::dynld::raf::SyncRecordReader::throw(), nidas::dynld::isff::Licor7500::validate(), nidas::dynld::isff::Wind2D::validate(), nidas::dynld::raf::SppSerial::validate(), and nidas::core::Site::validate().

static const XMLCh* nidas::core::DOMable::getNamespaceURI ( )
inlinestaticinherited
const std::string& nidas::core::Variable::getNameWithoutSite ( ) const
inline

Get the name without the site suffix.

References _nameWithoutSite.

Referenced by nidas::core::NearestResampler::connect(), and operator<().

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

Fetch a parameter by name.

Returns a NULL pointer if no such parameter exists.

References _constParameters.

Referenced by parseAnalog().

const std::list<const Parameter*>& nidas::core::Variable::getParameters ( ) const
inline
void nidas::core::Variable::getPlotRange ( float &  minv,
float &  maxv 
) const
inline

References _plotRange.

const std::string& nidas::core::Variable::getPrefix ( ) const
inline
float Variable::getSampleRate ( ) const

Convenience routine to get the SampleTag rate.

References _sampleTag, and nidas::core::SampleTag::getRate().

Referenced by SyncDumper::run().

const SampleTag* nidas::core::Variable::getSampleTag ( ) const
inline
const Site* nidas::core::Variable::getSite ( ) const
inline
const std::string& nidas::core::Variable::getSiteSuffix ( ) const
inline

Site suffix, which is added to the name.

References _siteSuffix.

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

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 _station.

Referenced by nidas::dynld::StatisticsCruncher::attach(), nidas::core::NearestResampler::connect(), nidas::core::SampleAverager::connect(), nidas::dynld::StatisticsCruncher::connect(), nidas::dynld::StatisticsProcessor::connectSource(), nidas::dynld::StatisticsCruncher::createCombinations(), nidas::core::NearestResampler::ctorCommon(), DataPrep::matchVariables(), DataPrep::run(), setSampleTag(), and setSite().

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

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 _suffix.

Referenced by nidas::dynld::isff::WisardMote::createSampleTags().

type_t nidas::core::Variable::getType ( ) const
inline
const std::string& nidas::core::Variable::getUnits ( ) const
inline
bool nidas::core::Variable::isDynamic ( ) const
inline

References _dynamic.

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

References operator==().

bool Variable::operator< ( const Variable x) const
Variable & Variable::operator= ( const Variable rhs)
bool Variable::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.

References _name, _nameWithoutSite, _station, getLength(), and getSite().

Referenced by operator!=().

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

The A2D channel for this variable.

References _A2dChannel.

Referenced by nidas::dynld::A2DSensor::validate().

void nidas::core::Variable::setConverter ( VariableConverter val)
inline

Set the VariableConverter for this Variable.

Variable will own the pointer and will delete it.

References _converter.

Referenced by nidas::dynld::raf::SyncRecordReader::scanHeader().

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

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 _dynamic.

Referenced by nidas::dynld::isff::WisardMote::createSampleTag().

void nidas::core::Variable::setLength ( unsigned int  val)
inline
void nidas::core::Variable::setLongName ( const std::string &  val)
inline
void nidas::core::Variable::setMaxValue ( float  val)
inline
void nidas::core::Variable::setMinValue ( float  val)
inline

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 _minValue, and _plotRange.

Referenced by nidas::dynld::isff::Licor7500::validate(), and nidas::dynld::isff::NCAR_TRH::validate().

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

References _missingValue.

void nidas::core::Variable::setName ( const std::string &  val)
inline
void nidas::core::Variable::setPlotRange ( float  minv,
float  maxv 
)
inline
void nidas::core::Variable::setPrefix ( const std::string &  val)
inline

Set the name prefix.

The full variable name will be the concatenation of: prefix + suffix + site

References _name, _nameWithoutSite, _prefix, _siteSuffix, and _suffix.

Referenced by nidas::dynld::isff::WisardMote::createSampleTags().

void Variable::setSampleTag ( const SampleTag val)

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 _sampleTag, getSite(), nidas::core::SampleTag::getSite(), getStation(), nidas::core::SampleTag::getStation(), setSite(), and setStation().

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

void nidas::core::Variable::setSite ( const Site val)
inline
void Variable::setSiteSuffix ( const std::string &  val)
private

References _name, _prefix, _siteSuffix, and _suffix.

Referenced by setSite(), and setStation().

void nidas::core::Variable::setStation ( int  val)
inline
void nidas::core::Variable::setSuffix ( const std::string &  val)
inline
void nidas::core::Variable::setType ( type_t  val)
inline
void nidas::core::Variable::setUnits ( const std::string &  val)
inline
xercesc::DOMElement * Variable::toDOMElement ( xercesc::DOMElement *  node,
bool  complete 
) const
throw (xercesc::DOMException
)
virtual

Add my content into a DOMElement.

Reimplemented from nidas::core::DOMable.

References nidas::core::VariableConverter::getUnits(), and nidas::core::XDOMElement::setAttributeValue().

xercesc::DOMElement * Variable::toDOMParent ( xercesc::DOMElement *  parent,
bool  complete 
) const
throw (xercesc::DOMException
)
virtual

Create a DOMElement and append it to the parent.

Reimplemented from nidas::core::DOMable.

References nidas::core::DOMable::getNamespaceURI().

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

Member Data Documentation

int nidas::core::Variable::_A2dChannel
private
std::list<const Parameter*> nidas::core::Variable::_constParameters
private

List of const pointers to Parameters for providing via getParameters().

Referenced by addParameter(), getParameter(), and getParameters().

VariableConverter* nidas::core::Variable::_converter
private
bool nidas::core::Variable::_dynamic
private

Referenced by isDynamic(), operator=(), and setDynamic().

unsigned int nidas::core::Variable::_length
private

Referenced by getLength(), operator=(), and setLength().

std::string nidas::core::Variable::_longname
private

Referenced by getLongName(), operator=(), and setLongName().

float nidas::core::Variable::_maxValue
private

Referenced by getMaxValue(), operator=(), and setMaxValue().

float nidas::core::Variable::_minValue
private

Referenced by getMinValue(), operator=(), and setMinValue().

float nidas::core::Variable::_missingValue
private
std::string nidas::core::Variable::_name
private
std::string nidas::core::Variable::_nameWithoutSite
private
std::list<Parameter*> nidas::core::Variable::_parameters
private

List of pointers to Parameters.

Referenced by addParameter(), operator=(), and ~Variable().

float nidas::core::Variable::_plotRange[2]
private
std::string nidas::core::Variable::_prefix
private
const SampleTag* nidas::core::Variable::_sampleTag
private
const Site* nidas::core::Variable::_site
private
std::string nidas::core::Variable::_siteSuffix
private
int nidas::core::Variable::_station
private
std::string nidas::core::Variable::_suffix
private
type_t nidas::core::Variable::_type
private

Referenced by getType(), operator=(), and setType().

std::string nidas::core::Variable::_units
private

Referenced by getUnits(), operator=(), and setUnits().


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