diff options
author | Loïc Collignon <loic.collignon@iot.bzh> | 2017-03-17 11:49:27 +0100 |
---|---|---|
committer | Loïc Collignon <loic.collignon@iot.bzh> | 2017-03-17 11:49:27 +0100 |
commit | cbc227941e8f65bf9e1a2cc8a178792a8462be18 (patch) | |
tree | 893ae20373a40d712c0a7b915922e4baa8292d54 | |
parent | d7c2e9b345cd02659f462083bfe555c5534d38c5 (diff) |
added support for diagnostic messages.
Signed-off-by: Loïc Collignon <loic.collignon@iot.bzh>
-rw-r--r-- | src/main.cpp | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp index 9497b3a5..4b3feb27 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -167,6 +167,22 @@ std::ostream& operator<<(std::ostream& o, const generator<openxc::signal>& v) return o;
}
+template <>
+std::ostream& operator<<(std::ostream& o, const generator<openxc::diagnostic_message>& v)
+{
+ o << v.line_prefix_ << "{\n"
+ << v.line_prefix_ << "\t" << v.v_.pid() << ",\n"
+ << v.line_prefix_ << "\t" << gen(v.v_.name()) << ",\n"
+ << v.line_prefix_ << "\t" << 0 << ",\n"
+ << v.line_prefix_ << "\t" << 0 << ",\n"
+ << v.line_prefix_ << "\t" << "UNIT::INVALID" << ",\n"
+ << v.line_prefix_ << "\t" << gen(v.v_.frequency()) << ",\n"
+ << v.line_prefix_ << "\t" << (v.v_.decoder().size() ? v.v_.decoder() : "nullptr") << ",\n"
+ << v.line_prefix_ << "\t" << (v.v_.callback().size() ? v.v_.callback() : "nullptr") << ",\n"
+ << v.line_prefix_ << "\t" << "true" << "\n"
+ << v.line_prefix_ << "}";
+ return o;
+}
/// @brief Generate the configuration code.
/// @param[in] header Content to be inserted as a header.
@@ -207,8 +223,24 @@ void generate(const std::string& header, const std::string& footer, const openxc out << '\n';
}
out << " }\n"
- << " //, obd2_signals_{" << "/*...*/" << "}\n"
+ << " , diagnostic_messages_\n"
+ << " {\n"
+ << gen(message_set.diagnostic_messages(), " ") << "\n"
+ << " }\n"
<< "{\n"
+ << "}\n\n"
+ << "const std::string configuration_t::get_diagnostic_bus() const\n"
+ << "{\n";
+
+ std::string active_bus = "";
+ for (const auto& d : message_set.diagnostic_messages())
+ {
+ if (d.bus().size() == 0) std::cerr << "ERROR: The bus name should be set for each diagnostic message." << std::endl;
+ if (active_bus.size() == 0) active_bus = d.bus();
+ if (active_bus != d.bus()) std::cerr << "ERROR: The bus name should be the same for each diagnostic message." << std::endl;
+ }
+
+ out << " return " << gen(active_bus) << ";\n"
<< "}\n\n";
out << footer << std::endl;
}
|