nidas v1.2.3
Public Member Functions | Public Attributes | List of all members
SampleCounter Class Reference

SampleCounter accumulates samples and values for a particular sample stream. More...

Public Member Functions

 SampleCounter (dsm_sample_id_t sid=0, const DSMSensor *sensor=0, const SampleTag *stag=0)
 Create a SampleCounter for the given sample id sid.
 
void enableJSON (bool enable)
 Set whether information for JSON output will be accumulated, according to whether enable is true or false.
 
void enableData (bool enable)
 Set whether data values will be extracted from processed samples and accumulated to compute data statistics.
 
std::string getHeaderLine (bool allnames)
 Format the sensor name or variable names for this SampleCounter into a comma-separated list, abbreviated to a shortened form unless allnames is true.
 
void reset ()
 Reset the accumulated data without changing the sample tag information.
 
bool receive (const Sample *samp)
 
void accumulateData (const Sample *samp)
 
double computeRate ()
 
void printData (std::ostream &outs)
 Format the data from this SampleCounter and write it to the given output stream outs.
 
std::string generateStreamId (const DSMSensor *sensor=0)
 Generate a streamid for this SampleCounter.
 
void collectMetadata (const DSMSensor *sensor=0, const SampleTag *stag=0)
 
void accumulateSample (const Sample *samp)
 
Json::Value jsonData ()
 Return a Json::Value node containing all the data in this SampleCounter.
 
Json::Value jsonStats (std::vector< Problem > &problems)
 Return a json object with the statistics calculated for this stream, and append any Problem instances to the vector problems.
 
Json::Value jsonHeader ()
 Return a Json::Value containing just the header for this SampleClient.
 

Public Attributes

string streamid
 
string sname
 
dsm_sample_id_t id
 
dsm_time_t t1s
 
dsm_time_t t2s
 
size_t nsamps
 
size_t minlens
 
size_t maxlens
 
size_t totalBytes
 
int minDeltaTs
 
int maxDeltaTs
 
vector< string > varnames
 
vector< string > fullnames
 
bool enable_json
 
bool enable_data
 
vector< floatsums
 
vector< intnnans
 
vector< std::string > rawmsg
 
vector< vector< float > > values
 
vector< dsm_time_ttimes
 
Json::Value header
 

Detailed Description

SampleCounter accumulates samples and values for a particular sample stream.

Constructor & Destructor Documentation

◆ SampleCounter()

SampleCounter::SampleCounter ( dsm_sample_id_t sid = 0,
const DSMSensor * sensor = 0,
const SampleTag * stag = 0 )
inline

Create a SampleCounter for the given sample id sid.

If available, pass the Sensor in sensor, and it will be used to collect metadata about this sample stream and to set a header name. If the SampleTag for this sample is passed in stag, then it is used to store the variable names for the sample values.

References collectMetadata(), fullnames, generateStreamId(), nidas::core::getSample(), sname, streamid, and varnames.

Member Function Documentation

◆ accumulateData()

void SampleCounter::accumulateData ( const Sample * samp)

◆ accumulateSample()

void SampleCounter::accumulateSample ( const Sample * samp)

◆ collectMetadata()

void SampleCounter::collectMetadata ( const DSMSensor * sensor = 0,
const SampleTag * stag = 0 )

◆ computeRate()

double SampleCounter::computeRate ( )
inline

◆ enableData()

void SampleCounter::enableData ( bool enable)
inline

Set whether data values will be extracted from processed samples and accumulated to compute data statistics.

Disabling data statistics automatically disables JSON information.

References enable_data, and enableJSON().

Referenced by enableJSON().

◆ enableJSON()

void SampleCounter::enableJSON ( bool enable)
inline

Set whether information for JSON output will be accumulated, according to whether enable is true or false.

Enabling JSON output automatically enables the collection of data statistics.

References enable_json, and enableData().

Referenced by enableData().

◆ generateStreamId()

std::string SampleCounter::generateStreamId ( const DSMSensor * sensor = 0)

Generate a streamid for this SampleCounter.

The streamid is the unique identifer for this stream of samples based on the available metadata.

References GET_DSM_ID, GET_SPS_ID, nidas::core::DSMSensor::getDSMConfig(), nidas::core::getSample(), and id_to_string().

Referenced by SampleCounter().

◆ getHeaderLine()

std::string SampleCounter::getHeaderLine ( bool allnames)
inline

Format the sensor name or variable names for this SampleCounter into a comma-separated list, abbreviated to a shortened form unless allnames is true.

If this is a raw counter, meaning no variables, then use the sensor name. The fully-qualified variable names are used in the header line to be compatible with historical behavior, but maybe someday this can change.

References fullnames, nidas::core::getSample(), sname, and varnames.

Referenced by DataStats::printReport().

◆ jsonData()

Json::Value SampleCounter::jsonData ( )

Return a Json::Value node containing all the data in this SampleCounter.

References enable_data, nidas::core::getSample(), nsamps, streamid, times, values, and varnames.

◆ jsonHeader()

Json::Value SampleCounter::jsonHeader ( )
inline

Return a Json::Value containing just the header for this SampleClient.

References header.

Referenced by DataStats::jsonReport().

◆ jsonStats()

Json::Value SampleCounter::jsonStats ( std::vector< Problem > & problems)

Return a json object with the statistics calculated for this stream, and append any Problem instances to the vector problems.

References computeRate(), nidas::core::getSample(), header, maxDeltaTs, maxlens, minDeltaTs, minlens, Problem::MISSING_VALUES, MSECS_PER_SEC, nnans, Problem::NO_SAMPLES, nsamps, rate, Problem::SAMPLE_RATE_MISMATCH, streamid, sums, t1s, t2s, totalBytes, and varnames.

Referenced by DataStats::printReport().

◆ printData()

void SampleCounter::printData ( std::ostream & outs)

Format the data from this SampleCounter and write it to the given output stream outs.

References nidas::core::getSample(), nnans, nsamps, rawmsg, sums, and varnames.

◆ receive()

bool SampleCounter::receive ( const Sample * samp)

◆ reset()

void SampleCounter::reset ( )
inline

Reset the accumulated data without changing the sample tag information.

References maxDeltaTs, maxlens, minDeltaTs, minlens, nnans, nsamps, rawmsg, sums, t1s, t2s, times, totalBytes, and values.

Member Data Documentation

◆ enable_data

bool SampleCounter::enable_data

◆ enable_json

bool SampleCounter::enable_json

Referenced by enableJSON().

◆ fullnames

vector<string> SampleCounter::fullnames

Referenced by getHeaderLine(), and SampleCounter().

◆ header

Json::Value SampleCounter::header

◆ id

dsm_sample_id_t SampleCounter::id

◆ maxDeltaTs

int SampleCounter::maxDeltaTs

Referenced by accumulateSample(), jsonStats(), and reset().

◆ maxlens

size_t SampleCounter::maxlens

Referenced by accumulateSample(), jsonStats(), and reset().

◆ minDeltaTs

int SampleCounter::minDeltaTs

Referenced by accumulateSample(), jsonStats(), and reset().

◆ minlens

size_t SampleCounter::minlens

Referenced by accumulateSample(), jsonStats(), and reset().

◆ nnans

vector<int> SampleCounter::nnans

◆ nsamps

size_t SampleCounter::nsamps

◆ rawmsg

vector<std::string> SampleCounter::rawmsg

Referenced by accumulateData(), printData(), and reset().

◆ sname

string SampleCounter::sname

Referenced by getHeaderLine(), and SampleCounter().

◆ streamid

string SampleCounter::streamid

◆ sums

vector<float> SampleCounter::sums

◆ t1s

dsm_time_t SampleCounter::t1s

◆ t2s

dsm_time_t SampleCounter::t2s

◆ times

vector<dsm_time_t> SampleCounter::times

Referenced by accumulateData(), jsonData(), and reset().

◆ totalBytes

size_t SampleCounter::totalBytes

Referenced by accumulateSample(), jsonStats(), and reset().

◆ values

vector<vector<float> > SampleCounter::values

Referenced by accumulateData(), jsonData(), and reset().

◆ varnames

vector<string> SampleCounter::varnames

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