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

Member Typedef Documentation

◆ sample_map_t

◆ sample_queue

Constructor & Destructor Documentation

◆ DataStats()

DataStats::DataStats ( )

◆ ~DataStats()

DataStats::~DataStats ( )
inline

References clearSampleQueue().

Member Function Documentation

◆ addCounter()

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

◆ clearSampleQueue()

void DataStats::clearSampleQueue ( )

◆ createCounters()

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

◆ createJsonWriters()

void DataStats::createJsonWriters ( )
inlineprivate

References headerWriter, and streamWriter.

Referenced by jsonReport().

◆ flush()

void DataStats::flush ( )
throw ( )
inlinevirtual

Ask that this SampleClient send out any buffered Samples that it may be holding.

Exceptions

)

Implements nidas::core::SampleClient.

◆ getCounter()

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

◆ handleSignal()

void DataStats::handleSignal ( int signum)
static

References _alarm, and nidas::core::NidasApp::setInterrupted().

Referenced by run().

◆ hashId()

dsm_sample_id_t DataStats::hashId ( dsm_sample_id_t sid)
private

◆ jsonReport()

void DataStats::jsonReport ( )

◆ main()

int DataStats::main ( int argc,
char ** argv )
static

◆ parseRunstring()

int DataStats::parseRunstring ( int argc,
char ** argv )

◆ printReport()

void DataStats::printReport ( std::ostream & outs)

◆ readHeader()

void DataStats::readHeader ( SampleInputStream & sis)

◆ readSamples()

void DataStats::readSamples ( SampleInputStream & sis)

◆ receive()

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.

Exceptions

)

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.

◆ report()

void DataStats::report ( )

◆ reportsExhausted()

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

References _count, _nreports, and nidas::core::getSample().

Referenced by readHeader(), and run().

◆ resetResults()

void DataStats::resetResults ( )

References _samples, and nidas::core::getSample().

Referenced by restartStats().

◆ 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, DLOG, getCounter(), nidas::core::getSample(), nidas::core::Sample::getTimeTag(), resetResults(), and nidas::util::UTime::toUsecs().

Referenced by run().

◆ run()

int DataStats::run ( )

◆ setStart()

void DataStats::setStart ( const UTime & start)

◆ usage()

int DataStats::usage ( const char * argv0)

Member Data Documentation

◆ _alarm

bool DataStats::_alarm
staticprivate

◆ _app

NidasApp DataStats::_app
private

◆ _count

int DataStats::_count
private

Referenced by parseRunstring(), and reportsExhausted().

◆ _counters_created

bool DataStats::_counters_created {false}
private

◆ _fullnames

bool DataStats::_fullnames
private

Referenced by parseRunstring(), and printReport().

◆ _nreports

int DataStats::_nreports
private

Referenced by readHeader(), reportsExhausted(), and run().

◆ _period

int DataStats::_period
private

◆ _period_end

UTime DataStats::_period_end
private

◆ _period_start

UTime DataStats::_period_start
private

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

◆ _realtime

bool DataStats::_realtime
private

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

◆ _reportall

bool DataStats::_reportall
private

◆ _reportdata

bool DataStats::_reportdata
private

◆ _sampleq

sample_queue DataStats::_sampleq
private

Referenced by clearSampleQueue(), and restartStats().

◆ _samples

sample_map_t DataStats::_samples
private

◆ _singlemote

bool DataStats::_singlemote
private

Referenced by hashId(), and parseRunstring().

◆ _start_time

UTime DataStats::_start_time
private

Referenced by jsonReport(), and setStart().

◆ _update

int DataStats::_update
private

◆ AllSamples

NidasAppArg DataStats::AllSamples
private

Referenced by DataStats(), and parseRunstring().

◆ allsensors

list<DSMSensor*> DataStats::allsensors {}
private

Referenced by run().

◆ Count

NidasAppArg DataStats::Count
private

Referenced by DataStats(), and parseRunstring().

◆ DEFAULT_PORT

const int DataStats::DEFAULT_PORT = 30000
staticprivate

Referenced by DataStats().

◆ FilterArg

BadSampleFilterArg DataStats::FilterArg
private

Referenced by DataStats(), and run().

◆ Fullnames

NidasAppArg DataStats::Fullnames
private

Referenced by DataStats(), and parseRunstring().

◆ headerWriter

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

Referenced by createJsonWriters(), and jsonReport().

◆ JsonOutput

NidasAppArg DataStats::JsonOutput
private

◆ Period

NidasAppArg DataStats::Period
private

Referenced by DataStats(), and parseRunstring().

◆ ShowData

NidasAppArg DataStats::ShowData
private

Referenced by DataStats(), and parseRunstring().

◆ ShowProblems

NidasAppArg DataStats::ShowProblems
private

Referenced by DataStats(), and printReport().

◆ SingleMote

NidasAppArg DataStats::SingleMote
private

Referenced by DataStats(), and parseRunstring().

◆ streamWriter

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

Referenced by createJsonWriters(), and jsonReport().

◆ Update

NidasAppArg DataStats::Update
private

Referenced by DataStats(), and parseRunstring().


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