aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2019-11-07 16:29:32 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2019-11-07 16:29:32 +0100
commit82e77bc582b4af1fdab39d08124a8d540636d515 (patch)
treefdc83c3424cac53cc6760b87de1bb7bea7c92ecc
parentb8850421ba13a408b413d23d4eb3e1fb7250196a (diff)
controller:initialize an empty message_set to fill
Initialize an empty message_set to fill later when loading the Plugins Add the required method to be able to add a message_set Change-Id: I1dc784648f69832de8681184adaccbf5300f831d Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
-rw-r--r--low-can-binding/binding/application.cpp41
-rw-r--r--low-can-binding/binding/application.hpp2
2 files changed, 43 insertions, 0 deletions
diff --git a/low-can-binding/binding/application.cpp b/low-can-binding/binding/application.cpp
index d22633f9..bcb8d732 100644
--- a/low-can-binding/binding/application.cpp
+++ b/low-can-binding/binding/application.cpp
@@ -52,6 +52,47 @@ uint8_t application_t::get_active_message_set() const
return active_message_set_;
}
+int application_t::add_message_set(std::shared_ptr<message_set_t> new_message_set)
+{
+
+ vect_ptr_msg_def_t messages_definition = new_message_set->get_messages_definition();
+ for(std::shared_ptr<message_definition_t> cmd : messages_definition)
+ {
+ cmd->set_parent(new_message_set);
+ std::vector<std::shared_ptr<signal_t>> signals = cmd->get_signals();
+ for(std::shared_ptr<signal_t> sig: signals)
+ sig->set_parent(cmd);
+ }
+
+ std::vector<std::shared_ptr<diagnostic_message_t>> diagnostic_messages = new_message_set->get_diagnostic_messages();
+ for(std::shared_ptr<diagnostic_message_t> dm : diagnostic_messages)
+ dm->set_parent(new_message_set);
+
+ for(auto old_msg_set : message_set_)
+ {
+ if(old_msg_set->get_index() == new_message_set->get_index())
+ {
+
+ for(auto new_msg_def : new_message_set->get_messages_definition())
+ {
+ if(old_msg_set->add_message_definition(new_msg_def) < 0)
+ return -1;
+ }
+
+ for(auto new_diag_msg : new_message_set->get_diagnostic_messages())
+ {
+ if(old_msg_set->add_diagnostic_message(new_diag_msg) < 0)
+ return -1;
+ }
+
+ return 0;
+ }
+ }
+
+ message_set_.push_back(new_message_set);
+ return 0;
+}
+
std::vector<std::shared_ptr<message_set_t> > application_t::get_message_set()
{
return message_set_;
diff --git a/low-can-binding/binding/application.hpp b/low-can-binding/binding/application.hpp
index 47a0e2f1..95f64cf3 100644
--- a/low-can-binding/binding/application.hpp
+++ b/low-can-binding/binding/application.hpp
@@ -71,6 +71,8 @@ class application_t
uint8_t get_active_message_set() const;
+ int add_message_set(std::shared_ptr<message_set_t> new_message_set);
+
std::vector<std::shared_ptr<message_set_t> > get_message_set();
vect_ptr_signal_t get_all_signals();