summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-03-13 17:46:50 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2017-03-16 17:15:55 +0100
commita0e0cb5ac95e779cd2746d8c1f0740e141bbcc41 (patch)
tree8ee9cb0cdd5344321da8bc6b948243ae49a2e33b /src
parent7abe7ef5336d88736b20b015ae219731d5f42365 (diff)
Adding/Fix classes constructors to make them correspond
to the ones generated. Change-Id: I6b0b778f59ac52fe66e36a327f60ae58550ac271 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'src')
-rw-r--r--src/can/can-signals.cpp8
-rw-r--r--src/can/can-signals.hpp5
-rw-r--r--src/configuration-generated.cpp49
-rw-r--r--src/configuration.cpp38
-rw-r--r--src/configuration.hpp7
-rw-r--r--src/utils/timer.cpp2
-rw-r--r--src/utils/timer.hpp1
7 files changed, 70 insertions, 40 deletions
diff --git a/src/can/can-signals.cpp b/src/can/can-signals.cpp
index ce4e264..b7b311b 100644
--- a/src/can/can-signals.cpp
+++ b/src/can/can-signals.cpp
@@ -27,6 +27,14 @@
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<int, 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_message_definition_t& can_signal_t::get_message()
{
return message_;
diff --git a/src/can/can-signals.hpp b/src/can/can-signals.hpp
index 7708461..53acd00 100644
--- a/src/can/can-signals.hpp
+++ b/src/can/can-signals.hpp
@@ -27,6 +27,7 @@
#include "../utils/timer.hpp"
#include "can-bus.hpp"
#include "can-message.hpp"
+#include "can-message-definition.hpp"
#include "../obd2/obd2-signals.hpp"
extern "C"
@@ -109,6 +110,10 @@ 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<int, std::string> states, bool writable, SignalDecoder decoder, SignalEncoder encoder, bool received);
+
can_message_definition_t& get_message();
const std::string& get_generic_name() const;
const std::string get_name() const;
diff --git a/src/configuration-generated.cpp b/src/configuration-generated.cpp
index 867f203..26d6564 100644
--- a/src/configuration-generated.cpp
+++ b/src/configuration-generated.cpp
@@ -3,17 +3,46 @@
// THIS IS AN EXAMPLE
/////////////////////////////////////////////////////////////////////////////////////
-#include <configuration.hpp>
+#include "configuration.hpp"
+#include "can/can-decoder.hpp"
+
+// Pre-defined OBD-II PIDs to query for if supported by the vehicle.
+ std::vector<obd2_signal_t> OBD2_PIDS = {
+ obd2_signal_t(0x04, "engine.load", 0, 100, POURCENT, 5, false),
+ obd2_signal_t(0x05, "engine.coolant.temperature", -40, 215, DEGREES_CELSIUS, 1, false),
+ obd2_signal_t(0x0a, "fuel.pressure", 0, 765, KPA, 1, false),
+ obd2_signal_t(0x0b, "intake.manifold.pressure", 0, 255, KPA, 1, false),
+ obd2_signal_t(0x0c, "engine.speed", 0, 16383, RPM, 5, false),
+ obd2_signal_t(0x0d, "vehicle.speed", 0, 255, KM_H, 5, false),
+ obd2_signal_t(0x0f, "intake.air.temperature", -40, 215, DEGREES_CELSIUS, 1, false),
+ obd2_signal_t(0x10, "mass.airflow", 0, 655, GRAMS_SEC, 5, false),
+ obd2_signal_t(0x11, "throttle.position", 0, 100, POURCENT, 5, false),
+ obd2_signal_t(0x1f, "running.time", 0, 65535, SECONDS, 1, false),
+ obd2_signal_t(0x2d, "EGR.error", -100, 99, POURCENT, 0, false),
+ obd2_signal_t(0x2f, "fuel.level", 0, 100, POURCENT, 1, false),
+ obd2_signal_t(0x33, "barometric.pressure", 0, 255, KPA, 1, false),
+ obd2_signal_t(0x4c, "commanded.throttle.position", 0, 100, POURCENT, 1, false),
+ obd2_signal_t(0x52, "ethanol.fuel.percentage", 0, 100, POURCENT, 1, false),
+ obd2_signal_t(0x5a, "accelerator.pedal.position", 0, 100, POURCENT, 5, false),
+ obd2_signal_t(0x5b, "hybrid.battery-pack.remaining.life", 0, 100, POURCENT, 5, false),
+ obd2_signal_t(0x5c, "engine.oil.temperature",-40, 210, DEGREES_CELSIUS, 1, false),
+ obd2_signal_t(0x63, "engine.torque", 0, 65535, NM, 1, false)
+};
+
+std::vector<obd2_signal_t> get_predefined_obd2()
+{
+ return OBD2_PIDS;
+}
std::vector<can_message_set_t> CAN_MESSAGE_SET =
{
- {0, "example_messages", 1, 2, 2, 0, 19},
+ can_message_set_t(0, "example_messages", 1, 2, 2, 0, 19),
};
-std::vector<std::vector<can_message_definition_t>> CAN_MESSAGES_DEFINTION = {
+std::vector<std::vector<can_message_definition_t>> CAN_MESSAGES_DEFINITION = {
{
- {0x620, can_message_format_t::STANDARD, {10, 0, nullptr}, false, (uint8_t)NULL},
- {0x442, can_message_format_t::STANDARD, {10, 0, nullptr}, false, (uint8_t)NULL},
+ can_message_definition_t(0, 0x620, can_message_format_t::STANDARD, frequency_clock_t(), false),
+ can_message_definition_t(0, 0x442, can_message_format_t::STANDARD, frequency_clock_t(), false),
},
};
@@ -23,7 +52,11 @@ std::vector<std::vector<can_message_definition_t>> CAN_MESSAGES_DEFINTION = {
*/
std::vector<std::vector<can_signal_t>> SIGNALS = {
{
- {&(CAN_MESSAGES_DEFINTION[MESSAGE_SET_ID][0]), "can.driver_door.open", 2, 4, 1.000000, 0.000000, 0.000000, 0.000000, {10, 0, nullptr}, false, true, nullptr, 0, false, decoder_t::booleanDecoder, nullptr, false, 0.0},
- {&(CAN_MESSAGES_DEFINTION[MESSAGE_SET_ID][1]), "can.driver_door.close", 0, 4, 1.000000, 0.000000, 0.000000, 0.000000, {10, 0, nullptr}, false, true, nullptr, 0, false, decoder_t::booleanDecoder, nullptr, false, 0.0}
+ can_signal_t((CAN_MESSAGES_DEFINITION[MESSAGE_SET_ID][0]), "can.driver_door.open", 2, 4, 1.000000, 0.000000, 0.000000, 0.000000, frequency_clock_t(), false, true, std::map<int, std::string>(), false, decoder_t::booleanDecoder, nullptr, false),
+ can_signal_t((CAN_MESSAGES_DEFINITION[MESSAGE_SET_ID][1]), "can.driver_door.close", 0, 4, 1.000000, 0.000000, 0.000000, 0.000000, frequency_clock_t(), false, true, std::map<int, std::string>(),false, decoder_t::booleanDecoder, nullptr, false)
},
-}; \ No newline at end of file
+};
+
+configuration_t::configuration_t()
+ : can_message_set_{CAN_MESSAGE_SET}, can_message_definition_{CAN_MESSAGES_DEFINITION}, can_signals_{SIGNALS}, obd2_signals_{OBD2_PIDS}
+{} \ No newline at end of file
diff --git a/src/configuration.cpp b/src/configuration.cpp
index 85840f8..de5cc3b 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -19,35 +19,12 @@
#include "utils/signals.hpp"
-// Pre-defined OBD-II PIDs to query for if supported by the vehicle.
- std::vector<obd2_signal_t> OBD2_PIDS = {
- obd2_signal_t(0x04, "engine.load", 0, 100, POURCENT, 5, false),
- obd2_signal_t(0x05, "engine.coolant.temperature", -40, 215, DEGREES_CELSIUS, 1, false),
- obd2_signal_t(0x0a, "fuel.pressure", 0, 765, KPA, 1, false),
- obd2_signal_t(0x0b, "intake.manifold.pressure", 0, 255, KPA, 1, false),
- obd2_signal_t(0x0c, "engine.speed", 0, 16383, RPM, 5, false),
- obd2_signal_t(0x0d, "vehicle.speed", 0, 255, KM_H, 5, false),
- obd2_signal_t(0x0f, "intake.air.temperature", -40, 215, DEGREES_CELSIUS, 1, false),
- obd2_signal_t(0x10, "mass.airflow", 0, 655, GRAMS_SEC, 5, false),
- obd2_signal_t(0x11, "throttle.position", 0, 100, POURCENT, 5, false),
- obd2_signal_t(0x1f, "running.time", 0, 65535, SECONDS, 1, false),
- obd2_signal_t(0x2d, "EGR.error", -100, 99, POURCENT, 0, false),
- obd2_signal_t(0x2f, "fuel.level", 0, 100, POURCENT, 1, false),
- obd2_signal_t(0x33, "barometric.pressure", 0, 255, KPA, 1, false),
- obd2_signal_t(0x4c, "commanded.throttle.position", 0, 100, POURCENT, 1, false),
- obd2_signal_t(0x52, "ethanol.fuel.percentage", 0, 100, POURCENT, 1, false),
- obd2_signal_t(0x5a, "accelerator.pedal.position", 0, 100, POURCENT, 5, false),
- obd2_signal_t(0x5b, "hybrid.battery-pack.remaining.life", 0, 100, POURCENT, 5, false),
- obd2_signal_t(0x5c, "engine.oil.temperature",-40, 210, DEGREES_CELSIUS, 1, false),
- obd2_signal_t(0x63, "engine.torque", 0, 65535, NM, 1, false)
-};
-
// Dumb signals and message implementation. To get compile.
-std::vector<can_message_set_t> CAN_MESSAGE_SET;
+/*std::vector<can_message_set_t> CAN_MESSAGE_SET;
-std::vector<std::vector<can_message_definition_t>> CAN_MESSAGES_DEFINTION;
+std::vector<std::vector<can_message_definition_t>> CAN_MESSAGES_DEFINITION;
-std::vector<std::vector<can_signal_t>> SIGNALS;
+std::vector<std::vector<can_signal_t>> SIGNALS;*/
configuration_t& configuration_t::instance()
{
@@ -55,10 +32,6 @@ configuration_t& configuration_t::instance()
return config;
}
-configuration_t::configuration_t()
- : can_message_set_{CAN_MESSAGE_SET}, can_signals_{SIGNALS}, obd2_signals_{OBD2_PIDS}, can_message_definition_{CAN_MESSAGES_DEFINTION}
-{}
-
configuration_t& configuration_t::get_configuration()
{
return *this;
@@ -69,6 +42,11 @@ can_bus_t& configuration_t::get_can_bus_manager()
return can_bus_manager_;
}
+const std::vector<std::shared_ptr<can_bus_dev_t>>& configuration_t::get_can_bus_devices()
+{
+ return can_bus_manager_.get_can_devices();
+}
+
diagnostic_manager_t& configuration_t::get_diagnostic_manager()
{
return diagnostic_manager_;
diff --git a/src/configuration.hpp b/src/configuration.hpp
index 82bcbc7..214b3e7 100644
--- a/src/configuration.hpp
+++ b/src/configuration.hpp
@@ -47,9 +47,9 @@ class configuration_t
std::vector<std::string> signals_prefix_;
std::vector<can_message_set_t> can_message_set_;
+ std::vector<std::vector<can_message_definition_t>> can_message_definition_;
std::vector<std::vector<can_signal_t>> can_signals_;
std::vector<std::vector<obd2_signal_t>> obd2_signals_;
- std::vector<std::vector<can_message_definition_t>> can_message_definition_;
/// Private constructor with implementation generated by the AGL generator.
configuration_t();
@@ -61,6 +61,8 @@ class configuration_t
can_bus_t& get_can_bus_manager();
+ const std::vector<std::shared_ptr<can_bus_dev_t>>& get_can_bus_devices();
+
diagnostic_manager_t& get_diagnostic_manager() ;
uint8_t get_active_message_set() const;
@@ -108,3 +110,6 @@ class configuration_t
bool isBusActive(can_bus_dev_t* bus);
*/
};
+
+// TEMP Function to access OBD2_PIDS vector
+std::vector<obd2_signal_t> get_predefined_obd2();
diff --git a/src/utils/timer.cpp b/src/utils/timer.cpp
index 1461ac4..e708a7e 100644
--- a/src/utils/timer.cpp
+++ b/src/utils/timer.cpp
@@ -35,7 +35,7 @@ long long int system_time_ms()
}
frequency_clock_t::frequency_clock_t()
- : frequency_{0.0}, last_tick_{0}, time_function_{nullptr}
+ : frequency_{10.0}, last_tick_{0}, time_function_{nullptr}
{}
diff --git a/src/utils/timer.hpp b/src/utils/timer.hpp
index ce6336e..b58397b 100644
--- a/src/utils/timer.hpp
+++ b/src/utils/timer.hpp
@@ -51,6 +51,7 @@ private:
public:
frequency_clock_t();
frequency_clock_t(float frequency);
+ frequency_clock_t(float frequency, unsigned long last_tick, time_function_t time_function);
static float frequency_to_period(float frequency);
bool started();