nidas v1.2.3
|
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. | |
SampleCounter * | addCounter (const SampleCounter &counter) |
Copy the counter into the samples map and return a reference to it. | |
SampleCounter * | getCounter (dsm_sample_id_t sid) |
Return a pointer to the SampleCounter for the given sample id sid . | |
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. | |
void | clearSampleQueue () |
void | report () |
void | flush () throw () |
Ask that this SampleClient send out any buffered Samples that it may be holding. | |
bool | receive (const Sample *samp) throw () |
Method called to pass a sample to this client. | |
void | printReport (std::ostream &outs) |
void | jsonReport () |
void | resetResults () |
void | setStart (const UTime &start) |
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 |
bool | _counters_created {false} |
list< DSMSensor * > | allsensors {} |
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 |
NidasAppArg | ShowProblems |
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, ShowProblems, SingleMote, Update, nidas::core::NidasApp::Version, and nidas::core::NidasApp::XmlHeaderFile.
|
inline |
References clearSampleQueue().
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, nidas::core::getSample(), hashId(), JsonOutput, and nidas::core::NidasAppArg::specified().
Referenced by createCounters().
void DataStats::clearSampleQueue | ( | ) |
References _sampleq, and nidas::core::Sample::freeReference().
Referenced by ~DataStats().
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::DSMSensor::getId(), nidas::core::SampleTag::getId(), nidas::core::getSample(), nidas::core::DSMSensor::getSampleTagIterator(), nidas::core::SampleTag::getVariables(), nidas::core::NidasApp::processData(), and nidas::core::NidasApp::sampleMatcher().
|
inlineprivate |
References headerWriter, and streamWriter.
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, nidas::core::getSample(), and hashId().
Referenced by createCounters(), and restartStats().
References _alarm, and nidas::core::NidasApp::setInterrupted().
Referenced by run().
|
private |
References _app, _singlemote, nidas::core::NidasApp::formatId(), nidas::core::getSample(), and VLOG.
Referenced by addCounter(), and getCounter().
void DataStats::jsonReport | ( | ) |
References _period, _period_end, _period_start, _reportall, _reportdata, _samples, _start_time, _update, Problem::asJsonArray(), createJsonWriters(), createObject(), nidas::util::UTime::format(), nidas::core::getSample(), nidas::core::NidasAppArg::getValue(), headerWriter, ILOG, SampleCounter::jsonHeader(), JsonOutput, and streamWriter.
Referenced by report().
References nidas::core::getSample(), and nidas::core::XMLImplementation::terminate().
Referenced by main().
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, and usage().
void DataStats::printReport | ( | std::ostream & | outs | ) |
References _fullnames, _reportall, _reportdata, _samples, nidas::core::NidasAppArg::asBool(), nidas::core::NidasApp::formatSampleId(), GET_DSM_ID, nidas::core::NidasApp::getApplicationInstance(), SampleCounter::getHeaderLine(), nidas::core::getSample(), SampleCounter::jsonStats(), MSECS_PER_SEC, rate, ShowProblems, USECS_PER_MSEC, and USECS_PER_SEC.
Referenced by report().
void DataStats::readHeader | ( | SampleInputStream & | sis | ) |
References _alarm, _app, _nreports, _realtime, _update, DLOG, nidas::core::getSample(), nidas::core::NidasApp::interrupted(), and reportsExhausted().
Referenced by run().
void DataStats::readSamples | ( | SampleInputStream & | sis | ) |
References _alarm, _app, _period_end, _realtime, _update, DLOG, nidas::core::getSample(), nidas::core::NidasApp::interrupted(), and nidas::util::UTime::toUsecs().
Referenced by run().
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.
References DLOG, nidas::core::NidasApp::formatId(), nidas::util::UTime::isZero(), nidas::core::SampleMatcher::match(), nidas::core::NidasApp::sampleMatcher(), nidas::util::UTime::toUsecs(), and VLOG.
void DataStats::report | ( | ) |
References _period, _period_end, _period_start, nidas::core::getSample(), ILOG, JsonOutput, jsonReport(), printReport(), and nidas::core::NidasAppArg::specified().
Referenced by run().
References _count, _nreports, and nidas::core::getSample().
Referenced by readHeader(), and run().
void DataStats::resetResults | ( | ) |
References _samples, and nidas::core::getSample().
Referenced by restartStats().
Recalculate statistics as needed based on the current collection of data and time period.
References _sampleq, DLOG, getCounter(), nidas::core::getSample(), 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, _update, nidas::core::NidasApp::addSignal(), allsensors, nidas::core::NidasApp::dataFileNames(), DLOG, FilterArg, nidas::core::SampleInputHeader::getConfigName(), nidas::core::FileSet::getFileSet(), nidas::core::BadSampleFilterArg::getFilter(), nidas::core::Project::getInstance(), nidas::core::DSMSensor::getRawSampleTag(), nidas::core::getSample(), nidas::core::DSMConfig::getSensors(), handleSignal(), ILOG, nidas::core::DSMSensor::init(), nidas::core::NidasApp::interrupted(), nidas::core::parseXMLConfigFile(), nidas::core::NidasApp::processData(), readHeader(), readSamples(), report(), reportsExhausted(), restartStats(), setStart(), nidas::core::NidasApp::socketAddress(), nidas::core::XMLImplementation::terminate(), USECS_PER_SEC, and nidas::core::NidasApp::xmlHeaderFile().
References _period, _period_end, _period_start, _start_time, _update, and USECS_PER_SEC.
Referenced by run().
References _app, nidas::core::NidasApp::briefHelp(), nidas::core::getSample(), and nidas::core::NidasApp::usage().
Referenced by parseRunstring().
|
staticprivate |
Referenced by handleSignal(), readHeader(), and readSamples().
|
private |
Referenced by createCounters(), DataStats(), hashId(), parseRunstring(), readHeader(), readSamples(), run(), and usage().
|
private |
Referenced by parseRunstring(), and reportsExhausted().
|
private |
Referenced by parseRunstring(), and printReport().
|
private |
Referenced by readHeader(), reportsExhausted(), and run().
|
private |
Referenced by jsonReport(), parseRunstring(), report(), run(), and setStart().
|
private |
Referenced by jsonReport(), readSamples(), report(), run(), and setStart().
|
private |
Referenced by jsonReport(), report(), run(), and setStart().
|
private |
Referenced by readHeader(), readSamples(), 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 setStart().
|
private |
Referenced by jsonReport(), parseRunstring(), readHeader(), readSamples(), run(), and setStart().
|
private |
Referenced by DataStats(), and parseRunstring().
|
private |
Referenced by DataStats(), and parseRunstring().
Referenced by DataStats().
|
private |
Referenced by DataStats(), and run().
|
private |
Referenced by DataStats(), and parseRunstring().
|
private |
Referenced by createJsonWriters(), and 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 printReport().
|
private |
Referenced by DataStats(), and parseRunstring().
|
private |
Referenced by createJsonWriters(), and jsonReport().
|
private |
Referenced by DataStats(), and parseRunstring().