aboutsummaryrefslogtreecommitdiffstats
path: root/src/openxc/message_set.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/openxc/message_set.cpp')
-rwxr-xr-xsrc/openxc/message_set.cpp40
1 files changed, 24 insertions, 16 deletions
diff --git a/src/openxc/message_set.cpp b/src/openxc/message_set.cpp
index d6745bf..7fd7e9d 100755
--- a/src/openxc/message_set.cpp
+++ b/src/openxc/message_set.cpp
@@ -5,6 +5,7 @@ namespace openxc
{
message_set::message_set()
: name_{""}
+ , version_{"1.0"}
, bit_numbering_inverted_{false}
, max_message_frequency_{0}
, raw_can_mode_{can_bus_mode::off}
@@ -19,67 +20,72 @@ namespace openxc
, commands_{}
{
}
-
+
std::string message_set::name() const
{
return name_;
}
-
+
+ std::string message_set::version() const
+ {
+ return version_;
+ }
+
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_;
@@ -88,6 +94,7 @@ namespace openxc
void message_set::from_json(const nlohmann::json& j)
{
name_ = j["name"].get<std::string>();
+ version_ = j["version"].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;
@@ -100,8 +107,8 @@ namespace openxc
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"];
@@ -117,7 +124,8 @@ namespace openxc
nlohmann::json message_set::to_json() const
{
nlohmann::json j;
- j["name_"] = name_;
+ j["name"] = name_;
+ j["version"] = version_;
j["bit_numbering_inverted"] = bit_numbering_inverted_;
j["max_message_frequency"] = max_message_frequency_;
j["raw_can_mode"] = raw_can_mode_;