DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
create_config_plot.cxx
Go to the documentation of this file.
1/************************************************************
2 * create_config_plot.cpp
3 *
4 * JCF, May-7-2024
5 *
6 * Main file of create_config_plot used to generate GraphViz dot
7 * files of DUNE DAQ configurations. The latter can
8 * be used to generate graphs that visualize the database
9 * patterns
10 *
11 * This is part of the DUNE DAQ Application Framework, copyright 2020.
12 * Licensing/copyright details are in the COPYING file that you should have
13 * received with this code.
14 *
15 *************************************************************/
16#include "GraphBuilder.hpp"
17
19#include "logging/Logging.hpp"
20
21#include <boost/program_options.hpp>
22
23#include <map>
24#include <numeric>
25#include <sstream>
26#include <stdexcept>
27#include <string>
28
29namespace bpo = boost::program_options;
30
31int
32main(int argc, char* argv[])
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
void construct_graph(std::string root_obj_uid)
void write_graph(const std::string &outputfilename) const
int main(int argc, char *argv[])
static volatile sig_atomic_t run
#define TLOG(...)
Definition macro.hpp:22
void fatal(const Issue &issue)
Definition ers.hpp:88