return o;\r
}\r
\r
+template <>\r
+std::ostream& operator<<(std::ostream& o, const generator<openxc::diagnostic_message>& v)\r
+{\r
+ o << v.line_prefix_ << "{\n"\r
+ << v.line_prefix_ << "\t" << v.v_.pid() << ",\n"\r
+ << v.line_prefix_ << "\t" << gen(v.v_.name()) << ",\n"\r
+ << v.line_prefix_ << "\t" << 0 << ",\n"\r
+ << v.line_prefix_ << "\t" << 0 << ",\n"\r
+ << v.line_prefix_ << "\t" << "UNIT::INVALID" << ",\n"\r
+ << v.line_prefix_ << "\t" << gen(v.v_.frequency()) << ",\n"\r
+ << v.line_prefix_ << "\t" << (v.v_.decoder().size() ? v.v_.decoder() : "nullptr") << ",\n"\r
+ << v.line_prefix_ << "\t" << (v.v_.callback().size() ? v.v_.callback() : "nullptr") << ",\n"\r
+ << v.line_prefix_ << "\t" << "true" << "\n"\r
+ << v.line_prefix_ << "}";\r
+ return o;\r
+}\r
\r
/// @brief Generate the configuration code.\r
/// @param[in] header Content to be inserted as a header.\r
out << '\n';\r
}\r
out << " }\n"\r
- << " //, obd2_signals_{" << "/*...*/" << "}\n"\r
+ << " , diagnostic_messages_\n"\r
+ << " {\n"\r
+ << gen(message_set.diagnostic_messages(), " ") << "\n"\r
+ << " }\n"\r
<< "{\n"\r
+ << "}\n\n"\r
+ << "const std::string configuration_t::get_diagnostic_bus() const\n"\r
+ << "{\n";\r
+\r
+ std::string active_bus = "";\r
+ for (const auto& d : message_set.diagnostic_messages())\r
+ {\r
+ if (d.bus().size() == 0) std::cerr << "ERROR: The bus name should be set for each diagnostic message." << std::endl;\r
+ if (active_bus.size() == 0) active_bus = d.bus();\r
+ if (active_bus != d.bus()) std::cerr << "ERROR: The bus name should be the same for each diagnostic message." << std::endl;\r
+ }\r
+\r
+ out << " return " << gen(active_bus) << ";\n"\r
<< "}\n\n";\r
out << footer << std::endl;\r
}\r