aboutsummaryrefslogtreecommitdiffstats
path: root/CAN-binder/low-can-binding/can/can-message-set.cpp
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-05-10 18:39:25 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-05-10 18:45:56 +0200
commitd253ada94487232ccd33b68a69fd44ff7840fab7 (patch)
tree67f5959138d0ddcad413f9ee692d087200e0b4df /CAN-binder/low-can-binding/can/can-message-set.cpp
parent3e2be4237ac6f3e8bcec8b10d295182cefe67330 (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/can/can-message-set.cpp')
-rw-r--r--CAN-binder/low-can-binding/can/can-message-set.cpp28
1 files changed, 27 insertions, 1 deletions
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 a9f8cf23..1877f3a2 100644
--- a/CAN-binder/low-can-binding/can/can-message-set.cpp
+++ b/CAN-binder/low-can-binding/can/can-message-set.cpp
@@ -25,7 +25,8 @@ can_message_set_t::can_message_set_t(
unsigned short can_message_count,
unsigned short can_signal_count,
unsigned short can_command_count,
- unsigned short obd2_signal_count)
+ unsigned short obd2_signal_count,
+ std::vector<std::shared_ptr<can_message_definition_t> > can_messages_definition)
: index_{index}
, name_{name}
, can_bus_count_{can_bus_count}
@@ -33,5 +34,30 @@ can_message_set_t::can_message_set_t(
, can_signal_count_{can_signal_count}
, can_command_count_{can_command_count}
, obd2_signal_count_{obd2_signal_count}
+ , can_messages_definition_{can_messages_definition}
{
+ for(auto& cmd : can_messages_definition_)
+ {
+ cmd->set_parent(std::make_shared<can_message_set_t>(this));
+ }
}
+
+/// @brief Return vector holding all message definition handled by this message set.
+std::vector<std::shared_ptr<can_message_definition_t> > can_message_set_t::get_can_message_definition()
+{
+ return can_messages_definition_;
+}
+
+std::vector<std::shared_ptr<can_signal_t> > can_message_set_t::get_can_signals() const
+{
+ std::vector<std::shared_ptr<can_signal_t> > can_signals(can_signal_count_);
+ for(const auto& cmd: can_messages_definition_)
+ {
+ can_signals.insert( can_signals.end(),
+ cmd->get_can_signals().begin(),
+ cmd->get_can_signals().end()
+ );
+ }
+
+ return can_signals;
+} \ No newline at end of file