15 #include <boost/uuid/name_generator.hpp> 17 namespace duds {
namespace hardware {
namespace devices {
77 template<
class SVT,
class SQT,
class TVT,
class TQT>
84 typedef std::shared_ptr<GenericClock < SVT, SQT, TVT, TQT > >
ClockSptr;
96 template<
class Ratio,
class Src,
class Dest>
97 static void convert(Dest &dest,
const Src &src) {
98 dest = (Dest)src * ((Dest)(Ratio::num) / (Dest)(Ratio::den));
110 template<
class Ratio,
class IST,
class Src>
113 typedef std::ratio_divide<Ratio, typename IST::period> r;
114 dest = IST(
typename IST::duration((src * r::num) / r::den));
116 #if !defined(HAVE_INT128) | defined(DOXYGEN) 129 template<
class Ratio,
class IST>
132 typedef std::ratio_divide<Ratio, typename IST::period> r;
133 dest = IST(
typename IST::duration(
134 ((src * r::num) / r::den).
template convert_to<typename IST::rep>()
145 template<
class Ratio,
class Src>
150 convertIST<Ratio, duds::time::interstellar::FemtoTime>(dest, src);
159 template<
class Ratio,
class Src>
161 convertIST<Ratio, duds::time::interstellar::NanoTime>(dest, src);
171 template<
class Ratio,
class Src>
174 typedef std::ratio_divide<Ratio, std::femto> r;
175 duds::time::interstellar::Femtoseconds::rep bigsrc = src;
177 (src * r::num) / r::den
187 boost::uuids::name_generator_latest g(
id);
194 return Something::sharedPtr< GenericClock< SVT, SQT, TVT, TQT > >();
216 virtual bool unambiguous()
const noexcept = 0;
235 virtual void sample() = 0;
249 virtual void sample(
const ClockSptr &clock) = 0;
267 #endif // #ifndef CLOCK_HPP boost::variant< std::string, duds::general::LanguageTaggedString, std::array< std::int32_t, 4 >, std::array< std::int64_t, 2 >, duds::data::int128_w, std::array< float, 4 >, std::array< double, 2 >, double, duds::data::Quantity, boost::recursive_wrapper< duds::data::QuantityNddArray >, duds::time::interstellar::Femtoseconds, duds::time::interstellar::Nanoseconds, duds::time::interstellar::FemtoTime, duds::time::interstellar::NanoTime, boost::uuids::uuid, boost::recursive_wrapper< duds::data::GenericValueTable >, std::shared_ptr< std::vector< char > >> GenericValue
A general value of a type can be serialized for transmission over a network and can be used with a re...
static void convert(duds::time::interstellar::NanoTime &dest, const Src &src)
Template specialization to convert time in one format to NanoTime.
boost::multiprecision::int128_t int128_t
The type used for 128-bit integers.
static void convert(duds::time::interstellar::FemtoTime &dest, const Src &src)
Template specialization to convert time in one format to FemtoTime.
The base type for errors from clocks.
A template for a sample from an insturment.
GenericClock(const boost::uuids::uuid &id)
static std::shared_ptr< GenericSensor< SVT, SQT, TVT, TQT > > make(Device *pdev)
Make a sensor without setting the UUID.
static void convert(Dest &dest, const Src &src)
General template to convert time in one format to another.
std::shared_ptr< Clock > ClockSptr
Measurement::TimeSample sampleTime()
Samples the time from the clock device without storing the result in the clock's sensor object...
duds::data::GenericSample< duds::time::interstellar::FemtoTime, double > FemtoTimeSample
A time sample fit for applications requiring very long-term time samples, or time samples with high r...
Represents something with one or more sensors that are sampled through the same hardware.
NanoTimeSample TimeSample
The regular time sample is currently NanoTimeSample for practicality.
An extention to the C++ std::chrono::time_point template to make time points easier to work with...
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 ...
std::shared_ptr< GenericClock< SVT, SQT, TVT, TQT > > ClockSptr
static void convert(duds::data::GenericValue &dest, const Src &src)
Template specialization to convert time in one format to FemtoTime in a GenericValue.
std::chrono::duration< int128_t, std::femto > Femtoseconds
Stores a duration in femtoseconds.
duds::data::GenericSample< duds::time::interstellar::NanoTime, float > NanoTimeSample
A compact time sample that works well for most purposes.
The foundation to a clock driver.
The base type for errors from devices.
Stores a sample of something along with a timestamp stored as a sample from a clock.
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.
duds::data::GenericMeasurement< SVT, SQT, TVT, TQT > Measurement
The measurement type provided by the instruments of this device.
GenericClock< duds::data::GenericValue, double, duds::time::interstellar::NanoTime, float > Clock
General use clock driver type.
NanoClock::time_point NanoTime
A point in time in Interstellar Time stored in Nanoseconds.