nidas  v1.2-1520
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. More...
 
void enableJSON (bool enable)
 Set whether information for JSON output will be accumulated, according to whether enable is true or false. More...
 
void enableData (bool enable)
 Set whether data values will be extracted from processed samples and accumulated to compute data statistics. More...
 
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. More...
 
void reset ()
 Reset the accumulated data without changing the sample tag information. More...
 
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. More...
 
std::string generateStreamId (const DSMSensor *sensor=0)
 Generate a streamid for this SampleCounter. More...
 
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. More...
 
Json::Value jsonStats ()
 Return a json object with the statistics calculated for this stream. More...
 
Json::Value jsonHeader ()
 Return a Json::Value containing just the header for this SampleClient. More...
 

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
 
int minDeltaTs
 
int maxDeltaTs
 
vector< string > varnames
 
vector< string > fullnames
 
bool enable_json
 
bool enable_data
 
vector< float > sums
 
vector< int > nnans
 
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 ( 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.

Member Function Documentation

void SampleCounter::accumulateData ( const Sample samp)
void SampleCounter::accumulateSample ( const Sample samp)
void SampleCounter::collectMetadata ( const DSMSensor sensor = 0,
const SampleTag stag = 0 
)
double SampleCounter::computeRate ( )
inline
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.

Referenced by DataStats::addCounter().

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.

Referenced by DataStats::addCounter().

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::Project::getName(), nidas::core::DSMConfig::getProject(), and id_to_string().

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.

Referenced by DataStats::printReport().

Json::Value SampleCounter::jsonData ( )

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

Referenced by DataStats::jsonReport().

Json::Value SampleCounter::jsonHeader ( )
inline

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

Referenced by DataStats::jsonReport().

Json::Value SampleCounter::jsonStats ( )

Return a json object with the statistics calculated for this stream.

References MSECS_PER_SEC.

Referenced by DataStats::jsonReport().

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

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

Referenced by DataStats::printReport().

bool SampleCounter::receive ( const Sample samp)
void SampleCounter::reset ( )
inline

Reset the accumulated data without changing the sample tag information.

Member Data Documentation

bool SampleCounter::enable_data
bool SampleCounter::enable_json
vector<string> SampleCounter::fullnames
Json::Value SampleCounter::header
dsm_sample_id_t SampleCounter::id
int SampleCounter::maxDeltaTs

Referenced by DataStats::printReport().

size_t SampleCounter::maxlens

Referenced by DataStats::printReport().

int SampleCounter::minDeltaTs

Referenced by DataStats::printReport().

size_t SampleCounter::minlens

Referenced by DataStats::printReport().

vector<int> SampleCounter::nnans
size_t SampleCounter::nsamps
vector<std::string> SampleCounter::rawmsg
string SampleCounter::sname
string SampleCounter::streamid

Referenced by DataStats::jsonReport().

vector<float> SampleCounter::sums
dsm_time_t SampleCounter::t1s

Referenced by DataStats::printReport().

dsm_time_t SampleCounter::t2s

Referenced by DataStats::printReport().

vector<dsm_time_t> SampleCounter::times
vector<vector<float> > SampleCounter::values
vector<string> SampleCounter::varnames

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