diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-04-11 15:49:47 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-04-11 15:49:47 +0200 |
commit | a58d40b5ae336a54408201963b065ee049b43acd (patch) | |
tree | 9769e3d5b624e0238fe550df601e5382f259c52e /can-config-generator/src/openxc/diagnostic_message.cpp | |
parent | 9e444ade872bc436cf12bc12d03c3a5d51ac0b9e (diff) | |
parent | b7591d16c2686214d5d8dcc0739a233f15aee5db (diff) |
Add 'can-config-generator/' from commit 'b7591d16c2686214d5d8dcc0739a233f15aee5db'
git-subtree-dir: can-config-generator
git-subtree-mainline: 9e444ade872bc436cf12bc12d03c3a5d51ac0b9e
git-subtree-split: b7591d16c2686214d5d8dcc0739a233f15aee5db
Diffstat (limited to 'can-config-generator/src/openxc/diagnostic_message.cpp')
-rwxr-xr-x | can-config-generator/src/openxc/diagnostic_message.cpp | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/can-config-generator/src/openxc/diagnostic_message.cpp b/can-config-generator/src/openxc/diagnostic_message.cpp new file mode 100755 index 00000000..3881abef --- /dev/null +++ b/can-config-generator/src/openxc/diagnostic_message.cpp @@ -0,0 +1,80 @@ +#include "diagnostic_message.hpp"
+
+namespace openxc
+{
+ std::string diagnostic_message::bus() const
+ {
+ return bus_;
+ }
+
+ std::uint32_t diagnostic_message::id() const
+ {
+ return id_;
+ }
+
+ std::uint32_t diagnostic_message::mode() const
+ {
+ return mode_;
+ }
+
+ float diagnostic_message::frequency() const
+ {
+ return frequency_;
+ }
+
+ std::uint32_t diagnostic_message::pid() const
+ {
+ return pid_;
+ }
+
+ std::string diagnostic_message::name() const
+ {
+ return name_;
+ }
+
+ std::string diagnostic_message::decoder() const
+ {
+ return decoder_;
+ }
+
+ std::string diagnostic_message::callback() const
+ {
+ return callback_;
+ }
+
+ void diagnostic_message::from_json(const nlohmann::json& j)
+ {
+ bus_ = j.count("bus") ? j["bus"].get<std::string>() : "";
+ id_ = j.count("id") ? j["id"].get<std::uint32_t>() : 0;
+ mode_ = j.count("mode") ? j["mode"].get<std::uint32_t>() : 1;
+ frequency_ = j.count("frequency") ? j["frequency"].get<float>() : 0;
+ pid_ = j.count("pid") ? j["pid"].get<std::uint32_t>() : 0;
+ name_ = j.count("name") ? j["name"].get<std::string>() : "";
+ decoder_ = j.count("decoder") ? j["decoder"].get<std::string>() : "";
+ callback_ = j.count("callback") ? j["callback"].get<std::string>() : "";
+ }
+
+ nlohmann::json diagnostic_message::to_json() const
+ {
+ nlohmann::json j;
+ j["bus"] = bus_;
+ j["id"] = id_;
+ j["mode"] = mode_;
+ j["frequency"] = frequency_;
+ j["pid"] = pid_;
+ j["name"] = name_;
+ j["decoder"] = decoder_;
+ j["callback"] = callback_;
+ return j;
+ }
+
+ void to_json(nlohmann::json& j, const diagnostic_message& p)
+ {
+ j = p.to_json();
+ }
+
+ void from_json(const nlohmann::json& j, diagnostic_message& p)
+ {
+ p.from_json(j);
+ }
+}
|