1 #include "otsdaq/ConfigurationInterface/ConfigurationManager.h"
2 #include "otsdaq/Macros/TablePluginMacros.h"
3 #include "otsdaq/TablePlugins/MessageFacilityTable.h"
11 #define MF_CFG_FILE std::string(__ENV__("USER_DATA")) + "/MessageFacilityConfigurations/MessageFacilityGen.fcl"
12 #define MF_ARTDAQ_INTERFACE_CFG_FILE std::string(__ENV__("USER_DATA")) + "/MessageFacilityConfigurations/ARTDAQInterfaceMessageFacilityGen.fcl"
13 #define QT_CFG_FILE std::string(__ENV__("USER_DATA")) + "/MessageFacilityConfigurations/QTMessageViewerGen.fcl"
14 #define QUIET_CFG_FILE std::string(__ENV__("USER_DATA")) + "/MessageFacilityConfigurations/QuietForwarderGen.cfg"
15 #define USE_WEB_BOOL_FILE std::string(__ENV__("USER_DATA")) + "/MessageFacilityConfigurations/UseWebConsole.bool"
16 #define USE_QT_BOOL_FILE std::string(__ENV__("USER_DATA")) + "/MessageFacilityConfigurations/UseQTViewer.bool"
19 #define COL_NAME "UID"
20 #define COL_STATUS TableViewColumnInfo::COL_NAME_STATUS
21 #define COL_ENABLE_FWD "EnableUDPForwarding"
23 #define COL_USE_WEB "ForwardToWebConsoleGUI"
24 #define COL_WEB_IP "WebConsoleForwardingIPAddress"
25 #define COL_WEB_PORT0 "WebConsoleForwardingPort0"
26 #define COL_WEB_PORT1 "WebConsoleForwardingPort1"
28 #define COL_USE_QT "ForwardToQTViewerGUI"
29 #define COL_QT_IP "QTViewerForwardingIPAddress"
30 #define COL_QT_PORT "QTViewerForwardingPort"
34 MessageFacilityTable::MessageFacilityTable(
void) :
TableBase(
"MessageFacilityTable")
41 MessageFacilityTable::~MessageFacilityTable(
void) {}
47 bool isFirstAppInContext = configManager->isOwnerFirstAppInContext();
50 if(!isFirstAppInContext)
56 bool status, enableFwd, useWeb, useQT;
60 auto childrenMap = configManager->__SELF_NODE__.getChildren();
62 std::stringstream fclSs;
66 for(
auto& child : childrenMap)
68 child.second.getNode(COL_STATUS).getValue(status);
73 child.second.getNode(COL_ENABLE_FWD).getValue(enableFwd);
75 child.second.getNode(COL_USE_WEB).getValue(useWeb);
76 child.second.getNode(COL_USE_QT).getValue(useQT);
80 __SS__ <<
"Illegal Message Facility table: "
81 <<
"Can only enable Web Console or QT Viewer, not both." << std::endl;
87 bfs.open(USE_WEB_BOOL_FILE, std::fstream::out | std::fstream::trunc);
90 __SS__ <<
"Failed to open boolean Use of Web Console table file: " << USE_WEB_BOOL_FILE << std::endl;
93 bfs << (useWeb ? 1 : 0);
97 bfs.open(USE_QT_BOOL_FILE, std::fstream::out | std::fstream::trunc);
100 __SS__ <<
"Failed to open boolean Use of QT Viewer table file: " << USE_QT_BOOL_FILE << std::endl;
103 bfs << (useQT ? 1 : 0);
111 __COUT__ <<
"Forwarding to Web GUI with UDP forward MesageFacility "
115 child.second.getNode(COL_WEB_PORT0).getValue(fwdPort);
116 child.second.getNode(COL_WEB_IP).getValue(fwdIP);
122 <<
"threshold: DEBUG\n";
124 <<
"port: " << fwdPort <<
"\n";
126 <<
"host: \"" << fwdIP <<
"\"\n";
129 fclSs <<
"console: {\n";
131 <<
"type: \"OTS\"\n";
133 <<
"threshold: \"DEBUG\"\n";
135 <<
"filename_delimit: \"/srcs/\"\n";
137 <<
"format_string: \"|%L:%N:%f [%u]\t%m\"\n";
143 qtfs.open(QUIET_CFG_FILE, std::fstream::out | std::fstream::trunc);
146 __SS__ <<
"Failed to open Web Console's 'Quiet Forwarder' "
148 << QUIET_CFG_FILE << std::endl;
151 qtfs <<
"RECEIVE_PORT \t " << fwdPort <<
"\n";
152 child.second.getNode(COL_WEB_PORT1).getValue(fwdPort);
153 qtfs <<
"DESTINATION_PORT \t " << fwdPort <<
"\n";
154 qtfs <<
"DESTINATION_IP \t " << fwdIP <<
"\n";
161 __COUT__ <<
"Forwarding to Web GUI with UDP forward MesageFacility "
165 child.second.getNode(COL_QT_PORT).getValue(fwdPort);
166 child.second.getNode(COL_QT_IP).getValue(fwdIP);
172 <<
"threshold: DEBUG\n";
174 <<
"port: " << fwdPort <<
"\n";
176 <<
"host: \"" << fwdIP <<
"\"\n";
181 qtfs.open(QT_CFG_FILE, std::fstream::out | std::fstream::trunc);
184 __SS__ <<
"Failed to open QT Message Viewer table file: " << QT_CFG_FILE << std::endl;
187 qtfs <<
"receivers: \n{\n";
195 <<
"port: " << fwdPort <<
"\n";
199 qtfs <<
"threshold: "
207 __COUT__ <<
"Using cout-only MesageFacility table." << std::endl;
208 fclSs <<
"console: {\n";
210 <<
"type: \"OTS\"\n";
212 <<
"threshold: \"DEBUG\"\n";
214 <<
"filename_delimit: \"/srcs/\"\n";
216 <<
"format_string: \"|%L:%N:%f [%u]\t%m\"\n";
226 fs.open(MF_CFG_FILE, std::fstream::out | std::fstream::trunc);
229 __SS__ <<
"Failed to open Message Facility table file: " << MF_CFG_FILE << __E__;
233 __COUT__ <<
"Opened.. " << MF_CFG_FILE << __E__;
236 std::fstream artdaqfs;
237 artdaqfs.open(MF_ARTDAQ_INTERFACE_CFG_FILE, std::fstream::out | std::fstream::trunc);
240 __SS__ <<
"Failed to open artdaq interface Message Facility table file: " << MF_ARTDAQ_INTERFACE_CFG_FILE << __E__;
244 __COUT__ <<
"Opened for artdaq.. " << MF_ARTDAQ_INTERFACE_CFG_FILE << __E__;
247 artdaqfs << fclSs.str();
249 fs << fclSs.str() <<
"\nfile: \"\"\n";