mueller_stopwatch #30
|
@ -2,11 +2,12 @@
|
|||
#define FRAMEWORK_TIMEMANAGER_CLOCK_H_
|
||||
|
||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/time.h>
|
||||
#include <framework/ipc/MutexFactory.h>
|
||||
#include <framework/globalfunctions/timevalOperations.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <sys/time.h>
|
||||
|
||||
|
||||
typedef uint32_t millis_t;
|
||||
gaisser
commented
Seconds are converted to double in timevalOperations::toDouble(elapsedTime), this would not fit to the float type. Seconds are converted to double in timevalOperations::toDouble(elapsedTime), this would not fit to the float type.
muellerr
commented
second is double now second is double now
gaisser
commented
I still don't think that those typedefs are a good idea. Maybe we should stick to the types timeval or timespec uses or even use the types C++11 uses in duration Link. I still don't think that those typedefs are a good idea. Maybe we should stick to the types timeval or timespec uses or even use the types C++11 uses in duration [Link](https://www.cplusplus.com/reference/chrono/duration/).
muellerr
commented
Hmmm.. it just makes it a bit mor explicit. I guess you mean for example time_t ? These typedefs were inteded to explicitely be used everywhere uint32_t is used to pass around millisecond values. The new C++ types are a bit more complicated but the clock library will become more powerful soon anyway. I started to play around with the chrono library. Hmmm.. it just makes it a bit mor explicit. I guess you mean for example time_t ?
These typedefs were inteded to explicitely be used everywhere uint32_t is used to pass around millisecond values.
The new C++ types are a bit more complicated but the clock library will become more powerful soon anyway. I started to play around with the chrono library.
Maybe continue using uint32_t for now?
muellerr
commented
instead of writing something like uint32_t lockTimeout, I could write millis_t lockTimeout for example instead of writing something like uint32_t lockTimeout, I could write millis_t lockTimeout for example
|
||||
typedef double seconds_t;
|
||||
|
||||
|
@ -22,7 +23,7 @@ public:
|
|||
uint32_t usecond; //!< Microseconds, 0 .. 999999
|
||||
} TimeOfDay_t;
|
||||
|
||||
/**static Clock* TimeOfDay_t();
|
||||
/**
|
||||
* This method returns the number of clock ticks per second.
|
||||
* In RTEMS, this is typically 1000.
|
||||
* @return The number of ticks.
|
||||
|
@ -34,22 +35,23 @@ public:
|
|||
* This system call sets the system time.
|
||||
* To set the time, it uses a TimeOfDay_t struct.
|
||||
* @param time The struct with the time settings to set.
|
||||
* @return \c RETURN_OK on success. Otherwise, the OS failure code is returned.
|
||||
* @return -@c RETURN_OK on success. Otherwise, the OS failure code
|
||||
* is returned.
|
||||
*/
|
||||
static ReturnValue_t setClock(const TimeOfDay_t* time);
|
||||
/**
|
||||
* This system call sets the system time.
|
||||
* To set the time, it uses a timeval struct.
|
||||
* @param time The struct with the time settings to set.
|
||||
* @return \c RETURN_OK on success. Otherwise, the OS failure code is returned.
|
||||
* @return -@c RETURN_OK on success. Otherwise, the OS failure code is returned.
|
||||
*/
|
||||
static ReturnValue_t setClock(const timeval* time);
|
||||
/**
|
||||
* This system call returns the current system clock in timeval format.
|
||||
* The timval format has the fields \c tv_sec with seconds and \c tv_usec with
|
||||
* The timval format has the fields @c tv_sec with seconds and @c tv_usec with
|
||||
* microseconds since an OS-defined epoch.
|
||||
* @param time A pointer to a timeval struct where the current time is stored.
|
||||
* @return \c RETURN_OK on success. Otherwise, the OS failure code is returned.
|
||||
* @return @c RETURN_OK on success. Otherwise, the OS failure code is returned.
|
||||
*/
|
||||
static ReturnValue_t getClock_timeval(timeval* time);
|
||||
|
||||
|
@ -57,7 +59,7 @@ public:
|
|||
* Get the time since boot in a timeval struct
|
||||
*
|
||||
* @param[out] time A pointer to a timeval struct where the uptime is stored.
|
||||
* @return\c RETURN_OK on success. Otherwise, the OS failure code is returned.
|
||||
* @return @c RETURN_OK on success. Otherwise, the OS failure code is returned.
|
||||
*
|
||||
* @deprecated, I do not think this should be able to fail, use timeval getUptime()
|
||||
*/
|
||||
|
|
Where are does types used?
stopwatch. could also be used somewhere else, is more explicit in my opinion. maybe also use it instead of uint32_t for all milliseconds related stuff?
Hm I think we should stick with timeval and the types defined there. Someday this might be replaced by timespec and uint32_t will be to small anyway.