diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-04-14 13:24:07 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-04-14 13:24:07 +0200 |
commit | 49fe0eec8f17698fc5f86d0abe01777af1fb2b23 (patch) | |
tree | 356cd3e3261934a3fb90786e1789ee4ad001cbe5 /CAN-config-generator/src/openxc/signal.cpp | |
parent | 044ef27d3667a114964549f89c63ab1ea6655877 (diff) |
Change directory architecture to use 2 separated projects.
Each projects, binder and generator, has to be compiled separatly.
CAN-binder will host high and low level binding
CAN-config-generator only the generator used for low level binding.
build.sh script just launch both build in their respective dir.
Change-Id: Ic77932660fcca507b23a631d4e4e790f608880ae
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'CAN-config-generator/src/openxc/signal.cpp')
-rwxr-xr-x | CAN-config-generator/src/openxc/signal.cpp | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/CAN-config-generator/src/openxc/signal.cpp b/CAN-config-generator/src/openxc/signal.cpp new file mode 100755 index 00000000..6c3ff82a --- /dev/null +++ b/CAN-config-generator/src/openxc/signal.cpp @@ -0,0 +1,142 @@ +#include "signal.hpp"
+
+namespace openxc
+{
+ std::string signal::id() const
+ {
+ return id_;
+ }
+
+ void signal::id(const std::string& id)
+ {
+ id_ = id;
+ }
+
+ void id(const std::string& id);
+
+ std::string signal::generic_name() const
+ {
+ return generic_name_;
+ }
+
+ std::uint32_t signal::bit_position() const
+ {
+ return bit_position_;
+ }
+
+ std::uint32_t signal::bit_size() const
+ {
+ return bit_size_;
+ }
+
+ float signal::factor() const
+ {
+ return factor_;
+ }
+
+ std::uint32_t signal::offset() const
+ {
+ return offset_;
+ }
+
+ std::string signal::decoder() const
+ {
+ return decoder_;
+ }
+
+ bool signal::ignore() const
+ {
+ return ignore_;
+ }
+
+ bool signal::enabled() const
+ {
+ return enabled_;
+ }
+
+ const std::map<std::string, std::vector<std::uint32_t>>& signal::states() const
+ {
+ return states_;
+ }
+
+ float signal::max_frequency() const
+ {
+ return max_frequency_;
+ }
+
+ bool signal::send_same() const
+ {
+ return send_same_;
+ }
+
+ bool signal::force_send_changed() const
+ {
+ return force_send_changed_;
+ }
+
+ bool signal::writable() const
+ {
+ return writable_;
+ }
+
+ std::string signal::encoder() const
+ {
+ return encoder_;
+ }
+
+ void signal::from_json(const nlohmann::json& j)
+ {
+ generic_name_ = j.count("generic_name") ? j["generic_name"].get<std::string>() : "";
+ bit_position_ = j.count("bit_position") ? j["bit_position"].get<std::uint32_t>() : 0;
+ bit_size_ = j.count("bit_size") ? j["bit_size"].get<std::uint32_t>() : 0;
+ factor_ = j.count("factor") ? j["factor"].get<float>() : 1.0f;
+ offset_ = j.count("offset") ? j["offset"].get<std::uint32_t>() : 0;
+ decoder_ = j.count("decoder") ? j["decoder"].get<std::string>() : "";
+ ignore_ = j.count("ignore") ? j["ignore"].get<bool>() : false;
+ enabled_ = j.count("enabled") ? j["enabled"].get<bool>() : true;
+ max_frequency_ = j.count("max_frequency") ? j["max_frequency"].get<std::uint32_t>() : 0;
+ send_same_ = j.count("send_same") ? j["send_same"].get<bool>() : true;
+ force_send_changed_ = j.count("force_send_changed") ? j["force_send_changed"].get<bool>() : false;
+ writable_ = j.count("writable") ? j["writable"].get<bool>() : false;
+ encoder_ = j.count("encoder") ? j["encoder"].get<std::string>() : "";
+
+ if (j.count("states"))
+ {
+ std::map<std::string, nlohmann::json> items = j["states"];
+ for(const auto& i : items)
+ {
+ states_[i.first] = i.second.get<std::vector<std::uint32_t>>();
+ }
+ }
+ }
+
+ nlohmann::json signal::to_json() const
+ {
+ nlohmann::json j;
+ j["generic_name"] = generic_name_;
+ j["bit_position"] = bit_position_;
+ j["bit_size"] = bit_size_;
+ j["factor"] = factor_;
+ j["offset"] = offset_;
+ j["decoder"] = decoder_;
+ j["ignore"] = ignore_;
+ j["enabled"] = enabled_;
+ j["states"] = states_;
+ j["max_frequency"] = max_frequency_;
+ j["send_same"] = send_same_;
+ j["force_send_changed"] = force_send_changed_;
+ j["writable"] = writable_;
+ j["encoder"] = encoder_;
+ return j;
+ }
+
+ void to_json(nlohmann::json& j, const signal& p)
+ {
+ j = p.to_json();
+ }
+
+ void from_json(const nlohmann::json& j, signal& p)
+ {
+ p.from_json(j);
+ }
+}
|