nidas  v1.2-1520
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | 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. More...
 
void setSyncRecOffset (int val)
 
int getLagOffset () const
 Get the index into the sync record of the lag value for this variable. More...
 
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. 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

SyncRecordVariableoperator= (const SyncRecordVariable &)
 Assignment not supported. More...
 

Private Attributes

int offset
 
int lagOffset
 

Detailed Description

A Variable associated with a SyncRecord.

Member Typedef Documentation

Member Enumeration Documentation

Enumerator
CONTINUOUS 
COUNTER 
CLOCK 
OTHER 
WEIGHT 

Constructor & Destructor Documentation

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

Member Function Documentation

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 main(), nidas::core::Variable::operator=(), and nidas::core::Variable::Variable().

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::Variable::_name, nidas::core::Variable::_nameWithoutSite, nidas::core::Variable::getLength(), and nidas::core::Variable::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 
)
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::VariableConverter::convert(), nidas::core::floatNAN, nidas::core::Site::getApplyVariableConversions(), nidas::core::Variable::getConverter(), nidas::core::Variable::getLength(), nidas::core::Variable::getMaxValue(), nidas::core::Variable::getMinValue(), and nidas::core::Variable::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
)
virtualinherited
int nidas::core::Variable::getA2dChannel ( ) const
inlineinherited
const VariableConverter* nidas::core::Variable::getConverter ( ) const
inlineinherited
VariableConverter* nidas::core::Variable::getConverter ( )
inlineinherited
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;

Referenced by SyncDumper::run().

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

References nidas::core::Variable::_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
inlineinherited
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.

Referenced by parseAnalog().

const std::list<const Parameter*>& nidas::core::Variable::getParameters ( ) const
inlineinherited
void nidas::core::Variable::getPlotRange ( float &  minv,
float &  maxv 
) const
inlineinherited
const std::string& nidas::core::Variable::getPrefix ( ) const
inlineinherited
float Variable::getSampleRate ( ) const
inherited

Convenience routine to get the SampleTag rate.

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

Referenced by SyncDumper::run().

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

Site suffix, which is added to the name.

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

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::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(), nidas::core::Variable::setSampleTag(), and nidas::core::Variable::setSite().

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.

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

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

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

Referenced by SyncDumper::run(), and nidas::dynld::raf::SyncRecordReader::throw().

type_t nidas::core::Variable::getType ( ) const
inlineinherited
const std::string& nidas::core::Variable::getUnits ( ) const
inlineinherited
bool nidas::core::Variable::isDynamic ( ) const
inlineinherited
bool Variable::operator!= ( const Variable x) const
inherited
bool Variable::operator< ( const Variable x) const
inherited
SyncRecordVariable& nidas::dynld::raf::SyncRecordVariable::operator= ( const SyncRecordVariable )
private

Assignment not supported.

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

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

The A2D channel for this variable.

References nidas::core::Variable::_A2dChannel.

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

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.

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

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.

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

void nidas::dynld::raf::SyncRecordVariable::setLagOffset ( int  val)
inline
void nidas::core::Variable::setLength ( unsigned int  val)
inlineinherited
void nidas::core::Variable::setLongName ( const std::string &  val)
inlineinherited
void nidas::core::Variable::setMaxValue ( float  val)
inlineinherited
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, and nidas::core::Variable::_plotRange.

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

void nidas::core::Variable::setMissingValue ( float  val)
inlineinherited
void nidas::core::Variable::setName ( const std::string &  val)
inlineinherited
void nidas::core::Variable::setPlotRange ( float  minv,
float  maxv 
)
inlineinherited
void nidas::core::Variable::setPrefix ( const std::string &  val)
inlineinherited
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::Variable::getSite(), nidas::core::SampleTag::getSite(), nidas::core::Variable::getStation(), nidas::core::SampleTag::getStation(), nidas::core::Variable::setSite(), and nidas::core::Variable::setStation().

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

void nidas::core::Variable::setSite ( const Site val)
inlineinherited
void nidas::core::Variable::setStation ( int  val)
inlineinherited
void nidas::core::Variable::setSuffix ( const std::string &  val)
inlineinherited
void nidas::dynld::raf::SyncRecordVariable::setSyncRecOffset ( int  val)
inline
void nidas::core::Variable::setType ( type_t  val)
inlineinherited
void nidas::core::Variable::setUnits ( const std::string &  val)
inlineinherited
xercesc::DOMElement * Variable::toDOMElement ( xercesc::DOMElement *  node,
bool  complete 
) const
throw (xercesc::DOMException
)
virtualinherited

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

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::dynld::raf::SyncRecordVariable::lagOffset
private
int nidas::dynld::raf::SyncRecordVariable::offset
private

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