Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
KM3NETDAQ::JDAQUTCExtended Class Reference

Data structure for UTC time. More...

#include <JDAQUTCExtended.hh>

Inheritance diagram for KM3NETDAQ::JDAQUTCExtended:
JDETECTOR::JModuleGeometry

Public Member Functions

 JDAQUTCExtended ()
 Default constructor.
 
 JDAQUTCExtended (const uint32_t seconds, const uint32_t cycles)
 Constructor.
 
 JDAQUTCExtended (const double nanoseconds)
 Constructor.
 
virtual ~JDAQUTCExtended ()
 Virtual destructor.
 
bool getWRStatus () const
 Get White Rabbit status.
 
uint32_t getUTCseconds () const
 Get major time.
 
uint32_t getUTC16nanosecondcycles () const
 Get minor time.
 
double getTimeNanoSecond () const
 Get time (limited to 16 ns cycles).
 
void setTimeNanoSecond (const double utc_ns)
 Set time.
 
void addTimeNanoSecond (const double t_ns)
 Add time.
 
 ClassDef (JDAQUTCExtended, 1)
 

Static Public Member Functions

static JDAQUTCExtended min ()
 Get minimum possible value.
 
static JDAQUTCExtended max ()
 Get maximum possible value.
 
static uint32_t getMask ()
 Get mask for seconds data.
 
static double getTick ()
 Get number of nano-seconds per tick.
 
static const JDAQUTCExtendedgetInstance ()
 Get arbitrary offset (e.g.
 

Protected Attributes

uint32_t UTC_seconds
 
uint32_t UTC_16nanosecondcycles
 

Friends

size_t getSizeof ()
 Definition of method to get size of data type.
 
JReaderoperator>> (JReader &in, JDAQUTCExtended &utc)
 Read UTC from input.
 
JWriteroperator<< (JWriter &out, const JDAQUTCExtended &utc)
 Write UTC to output.
 
std::istream & operator>> (std::istream &in, JDAQUTCExtended &utc)
 Read UTC time.
 
std::ostream & operator<< (std::ostream &out, const JDAQUTCExtended &utc)
 Write UTC time.
 

Detailed Description

Data structure for UTC time.

Definition at line 22 of file JDAQUTCExtended.hh.

Constructor & Destructor Documentation

◆ JDAQUTCExtended() [1/3]

KM3NETDAQ::JDAQUTCExtended::JDAQUTCExtended ( )
inline

Default constructor.

Definition at line 34 of file JDAQUTCExtended.hh.

◆ JDAQUTCExtended() [2/3]

KM3NETDAQ::JDAQUTCExtended::JDAQUTCExtended ( const uint32_t seconds,
const uint32_t cycles )
inline

Constructor.

Parameters
secondsseconds [s]
cyclescycles [16 ns]

Definition at line 46 of file JDAQUTCExtended.hh.

47 :
48 UTC_seconds(seconds),
50 {}

◆ JDAQUTCExtended() [3/3]

KM3NETDAQ::JDAQUTCExtended::JDAQUTCExtended ( const double nanoseconds)
inline

Constructor.

Parameters
nanosecondstime [ns]

Definition at line 58 of file JDAQUTCExtended.hh.

59 {
60 setTimeNanoSecond(nanoseconds);
61 }
void setTimeNanoSecond(const double utc_ns)
Set time.

◆ ~JDAQUTCExtended()

virtual KM3NETDAQ::JDAQUTCExtended::~JDAQUTCExtended ( )
inlinevirtual

Virtual destructor.

Definition at line 67 of file JDAQUTCExtended.hh.

68 {}

Member Function Documentation

◆ getWRStatus()

bool KM3NETDAQ::JDAQUTCExtended::getWRStatus ( ) const
inline

Get White Rabbit status.

Returns
true if okay; else false

Definition at line 76 of file JDAQUTCExtended.hh.

77 {
78 return (UTC_seconds & ~getMask()) != 0;
79 }
static uint32_t getMask()
Get mask for seconds data.

◆ getUTCseconds()

uint32_t KM3NETDAQ::JDAQUTCExtended::getUTCseconds ( ) const
inline

Get major time.

Returns
time [s]

Definition at line 87 of file JDAQUTCExtended.hh.

88 {
89 return (UTC_seconds & getMask());
90 }

◆ getUTC16nanosecondcycles()

uint32_t KM3NETDAQ::JDAQUTCExtended::getUTC16nanosecondcycles ( ) const
inline

Get minor time.

Returns
time [16 ns]

Definition at line 98 of file JDAQUTCExtended.hh.

99 {
101 }

◆ getTimeNanoSecond()

double KM3NETDAQ::JDAQUTCExtended::getTimeNanoSecond ( ) const
inline

Get time (limited to 16 ns cycles).

Returns
time [ns]

Definition at line 109 of file JDAQUTCExtended.hh.

110 {
111 return getUTCseconds() * 1.0e9 + getUTC16nanosecondcycles() * getTick();
112 }
uint32_t getUTC16nanosecondcycles() const
Get minor time.
static double getTick()
Get number of nano-seconds per tick.
uint32_t getUTCseconds() const
Get major time.

◆ setTimeNanoSecond()

void KM3NETDAQ::JDAQUTCExtended::setTimeNanoSecond ( const double utc_ns)
inline

Set time.

Parameters
utc_nstime [ns]

Definition at line 120 of file JDAQUTCExtended.hh.

121 {
122 UTC_seconds = (uint32_t) ( utc_ns * 1.0e-9);
123 UTC_16nanosecondcycles = (uint32_t) ((utc_ns - UTC_seconds*1.0e9) / getTick());
124 }

◆ addTimeNanoSecond()

void KM3NETDAQ::JDAQUTCExtended::addTimeNanoSecond ( const double t_ns)
inline

Add time.

Parameters
t_nstime [ns]

Definition at line 132 of file JDAQUTCExtended.hh.

133 {
134 const double x_ns = (double) getUTC16nanosecondcycles() * (double) getTick() + t_ns;
135 const uint32_t t_s = (uint32_t) (x_ns * 1.0e-9);
136
137 UTC_seconds += t_s;
138 UTC_16nanosecondcycles = (uint32_t) ((x_ns - t_s*1.0e9) / getTick());
139 }

◆ min()

static JDAQUTCExtended KM3NETDAQ::JDAQUTCExtended::min ( )
inlinestatic

Get minimum possible value.

Returns
minimum possible value

Definition at line 147 of file JDAQUTCExtended.hh.

148 {
149 return JDAQUTCExtended(0,0);
150 }
JDAQUTCExtended()
Default constructor.

◆ max()

static JDAQUTCExtended KM3NETDAQ::JDAQUTCExtended::max ( )
inlinestatic

Get maximum possible value.

Returns
maximum possible value

Definition at line 158 of file JDAQUTCExtended.hh.

159 {
160 return JDAQUTCExtended(std::numeric_limits<uint32_t>::max(),
161 std::numeric_limits<uint32_t>::max());
162 }

◆ getMask()

static uint32_t KM3NETDAQ::JDAQUTCExtended::getMask ( )
inlinestatic

Get mask for seconds data.

Returns
mask

Definition at line 170 of file JDAQUTCExtended.hh.

171 {
172 return 0x7FFFFFFF;
173 }

◆ getTick()

static double KM3NETDAQ::JDAQUTCExtended::getTick ( )
inlinestatic

Get number of nano-seconds per tick.

Returns
time [ns]

Definition at line 181 of file JDAQUTCExtended.hh.

182 {
183 return 16.0;
184 }

◆ getInstance()

static const JDAQUTCExtended & KM3NETDAQ::JDAQUTCExtended::getInstance ( )
inlinestatic

Get arbitrary offset (e.g.

for accuracy of time differences).

Returns
UTC time

Definition at line 192 of file JDAQUTCExtended.hh.

193 {
194 static JDAQUTCExtended utc(1600000000, 0);
195
196 return utc;
197 }
Data structure for UTC time.

◆ ClassDef()

KM3NETDAQ::JDAQUTCExtended::ClassDef ( JDAQUTCExtended ,
1  )

Friends And Related Symbol Documentation

◆ getSizeof

size_t getSizeof ( )
friend

Definition of method to get size of data type.

This method should be specialised for each desired data type with fixed length.

Returns
number of bytes

◆ operator>> [1/2]

JReader & operator>> ( JReader & in,
JDAQUTCExtended & utc )
friend

Read UTC from input.

Parameters
inreader
utcUTC
Returns
reader

Definition at line 33 of file JDAQUTCExtendedIO.hh.

34 {
35 in >> utc.UTC_seconds;
36 in >> utc.UTC_16nanosecondcycles;
37
38 return in;
39 }

◆ operator<< [1/2]

JWriter & operator<< ( JWriter & out,
const JDAQUTCExtended & utc )
friend

Write UTC to output.

Parameters
outwriter
utcUTC
Returns
writer

Definition at line 49 of file JDAQUTCExtendedIO.hh.

50 {
51 out << utc.UTC_seconds;
52 out << utc.UTC_16nanosecondcycles;
53
54 return out;
55 }

◆ operator>> [2/2]

std::istream & operator>> ( std::istream & in,
JDAQUTCExtended & utc )
friend

Read UTC time.

Parameters
inintput stream
utcUTC extended time
Returns
intput stream

Definition at line 207 of file JDAQUTCExtended.hh.

208 {
209 in >> utc.UTC_seconds;
210 in.get();
211 in >> utc.UTC_16nanosecondcycles;
212
213 return in;
214 }

◆ operator<< [2/2]

std::ostream & operator<< ( std::ostream & out,
const JDAQUTCExtended & utc )
friend

Write UTC time.

Parameters
outoutput stream
utcUTC extended time
Returns
output stream

Definition at line 224 of file JDAQUTCExtended.hh.

225 {
226 using namespace std;
227
228 const char c = out.fill();
229
230 out << setw(10) << utc.getUTCseconds();
231 out << ':';
232 out << setw(10) << setfill('0') << utc.getUTC16nanosecondcycles() << setfill(c);
233
234 return out;
235 }

Member Data Documentation

◆ UTC_seconds

uint32_t KM3NETDAQ::JDAQUTCExtended::UTC_seconds
protected

Definition at line 242 of file JDAQUTCExtended.hh.

◆ UTC_16nanosecondcycles

uint32_t KM3NETDAQ::JDAQUTCExtended::UTC_16nanosecondcycles
protected

Definition at line 243 of file JDAQUTCExtended.hh.


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