summaryrefslogtreecommitdiffstats
path: root/src/diagnostic/active-diagnostic-request.cpp
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-03-12 19:48:21 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2017-03-16 17:10:41 +0100
commit7617950b0ab386949b43c6f221b02826e18548d6 (patch)
treebd695ba29cbf87550288734690556af9df6615f7 /src/diagnostic/active-diagnostic-request.cpp
parent6c40a7192cd6ddf89e625b53dd489b7a91a423e1 (diff)
Implemente way to send diagnostic request when subscribed.
When subscribed, the signal is added to recurring request list of diagnostic manager and an event is added to the systemd event loop with timer set using frequency parameter from the requested signal. Change-Id: I4d604c498047d7744c090b7f03fce0f2b427fd01 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'src/diagnostic/active-diagnostic-request.cpp')
-rw-r--r--src/diagnostic/active-diagnostic-request.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/diagnostic/active-diagnostic-request.cpp b/src/diagnostic/active-diagnostic-request.cpp
index 505d816..7a43a0d 100644
--- a/src/diagnostic/active-diagnostic-request.cpp
+++ b/src/diagnostic/active-diagnostic-request.cpp
@@ -57,6 +57,11 @@ active_diagnostic_request_t::active_diagnostic_request_t(std::shared_ptr<can_bus
in_flight_{false}, frequency_clock_{frequency_clock_t(frequencyHz)}, timeout_clock_{frequency_clock_t(10)}
{}
+uint32_t active_diagnostic_request_t::get_id() const
+{
+ return id_;
+}
+
std::shared_ptr<can_bus_dev_t> active_diagnostic_request_t::get_can_bus_dev()
{
return bus_;
@@ -77,6 +82,16 @@ bool active_diagnostic_request_t::get_in_flight() const
return in_flight_;
}
+frequency_clock_t& active_diagnostic_request_t::get_frequency_clock()
+{
+ return frequency_clock_;
+}
+
+frequency_clock_t& active_diagnostic_request_t::get_timeout_clock()
+{
+ return timeout_clock_;
+}
+
void active_diagnostic_request_t::set_handle(DiagnosticShims& shims, DiagnosticRequest* request)
{
handle_ = new DiagnosticRequestHandle(generate_diagnostic_request(&shims, request, nullptr));
@@ -87,6 +102,13 @@ void active_diagnostic_request_t::set_in_flight(bool val)
in_flight_ = val;
}
+bool active_diagnostic_request_t::should_send()
+{
+ return !get_in_flight() && (
+ (!get_recurring() && !request_completed()) ||
+ (get_recurring() && get_frequency_clock().elapsed(true)));
+}
+
bool active_diagnostic_request_t::timed_out()
{
// don't use staggered start with the timeout clock