nidas
v1.2-1520
|
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_t > | times |
Json::Value | header |
SampleCounter accumulates samples and values for a particular sample stream.
|
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.
void SampleCounter::accumulateData | ( | const Sample * | samp | ) |
References nidas::util::addBackslashSequences(), nidas::core::CHAR_ST, nidas::core::DOUBLE_ST, nidas::core::FLOAT_ST, nidas::core::Sample::getConstVoidDataPtr(), nidas::core::Sample::getDataByteLength(), nidas::core::Sample::getDataLength(), nidas::core::Sample::getDataValue(), nidas::core::Sample::getTimeTag(), and nidas::core::Sample::getType().
void SampleCounter::accumulateSample | ( | const Sample * | samp | ) |
References nidas::core::Sample::getDataByteLength(), nidas::core::Sample::getTimeTag(), and USECS_PER_MSEC.
Referenced by DataStats::restartStats().
References assign_if_set(), GET_DSM_ID, GET_SPS_ID, nidas::core::DSMSensor::getCatalogName(), nidas::core::DSMSensor::getClassName(), nidas::core::DSMSensor::getDepthString(), nidas::core::DSMSensor::getDeviceName(), nidas::core::DSMSensor::getDSMConfig(), nidas::core::DSMSensor::getHeightString(), nidas::core::DSMSensor::getLocation(), nidas::core::Variable::getLongName(), nidas::core::Site::getName(), nidas::core::DSMConfig::getName(), nidas::core::Project::getName(), nidas::core::Variable::getName(), nidas::core::Variable::getPrefix(), nidas::core::DSMConfig::getProject(), nidas::core::SampleTag::getRate(), nidas::core::DSMSensor::getSite(), nidas::core::Variable::getUnits(), nidas::core::SampleTag::getVariables(), and rate.
|
inline |
References nidas::core::floatNAN, rate, and USECS_PER_SEC.
Referenced by DataStats::printReport().
|
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().
|
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().
|
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().
|
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 | ) |
References ELOG, nidas::core::NidasApp::getApplicationInstance(), nidas::core::Sample::getId(), ILOG, and VLOG.
|
inline |
Reset the accumulated data without changing the sample tag information.
bool SampleCounter::enable_data |
bool SampleCounter::enable_json |
vector<string> SampleCounter::fullnames |
Json::Value SampleCounter::header |
dsm_sample_id_t SampleCounter::id |
Referenced by DataStats::addCounter(), and DataStats::printReport().
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 |
Referenced by DataStats::jsonReport(), and DataStats::printReport().
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 |