DUDS
Distributed Update of Data from Something
duds::hardware::devices::clocks::GenericClock< SVT, SQT, TVT, TQT > Class Template Referenceabstract

The foundation to a clock driver. More...

#include <Clock.hpp>

Inheritance diagram for duds::hardware::devices::clocks::GenericClock< SVT, SQT, TVT, TQT >:
Collaboration diagram for duds::hardware::devices::clocks::GenericClock< SVT, SQT, TVT, TQT >:

Public Types

typedef std::shared_ptr< GenericClock< SVT, SQT, TVT, TQT > > ClockSptr
 
typedef duds::data::GenericMeasurement< SVT, SQT, TVT, TQT > Measurement
 The measurement type provided by the instruments of this device. More...
 
- Public Types inherited from duds::hardware::devices::GenericDevice< SVT, SQT, TVT, TQT >
typedef clocks::GenericClock< SVT, SQT, TVT, TQT > Clock
 The clock driver type used by the instruments of this device for time stamps. More...
 
typedef std::shared_ptr< ClockClockSptr
 A shared pointer type to the clock type used by this device. More...
 
typedef std::shared_ptr< const MeasurementConstMeasurementSptr
 A shared pointer type to the const measurement type used by this device. More...
 
typedef std::shared_ptr< const SensorConstSensorSptr
 A shared pointer type to the const sensor type used by this device. More...
 
typedef duds::data::GenericMeasurement< SVT, SQT, TVT, TQT > Measurement
 The measurement type provided by the instruments of this device. More...
 
typedef std::shared_ptr< MeasurementMeasurementSptr
 A shared pointer type to the measurement type used by this device. More...
 
typedef GenericSensor< SVT, SQT, TVT, TQT > Sensor
 The sensor type used by this device. More...
 
typedef std::shared_ptr< SensorSensorSptr
 A shared pointer type to the sensor type used by this device. More...
 
typedef std::weak_ptr< SensorSensorWptr
 A weak pointer type to the sensor type used by this device. More...
 

Public Member Functions

 operator ClockSptr () const
 
virtual void sample ()=0
 Samples the time from this clock stores it in the measured field of the Measurement object of the device's first sensor. More...
 
virtual void sample (const ClockSptr &clock)=0
 Samples the time from this clock and the given clock, then stores the measurement. More...
 
virtual void sampleTime (typename Measurement::TimeSample &time)=0
 Samples the time from the clock device without storing the result in the clock's sensor object. More...
 
Measurement::TimeSample sampleTime ()
 Samples the time from the clock device without storing the result in the clock's sensor object. More...
 
virtual bool unambiguous () const noexcept=0
 Returns true if the clock properly reports the time during a leap second. More...
 
- Public Member Functions inherited from duds::hardware::devices::GenericDevice< SVT, SQT, TVT, TQT >
 ~GenericDevice ()
 Modifies member Sensor objects so they no longer have a pointer back to this object, and waits for calls those objects may be making to sharedPtr() to complete. More...
 
ConstMeasurementSptr currentMeasurement (unsigned int sIdx=0) const
 Returns the measurement object for the sensor at the given device specific index. More...
 
unsigned int numSensors () const
 Returns the number of sensors provided by this device. More...
 
virtual void sample (const ClockSptr &clock)=0
 Samples the device and updates its sensor objects, and provides a timestamp from the given clock device. More...
 
const SensorSptrsensor (unsigned int sIdx=0) const
 Returns the sensor object at the given device specific index. More...
 
std::shared_ptr< GenericDevice< SVT, SQT, TVT, TQT > > sharedPtr ()
 Returns a shared pointer to this device object; will be empty if this object's destructor is running. More...
 
- Public Member Functions inherited from duds::Something
virtual ~Something ()=0
 
std::string getName () const
 Returns the name for the current locale. More...
 
const general::LanguageTaggedStringMapnames () const
 Returns the set of names for all locales and languages. More...
 
bool operator!= (const Something &s) const
 Something objects are compared using the someId member. More...
 
bool operator< (const Something &s) const
 Something objects are compared using the someId member. More...
 
bool operator<= (const Something &s) const
 Something objects are compared using the someId member. More...
 
bool operator== (const Something &s) const
 Something objects are compared using the someId member. More...
 
bool operator> (const Something &s) const
 Something objects are compared using the someId member. More...
 
bool operator>= (const Something &s) const
 Something objects are compared using the someId member. More...
 
template<class DerivedClass >
std::shared_ptr< DerivedClass > sharedPtr () const
 Returns a shared pointer to this object for a derived class. More...
 
const boost::uuids::uuid & uuid () const
 Returns the object's unique identifier. More...
 

Protected Member Functions

 GenericClock ()=delete
 
 GenericClock (const boost::uuids::uuid &id)
 
- Protected Member Functions inherited from duds::hardware::devices::GenericDevice< SVT, SQT, TVT, TQT >
 GenericDevice ()=default
 Derived classes should create Sensor objects and place them in sens either in the constructor or an initialization function. More...
 
 GenericDevice (const boost::uuids::uuid &id)
 Derived classes should create Sensor objects and place them in sens either in the constructor or an initialization function. More...
 
void setMeasurement (const ConstMeasurementSptr &store, int sIdx=0) const
 Updates the current measurement of a member sensor. More...
 
void setMeasurement (ConstMeasurementSptr &&store, int sIdx=0) const
 Updates the current measurement of a member sensor. More...
 
- Protected Member Functions inherited from duds::Something
 Something ()=default
 Simple constructor. More...
 
 Something (const boost::uuids::uuid &id)
 Creates Something with the given UUID. More...
 
void setUuid (const boost::uuids::uuid &id)
 Sets the UUID that is associated with this object. More...
 

Static Protected Member Functions

template<class Ratio , class Src , class Dest >
static void convert (Dest &dest, const Src &src)
 General template to convert time in one format to another. More...
 
template<class Ratio , class Src >
static void convert (duds::time::interstellar::FemtoTime &dest, const Src &src)
 Template specialization to convert time in one format to FemtoTime. More...
 
template<class Ratio , class Src >
static void convert (duds::time::interstellar::NanoTime &dest, const Src &src)
 Template specialization to convert time in one format to NanoTime. More...
 
template<class Ratio , class Src >
static void convert (duds::data::GenericValue &dest, const Src &src)
 Template specialization to convert time in one format to FemtoTime in a GenericValue. More...
 
template<class Ratio , class IST , class Src >
static void convertIST (IST &dest, const Src &src)
 Template to convert time in one format to one of the types defined in duds::time::interstellar. More...
 
template<class Ratio , class IST >
static void convertIST (IST &dest, const duds::data::int128_t &src)
 More specialized template to convert time stored in a 128-bit integer to one of the types defined in duds::time::interstellar. More...
 

Additional Inherited Members

- Protected Attributes inherited from duds::hardware::devices::GenericDevice< SVT, SQT, TVT, TQT >
std::vector< SensorSptrsens
 Contains Sensor objects to represent all the kinds of data this device can collect. More...
 
- Protected Attributes inherited from duds::Something
general::LanguageTaggedStringMap ltnames
 A name for this item intended for user presentation. More...
 

Detailed Description

template<class SVT, class SQT, class TVT, class TQT>
class duds::hardware::devices::clocks::GenericClock< SVT, SQT, TVT, TQT >

The foundation to a clock driver.

Todo:
Need to include a way to get a UUID for the clock from a config file.
Template Parameters
SVTSample value type
SQTSample quality type
TVTTime value type
TQTTime quality type
Author
Jeff Jackowski

Definition at line 78 of file Clock.hpp.

Member Typedef Documentation

◆ ClockSptr

template<class SVT, class SQT, class TVT, class TQT>
typedef std::shared_ptr<GenericClock < SVT, SQT, TVT, TQT > > duds::hardware::devices::clocks::GenericClock< SVT, SQT, TVT, TQT >::ClockSptr

Definition at line 84 of file Clock.hpp.

◆ Measurement

template<class SVT, class SQT, class TVT, class TQT>
typedef duds::data::GenericMeasurement<SVT, SQT, TVT, TQT> duds::hardware::devices::clocks::GenericClock< SVT, SQT, TVT, TQT >::Measurement

The measurement type provided by the instruments of this device.

Definition at line 83 of file Clock.hpp.

Constructor & Destructor Documentation

◆ GenericClock() [1/2]

template<class SVT, class SQT, class TVT, class TQT>
duds::hardware::devices::clocks::GenericClock< SVT, SQT, TVT, TQT >::GenericClock ( )
protecteddelete

◆ GenericClock() [2/2]

template<class SVT, class SQT, class TVT, class TQT>
duds::hardware::devices::clocks::GenericClock< SVT, SQT, TVT, TQT >::GenericClock ( const boost::uuids::uuid &  id)
inlineprotected
Todo:
Allow naming the clock sensor object.
Todo:
Provide the name of the clock to the Something base class.

Definition at line 185 of file Clock.hpp.

Member Function Documentation

◆ convert() [1/4]

template<class SVT, class SQT, class TVT, class TQT>
template<class Ratio , class Src , class Dest >
static void duds::hardware::devices::clocks::GenericClock< SVT, SQT, TVT, TQT >::convert ( Dest &  dest,
const Src &  src 
)
inlinestaticprotected

General template to convert time in one format to another.

Template Parameters
RatioThe ratio of one second to one unit of Src.
SrcThe source type.
DestThe destination type. This implementation is for a floating point type.
Parameters
destWhere to put the converted time value. Not a return value because some destination types are large.
srcThe source time.

Definition at line 97 of file Clock.hpp.

◆ convert() [2/4]

template<class SVT, class SQT, class TVT, class TQT>
template<class Ratio , class Src >
static void duds::hardware::devices::clocks::GenericClock< SVT, SQT, TVT, TQT >::convert ( duds::time::interstellar::FemtoTime dest,
const Src &  src 
)
inlinestaticprotected

Template specialization to convert time in one format to FemtoTime.

Template Parameters
RatioThe ratio of one second to one unit of Src.
SrcThe source type.
Parameters
destWhere to put the converted time value.
srcThe source time.

Definition at line 146 of file Clock.hpp.

◆ convert() [3/4]

template<class SVT, class SQT, class TVT, class TQT>
template<class Ratio , class Src >
static void duds::hardware::devices::clocks::GenericClock< SVT, SQT, TVT, TQT >::convert ( duds::time::interstellar::NanoTime dest,
const Src &  src 
)
inlinestaticprotected

Template specialization to convert time in one format to NanoTime.

Template Parameters
RatioThe ratio of one second to one unit of Src.
SrcThe source type.
Parameters
destWhere to put the converted time value.
srcThe source time.

Definition at line 160 of file Clock.hpp.

◆ convert() [4/4]

template<class SVT, class SQT, class TVT, class TQT>
template<class Ratio , class Src >
static void duds::hardware::devices::clocks::GenericClock< SVT, SQT, TVT, TQT >::convert ( duds::data::GenericValue dest,
const Src &  src 
)
inlinestaticprotected

Template specialization to convert time in one format to FemtoTime in a GenericValue.

Template Parameters
RatioThe ratio of one second to one unit of Src.
SrcThe source type.
Parameters
destWhere to put the converted time value.
srcThe source time.

Definition at line 172 of file Clock.hpp.

◆ convertIST() [1/2]

template<class SVT, class SQT, class TVT, class TQT>
template<class Ratio , class IST , class Src >
static void duds::hardware::devices::clocks::GenericClock< SVT, SQT, TVT, TQT >::convertIST ( IST &  dest,
const Src &  src 
)
inlinestaticprotected

Template to convert time in one format to one of the types defined in duds::time::interstellar.

Template Parameters
RatioThe ratio of one second to one unit of Src.
ISTThe destination time type. It should be a time point type from duds::time::interstellar.
SrcThe source type.
Parameters
destWhere to put the converted time value.
srcThe source time.

Definition at line 111 of file Clock.hpp.

◆ convertIST() [2/2]

template<class SVT, class SQT, class TVT, class TQT>
template<class Ratio , class IST >
static void duds::hardware::devices::clocks::GenericClock< SVT, SQT, TVT, TQT >::convertIST ( IST &  dest,
const duds::data::int128_t src 
)
inlinestaticprotected

More specialized template to convert time stored in a 128-bit integer to one of the types defined in duds::time::interstellar.

The specialization is needed to deal with a type conversion of the 128-bit integer from Boost's multiprecision library. It is not needed if the compiler provides a 128-bit integer type.

Template Parameters
RatioThe ratio of one second to one unit of Src.
ISTThe destination time type. It should be a time point type from duds::time::interstellar.
Parameters
destWhere to put the converted time value.
srcThe source time.

Definition at line 130 of file Clock.hpp.

◆ operator ClockSptr()

template<class SVT, class SQT, class TVT, class TQT>
duds::hardware::devices::clocks::GenericClock< SVT, SQT, TVT, TQT >::operator ClockSptr ( ) const
inline

Definition at line 193 of file Clock.hpp.

◆ sample() [1/2]

template<class SVT, class SQT, class TVT, class TQT>
virtual void duds::hardware::devices::clocks::GenericClock< SVT, SQT, TVT, TQT >::sample ( )
pure virtual

Samples the time from this clock stores it in the measured field of the Measurement object of the device's first sensor.

The timestamp field will be clear.

Implements duds::hardware::devices::GenericDevice< SVT, SQT, TVT, TQT >.

Implemented in duds::hardware::devices::clocks::GenericPosixClock< SVT, SQT, TVT, TQT >, duds::hardware::devices::clocks::GenericLinuxClock< SVT, SQT, TVT, TQT >, and duds::hardware::devices::clocks::GenericCppClock< CLK, SVT, SQT, TVT, TQT >.

◆ sample() [2/2]

template<class SVT, class SQT, class TVT, class TQT>
virtual void duds::hardware::devices::clocks::GenericClock< SVT, SQT, TVT, TQT >::sample ( const ClockSptr clock)
pure virtual

Samples the time from this clock and the given clock, then stores the measurement.

The sample from this clock will be in the measured field of the Measurement object, while the sample from the given clock will be in the timestamp field.

Parameters
clockThe clock that will be sampled for the timestamp in the resulting measurement. If it is this clock, the clock must only be sampled once and the same time must be in both the measured and timestamp fields of the Measurement object. Different types may be used to hold the time in those fields so they might not evaluate as equal.

Implemented in duds::hardware::devices::clocks::GenericPosixClock< SVT, SQT, TVT, TQT >, duds::hardware::devices::clocks::GenericLinuxClock< SVT, SQT, TVT, TQT >, and duds::hardware::devices::clocks::GenericCppClock< CLK, SVT, SQT, TVT, TQT >.

◆ sampleTime() [1/2]

template<class SVT, class SQT, class TVT, class TQT>
virtual void duds::hardware::devices::clocks::GenericClock< SVT, SQT, TVT, TQT >::sampleTime ( typename Measurement::TimeSample time)
pure virtual

Samples the time from the clock device without storing the result in the clock's sensor object.

Parameters
timeThe place to put the sampled time.

Implemented in duds::hardware::devices::clocks::GenericPosixClock< SVT, SQT, TVT, TQT >, duds::hardware::devices::clocks::GenericLinuxClock< SVT, SQT, TVT, TQT >, and duds::hardware::devices::clocks::GenericCppClock< CLK, SVT, SQT, TVT, TQT >.

◆ sampleTime() [2/2]

template<class SVT, class SQT, class TVT, class TQT>
Measurement::TimeSample duds::hardware::devices::clocks::GenericClock< SVT, SQT, TVT, TQT >::sampleTime ( )
inline

Samples the time from the clock device without storing the result in the clock's sensor object.

Returns
The sampled time.

Definition at line 222 of file Clock.hpp.

◆ unambiguous()

template<class SVT, class SQT, class TVT, class TQT>
virtual bool duds::hardware::devices::clocks::GenericClock< SVT, SQT, TVT, TQT >::unambiguous ( ) const
pure virtualnoexcept

Returns true if the clock properly reports the time during a leap second.

Should the clock replay the second 59 for the leap second, then two seconds appear the same making the time ambiguous. If the clock reports 60 for the second field during a leap second, increments normally, or otherwise makes the leap second distinct, then it is unambiguous.

Ideally, ambiguous clocks should also indicate the problem in the reported quality values. For example, if a clock replays the previous second during the leap second, the accracy value should increase by a second starting one second before the leap second and continuing until after the leap second.

Implemented in duds::hardware::devices::clocks::GenericPosixClock< SVT, SQT, TVT, TQT >, duds::hardware::devices::clocks::GenericLinuxClock< SVT, SQT, TVT, TQT >, and duds::hardware::devices::clocks::GenericCppClock< CLK, SVT, SQT, TVT, TQT >.


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