summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-03-16 18:16:56 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2017-03-16 18:16:56 +0100
commit8fc21efc5ec7669d38712f44d71d10056614ea64 (patch)
tree481362d3cb7c744699321fee3d7f346a038c0eee /src
parent29a91626fe9445823ab26157c976b76856901588 (diff)
Use index number between objects to set their links.
Needed to use generator. Change-Id: I82b44fa1e53c55e2cd90ae7017906a22b7f0636e Signed-off-by: Loïc Collignon <loic.collignon@iot.bzh>
Diffstat (limited to 'src')
-rw-r--r--src/can/can-message-definition.cpp12
-rw-r--r--src/can/can-message-definition.hpp7
-rw-r--r--src/can/can-signals.cpp46
-rw-r--r--src/can/can-signals.hpp26
-rw-r--r--src/configuration.cpp5
-rw-r--r--src/configuration.hpp1
6 files changed, 75 insertions, 22 deletions
diff --git a/src/can/can-message-definition.cpp b/src/can/can-message-definition.cpp
index 7aca19e9..fb7efce5 100644
--- a/src/can/can-message-definition.cpp
+++ b/src/can/can-message-definition.cpp
@@ -17,16 +17,16 @@
#include "can-message-definition.hpp"
-can_message_definition_t::can_message_definition_t(const std::string bus)
- : bus_{bus}, last_value_(CAN_MESSAGE_SIZE)
+can_message_definition_t::can_message_definition_t(std::uint8_t message_set_id, const std::string bus)
+ : message_set_id_{message_set_id}, bus_{bus}, last_value_{CAN_MESSAGE_SIZE}
{}
-can_message_definition_t::can_message_definition_t(const std::string bus, uint32_t id, frequency_clock_t frequency_clock, bool force_send_changed)
-: bus_{bus}, id_{id}, frequency_clock_{frequency_clock}, force_send_changed_{force_send_changed}, last_value_(CAN_MESSAGE_SIZE)
+can_message_definition_t::can_message_definition_t(std::uint8_t message_set_id, const std::string bus, uint32_t id, frequency_clock_t frequency_clock, bool force_send_changed)
+ : message_set_id_{message_set_id}, bus_{bus}, id_{id}, frequency_clock_{frequency_clock}, force_send_changed_{force_send_changed}, last_value_{CAN_MESSAGE_SIZE}
{}
-can_message_definition_t::can_message_definition_t(const std::string bus, uint32_t id, can_message_format_t format, frequency_clock_t frequency_clock, bool force_send_changed)
- : bus_{bus}, id_{id}, format_{format}, frequency_clock_{frequency_clock}, force_send_changed_{force_send_changed}, last_value_(CAN_MESSAGE_SIZE)
+can_message_definition_t::can_message_definition_t(std::uint8_t message_set_id, const std::string bus, uint32_t id, can_message_format_t format, frequency_clock_t frequency_clock, bool force_send_changed)
+ : message_set_id_{message_set_id}, bus_{bus}, id_{id}, format_{format}, frequency_clock_{frequency_clock}, force_send_changed_{force_send_changed}, last_value_{CAN_MESSAGE_SIZE}
{}
uint32_t can_message_definition_t::get_id() const
diff --git a/src/can/can-message-definition.hpp b/src/can/can-message-definition.hpp
index 921b58ad..98cb2c5d 100644
--- a/src/can/can-message-definition.hpp
+++ b/src/can/can-message-definition.hpp
@@ -35,6 +35,7 @@
class can_message_definition_t
{
private:
+ std::uint8_t message_set_id_;
std::string bus_; /*!< bus_ - Address of CAN bus device. */
uint32_t id_; /*!< id_ - The ID of the message.*/
can_message_format_t format_; /*!< format_ - the format of the message's ID.*/
@@ -48,9 +49,9 @@ private:
* needs to compare an incoming CAN message with the previous frame.*/
public:
- can_message_definition_t(const std::string bus);
- can_message_definition_t(const std::string bus, uint32_t id, frequency_clock_t frequency_clock, bool force_send_changed);
- can_message_definition_t(const std::string bus, uint32_t id, can_message_format_t format, frequency_clock_t frequency_clock, bool force_send_changed);
+ can_message_definition_t(std::uint8_t message_set_id, const std::string bus);
+ can_message_definition_t(std::uint8_t message_set_id, const std::string bus, uint32_t id, frequency_clock_t frequency_clock, bool force_send_changed);
+ can_message_definition_t(std::uint8_t message_set_id, const std::string bus, uint32_t id, can_message_format_t format, frequency_clock_t frequency_clock, bool force_send_changed);
uint32_t get_id() const;
};
diff --git a/src/can/can-signals.cpp b/src/can/can-signals.cpp
index 0dcc6297..72c93013 100644
--- a/src/can/can-signals.cpp
+++ b/src/can/can-signals.cpp
@@ -27,17 +27,47 @@
std::string can_signal_t::prefix_ = "messages";
-can_signal_t::can_signal_t(can_message_definition_t& message, std::string generic_name, uint8_t bit_position, uint8_t bit_size,
- float factor, float offset, float min_value, float max_value, frequency_clock_t frequency, bool send_same, bool force_send_changed,
- std::map<uint8_t, std::string> states, bool writable, SignalDecoder decoder, SignalEncoder encoder, bool received)
- : message_{message}, generic_name_{generic_name}, bit_position_{bit_position}, bit_size_{bit_size}, factor_{factor}, offset_{offset},
- min_value_{min_value}, max_value_{max_value}, frequency_{frequency}, send_same_{send_same}, force_send_changed_{force_send_changed}, states_{states},
- writable_{writable}, decoder_{decoder}, encoder_{encoder}, received_{received}, last_value_{(float)NULL}
+can_signal_t::can_signal_t(std::uint8_t message_set_id,
+ std::uint8_t message_id,
+ std::string generic_name,
+ uint8_t bit_position,
+ uint8_t bit_size,
+ float factor,
+ float offset,
+ float min_value,
+ float max_value,
+ frequency_clock_t frequency,
+ bool send_same,
+ bool force_send_changed,
+ std::map<uint8_t, std::string> states,
+ bool writable,
+ SignalDecoder decoder,
+ SignalEncoder encoder,
+ bool received)
+ : message_set_id_{ message_set_id }
+ , message_id_{ message_id }
+ , generic_name_{ generic_name }
+ , bit_position_{ bit_position }
+ , bit_size_{ bit_size }
+ , factor_{ factor }
+ , offset_{ offset }
+ , min_value_{min_value}
+ , max_value_{max_value}
+ , frequency_{frequency}
+ , send_same_{send_same}
+ , force_send_changed_{force_send_changed}
+ , states_{states}
+ , writable_{writable}
+ , decoder_{decoder}
+ , encoder_{encoder}
+ , received_{received}
+ , last_value_{.0f}
{}
-can_message_definition_t& can_signal_t::get_message()
+
+const can_message_definition_t& can_signal_t::get_message() const
{
- return message_;
+ return configuration_t::instance().get_can_message_definition(message_set_id_, message_id_);
}
const std::string& can_signal_t::get_generic_name() const
diff --git a/src/can/can-signals.hpp b/src/can/can-signals.hpp
index b22bf7a2..aacb8883 100644
--- a/src/can/can-signals.hpp
+++ b/src/can/can-signals.hpp
@@ -76,7 +76,8 @@ typedef uint64_t (*SignalEncoder)(can_signal_t* signal,
class can_signal_t
{
private:
- can_message_definition_t message_; /*!< message_ - The message this signal is a part of. */
+ std::uint8_t message_set_id_;
+ std::uint8_t message_id_;
std::string generic_name_; /*!< generic_name_ - The name of the signal to be output.*/
static std::string prefix_; /*!< prefix_ - generic_name_ will be prefixed with it. It has to reflect the used protocol.
* which make easier to sort message when the come in.*/
@@ -110,11 +111,26 @@ private:
* this value is undefined. */
public:
- can_signal_t(can_message_definition_t& message, std::string generic_name, uint8_t bit_position, uint8_t bit_size,
- float factor, float offset, float min_value, float max_value, frequency_clock_t frequency, bool send_same, bool force_send_changed,
- std::map<uint8_t, std::string> states, bool writable, SignalDecoder decoder, SignalEncoder encoder, bool received);
+ can_signal_t(
+ std::uint8_t message_set_id,
+ std::uint8_t message_id,
+ std::string generic_name,
+ uint8_t bit_position,
+ uint8_t bit_size,
+ float factor,
+ float offset,
+ float min_value,
+ float max_value,
+ frequency_clock_t frequency,
+ bool send_same,
+ bool force_send_changed,
+ std::map<uint8_t, std::string> states,
+ bool writable,
+ SignalDecoder decoder,
+ SignalEncoder encoder,
+ bool received);
- can_message_definition_t& get_message();
+ const can_message_definition_t& get_message() const;
const std::string& get_generic_name() const;
const std::string get_name() const;
const std::string& get_prefix() const;
diff --git a/src/configuration.cpp b/src/configuration.cpp
index 52ddde42..8a2df909 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -82,6 +82,11 @@ const std::vector<can_message_definition_t>& configuration_t::get_can_message_de
return can_message_definition_[active_message_set_];
}
+const 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];
+}
+
uint32_t configuration_t::get_signal_id(diagnostic_message_t& sig) const
{
return sig.get_pid();
diff --git a/src/configuration.hpp b/src/configuration.hpp
index 25c29b98..fb7b8402 100644
--- a/src/configuration.hpp
+++ b/src/configuration.hpp
@@ -78,6 +78,7 @@ class configuration_t
const std::vector<std::string>& get_signals_prefix() const;
const std::vector<can_message_definition_t>& get_can_message_definition();
+ const can_message_definition_t& get_can_message_definition(std::uint8_t message_set_id, std::uint8_t message_id);
uint32_t get_signal_id(diagnostic_message_t& sig) const;