diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-05-10 18:39:25 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-05-10 18:45:56 +0200 |
commit | d253ada94487232ccd33b68a69fd44ff7840fab7 (patch) | |
tree | 67f5959138d0ddcad413f9ee692d087200e0b4df /CAN-binder/low-can-binding/binding | |
parent | 3e2be4237ac6f3e8bcec8b10d295182cefe67330 (diff) |
Use a tree instead of separated object lists. WIP
Now we respect JSON description file, which is can_message_set contains
can_message_definition which contains can_signals.
Diagnostic messages aren't processed for now.
Change-Id: I94aaf5eded14dd84395bd4fd749df58dee5f533e
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'CAN-binder/low-can-binding/binding')
3 files changed, 107 insertions, 127 deletions
diff --git a/CAN-binder/low-can-binding/binding/configuration-generated.cpp b/CAN-binder/low-can-binding/binding/configuration-generated.cpp index c96a103a..3ab911a9 100644 --- a/CAN-binder/low-can-binding/binding/configuration-generated.cpp +++ b/CAN-binder/low-can-binding/binding/configuration-generated.cpp @@ -3,117 +3,103 @@ configuration_t::configuration_t() :can_bus_manager_{utils::config_parser_t{"/etc/dev-mapping.conf"}} - , can_message_set_{{0, "example", 0, 1, 5, 0, 20}} - , can_message_definition_ - { - { - can_message_definition_t{0, "can0", 0x620, can_message_format_t::STANDARD, frequency_clock_t(0.00000f), true} - } - } - , can_signals_ - { - { - { - 0, - 0, - "doors.coffer.open", - 56, - 1, - 1.00000f, - 0, - 0, - 0, - frequency_clock_t(0.00000f), - false, - false, - { - }, - false, - decoder_t::booleanDecoder, - nullptr, - false - }, - { - 0, - 0, - "doors.driver.open", - 46, - 1, - 1.00000f, - 0, - 0, - 0, - frequency_clock_t(0.00000f), - false, - false, + , can_message_set_{ + can_message_set_t{0, "example", 0, 1, 5, 0, 20, { + {std::make_shared<can_message_definition_t>(can_message_definition_t{"can0", 0x620, can_message_format_t::STANDARD, frequency_clock_t(0.00000f), true, { - }, - false, - decoder_t::booleanDecoder, - nullptr, - false - }, - { - 0, - 0, - "doors.passenger.open", - 47, - 1, - 1.00000f, - 0, - 0, - 0, - frequency_clock_t(0.00000f), - false, - false, - { - }, - false, - decoder_t::booleanDecoder, - nullptr, - false - }, - { - 0, - 0, - "doors.rearleft.open", - 54, - 1, - 1.00000f, - 0, - 0, - 0, - frequency_clock_t(0.00000f), - false, - false, - { - }, - false, - decoder_t::booleanDecoder, - nullptr, - false - }, - { - 0, - 0, - "doors.rearright.open", - 55, - 4, - 1.00000f, - 0, - 0, - 0, - frequency_clock_t(0.00000f), - false, - false, - { - }, - false, - decoder_t::booleanDecoder, - nullptr, - false - } - } + {std::make_shared<can_signal_t>( + can_signal_t{ + "doors.coffer.open", + 56, + 1, + 1.00000f, + 0, + 0, + 0, + frequency_clock_t(0.00000f), + false, + false, + {}, + false, + decoder_t::booleanDecoder, + nullptr, + false + })}, + {std::make_shared<can_signal_t> ( + can_signal_t{ + "doors.driver.open", + 46, + 1, + 1.00000f, + 0, + 0, + 0, + frequency_clock_t(0.00000f), + false, + false, + {}, + false, + decoder_t::booleanDecoder, + nullptr, + false + })}, + {std::make_shared<can_signal_t> ( + can_signal_t{ + "doors.passenger.open", + 47, + 1, + 1.00000f, + 0, + 0, + 0, + frequency_clock_t(0.00000f), + false, + false, + {}, + false, + decoder_t::booleanDecoder, + nullptr, + false + })}, + {std::make_shared<can_signal_t> ( + can_signal_t{ + "doors.rearleft.open", + 54, + 1, + 1.00000f, + 0, + 0, + 0, + frequency_clock_t(0.00000f), + false, + false, + {}, + false, + decoder_t::booleanDecoder, + nullptr, + false + })}, + {std::make_shared<can_signal_t> ( + can_signal_t{ + "doors.rearright.open", + 55, + 4, + 1.00000f, + 0, + 0, + 0, + frequency_clock_t(0.00000f), + false, + false, + {}, + false, + decoder_t::booleanDecoder, + nullptr, + false + })} + } + })} + }} } , diagnostic_messages_ { diff --git a/CAN-binder/low-can-binding/binding/configuration.cpp b/CAN-binder/low-can-binding/binding/configuration.cpp index 0c0c9ba8..da9d16b2 100644 --- a/CAN-binder/low-can-binding/binding/configuration.cpp +++ b/CAN-binder/low-can-binding/binding/configuration.cpp @@ -52,9 +52,9 @@ const std::vector<can_message_set_t>& configuration_t::get_can_message_set() return can_message_set_; } -std::vector<can_signal_t>& configuration_t::get_can_signals() +std::vector<std::shared_ptr<can_signal_t> > configuration_t::get_can_signals() { - return can_signals_[active_message_set_]; + return can_message_set_[active_message_set_].get_can_signals(); } std::vector<diagnostic_message_t>& configuration_t::get_diagnostic_messages() @@ -62,14 +62,9 @@ std::vector<diagnostic_message_t>& configuration_t::get_diagnostic_messages() return diagnostic_messages_[active_message_set_]; } -const std::vector<can_message_definition_t>& configuration_t::get_can_message_definition() +std::vector<std::shared_ptr<can_message_definition_t> > configuration_t::get_can_message_definition() { - return can_message_definition_[active_message_set_]; -} - -can_message_definition_t& configuration_t::get_can_message_definition(std::uint8_t message_set_id, std::uint8_t message_id) -{ - return can_message_definition_[message_set_id][message_id]; + return can_message_set_[active_message_set_].get_can_message_definition(); } uint32_t configuration_t::get_signal_id(diagnostic_message_t& sig) const @@ -79,7 +74,7 @@ uint32_t configuration_t::get_signal_id(diagnostic_message_t& sig) const uint32_t configuration_t::get_signal_id(can_signal_t& sig) const { - return sig.get_message().get_id(); + return sig.get_message()->get_id(); } void configuration_t::set_active_message_set(uint8_t id) diff --git a/CAN-binder/low-can-binding/binding/configuration.hpp b/CAN-binder/low-can-binding/binding/configuration.hpp index dd25a206..44881645 100644 --- a/CAN-binder/low-can-binding/binding/configuration.hpp +++ b/CAN-binder/low-can-binding/binding/configuration.hpp @@ -20,11 +20,11 @@ #include <map> #include <vector> #include <string> -#include <fcntl.h> +#include <memory> #include "../can/can-bus.hpp" +#include "../can/can-message-set.hpp" #include "../can/can-signals.hpp" -#include "../can/can-message.hpp" #include "../diagnostic/diagnostic-manager.hpp" #include "low-can-hat.hpp" @@ -48,8 +48,8 @@ class configuration_t uint8_t active_message_set_ = 0; ///< Which is the active message set ? Default to 0. 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<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<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. @@ -69,14 +69,13 @@ class configuration_t const std::vector<can_message_set_t>& get_can_message_set(); - std::vector<can_signal_t>& get_can_signals(); + std::vector<std::shared_ptr<can_signal_t> > get_can_signals(); std::vector<diagnostic_message_t>& get_diagnostic_messages(); const std::vector<std::string>& get_signals_prefix() const; - const std::vector<can_message_definition_t>& get_can_message_definition(); - can_message_definition_t& get_can_message_definition(std::uint8_t message_set_id, std::uint8_t message_id); + std::vector<std::shared_ptr<can_message_definition_t> > get_can_message_definition(); uint32_t get_signal_id(diagnostic_message_t& sig) const; |