Retrieve signal last value and timestamp at once.
authorRomain Forlot <romain.forlot@iot.bzh>
Wed, 31 May 2017 15:01:54 +0000 (17:01 +0200)
committerRomain Forlot <romain.forlot@iot.bzh>
Thu, 1 Jun 2017 16:26:18 +0000 (18:26 +0200)
Change-Id: I8401030ece94b5e397b6d2b71b29ff4e435d1486
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
CAN-binder/low-can-binding/can/can-signals.cpp
CAN-binder/low-can-binding/can/can-signals.hpp
CAN-binder/low-can-binding/utils/timer.cpp
CAN-binder/low-can-binding/utils/timer.hpp

index 260d577..fe74115 100644 (file)
@@ -165,11 +165,17 @@ bool can_signal_t::get_received() const
 {
        return received_;
 }
+
 float can_signal_t::get_last_value() const
 {
        return last_value_;
 }
 
+std::pair<float, uint64_t> can_signal_t::get_last_value_with_timestamp() const
+{
+       return std::make_pair(last_value_, frequency_.get_last_tick());
+}
+
 void can_signal_t::set_parent(can_message_definition_t* parent)
 {
        parent_ = parent;
index 2d67f27..d528f6a 100644 (file)
@@ -147,6 +147,7 @@ public:
        SignalEncoder& get_encoder();
        bool get_received() const;
        float get_last_value() const;
+       std::pair<float, uint64_t> get_last_value_with_timestamp() const;
 
        void set_parent(can_message_definition_t* parent);
        void set_prefix(std::string val);
index 4584b85..eb79f85 100644 (file)
@@ -113,6 +113,11 @@ float frequency_clock_t::get_frequency() const
        return frequency_;
 }
 
+uint64_t frequency_clock_t::get_last_tick() const
+{
+       return last_tick_;
+}
+
 /// @brief Force the clock to tick, regardless of it its time has actually
 /// elapsed.
 void frequency_clock_t::tick(uint64_t timestamp)
index 560a818..a667022 100644 (file)
@@ -53,5 +53,6 @@ public:
        time_function_t get_time_function();
        bool elapsed(bool stagger);
 
+       uint64_t get_last_tick() const;
        void tick(uint64_t timestamp);
 };
\ No newline at end of file