DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
create_config_plot.cxx File Reference
#include "GraphBuilder.hpp"
#include "appmodel/appmodelIssues.hpp"
#include "logging/Logging.hpp"
#include <boost/program_options.hpp>
#include <map>
#include <numeric>
#include <sstream>
#include <stdexcept>
#include <string>
Include dependency graph for create_config_plot.cxx:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 32 of file create_config_plot.cxx.

33{
34
35 std::string oksfilename{ "" };
36 std::string outputfilename{ "" };
37 std::string object_uid{ "" };
38 std::string sessionname{ "" };
39
40 bpo::options_description options_description("Allowed options", 128);
41
42 options_description.add_options()
43
44 ("help,h", "Provide help message")
45
46 ("file,f", bpo::value<std::string>(&oksfilename), "OKS database file name")
47
48 ("root-object,r",
49 bpo::value<std::string>(&object_uid)->default_value(""),
50 "OKS object UID of root vertex; must be session, segment or application")(
51 "session,s",
52 bpo::value<std::string>(&sessionname)->default_value(""),
53 "Name of the session associated with the root object (only needed if >1 session in the database)")(
54 "output,o",
55 bpo::value<std::string>(&outputfilename)->default_value("config.dot"),
56 "Output DOT file which can be used as input to GraphViz");
57
58 bpo::variables_map args;
59
60 auto display_help_message = [&options_description]() {
61 TLOG() << "create_config_plot : Generate dot graphs from database files" << std::endl
62 << std::endl
63 << "Usage: create_config_plot -f/--file <input OKS file> -r/--root-object <object UID for session, segment "
64 "or application> (-s/--session <session containing root-object>) (-o/--output <output DOT file, default "
65 "is config.dot>)"
66 << std::endl
67 << std::endl
68 << options_description << std::endl;
69 };
70
71 try {
72 bpo::store(bpo::command_line_parser(argc, argv).options(options_description).run(), args);
73 bpo::notify(args);
74
75 if (args.count("help") || !args.count("file")) {
76 display_help_message();
77 return EXIT_FAILURE;
78 }
79
80 daqconf::GraphBuilder graphbuilder(oksfilename, sessionname);
81 graphbuilder.construct_graph(object_uid);
82 graphbuilder.write_graph(outputfilename);
83
84 } catch (const bpo::error& e) {
85
86 display_help_message();
87
88 std::stringstream errmsgstr;
89 errmsgstr << "Incorrect command line argument: " << e.what();
90 ers::fatal(daqconf::GeneralGraphToolError(ERS_HERE, errmsgstr.str()));
91
92 } catch (const dunedaq::appmodel::BadConf& exc) {
93 std::stringstream errmsgstr;
94 errmsgstr << "Caught BadConf exception: " << exc;
95 ers::fatal(daqconf::GeneralGraphToolError(ERS_HERE, errmsgstr.str()));
96
97 } catch (const daqconf::GeneralGraphToolError& e) {
98
99 ers::fatal(e);
100 }
101
102 return 0;
103}
#define ERS_HERE
static volatile sig_atomic_t run
#define TLOG(...)
Definition macro.hpp:22
void fatal(const Issue &issue)
Definition ers.hpp:88