Line data Source code
1 : #include <QtCore/QSettings>
2 : #include <QtWidgets/QApplication>
3 :
4 : #include "ErrorHandler/MsgAnalyzerDlg.h"
5 :
6 : #include <messagefacility/MessageLogger/MessageLogger.h>
7 : #include <iostream>
8 :
9 : using namespace novadaq::errorhandler;
10 : using namespace std;
11 :
12 0 : void printUsage()
13 : {
14 : std::cout << "MsgAnalyzer usage:\n"
15 : << " -h, --help \tdisplay help message\n"
16 : << " -c, --configuration [file]\tspecify the path and filename to the message analyzer conf file\n"
17 0 : << " -l, --log [file] \tspecify the path and filename to the log (messagefacility) conf file\n";
18 0 : }
19 :
20 0 : int main(int argc, char* argv[])
21 : {
22 0 : QApplication app(argc, argv);
23 :
24 0 : std::string cfg("msganalyzer.fcl");
25 0 : std::string mf_cfg("msganalyzer_mf.fcl");
26 :
27 0 : int partition = 0;
28 : // The following lines will cause the application not working properly.
29 : // There is a hidden error involving pointers in QT in this code.
30 0 : auto partenv = getenv("ARTDAQ_PARTITION_NUMBER");
31 0 : if (partenv != nullptr)
32 : {
33 0 : partition = atoi(partenv);
34 : }
35 :
36 0 : if (argc > 1)
37 : {
38 0 : for (int i = 0; i < argc; ++i)
39 : {
40 0 : if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help"))
41 : {
42 0 : printUsage();
43 0 : return 0;
44 : }
45 :
46 0 : if ((!strcmp(argv[i], "-c") || !strcmp(argv[i], "--configuration")) && i < argc - 1)
47 : {
48 0 : cfg = std::string(argv[i + 1]);
49 0 : ++i;
50 0 : continue;
51 : }
52 :
53 0 : if ((!strcmp(argv[i], "-l") || !strcmp(argv[i], "--log")) && i < argc - 1)
54 : {
55 0 : mf_cfg = std::string(argv[i + 1]);
56 0 : ++i;
57 0 : continue;
58 : }
59 : }
60 : }
61 :
62 : // message facility
63 : // putenv((char*)"FHICL_FILE_PATH=.");
64 0 : fhicl::ParameterSet pset;
65 : try
66 : {
67 0 : cet::filepath_lookup_after1 lookup_policy("FHICL_FILE_PATH");
68 0 : pset = fhicl::ParameterSet::make(mf_cfg, lookup_policy);
69 0 : }
70 0 : catch (cet::exception const& ex)
71 : {
72 0 : TLOG(TLVL_ERROR) << "Unable to load configuration file " << mf_cfg << ": " << ex.explain_self();
73 0 : }
74 :
75 0 : mf::StartMessageFacility(pset, "MsgAnalyzer");
76 :
77 0 : mf::SetIteration("context");
78 0 : mf::SetModuleName("module");
79 :
80 : // first log
81 0 : TLOG_DEBUG("category") << "DEBUG: MessageFacility service started";
82 0 : TLOG_INFO("category") << "INFO: MessageFacility service started";
83 :
84 : // start MA dialog
85 0 : MsgAnalyzerDlg dialog(cfg, partition);
86 :
87 0 : QSettings settings("artdaq", "MsgAnalyzer");
88 0 : dialog.restoreGeometry(settings.value("geometry").toByteArray());
89 0 : dialog.show();
90 :
91 0 : return app.exec();
92 0 : }
|