aboutsummaryrefslogtreecommitdiffstats
path: root/low-can-binding/diagnostic/diagnostic-message.cpp
diff options
context:
space:
mode:
authorJonathan Aillet <jonathan.aillet@iot.bzh>2018-04-09 09:02:52 +0200
committerJonathan Aillet <jonathan.aillet@iot.bzh>2018-04-17 11:42:07 +0200
commit29de76e9beac2a8e7ffcd1ccba07a927df1f2bcc (patch)
tree7e4c60d31d0283a0e67dba8b9ae11e35e9e52c02 /low-can-binding/diagnostic/diagnostic-message.cpp
parentddd4374f35df2d8b8e9b4ecf4890abba6fab3734 (diff)
Add saving of diagnostic messages information
Add saving of diagnostic messages receive state, last value, and timestamp associated to it. Add methods to get/set these information. Add initialisation for added atributes. Add boolean to set receive state at initialisation. Generate all 'diagnostic-message.cpp' containing diagnostic messages to add receive state initialisation. Bug-AGL: SPEC-1347 Change-Id: Iee82ca3b5f79fd267717ae074d5456b8cbc1c377 Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
Diffstat (limited to 'low-can-binding/diagnostic/diagnostic-message.cpp')
-rw-r--r--low-can-binding/diagnostic/diagnostic-message.cpp59
1 files changed, 54 insertions, 5 deletions
diff --git a/low-can-binding/diagnostic/diagnostic-message.cpp b/low-can-binding/diagnostic/diagnostic-message.cpp
index 69ca4e34..701248dc 100644
--- a/low-can-binding/diagnostic/diagnostic-message.cpp
+++ b/low-can-binding/diagnostic/diagnostic-message.cpp
@@ -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)
- : parent_{nullptr}, 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()
@@ -75,6 +94,21 @@ 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<float, uint64_t> 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;
@@ -85,6 +119,21 @@ void diagnostic_message_t::set_parent(can_message_set_t* 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.