diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-05-16 17:37:07 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-05-19 11:36:43 +0200 |
commit | d91f5f743bc6f6ec9aadfe96187b45dc93043f61 (patch) | |
tree | e79bb26cb4ad4c97c07941ab6f31bb6b7c3fde22 /CAN-binder | |
parent | fd3978709abbb3ed46caaf48c1d2f45b2c74fa89 (diff) |
Include diagnostic_message_t into can_message_set.
Change-Id: I7372e469752dd8e90dc9431b9e5c67df12f56c29
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'CAN-binder')
11 files changed, 46 insertions, 21 deletions
diff --git a/CAN-binder/low-can-binding/binding/configuration-generated.cpp b/CAN-binder/low-can-binding/binding/configuration-generated.cpp index 584fc397..a97b9ee9 100644 --- a/CAN-binder/low-can-binding/binding/configuration-generated.cpp +++ b/CAN-binder/low-can-binding/binding/configuration-generated.cpp @@ -96,13 +96,10 @@ configuration_t::configuration_t() decoder_t::booleanDecoder, nullptr, false - })} - } - })} - }} - } - , diagnostic_messages_ - { + })} // end can_signals entry + } // end can_signals vector + })} // end can_message_definition entry + }, // end can_message_definition vector { {std::make_shared<diagnostic_message_t>(diagnostic_message_t{ 4, @@ -324,8 +321,9 @@ configuration_t::configuration_t() nullptr, true })} - } - } + } // end diagnostic_messages_ vector + }// end can_message_set entry + } // end can_message_set vector {} const std::string configuration_t::get_diagnostic_bus() const diff --git a/CAN-binder/low-can-binding/binding/configuration.cpp b/CAN-binder/low-can-binding/binding/configuration.cpp index 6e2ccc4c..7f53c620 100644 --- a/CAN-binder/low-can-binding/binding/configuration.cpp +++ b/CAN-binder/low-can-binding/binding/configuration.cpp @@ -54,7 +54,7 @@ std::vector<std::shared_ptr<can_signal_t> > configuration_t::get_can_signals() std::vector<std::shared_ptr<diagnostic_message_t> > configuration_t::get_diagnostic_messages() { - return diagnostic_messages_[active_message_set_]; + return can_message_set_[active_message_set_].get_diagnostic_messages(); } std::vector<std::shared_ptr<can_message_definition_t> > configuration_t::get_can_message_definition() diff --git a/CAN-binder/low-can-binding/binding/configuration.hpp b/CAN-binder/low-can-binding/binding/configuration.hpp index ab6a793a..409c4cda 100644 --- a/CAN-binder/low-can-binding/binding/configuration.hpp +++ b/CAN-binder/low-can-binding/binding/configuration.hpp @@ -50,7 +50,7 @@ class configuration_t std::vector<can_message_set_t> can_message_set_; ///< Vector holding all message set from JSON signals description file //std::vector<std::vector<can_message_definition_t>> can_message_definition_; ///< Vector of vector holding all can message definition from JSON signals description file. This describe a CAN message. First vector map to message set //std::vector<std::vector<can_signal_t>> can_signals_; ///< Vector of vector holding all can signasl from JSON signals description file. A CAN signal is a part of a CAN message. First vector map to message set - std::vector<std::vector<std::shared_ptr<diagnostic_message_t> > > diagnostic_messages_; ///< Vector of vector holding all diagnostics messages from JSON signals description file. First vector map to message set + //std::vector<std::vector<std::shared_ptr<diagnostic_message_t> > > diagnostic_messages_; ///< Vector of vector holding all diagnostics messages from JSON signals description file. First vector map to message set configuration_t(); ///< Private constructor with implementation generated by the AGL generator. diff --git a/CAN-binder/low-can-binding/can/can-bus.cpp b/CAN-binder/low-can-binding/can/can-bus.cpp index 17a77650..06338b4e 100644 --- a/CAN-binder/low-can-binding/can/can-bus.cpp +++ b/CAN-binder/low-can-binding/can/can-bus.cpp @@ -308,7 +308,7 @@ int can_bus_t::get_can_device_index(std::string bus_name) const return i; } -const std::string can_bus_t::get_can_device_name(std::string id_name) const +std::string can_bus_t::get_can_device_name(std::string id_name) const { std::string ret; for(const auto& d: can_devices_) diff --git a/CAN-binder/low-can-binding/can/can-bus.hpp b/CAN-binder/low-can-binding/can/can-bus.hpp index 7fe6ebf3..c300c7f4 100644 --- a/CAN-binder/low-can-binding/can/can-bus.hpp +++ b/CAN-binder/low-can-binding/can/can-bus.hpp @@ -26,9 +26,7 @@ #include "openxc.pb.h" #include "can-message.hpp" -#include "can-signals.hpp" #include "../utils/config-parser.hpp" -#include "../diagnostic/diagnostic-manager.hpp" #include "../binding/low-can-hat.hpp" // TODO actual max is 32 but dropped to 24 for memory considerations @@ -38,6 +36,8 @@ #define CAN_ACTIVE_TIMEOUT_S 30 +class diagnostic_manager_t; + /// @brief Object used to handle decoding and manage event queue to be pushed. /// /// This object is also used to initialize can_bus_dev_t object after reading @@ -76,7 +76,7 @@ public: void set_can_devices(); int get_can_device_index(std::string bus_name) const; - const std::string get_can_device_name(std::string id_name) const; + std::string get_can_device_name(std::string id_name) const; void start_threads(); void stop_threads(); diff --git a/CAN-binder/low-can-binding/can/can-message-definition.hpp b/CAN-binder/low-can-binding/can/can-message-definition.hpp index 0c7d7c1a..5d8514fa 100644 --- a/CAN-binder/low-can-binding/can/can-message-definition.hpp +++ b/CAN-binder/low-can-binding/can/can-message-definition.hpp @@ -30,6 +30,7 @@ #include "can-signals.hpp" #include "can-message.hpp" +#include "can-message-set.hpp" #include "../utils/timer.hpp" class can_message_set_t; diff --git a/CAN-binder/low-can-binding/can/can-message-set.cpp b/CAN-binder/low-can-binding/can/can-message-set.cpp index 9216f3a3..cfa640a6 100644 --- a/CAN-binder/low-can-binding/can/can-message-set.cpp +++ b/CAN-binder/low-can-binding/can/can-message-set.cpp @@ -18,18 +18,27 @@ #include "can-message-set.hpp" +#include "../can/can-message-definition.hpp" + can_message_set_t::can_message_set_t( uint8_t index, const std::string& name, - std::vector<std::shared_ptr<can_message_definition_t> > can_messages_definition) + std::vector<std::shared_ptr<can_message_definition_t> > can_messages_definition, + std::vector<std::shared_ptr<diagnostic_message_t> > diagnostic_messages) : index_{index} , name_{name} , can_messages_definition_{can_messages_definition} + , diagnostic_messages_{diagnostic_messages} { for(auto& cmd : can_messages_definition_) { cmd->set_parent(this); } + + for(auto& dm : diagnostic_messages_) + { + dm->set_parent(this); + } } /// @brief Return vector holding all message definition handled by this message set. @@ -51,4 +60,9 @@ std::vector<std::shared_ptr<can_signal_t> > can_message_set_t::get_can_signals() } return can_signals; +} + +std::vector<std::shared_ptr<diagnostic_message_t> > can_message_set_t::get_diagnostic_messages() +{ + return diagnostic_messages_; }
\ No newline at end of file diff --git a/CAN-binder/low-can-binding/can/can-message-set.hpp b/CAN-binder/low-can-binding/can/can-message-set.hpp index 9555d005..1cc50429 100644 --- a/CAN-binder/low-can-binding/can/can-message-set.hpp +++ b/CAN-binder/low-can-binding/can/can-message-set.hpp @@ -23,9 +23,9 @@ #include <vector> #include <memory> -#include "can-message-definition.hpp" - class can_signal_t; +class can_message_definition_t; +class diagnostic_message_t; /// @brief A parent wrapper for a particular set of CAN messages and associated /// CAN buses(e.g. a vehicle or program). @@ -35,13 +35,16 @@ private: uint8_t index_; /// < A numerical ID for the message set, ideally the index in an array for fast lookup const std::string name_; /// < The name of the message set. std::vector<std::shared_ptr<can_message_definition_t> > can_messages_definition_; ///< Vector holding all message definition handled by this message set. + std::vector<std::shared_ptr<diagnostic_message_t> > diagnostic_messages_; ///< Vector holding all diagnostics messages from JSON signals description file. First vector map to message set public: can_message_set_t( uint8_t index, const std::string& name, - std::vector<std::shared_ptr<can_message_definition_t> > can_messages_definition); + std::vector<std::shared_ptr<can_message_definition_t> > can_messages_definition, + std::vector<std::shared_ptr<diagnostic_message_t> > diagnostic_messages); std::vector<std::shared_ptr<can_message_definition_t> > get_can_message_definition(); std::vector<std::shared_ptr<can_signal_t> > get_can_signals() const; + std::vector<std::shared_ptr<diagnostic_message_t> > get_diagnostic_messages(); }; diff --git a/CAN-binder/low-can-binding/can/can-signals.hpp b/CAN-binder/low-can-binding/can/can-signals.hpp index 1277bf36..addca1d3 100644 --- a/CAN-binder/low-can-binding/can/can-signals.hpp +++ b/CAN-binder/low-can-binding/can/can-signals.hpp @@ -24,6 +24,7 @@ #include <memory> #include "openxc.pb.h" +#include "can-message-definition.hpp" #include "../utils/timer.hpp" #include "../utils/socketcan-bcm.hpp" #include "can-message.hpp" @@ -38,7 +39,6 @@ extern "C" #define MESSAGE_SET_ID 0 class can_signal_t; -class can_message_definition_t; /// /// @brief The type signature for a CAN signal decoder. /// diff --git a/CAN-binder/low-can-binding/diagnostic/diagnostic-message.cpp b/CAN-binder/low-can-binding/diagnostic/diagnostic-message.cpp index a7207ae8..9459de6c 100644 --- a/CAN-binder/low-can-binding/diagnostic/diagnostic-message.cpp +++ b/CAN-binder/low-can-binding/diagnostic/diagnostic-message.cpp @@ -80,6 +80,11 @@ void diagnostic_message_t::set_supported(bool value) supported_ = value; } +void diagnostic_message_t::set_parent(can_message_set_t* parent) +{ + parent_ = parent; +} + /// /// @brief Build a DiagnosticRequest struct to be passed /// to diagnostic manager instance. diff --git a/CAN-binder/low-can-binding/diagnostic/diagnostic-message.hpp b/CAN-binder/low-can-binding/diagnostic/diagnostic-message.hpp index e49acd90..675e189e 100644 --- a/CAN-binder/low-can-binding/diagnostic/diagnostic-message.hpp +++ b/CAN-binder/low-can-binding/diagnostic/diagnostic-message.hpp @@ -21,6 +21,7 @@ #include <string> #include "uds/uds.h" +#include "../can/can-message-set.hpp" #include "../can/can-message.hpp" #include "active-diagnostic-request.hpp" @@ -38,12 +39,15 @@ enum UNIT { INVALID }; +class can_message_set_t; + /// /// @brief - A representation of an OBD-II PID. /// class diagnostic_message_t { private: + can_message_set_t* parent_; /*!< parent_ - Pointer to the CAN message set holding this diagnostic message */ uint8_t pid_; /*!< pid_ - The 1 byte PID.*/ std::string generic_name_; /*!< generic_name_ - A human readable name to use for this PID when published.*/ int min_; /*!< min_ - Minimum value that can take this pid */ @@ -72,7 +76,7 @@ class diagnostic_message_t bool get_supported() const; void set_supported(bool value); - + void set_parent(can_message_set_t* parent); const DiagnosticRequest build_diagnostic_request(); bool is_obd2_response(const can_message_t& can_message); |