summaryrefslogtreecommitdiffstats
path: root/CAN-config-generator/src/openxc/message_set.cpp
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-06-20 10:24:05 +0000
committerRomain Forlot <romain.forlot@iot.bzh>2017-06-20 10:24:05 +0000
commit32e25cbca210a359b09768537b6f443fe90a3070 (patch)
tree3309794c15d8a8f8e9c1c08cad072ee1378813ba /CAN-config-generator/src/openxc/message_set.cpp
parent76c43dec62b2e21cd6446360c00d4fe6b437533f (diff)
Separation Generator to a dedicated repo
Change-Id: Id94831651c3266861435272a6e36c7884bef2c45 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'CAN-config-generator/src/openxc/message_set.cpp')
-rwxr-xr-xCAN-config-generator/src/openxc/message_set.cpp145
1 files changed, 0 insertions, 145 deletions
diff --git a/CAN-config-generator/src/openxc/message_set.cpp b/CAN-config-generator/src/openxc/message_set.cpp
deleted file mode 100755
index d6745bfc..00000000
--- a/CAN-config-generator/src/openxc/message_set.cpp
+++ /dev/null
@@ -1,145 +0,0 @@
-#include <sstream>
-#include "message_set.hpp"
-
-namespace openxc
-{
- message_set::message_set()
- : name_{""}
- , bit_numbering_inverted_{false}
- , max_message_frequency_{0}
- , raw_can_mode_{can_bus_mode::off}
- , parents_{}
- , initializers_{}
- , loopers_{}
- , buses_{}
- , messages_{}
- , diagnostic_messages_{}
- , mappings_{}
- , extra_sources_{}
- , commands_{}
- {
- }
-
- std::string message_set::name() const
- {
- return name_;
- }
-
- bool message_set::bit_numbering_inverted() const
- {
- return bit_numbering_inverted_;
- }
-
- float message_set::max_message_frequency() const
- {
- return max_message_frequency_;
- }
-
- can_bus_mode message_set::raw_can_mode() const
- {
- return raw_can_mode_;
- }
-
- const std::vector<std::string>& message_set::parents() const
- {
- return parents_;
- }
-
- const std::vector<std::string>& message_set::initializers() const
- {
- return initializers_;
- }
-
- const std::vector<std::string>& message_set::loopers() const
- {
- return loopers_;
- }
-
- const std::map<std::string, can_bus>& message_set::buses() const
- {
- return buses_;
- }
-
- const std::vector<can_message>& message_set::messages() const
- {
- return messages_;
- }
-
- const std::vector<diagnostic_message>& message_set::diagnostic_messages() const
- {
- return diagnostic_messages_;
- }
-
- const std::vector<mapping>& message_set::mappings() const
- {
- return mappings_;
- }
-
- const std::vector<std::string>& message_set::extra_sources() const
- {
- return extra_sources_;
- }
-
- const std::vector<command>& message_set::commands() const
- {
- return commands_;
- }
-
- void message_set::from_json(const nlohmann::json& j)
- {
- name_ = j["name"].get<std::string>();
- bit_numbering_inverted_ = j.count("bit_numbering_inverted") ? j["bit_numbering_inverted"].get<bool>() : false; // TODO: should be true by default if database-backed.
- max_message_frequency_ = j.count("max_message_frequency") ? j["max_message_frequency"].get<float>() : 0.0f;
- raw_can_mode_ = j.count("raw_can_mode") ? j["raw_can_mode"].get<can_bus_mode>() : can_bus_mode::off;
- parents_ = j.count("parents") ? j["parents"].get<std::vector<std::string>>() : std::vector<std::string>();
- initializers_ = j.count("initializers") ? j["initializers"].get<std::vector<std::string>>() : std::vector<std::string>();
- loopers_ = j.count("loopers") ? j["loopers"].get<std::vector<std::string>>() : std::vector<std::string>();
- buses_ = j.count("buses") ? j["buses"].get<std::map<std::string, can_bus>>() : std::map<std::string, can_bus>();
- //messages_ = j.count("messages") ? j["messages"].get<std::map<std::string, can_message>>() : std::map<std::string, can_message>();
- diagnostic_messages_ = j.count("diagnostic_messages") ? j["diagnostic_messages"].get<std::vector<diagnostic_message>>() : std::vector<diagnostic_message>();
- mappings_ = j.count("mappings") ? j["mappings"].get<std::vector<mapping>>() : std::vector<mapping>();
- extra_sources_ = j.count("extra_sources") ? j["extra_sources"].get<std::vector<std::string>>() : std::vector<std::string>();
- commands_ = j.count("commands") ? j["commands"].get<std::vector<command>>() : std::vector<command>();
-
-
- if (j.count("messages"))
- {
- std::map<std::string, nlohmann::json> messages = j["messages"];
- for(const std::map<std::string, nlohmann::json>::value_type& m : messages)
- {
- can_message cm = m.second.get<can_message>();
- cm.id(m.first);
- messages_.push_back(cm);
- }
- }
- }
-
- nlohmann::json message_set::to_json() const
- {
- nlohmann::json j;
- j["name_"] = name_;
- j["bit_numbering_inverted"] = bit_numbering_inverted_;
- j["max_message_frequency"] = max_message_frequency_;
- j["raw_can_mode"] = raw_can_mode_;
- j["parents"] = parents_;
- j["initializers"] = initializers_;
- j["loopers"] = loopers_;
- j["buses"] = buses_;
- j["messages"] = messages_;
- j["diagnostic_messages"] = diagnostic_messages_;
- j["mappings"] = mappings_;
- j["extra_sources"] = extra_sources_;
- j["commands"] = commands_;
- return j;
- }
-
- void to_json(nlohmann::json& j, const message_set& p)
- {
- j = p.to_json();
- }
-
- void from_json(const nlohmann::json& j, message_set& p)
- {
- p.from_json(j);
- }
-}