Include diagnostic_message_t into can_message_set.
authorRomain Forlot <romain.forlot@iot.bzh>
Tue, 16 May 2017 15:37:07 +0000 (17:37 +0200)
committerRomain Forlot <romain.forlot@iot.bzh>
Fri, 19 May 2017 09:36:43 +0000 (11:36 +0200)
Change-Id: I7372e469752dd8e90dc9431b9e5c67df12f56c29
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
CAN-binder/low-can-binding/binding/configuration-generated.cpp
CAN-binder/low-can-binding/binding/configuration.cpp
CAN-binder/low-can-binding/binding/configuration.hpp
CAN-binder/low-can-binding/can/can-bus.cpp
CAN-binder/low-can-binding/can/can-bus.hpp
CAN-binder/low-can-binding/can/can-message-definition.hpp
CAN-binder/low-can-binding/can/can-message-set.cpp
CAN-binder/low-can-binding/can/can-message-set.hpp
CAN-binder/low-can-binding/can/can-signals.hpp
CAN-binder/low-can-binding/diagnostic/diagnostic-message.cpp
CAN-binder/low-can-binding/diagnostic/diagnostic-message.hpp

index 584fc39..a97b9ee 100644 (file)
@@ -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
index 6e2ccc4..7f53c62 100644 (file)
@@ -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()
index ab6a793..409c4cd 100644 (file)
@@ -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.
 
index 17a7765..06338b4 100644 (file)
@@ -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_)
index 7fe6ebf..c300c7f 100644 (file)
@@ -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();
index 0c7d7c1..5d8514f 100644 (file)
@@ -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;
index 9216f3a..cfa640a 100644 (file)
 
 #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
index 9555d00..1cc5042 100644 (file)
@@ -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();
 };
index 1277bf3..addca1d 100644 (file)
@@ -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.
 ///
index a7207ae..9459de6 100644 (file)
@@ -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.
index e49acd9..675e189 100644 (file)
@@ -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);