X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fopenxc%2Fsignal.cpp;h=858f64b2615563416976a532d403eab1bc681bbe;hb=HEAD;hp=e9c1088b43bab9c0e62008ae3554e45d82c9c1a8;hpb=014ba2dd29eaadb4d61948ca417c25112f76ee0e;p=src%2Flow-level-can-generator.git diff --git a/src/openxc/signal.cpp b/src/openxc/signal.cpp index e9c1088..858f64b 100755 --- a/src/openxc/signal.cpp +++ b/src/openxc/signal.cpp @@ -83,6 +83,25 @@ namespace openxc { return encoder_; } + + std::pair signal::multiplex() const{ + return multiplex_; + } + + sign_t signal::sign() const + { + return sign_; + } + + std::int32_t signal::bit_sign_position() const + { + return bit_sign_position_; + } + + std::string signal::unit() const{ + return unit_; + } + void signal::from_json(const nlohmann::json& j) { @@ -99,6 +118,28 @@ 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); + } + + bit_sign_position_ = j.count("bit_sign_position") ? j["bit_sign_position"].get() : -1; + sign_ = j.count("signed") ? (sign_t) j["signed"].get() : sign_t::UNSIGNED; + unit_ = j.count("unit") ? j["unit"].get() : ""; if (j.count("states")) { @@ -127,6 +168,27 @@ 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["bit_sign_position"] = bit_sign_position_; + j["signed"] = static_cast(sign_); + j["unit"] = unit_; return j; }