1 #include "otsdaq-core/ConfigurationInterface/ConfigurationManager.h"
2 #include "otsdaq-core/Macros/TablePluginMacros.h"
3 #include "otsdaq-core/TablePlugins/MessageFacilityTable.h"
11 std::string(__ENV__("USER_DATA")) + \
12 "/MessageFacilityConfigurations/MessageFacilityGen.fcl"
14 std::string(__ENV__("USER_DATA")) + \
15 "/MessageFacilityConfigurations/QTMessageViewerGen.fcl"
16 #define QUIET_CFG_FILE \
17 std::string(__ENV__("USER_DATA")) + \
18 "/MessageFacilityConfigurations/QuietForwarderGen.cfg"
19 #define USE_WEB_BOOL_FILE \
20 std::string(__ENV__("USER_DATA")) + \
21 "/MessageFacilityConfigurations/" \
23 #define USE_QT_BOOL_FILE \
24 std::string(__ENV__("USER_DATA")) + \
25 "/MessageFacilityConfigurations/" \
29 #define COL_NAME "UID"
30 #define COL_STATUS TableViewColumnInfo::COL_NAME_STATUS
31 #define COL_ENABLE_FWD "EnableUDPForwarding"
33 #define COL_USE_WEB "ForwardToWebConsoleGUI"
34 #define COL_WEB_IP "WebConsoleForwardingIPAddress"
35 #define COL_WEB_PORT0 "WebConsoleForwardingPort0"
36 #define COL_WEB_PORT1 "WebConsoleForwardingPort1"
38 #define COL_USE_QT "ForwardToQTViewerGUI"
39 #define COL_QT_IP "QTViewerForwardingIPAddress"
40 #define COL_QT_PORT "QTViewerForwardingPort"
42 MessageFacilityTable::MessageFacilityTable(
void) :
TableBase(
"MessageFacilityTable")
49 MessageFacilityTable::~MessageFacilityTable(
void) {}
55 bool isFirstAppInContext = configManager->isOwnerFirstAppInContext();
58 if(!isFirstAppInContext)
64 bool status, enableFwd, useWeb, useQT;
68 auto childrenMap = configManager->__SELF_NODE__.getChildren();
72 fs.open(MF_CFG_FILE, std::fstream::out | std::fstream::trunc);
75 __SS__ <<
"Failed to open Message Facility table file: " << MF_CFG_FILE
80 __COUT__ <<
"Opened.. " << MF_CFG_FILE << __E__;
84 for(
auto& child : childrenMap)
86 child.second.getNode(COL_STATUS).getValue(status);
91 child.second.getNode(COL_ENABLE_FWD).getValue(enableFwd);
93 child.second.getNode(COL_USE_WEB).getValue(useWeb);
94 child.second.getNode(COL_USE_QT).getValue(useQT);
99 __SS__ <<
"Illegal Message Facility table: "
100 <<
"Can only enable Web Console or QT Viewer, not both." << std::endl;
106 bfs.open(USE_WEB_BOOL_FILE, std::fstream::out | std::fstream::trunc);
110 __SS__ <<
"Failed to open boolean Use of Web Console table file: "
111 << USE_WEB_BOOL_FILE << std::endl;
114 bfs << (useWeb ? 1 : 0);
118 bfs.open(USE_QT_BOOL_FILE, std::fstream::out | std::fstream::trunc);
122 __SS__ <<
"Failed to open boolean Use of QT Viewer table file: "
123 << USE_QT_BOOL_FILE << std::endl;
126 bfs << (useQT ? 1 : 0);
134 __COUT__ <<
"Forwarding to Web GUI with UDP forward MesageFacility "
138 child.second.getNode(COL_WEB_PORT0).getValue(fwdPort);
139 child.second.getNode(COL_WEB_IP).getValue(fwdIP);
145 <<
"threshold: DEBUG\n";
147 <<
"port: " << fwdPort <<
"\n";
149 <<
"host: \"" << fwdIP <<
"\"\n";
154 qtfs.open(QUIET_CFG_FILE, std::fstream::out | std::fstream::trunc);
158 __SS__ <<
"Failed to open Web Console's 'Quiet Forwarder' "
160 << QUIET_CFG_FILE << std::endl;
163 qtfs <<
"RECEIVE_PORT \t " << fwdPort <<
"\n";
164 child.second.getNode(COL_WEB_PORT1).getValue(fwdPort);
165 qtfs <<
"DESTINATION_PORT \t " << fwdPort <<
"\n";
166 qtfs <<
"DESTINATION_IP \t " << fwdIP <<
"\n";
173 __COUT__ <<
"Forwarding to Web GUI with UDP forward MesageFacility "
177 child.second.getNode(COL_QT_PORT).getValue(fwdPort);
178 child.second.getNode(COL_QT_IP).getValue(fwdIP);
184 <<
"threshold: DEBUG\n";
186 <<
"port: " << fwdPort <<
"\n";
188 <<
"host: \"" << fwdIP <<
"\"\n";
193 qtfs.open(QT_CFG_FILE, std::fstream::out | std::fstream::trunc);
197 __SS__ <<
"Failed to open QT Message Viewer table file: "
198 << QT_CFG_FILE << std::endl;
201 qtfs <<
"receivers: \n{\n";
209 <<
"port: " << fwdPort <<
"\n";
213 qtfs <<
"threshold: "
221 __COUT__ <<
"Using cout-only MesageFacility table." << std::endl;
222 fs <<
"console: {\n";
224 <<
"type: \"cout\"\n";
226 <<
"threshold: \"DEBUG\"\n";
228 <<
"noTimeStamps: true\n";
230 <<
"noLineBreaks: true\n";