xsens_imu
xsens_time.h
Go to the documentation of this file.
1 #ifndef XSENS_TIME_H
2 #define XSENS_TIME_H
3 
4 #ifndef _PSTDINT_H_INCLUDED
5 # include "pstdint.h"
6 #endif
7 
8 #include <time.h>
9 
10 namespace xsens {
11 
13 #define XSENS_SEC_PER_DAY (60*60*24)
14 #define XSENS_MS_PER_DAY (XSENS_SEC_PER_DAY*1000)
16 #define XSENS_TIMESTAMP_MAX (0x7FFFFFFFFFFFFFFFLL)
18 
20 typedef int64_t TimeStamp;
21 
27 uint32_t getTimeOfDay(tm* date_ = NULL, time_t* secs_ = NULL);
28 
33 int64_t getDateTime(tm * date = 0);
34 
41 void getDateAsString(uint8_t* dest, tm const* date = 0);
42 
50 void getTimeAsString(uint8_t* dest, tm const* date = 0);
51 
57 void msleep(uint32_t ms);
58 
60 void initializeTime();
61 
62 
63 class TimeSyncPrivate;
64 class TimeSync {
65 private:
66  TimeSyncPrivate* d;
67 
68 public:
69  TimeSync(double skew, int historySize);
70  ~TimeSync();
71 
72  int isInitialized() const;
73  void reset();
74  void update(TimeStamp local, TimeStamp external);
75  void setInitialSkew(double skew);
76 
77  TimeStamp localTime(TimeStamp external);
79 };
80 
81 
83 {
84 public:
86  void restart();
87  uint32_t millisecondsElapsed();
88 private:
89  uint32_t m_tstart;
90 };
91 
92 
93 } // end of xsens namespace
94 
95 
96 
97 
98 #endif // XSENS_TIME_H
uint32_t millisecondsElapsed()
Returns the number of milliseconds that has elapsed since the constructor or the restart function wer...
Definition: xsens_time.cpp:522
int isInitialized() const
Returns whether the TimeSync has passed the initial stage of initialization.
Definition: xsens_time.cpp:374
void reset()
Reset the time sync algorithm.
Definition: xsens_time.cpp:348
void getTimeAsString(uint8_t *dest, const tm *date)
Retrieves the time as binary The format is HHMMSShh (where H is hour and 'h' is hundredths) so 14:25:...
Definition: xsens_time.cpp:144
int64_t getDateTime(tm *date)
Retrieves the date and time (platform-independent)
Definition: xsens_time.cpp:108
int64_t TimeStamp
A real-time timestamp (ms)
Definition: xsens_time.h:20
TimeStamp localTime(TimeStamp external)
Returns the local time computed from the supplied reference time.
Definition: xsens_time.cpp:470
uint32_t getTimeOfDay(tm *date_, time_t *secs_)
A platform-independent clock.
Definition: xsens_time.cpp:54
TimeSync(double skew, int historySize)
Constructor.
Definition: xsens_time.cpp:323
void msleep(uint32_t ms)
Sleep for ms milliseconds.
Definition: xsens_time.cpp:165
void getDateAsString(uint8_t *dest, const tm *date)
Retrieves the date as string representation The format is YYYYMMDD so 25 dec 2010 is stored as an arr...
Definition: xsens_time.cpp:128
void initializeTime()
Stabilize the clock.
Definition: xsens_time.cpp:495
Private data for the TimeSync class.
Definition: xsens_time.cpp:231
void setInitialSkew(double skew)
Set the initial skew value. Since using this value requires a reset, the function automatically reset...
Definition: xsens_time.cpp:366
~TimeSync()
Destructor.
Definition: xsens_time.cpp:340
void restart()
Set the timer back to 0.
Definition: xsens_time.cpp:514
Class for synchronizing two clocks.
Definition: xsens_time.h:64
Definition: xsens_time.h:82
TimeStamp timeStampNow()
Definition: xsens_time.cpp:482
MillisecondTimer()
Constructor.
Definition: xsens_time.cpp:507
TimeStamp externalTime(TimeStamp local)
Returns the reference time computed from the supplied local time.
Definition: xsens_time.cpp:477
void update(TimeStamp local, TimeStamp external)
Update the time synchronization with new information.
Definition: xsens_time.cpp:387