X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=low-can-binding%2Fdiagnostic%2Fdiagnostic-message.cpp;h=9b4733da53f8f07ac1c5fba45033771cd509b327;hb=fae627b646e9ab709adbd0c60d7582176375e0c3;hp=6f6155745daa1bc0958b83dc520f43935d85de16;hpb=9e444ade872bc436cf12bc12d03c3a5d51ac0b9e;p=apps%2Fagl-service-can-low-level.git diff --git a/low-can-binding/diagnostic/diagnostic-message.cpp b/low-can-binding/diagnostic/diagnostic-message.cpp index 6f615574..9b4733da 100644 --- a/low-can-binding/diagnostic/diagnostic-message.cpp +++ b/low-can-binding/diagnostic/diagnostic-message.cpp @@ -18,7 +18,7 @@ #include "diagnostic-message.hpp" -#include "../configuration.hpp" +#include "../binding/application.hpp" #include "../utils/signals.hpp" const char *UNIT_NAMES[10] = { @@ -34,11 +34,30 @@ const char *UNIT_NAMES[10] = { "NM" }; -diagnostic_message_t::diagnostic_message_t(uint8_t pid, const std::string generic_name, const int min, - const int max, enum UNIT unit, float frequency, DiagnosticResponseDecoder decoder, - DiagnosticResponseCallback callback, bool supported) - : pid_{pid}, generic_name_{generic_name}, min_{min}, max_{max}, unit_{unit}, - frequency_{frequency}, decoder_{decoder}, callback_{callback}, supported_{supported} +diagnostic_message_t::diagnostic_message_t( + uint8_t pid, + const std::string& generic_name, + const int min, + const int max, + enum UNIT unit, + float frequency, + DiagnosticResponseDecoder decoder, + DiagnosticResponseCallback callback, + bool supported, + bool received) + : parent_{nullptr}, + pid_{pid}, + generic_name_{generic_name}, + min_{min}, + max_{max}, + unit_{unit}, + frequency_{frequency}, + decoder_{decoder}, + callback_{callback}, + supported_{supported}, + last_timestamp_{0}, + received_{received}, + last_value_{.0f} {} uint32_t diagnostic_message_t::get_pid() @@ -46,7 +65,7 @@ uint32_t diagnostic_message_t::get_pid() return (uint32_t)pid_; } -const std::string& diagnostic_message_t::get_generic_name() const +const std::string diagnostic_message_t::get_generic_name() const { return generic_name_; } @@ -75,16 +94,51 @@ bool diagnostic_message_t::get_supported() const return supported_; } +bool diagnostic_message_t::get_received() const +{ + return received_; +} + +float diagnostic_message_t::get_last_value() const +{ + return last_value_; +} + +std::pair diagnostic_message_t::get_last_value_with_timestamp() const +{ + return std::make_pair(last_value_, last_timestamp_); +} + void diagnostic_message_t::set_supported(bool value) { supported_ = value; } +void diagnostic_message_t::set_parent(std::shared_ptr parent) +{ + parent_ = parent; +} + +void diagnostic_message_t::set_received(bool r) +{ + received_ = r; +} + +void diagnostic_message_t::set_last_value(float val) +{ + last_value_ = val; +} + +void diagnostic_message_t::set_timestamp(uint64_t timestamp) +{ + last_timestamp_ = timestamp; +} + /// /// @brief Build a DiagnosticRequest struct to be passed /// to diagnostic manager instance. /// -const DiagnosticRequest diagnostic_message_t::build_diagnostic_request() + const DiagnosticRequest diagnostic_message_t::build_diagnostic_request() const { return {/*arbitration_id: */OBD2_FUNCTIONAL_BROADCAST_ID, /*mode: */0x1,