nidas  v1.2-1520
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
DataStats Class Reference
Inheritance diagram for DataStats:
Inheritance graph
[legend]

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...
 
SampleCounteraddCounter (const SampleCounter &counter)
 Copy the counter into the samples map and return a reference to it. More...
 
SampleCountergetCounter (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
 

Member Typedef Documentation

typedef std::list<const Sample*> DataStats::sample_queue
private

Constructor & Destructor Documentation

DataStats::DataStats ( )
DataStats::~DataStats ( )
inline

Member Function Documentation

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 ( )
void DataStats::createCounters ( const list< DSMSensor * > &  sensors)
void DataStats::createJsonWriters ( )
inlineprivate

Referenced by jsonReport().

void DataStats::flush ( )
throw (
)
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().

void DataStats::handleSignal ( int  signum)
static

References nidas::core::NidasApp::setInterrupted().

Referenced by run().

dsm_sample_id_t DataStats::hashId ( dsm_sample_id_t  sid)
private
void DataStats::jsonReport ( )
int DataStats::main ( int  argc,
char **  argv 
)
static

References parseRunstring(), run(), and nidas::util::Exception::what().

Referenced by main().

int DataStats::parseRunstring ( int  argc,
char **  argv 
)
void DataStats::printReport ( std::ostream &  outs)
void DataStats::readHeader ( SampleInputStream sis)
void DataStats::readSamples ( SampleInputStream sis)
bool DataStats::receive ( const Sample s)
throw (
)
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.

References DLOG, and VLOG.

void DataStats::report ( )
bool DataStats::reportsExhausted ( int  nreports = -1)
inline

Referenced by readHeader(), and run().

void DataStats::resetResults ( )

References _samples.

Referenced by restartStats().

void DataStats::restartStats ( const UTime start,
const UTime end 
)

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().

Member Data Documentation

bool DataStats::_alarm
staticprivate

Referenced by readHeader(), and readSamples().

NidasApp DataStats::_app
private
int DataStats::_count
private

Referenced by parseRunstring().

bool DataStats::_fullnames
private

Referenced by parseRunstring(), and printReport().

int DataStats::_nreports
private

Referenced by readHeader(), and run().

int DataStats::_period
private
UTime DataStats::_period_end
private

Referenced by jsonReport(), readSamples(), report(), and run().

UTime DataStats::_period_start
private

Referenced by jsonReport(), report(), and run().

bool DataStats::_realtime
private

Referenced by readHeader(), readSamples(), report(), and run().

bool DataStats::_reportall
private
bool DataStats::_reportdata
private
sample_queue DataStats::_sampleq
private

Referenced by clearSampleQueue(), and restartStats().

sample_map_t DataStats::_samples
private
bool DataStats::_singlemote
private

Referenced by hashId(), and parseRunstring().

UTime DataStats::_start_time
private

Referenced by jsonReport(), and run().

int DataStats::_update
private
NidasAppArg DataStats::AllSamples
private

Referenced by DataStats(), and parseRunstring().

NidasAppArg DataStats::Count
private

Referenced by DataStats(), and parseRunstring().

const int DataStats::DEFAULT_PORT = 30000
staticprivate

Referenced by DataStats().

BadSampleFilterArg DataStats::FilterArg
private

Referenced by DataStats(), and run().

NidasAppArg DataStats::Fullnames
private

Referenced by DataStats(), and parseRunstring().

n_u::auto_ptr<Json::StyledStreamWriter> DataStats::headerWriter
private

Referenced by jsonReport().

NidasAppArg DataStats::JsonOutput
private
NidasAppArg DataStats::Period
private

Referenced by DataStats(), and parseRunstring().

NidasAppArg DataStats::ShowData
private

Referenced by DataStats(), and parseRunstring().

NidasAppArg DataStats::SingleMote
private

Referenced by DataStats(), and parseRunstring().

n_u::auto_ptr<Json::StyledStreamWriter> DataStats::streamWriter
private

Referenced by jsonReport().

NidasAppArg DataStats::Update
private

Referenced by DataStats(), and parseRunstring().


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