1 #ifndef MADARA_UTILITY_SIMTIME_H_ 2 #define MADARA_UTILITY_SIMTIME_H_ 6 #include <madara/MADARA_export.h> 8 #define MADARA_EXTERN_C extern "C" MADARA_Export 12 #define MADARA_EXTERN_C 15 #if defined(MADARA_FEATURE_SIMTIME) && MADARA_FEATURE_SIMTIME==1 17 typedef void (*sim_time_callback_fn)(uint64_t*,
double*);
23 sim_time_callback_fn fn);
34 constexpr
bool simtime =
true;
38 static std::mutex mutex_;
39 static sim_time_callback_fn callback_;
41 static uint64_t last_realtime_;
42 static uint64_t last_simtime_;
43 static double last_rate_;
48 static uint64_t last_realtime() {
49 std::lock_guard<std::mutex> guard(mutex_);
50 return last_realtime_;
53 static uint64_t last_simtime() {
54 std::lock_guard<std::mutex> guard(mutex_);
58 static double last_rate() {
59 std::lock_guard<std::mutex> guard(mutex_);
63 static uint64_t realtime();
64 static uint64_t time();
66 static uint64_t duration(uint64_t sim_duration);
67 static uint64_t future(uint64_t sim_offset);
69 friend sim_time_callback_fn set_sim_time_callback(
70 sim_time_callback_fn fn);
72 friend void sim_time_notify(uint64_t,
double);
75 #endif // ifdef __cplusplus 78 constexpr
bool simtime =
false;
Provides utility functions and classes for common tasks and needs.
Copyright (c) 2015 Carnegie Mellon University.