nidas  v1.2-1520
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes | List of all members
nidas::core::SampleClock Class Reference

SampleClock adds date information to sample time tags. More...

#include <SampleClock.h>

Public Types

enum  status_t { NO_CLOCK, OUT_OF_SPEC, OK }
 Enumeration of the result of addSampleDate(). More...
 

Public Member Functions

 SampleClock ()
 Constructor. More...
 
void setMaxClockDiff (int val)
 
void setTime ()
 Update the SampleClock from the UNIX OS clock. More...
 
status_t addSampleDate (Sample *samp)
 Add date information to a sample time tag. More...
 

Static Public Member Functions

static SampleClockgetInstance ()
 

Private Attributes

int _maxClockDiffSec
 
dsm_time_t _t0day
 
dsm_time_t _clockTime
 

Static Private Attributes

static SampleClock_instance = new SampleClock()
 

Detailed Description

SampleClock adds date information to sample time tags.

Sample timetags from the various NIDAS driver modules are only timetagged with the time since 00:00 GMT of the current day. SampleClock adds the day offset to the timetags, so that they are an absolute time.

Member Enumeration Documentation

Enumeration of the result of addSampleDate().

Enumerator
NO_CLOCK 
OUT_OF_SPEC 
OK 

Constructor & Destructor Documentation

SampleClock::SampleClock ( )

Member Function Documentation

SampleClock::status_t SampleClock::addSampleDate ( Sample samp)

Add date information to a sample time tag.

Parameters
sampA Sample, whose timetag value is a relative time in microseconds since 00:00 GMT.
Returns
Enumeration of time tag status: NO_CLOCK: we don't have absolute time information yet, sample time tag is not valid, OUT_OF_SPEC: sample time differs from absolute time, by more than maxClockDiff, sample time tag is not valid, OK: good sample time.

References _clockTime, _maxClockDiffSec, _t0day, nidas::util::UTime::format(), GET_DSM_ID, GET_SHORT_ID, nidas::core::Sample::getId(), nidas::util::Logger::getInstance(), nidas::util::getSystemTime(), nidas::core::Sample::getTimeTag(), nidas::util::Logger::log(), LOG_DEBUG, OK, OUT_OF_SPEC, SECS_PER_DAY, setTime(), nidas::core::Sample::setTimeTag(), USECS_PER_DAY, and USECS_PER_SEC.

Referenced by nidas::core::DriverSampleScanner::nextSample().

static SampleClock* nidas::core::SampleClock::getInstance ( )
inlinestatic
void nidas::core::SampleClock::setMaxClockDiff ( int  val)
inline
Parameters
val,:A check for reasonable sample times (seconds). If the sample time differs from the clock source time (as set by setTime) by more than maxClockDiff, then the state is set to OUT_OF_SPEC.

References _maxClockDiffSec.

void SampleClock::setTime ( )

Update the SampleClock from the UNIX OS clock.

References _clockTime, _t0day, nidas::util::getSystemTime(), nidas::util::timeFloor(), and USECS_PER_DAY.

Referenced by addSampleDate().

Member Data Documentation

dsm_time_t nidas::core::SampleClock::_clockTime
private

Referenced by addSampleDate(), SampleClock(), and setTime().

SampleClock * SampleClock::_instance = new SampleClock()
staticprivate

Referenced by getInstance().

int nidas::core::SampleClock::_maxClockDiffSec
private

Referenced by addSampleDate(), and setMaxClockDiff().

dsm_time_t nidas::core::SampleClock::_t0day
private

Referenced by addSampleDate(), SampleClock(), and setTime().


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