Rename class and 1:1 map to JSON description file
[apps/agl-service-can-low-level.git] / src / diagnostic / active-diagnostic-request.hpp
index 1e996c0..b40ae08 100644 (file)
@@ -23,7 +23,6 @@
 #include "uds/uds_types.h"
 #include "../can/can-bus-dev.hpp"
 #include "../can/can-message.hpp"
-#include "diagnostic-manager.hpp"
 
 #include "../low-can-binding.hpp"
 
@@ -57,12 +56,14 @@ typedef void (*DiagnosticResponseCallback)(const active_diagnostic_request_t* re
  */
 class active_diagnostic_request_t {
 private:
-       can_bus_dev_t* bus_; /*!< bus_ - The CAN bus this request should be made on, or is currently in flight-on*/
+       std::string bus_; /*!< bus_ - The CAN bus this request should be made on, or is currently in flight-on*/
        uint32_t id_; /*!< id_ - The arbitration ID (aka message ID) for the request.*/
        DiagnosticRequestHandle* handle_; /*!< handle_ - A handle for the request to keep track of it between
                                                                                * sending the frames of the request and receiving all frames of the response.*/
        std::string name_; /*!< name_ - An optional human readable name this response, to be used when publishing received 
                                                * responses. If the name is NULL, the published output will use the raw OBD-II response format.*/
+       static std::string prefix_; /*!< prefix_ - generic_name_ will be prefixed with it. It has to reflect the used protocol.
+                                                                * which make easier to sort message when the come in.*/
        DiagnosticResponseDecoder decoder_; /*!< decoder_ - An optional DiagnosticResponseDecoder to parse the payload of responses
                                                                                        * to this request. If the decoder is NULL, the output will include the raw payload
                                                                                        * instead of a parsed value.*/
@@ -79,25 +80,36 @@ private:
        frequency_clock_t timeout_clock_; /*!< timeout_clock_ - A frequency_clock_t object to monitor how long it's been since
                                                                        * this request was sent.*/
 public:
-       bool& operator==(const active_diagnostic_request_t& adr) const;
+       bool operator==(const active_diagnostic_request_t& b);
        active_diagnostic_request_t& operator=(const active_diagnostic_request_t& adr);
+
        active_diagnostic_request_t();
        active_diagnostic_request_t(active_diagnostic_request_t&&) = default;
-       active_diagnostic_request_t(const active_diagnostic_request_t&) = default;
-       active_diagnostic_request_t(can_bus_dev_t* bus, DiagnosticRequest* request,
-               const std::string& name, bool waitForMultipleResponses,
+       active_diagnostic_request_t(const std::string& bus, DiagnosticRequest* request,
+               const std::string& name, bool wait_for_multiple_responses,
                const DiagnosticResponseDecoder decoder,
                const DiagnosticResponseCallback callback, float frequencyHz);
        
-       can_bus_dev_t* get_can_bus_dev();
-       DiagnosticRequestHandle& get_handle();
+       uint32_t get_id() const;
+       const std::shared_ptr<can_bus_dev_t> get_can_bus_dev() const;
+       DiagnosticRequestHandle* get_handle();
+       const std::string get_name() const;
+       static std::string& get_prefix();
+       DiagnosticResponseDecoder& get_decoder();
+       DiagnosticResponseCallback& get_callback();
        bool get_recurring() const;
        bool get_in_flight() const;
-
+       frequency_clock_t& get_frequency_clock();
+       frequency_clock_t& get_timeout_clock();
+       
        void set_handle(DiagnosticShims& shims, DiagnosticRequest* request);
        void set_in_flight(bool val);
 
-       bool timed_out() const;
+       static bool is_diagnostic_signal(const std::string& name);
+
+       bool should_send();
+
+       bool timed_out();
        bool response_received() const;
-       bool request_completed() const;
+       bool request_completed();
 };