nidas
v1.2-1520
|
Public Member Functions | |
DataStats () | |
~DataStats () | |
int | run () |
void | readHeader (SampleInputStream &sis) |
void | readSamples (SampleInputStream &sis) |
int | parseRunstring (int argc, char **argv) |
int | usage (const char *argv0) |
void | createCounters (const list< DSMSensor * > &sensors) |
Create a SampleCounter for each of the sample tags in the given sensors, if any. More... | |
SampleCounter * | addCounter (const SampleCounter &counter) |
Copy the counter into the samples map and return a reference to it. More... | |
SampleCounter * | getCounter (dsm_sample_id_t sid) |
Return a pointer to the SampleCounter for the given sample id sid . More... | |
bool | reportsExhausted (int nreports=-1) |
void | restartStats (const UTime &start, const UTime &end) |
Recalculate statistics as needed based on the current collection of data and time period. More... | |
void | clearSampleQueue () |
void | report () |
void | flush () throw () |
Ask that this SampleClient send out any buffered Samples that it may be holding. More... | |
bool | receive (const Sample *samp) throw () |
Method called to pass a sample to this client. More... | |
void | printReport (std::ostream &outs) |
void | jsonReport () |
void | resetResults () |
Static Public Member Functions | |
static int | main (int argc, char **argv) |
static void | handleSignal (int signum) |
Private Types | |
typedef map< dsm_sample_id_t, SampleCounter > | sample_map_t |
typedef std::list< const Sample * > | sample_queue |
Private Member Functions | |
dsm_sample_id_t | hashId (dsm_sample_id_t sid) |
void | createJsonWriters () |
Private Attributes | |
sample_map_t | _samples |
bool | _reportall |
bool | _reportdata |
bool | _singlemote |
bool | _fullnames |
bool | _realtime |
UTime | _period_start |
UTime | _period_end |
UTime | _start_time |
int | _count |
int | _period |
int | _update |
int | _nreports |
sample_queue | _sampleq |
NidasApp | _app |
NidasAppArg | Period |
NidasAppArg | Update |
NidasAppArg | Count |
NidasAppArg | AllSamples |
NidasAppArg | ShowData |
NidasAppArg | SingleMote |
NidasAppArg | Fullnames |
BadSampleFilterArg | FilterArg |
NidasAppArg | JsonOutput |
n_u::auto_ptr < Json::StyledStreamWriter > | streamWriter |
n_u::auto_ptr < Json::StyledStreamWriter > | headerWriter |
Static Private Attributes | |
static const int | DEFAULT_PORT = 30000 |
static bool | _alarm |
|
private |
|
private |
DataStats::DataStats | ( | ) |
References _app, nidas::core::NidasAppInputFilesArg::allowFiles, nidas::core::NidasAppInputFilesArg::allowSockets, AllSamples, Count, DEFAULT_PORT, nidas::core::NidasApp::enableArguments(), FilterArg, nidas::core::NidasApp::FormatHexId, nidas::core::NidasApp::FormatSampleId, Fullnames, nidas::core::NidasApp::Help, nidas::core::NidasApp::InputFiles, JsonOutput, nidas::core::NidasApp::loggingArgs(), Period, nidas::core::NidasApp::ProcessData, nidas::core::NidasApp::SampleRanges, nidas::core::NidasApp::setApplicationInstance(), nidas::core::NidasAppInputFilesArg::setDefaultInput(), nidas::core::NidasApp::setupSignals(), ShowData, SingleMote, Update, nidas::core::NidasApp::Version, and nidas::core::NidasApp::XmlHeaderFile.
|
inline |
SampleCounter * DataStats::addCounter | ( | const SampleCounter & | counter | ) |
Copy the counter into the samples map and return a reference to it.
Also configure the counter according to whether json output or data statistics should be enabled. Mote sensor IDs for the same sensor type will be hashed to one bucket, as will sensors with different mote IDs if _singlemote is enabled. This should only be called if getCounter() does not return a counter for the sample ID.
References _reportdata, _samples, SampleCounter::enableData(), SampleCounter::enableJSON(), hashId(), SampleCounter::id, JsonOutput, and nidas::core::NidasAppArg::specified().
Referenced by createCounters().
void DataStats::clearSampleQueue | ( | ) |
References _sampleq, and nidas::core::Sample::freeReference().
void DataStats::createCounters | ( | const list< DSMSensor * > & | sensors | ) |
Create a SampleCounter for each of the sample tags in the given sensors, if any.
Set singlemote
to expect only one mote for each sensor type. When a wisard sensor returns multiple sample tags with different mote IDs, samples will only be expected from one of those tags.
References _app, addCounter(), DLOG, nidas::core::NidasApp::formatId(), getCounter(), nidas::core::DSMSensor::getDeviceName(), nidas::core::DSMSensor::getDSMConfig(), nidas::core::SampleTag::getId(), nidas::core::DSMSensor::getId(), nidas::core::DSMConfig::getName(), nidas::core::DSMSensor::getSampleTagIterator(), nidas::core::SampleTag::getVariables(), nidas::core::SampleTagIterator::hasNext(), nidas::core::SampleMatcher::match(), nidas::core::SampleTagIterator::next(), nidas::core::NidasApp::processData(), and nidas::core::NidasApp::sampleMatcher().
Referenced by run().
|
inlineprivate |
Referenced by jsonReport().
|
inlinevirtual |
Ask that this SampleClient send out any buffered Samples that it may be holding.
Implements nidas::core::SampleClient.
SampleCounter * DataStats::getCounter | ( | dsm_sample_id_t | sid | ) |
Return a pointer to the SampleCounter for the given sample id sid
.
If no such counter exists, return null. Mote sensor sample IDs are hashed into buckets by sensor type and according to the _singlemote setting, so the returned SampleCounter may not have the same ID as the one passed in.
References _samples, and hashId().
Referenced by createCounters(), and restartStats().
|
static |
References nidas::core::NidasApp::setInterrupted().
Referenced by run().
|
private |
References _app, _singlemote, nidas::core::NidasApp::formatId(), and VLOG.
Referenced by addCounter(), and getCounter().
void DataStats::jsonReport | ( | ) |
References _period, _period_end, _period_start, _reportall, _reportdata, _samples, _start_time, _update, createJsonWriters(), createObject(), nidas::core::NidasAppArg::getValue(), headerWriter, ILOG, SampleCounter::jsonData(), SampleCounter::jsonHeader(), JsonOutput, SampleCounter::jsonStats(), SampleCounter::nsamps, SampleCounter::streamid, and streamWriter.
Referenced by report().
|
static |
References parseRunstring(), run(), and nidas::util::Exception::what().
Referenced by main().
int DataStats::parseRunstring | ( | int | argc, |
char ** | argv | ||
) |
References _app, _count, _fullnames, _period, _reportall, _reportdata, _singlemote, _update, AllSamples, nidas::core::NidasAppArg::asBool(), nidas::core::NidasAppArg::asInt(), Count, Fullnames, nidas::core::NidasApp::helpRequested(), nidas::core::NidasApp::parseArgs(), nidas::core::NidasApp::parseInputs(), Period, ShowData, SingleMote, Update, usage(), and nidas::util::Exception::what().
Referenced by main().
void DataStats::printReport | ( | std::ostream & | outs | ) |
References _fullnames, _reportall, _reportdata, _samples, SampleCounter::computeRate(), nidas::core::NidasApp::formatSampleId(), GET_DSM_ID, SampleCounter::getHeaderLine(), SampleCounter::id, SampleCounter::maxDeltaTs, SampleCounter::maxlens, SampleCounter::minDeltaTs, SampleCounter::minlens, MSECS_PER_SEC, SampleCounter::nsamps, SampleCounter::printData(), rate, SampleCounter::t1s, SampleCounter::t2s, USECS_PER_MSEC, and USECS_PER_SEC.
Referenced by report().
void DataStats::readHeader | ( | SampleInputStream & | sis | ) |
void DataStats::readSamples | ( | SampleInputStream & | sis | ) |
References _alarm, _app, _period_end, _realtime, _update, DLOG, nidas::util::Exception::getErrno(), nidas::core::NidasApp::interrupted(), nidas::dynld::SampleInputStream::readSamples(), nidas::util::UTime::toSecs(), nidas::util::UTime::toUsecs(), and nidas::util::Exception::what().
Referenced by run().
|
virtual |
Method called to pass a sample to this client.
This method is typically called by a SampleSource for each of its SampleClients when it has a sample ready. Returns true: success false: sample rejected. This is meant to signal a warning-type situation - like a socket not being available temporarily. True errors will be thrown as an IOException.
Implements nidas::core::SampleClient.
void DataStats::report | ( | ) |
References _period, _period_end, _period_start, _realtime, ILOG, JsonOutput, jsonReport(), printReport(), and nidas::core::NidasAppArg::specified().
Referenced by run().
|
inline |
Referenced by readHeader(), and run().
void DataStats::resetResults | ( | ) |
References _samples.
Referenced by restartStats().
Recalculate statistics as needed based on the current collection of data and time period.
References _sampleq, SampleCounter::accumulateSample(), DLOG, getCounter(), nidas::core::Sample::getId(), nidas::core::Sample::getTimeTag(), resetResults(), and nidas::util::UTime::toUsecs().
Referenced by run().
int DataStats::run | ( | ) |
References _app, _nreports, _period, _period_end, _period_start, _realtime, _start_time, _update, nidas::core::SampleSource::addSampleClient(), nidas::core::NidasApp::addSignal(), nidas::core::FileSet::connect(), nidas::core::SamplePipeline::connect(), createCounters(), nidas::core::NidasApp::dataFileNames(), nidas::core::SamplePipeline::disconnect(), DLOG, nidas::util::Process::expandEnvVars(), FilterArg, nidas::core::SamplePipeline::flush(), nidas::core::SampleInputHeader::getConfigName(), nidas::core::FileSet::getFileSet(), nidas::core::BadSampleFilterArg::getFilter(), nidas::core::SamplePipeline::getProcessedSampleSource(), nidas::core::DSMSensor::getRawSampleTag(), nidas::core::DSMConfig::getSensors(), handleSignal(), nidas::core::DSMConfigIterator::hasNext(), ILOG, nidas::core::DSMSensor::init(), nidas::core::SamplePipeline::interrupt(), nidas::core::NidasApp::interrupted(), nidas::core::SamplePipeline::join(), nidas::core::DSMConfigIterator::next(), nidas::core::parseXMLConfigFile(), nidas::core::NidasApp::processData(), readHeader(), readSamples(), nidas::core::SampleSource::removeSampleClient(), report(), reportsExhausted(), restartStats(), nidas::dynld::SampleInputStream::setBadSampleFilter(), nidas::core::SamplePipeline::setProcSorterLength(), nidas::core::SamplePipeline::setRawSorterLength(), nidas::core::SamplePipeline::setRealTime(), nidas::core::NidasApp::socketAddress(), USECS_PER_SEC, nidas::util::Exception::what(), and nidas::core::NidasApp::xmlHeaderFile().
Referenced by main().
int DataStats::usage | ( | const char * | argv0 | ) |
References _app, and nidas::core::NidasApp::usage().
Referenced by parseRunstring().
|
staticprivate |
Referenced by readHeader(), and readSamples().
|
private |
Referenced by createCounters(), DataStats(), hashId(), parseRunstring(), readHeader(), readSamples(), run(), and usage().
|
private |
Referenced by parseRunstring().
|
private |
Referenced by parseRunstring(), and printReport().
|
private |
Referenced by readHeader(), and run().
|
private |
Referenced by jsonReport(), parseRunstring(), report(), and run().
|
private |
Referenced by jsonReport(), readSamples(), report(), and run().
|
private |
Referenced by jsonReport(), report(), and run().
|
private |
Referenced by readHeader(), readSamples(), report(), and run().
|
private |
Referenced by jsonReport(), parseRunstring(), and printReport().
|
private |
Referenced by addCounter(), jsonReport(), parseRunstring(), and printReport().
|
private |
Referenced by clearSampleQueue(), and restartStats().
|
private |
Referenced by addCounter(), getCounter(), jsonReport(), printReport(), and resetResults().
|
private |
Referenced by hashId(), and parseRunstring().
|
private |
Referenced by jsonReport(), and run().
|
private |
Referenced by jsonReport(), parseRunstring(), readHeader(), readSamples(), and run().
|
private |
Referenced by DataStats(), and parseRunstring().
|
private |
Referenced by DataStats(), and parseRunstring().
|
staticprivate |
Referenced by DataStats().
|
private |
Referenced by DataStats(), and run().
|
private |
Referenced by DataStats(), and parseRunstring().
|
private |
Referenced by jsonReport().
|
private |
Referenced by addCounter(), DataStats(), jsonReport(), and report().
|
private |
Referenced by DataStats(), and parseRunstring().
|
private |
Referenced by DataStats(), and parseRunstring().
|
private |
Referenced by DataStats(), and parseRunstring().
|
private |
Referenced by jsonReport().
|
private |
Referenced by DataStats(), and parseRunstring().