1 #include "otsdaq-core/ConfigurationPluginDataFormats/MessageFacilityConfiguration.h"
2 #include "otsdaq-core/Macros/ConfigurationPluginMacros.h"
3 #include "otsdaq-core/ConfigurationInterface/ConfigurationManager.h"
10 #define MF_CFG_FILE std::string(getenv("USER_DATA")) + "/MessageFacilityConfigurations/MessageFacilityGen.fcl"
11 #define QT_CFG_FILE std::string(getenv("USER_DATA")) + "/MessageFacilityConfigurations/QTMessageViewerGen.fcl"
12 #define QUIET_CFG_FILE std::string(getenv("USER_DATA")) + "/MessageFacilityConfigurations/QuietForwarderGen.cfg"
13 #define USE_WEB_BOOL_FILE std::string(getenv("USER_DATA")) + "/MessageFacilityConfigurations/UseWebConsole.bool"
14 #define USE_QT_BOOL_FILE std::string(getenv("USER_DATA")) + "/MessageFacilityConfigurations/UseQTViewer.bool"
17 #define COL_NAME "UID"
18 #define COL_STATUS "Status"
19 #define COL_ENABLE_FWD "EnableUDPForwarding"
21 #define COL_USE_WEB "ForwardToWebConsoleGUI"
22 #define COL_WEB_IP "WebConsoleForwardingIPAddress"
23 #define COL_WEB_PORT0 "WebConsoleForwardingPort0"
24 #define COL_WEB_PORT1 "WebConsoleForwardingPort1"
26 #define COL_USE_QT "ForwardToQTViewerGUI"
27 #define COL_QT_IP "QTViewerForwardingIPAddress"
28 #define COL_QT_PORT "QTViewerForwardingPort"
32 MessageFacilityConfiguration::MessageFacilityConfiguration(
void) :
64 MessageFacilityConfiguration::~MessageFacilityConfiguration(
void)
69 __MOUT__ <<
"*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*" << std::endl;
71 __MOUT__ << configManager->__SELF_NODE__ << std::endl;
74 bool status,enableFwd,useWeb,useQT;
78 auto childrenMap = configManager->__SELF_NODE__.getChildren();
83 fs.open(MF_CFG_FILE, std::fstream::out | std::fstream::trunc);
86 __SS__ <<
"Failed to open Message Facility configuration file: " << MF_CFG_FILE << std::endl;
87 throw std::runtime_error(ss.str());
92 for(
auto &child:childrenMap)
94 child.second.getNode(COL_STATUS ).getValue(status);
98 child.second.getNode(COL_ENABLE_FWD ).getValue(enableFwd);
100 child.second.getNode(COL_USE_WEB ).getValue(useWeb);
101 child.second.getNode(COL_USE_QT ).getValue(useQT);
106 __SS__ <<
"Illegal Message Facility configuration: " <<
107 "Can only enable Web Console or QT Viewer, not both." << std::endl;
108 throw std::runtime_error(ss.str());
113 bfs.open(USE_WEB_BOOL_FILE, std::fstream::out | std::fstream::trunc);
117 __SS__ <<
"Failed to open boolean Use of Web Console configuration file: " <<
118 USE_WEB_BOOL_FILE << std::endl;
119 throw std::runtime_error(ss.str());
125 bfs.open(USE_QT_BOOL_FILE, std::fstream::out | std::fstream::trunc);
129 __SS__ <<
"Failed to open boolean Use of QT Viewer configuration file: " <<
130 USE_QT_BOOL_FILE << std::endl;
131 throw std::runtime_error(ss.str());
142 __MOUT__ <<
"Forwarding to Web GUI with UDP forward MesageFacility configuration." << std::endl;
144 child.second.getNode(COL_WEB_PORT0 ).getValue(fwdPort);
145 child.second.getNode(COL_WEB_IP ).getValue(fwdIP);
148 fs <<
"\t" <<
"type: UDP\n";
149 fs <<
"\t" <<
"threshold: DEBUG\n";
150 fs <<
"\t" <<
"port: " << fwdPort <<
"\n";
151 fs <<
"\t" <<
"host: \"" << fwdIP <<
"\"\n";
156 qtfs.open(QUIET_CFG_FILE, std::fstream::out | std::fstream::trunc);
160 __SS__ <<
"Failed to open Web Console's 'Quiet Forwarder' configuration file: " <<
161 QUIET_CFG_FILE << std::endl;
162 throw std::runtime_error(ss.str());
164 qtfs <<
"RECEIVE_PORT \t " << fwdPort <<
"\n";
165 child.second.getNode(COL_WEB_PORT1 ).getValue(fwdPort);
166 qtfs <<
"DESTINATION_PORT \t " << fwdPort <<
"\n";
173 __MOUT__ <<
"Forwarding to Web GUI with UDP forward MesageFacility configuration." << std::endl;
175 child.second.getNode(COL_QT_PORT ).getValue(fwdPort);
176 child.second.getNode(COL_QT_IP ).getValue(fwdIP);
179 fs <<
"\t" <<
"type: UDP\n";
180 fs <<
"\t" <<
"threshold: DEBUG\n";
181 fs <<
"\t" <<
"port: " << fwdPort <<
"\n";
182 fs <<
"\t" <<
"host: \"" << fwdIP <<
"\"\n";
187 qtfs.open(QT_CFG_FILE, std::fstream::out | std::fstream::trunc);
191 __SS__ <<
"Failed to open QT Message Viewer configuration file: " <<
192 QT_CFG_FILE << std::endl;
193 throw std::runtime_error(ss.str());
195 qtfs <<
"receivers: \n{\n";
196 qtfs <<
"\t" <<
"syslog: \n{\n";
197 qtfs <<
"\t\t" <<
"receiverType: " <<
"\"UDP\"" <<
"\n";
198 qtfs <<
"\t\t" <<
"port: " << fwdPort <<
"\n";
202 qtfs <<
"threshold: " <<
"DEBUG" <<
"\n";
208 __MOUT__ <<
"Using cout-only MesageFacility configuration." << std::endl;
209 fs <<
"console: {\n";
210 fs <<
"\t" <<
"type: \"cout\"\n";
211 fs <<
"\t" <<
"threshold: \"DEBUG\"\n";
212 fs <<
"\t" <<
"noTimeStamps: true\n";
213 fs <<
"\t" <<
"noLineBreaks: true\n";