diff options
Diffstat (limited to 'src/openxc/can_message.cpp')
-rwxr-xr-x | src/openxc/can_message.cpp | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/src/openxc/can_message.cpp b/src/openxc/can_message.cpp index d42d1efa..fab5a85f 100755 --- a/src/openxc/can_message.cpp +++ b/src/openxc/can_message.cpp @@ -2,6 +2,16 @@ namespace openxc
{
+ std::string can_message::id() const
+ {
+ return id_;
+ }
+
+ void can_message::id(const std::string& id)
+ {
+ id_ = id;
+ }
+
std::string can_message::bus() const
{
return bus_;
@@ -12,7 +22,7 @@ namespace openxc return bit_numbering_inverted_;
}
- const std::map<std::string, signal>& can_message::signals() const
+ const std::vector<signal>& can_message::signals() const
{
return signals_;
}
@@ -32,12 +42,12 @@ namespace openxc return enabled_;
}
- std::uint32_t can_message::max_frequency() const
+ float can_message::max_frequency() const
{
return max_frequency_;
}
- std::uint32_t can_message::max_signal_frequency() const
+ float can_message::max_signal_frequency() const
{
return max_signal_frequency_;
}
@@ -56,14 +66,25 @@ namespace openxc {
bus_ = j.count("bus") ? j["bus"].get<std::string>() : "";
bit_numbering_inverted_ = j.count("bit_numbering_inverted") ? j["bit_numbering_inverted"].get<bool>() : false;
- signals_= j.count("signals") ? j["signals"].get<std::map<std::string, signal>>() : std::map<std::string, signal>();
name_ = j.count("name") ? j["name"].get<std::string>() : "";
handlers_ = j.count("handlers") ? j["handlers"].get<std::vector<std::string>>() : std::vector<std::string>();
enabled_ = j.count("enabled") ? j["enabled"].get<bool>() : true;
- max_frequency_ = j.count("max_frequency") ? j["max_frequency"].get<std::uint32_t>() : 0;
- max_signal_frequency_ = j.count("max_signal_frequency") ? j["max_signal_frequency"].get<std::uint32_t>() : 0;
+ max_frequency_ = j.count("max_frequency") ? j["max_frequency"].get<float>() : 0;
+ max_signal_frequency_ = j.count("max_signal_frequency") ? j["max_signal_frequency"].get<float>() : 0;
force_send_changed_ = j.count("force_send_changed") ? j["force_send_changed"].get<bool>() : true;
force_send_changed_signals_ = j.count("force_send_changed_signals") ? j["force_send_changed_signals"].get<bool>() : false;
+
+ if(j.count("signals"))
+ {
+ std::map<std::string, nlohmann::json> signals = j["signals"];
+ for(const auto& s : signals)
+ {
+ signal sig = s.second.get<signal>();
+ sig.id(s.first);
+ signals_.push_back(sig);
+ }
+ }
+
}
std::uint32_t can_message::get_signals_count() const
@@ -91,9 +112,15 @@ namespace openxc {
j = p.to_json();
}
-
+
void from_json(const nlohmann::json& j, can_message& p)
{
p.from_json(j);
}
+
+ void from_json(const nlohmann::json& j, can_message& p, const std::string& id)
+ {
+ p.from_json(j);
+ p.id(id);
+ }
}
|