From 8863689b9b1649cc05303c643340f5f099e5e286 Mon Sep 17 00:00:00 2001 From: Arthur Guyader Date: Wed, 24 Apr 2019 13:28:23 +0200 Subject: Add modification for j1939 low-can Change-Id: I36d74f76e311b082cd492425a1fb57e48ad695ed Signed-off-by: Arthur Guyader --- src/openxc/signal.cpp | 96 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 79 insertions(+), 17 deletions(-) (limited to 'src/openxc/signal.cpp') diff --git a/src/openxc/signal.cpp b/src/openxc/signal.cpp index e9c1088..1bcd869 100755 --- a/src/openxc/signal.cpp +++ b/src/openxc/signal.cpp @@ -6,84 +6,100 @@ namespace openxc { 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_; } - + float 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>& 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_; } - + + std::pair signal::multiplex() const{ + return multiplex_; + } + + bool signal::is_big_endian() const{ + return is_big_endian_; + } + + bool signal::is_signed() const{ + return is_signed_; + } + + std::string signal::unit() const{ + return unit_; + } + void signal::from_json(const nlohmann::json& j) { generic_name_ = j.count("generic_name") ? j["generic_name"].get() : ""; @@ -99,6 +115,29 @@ namespace openxc force_send_changed_ = j.count("force_send_changed") ? j["force_send_changed"].get() : false; writable_ = j.count("writable") ? j["writable"].get() : false; encoder_ = j.count("encoder") ? j["encoder"].get() : ""; + if(j.count("multiplex")) + { + std::string mult = j["multiplex"].get(); + bool first = false; + int second = 0 ; + if(mult.compare("Multiplexor") == 0){ + first = true; + } + else if (mult.compare("") != 0) + { + second = std::stoi(mult); + } + multiplex_ = std::make_pair(first,second); + } + else + { + multiplex_ = std::make_pair(false,0); + } + is_big_endian_ = j.count("is_big_endian") ? j["is_big_endian"].get() : false; + is_signed_ = j.count("is_signed") ? j["is_signed"].get() : false; + unit_ = j.count("unit") ? j["unit"].get() : ""; + + if (j.count("states")) { @@ -127,6 +166,29 @@ namespace openxc j["force_send_changed"] = force_send_changed_; j["writable"] = writable_; j["encoder"] = encoder_; + + std::string multi = ""; + + if(multiplex_.first) + { + multi = "Multiplexor"; + } + else if(multiplex_.second != 0) + { + multi = std::to_string(multiplex_.second); + } + else + { + multi = ""; + } + + j["multiplex"] = multi; + + + + j["is_big_endian"] = is_big_endian_; + j["is_signed"] = is_signed_; + j["unit"] = unit_; return j; } -- cgit 1.2.3-korg