From 78daa605c5abd64054dad9f5fcfee638f8c515e0 Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Thu, 9 Mar 2017 16:01:08 +0100 Subject: [PATCH] Change FrequencyClock struct to class and rename it. Change-Id: I1076ad90e14815f3d0ab71ca9fa359d1d3c1748d Signed-off-by: Romain Forlot --- src/can/can-message.hpp | 2 +- src/can/can-signals.cpp | 2 +- src/can/can-signals.hpp | 4 ++-- src/utils/timer.cpp | 9 +++++++-- src/utils/timer.hpp | 23 ++++++++++++++--------- 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/can/can-message.hpp b/src/can/can-message.hpp index 19744d9..629fb93 100644 --- a/src/can/can-message.hpp +++ b/src/can/can-message.hpp @@ -86,7 +86,7 @@ class can_message_definition_t can_bus_dev_t& bus_; /*!< bus_ - A pointer to the bus this message is on. */ uint32_t id_; /*!< id_ - The ID of the message.*/ can_message_format_t format_; /*!< format_ - the format of the message's ID.*/ - FrequencyClock clock_; /*!< clock_ - an optional frequency clock to control the output of this + frequency_clock_t clock_; /*!< clock_ - an optional frequency clock to control the output of this * message, if sent raw, or simply to mark the max frequency for custom * handlers to retrieve.*/ bool force_send_changed_; /*!< force_send_changed_ - If true, regardless of the frequency, it will send CAN diff --git a/src/can/can-signals.cpp b/src/can/can-signals.cpp index a2c6ae7..0f774a1 100644 --- a/src/can/can-signals.cpp +++ b/src/can/can-signals.cpp @@ -65,7 +65,7 @@ float can_signal_t::get_max_value() const return max_value_; } -FrequencyClock& can_signal_t::get_frequency() +frequency_clock_t& can_signal_t::get_frequency() { return frequency_; } diff --git a/src/can/can-signals.hpp b/src/can/can-signals.hpp index 91403d1..63903bd 100644 --- a/src/can/can-signals.hpp +++ b/src/can/can-signals.hpp @@ -87,7 +87,7 @@ private: * don't need an offset. */ float min_value_; /*!< min_value_ - The minimum value for the processed signal.*/ float max_value_; /*!< max_value_ - The maximum value for the processed signal. */ - FrequencyClock frequency_; /*!< frequency_ - A FrequencyClock struct to control the maximum frequency to + frequency_clock_t frequency_; /*!< frequency_ - A frequency_clock_t struct to control the maximum frequency to * process and send this signal. To process every value, set the * clock's frequency to 0. */ bool send_same_; /*!< send_same_ - If true, will re-send even if the value hasn't changed.*/ @@ -115,7 +115,7 @@ public: float get_offset() const; float get_min_value() const; float get_max_value() const; - FrequencyClock& get_frequency(); + frequency_clock_t& get_frequency(); bool get_send_same() const; bool get_force_send_changed() const; std::map get_state() const; diff --git a/src/utils/timer.cpp b/src/utils/timer.cpp index 8dec706..433fcb2 100644 --- a/src/utils/timer.cpp +++ b/src/utils/timer.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "utils/timer.hpp" +#include "timer.hpp" long long int systemTimeMs() { @@ -28,4 +28,9 @@ long long int systemTimeMs() t_msec.millitm; } return timestamp_msec; -} \ No newline at end of file +} + + +frequency_clock_t::frequency_clock_t() + : frequency_{0.0}, last_tick_{0}, time_function_{nullptr} +{} \ No newline at end of file diff --git a/src/utils/timer.hpp b/src/utils/timer.hpp index 7d0e466..c8b7fb9 100644 --- a/src/utils/timer.hpp +++ b/src/utils/timer.hpp @@ -27,19 +27,24 @@ typedef long long int (*TimeFunction)(); /** - * @struct FrequencyClock + * @class frequency_clock_t * @brief A frequency counting clock. * - * @var FrequencyClock::frequency + * @var frequency_clock_t::frequency * the clock frequency in Hz. - * @var FrequencyClock::last_time + * @var frequency_clock_t::last_time * the last time (in milliseconds since startup) that the clock * ticked. - * @var FrequencyClock::time_function + * @var frequency_clock_t::time_function * a function returning current time */ -typedef struct { - float frequency; - unsigned long lastTick; - TimeFunction timeFunction; -} FrequencyClock; \ No newline at end of file +class frequency_clock_t +{ +private: + float frequency_; + unsigned long last_tick_; + TimeFunction time_function_; + +public: + frequency_clock_t(); +} \ No newline at end of file -- 2.16.6