X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=CAN-binder%2Flow-can-binding%2Futils%2Ftimer.hpp;h=560a818155e393ed8d06db00b19efee7d23f224b;hb=7747851ca010a3dfe9ffee808376dd5a7af68b91;hp=f565904482b263995093372e698d16e68bbfa4c0;hpb=d170c9faeae2cf29c19f3523714ecdf58be73bed;p=apps%2Fagl-service-can-low-level.git diff --git a/CAN-binder/low-can-binding/utils/timer.hpp b/CAN-binder/low-can-binding/utils/timer.hpp index f5659044..560a8181 100644 --- a/CAN-binder/low-can-binding/utils/timer.hpp +++ b/CAN-binder/low-can-binding/utils/timer.hpp @@ -17,6 +17,9 @@ #pragma once +#include +#include + /// @brief return epoch in milliseconds /// /// @return long long int epoch in milliseconds @@ -34,20 +37,21 @@ class frequency_clock_t private: float unit_; ///< unit_ - multiplicator to make operation to be in the right unit (milli, micro, nano, etc) float frequency_; ///< the clock frequency in Hz. - unsigned long last_tick_; ///< the last time (in milliseconds since startup) that the clock ticked. + uint64_t last_tick_; ///< the last time (in microseconds since startup) that the clock ticked. time_function_t time_function_; ///< a function returning current time public: frequency_clock_t(); - frequency_clock_t(float frequency); - frequency_clock_t(float frequency, unsigned long last_tick, time_function_t time_function); + explicit frequency_clock_t(float frequency); + frequency_clock_t(float frequency, uint64_t last_tick, time_function_t time_function); float get_frequency() const; + const struct timeval get_timeval_from_period() const; - float frequency_to_period(); + float frequency_to_period() const; bool started(); time_function_t get_time_function(); bool elapsed(bool stagger); - void tick(); + void tick(uint64_t timestamp); }; \ No newline at end of file