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 ViewColumnInfo::COL_NAME_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)
73 bool status,enableFwd,useWeb,useQT;
77 auto childrenMap = configManager->__SELF_NODE__.getChildren();
82 fs.open(MF_CFG_FILE, std::fstream::out | std::fstream::trunc);
85 __SS__ <<
"Failed to open Message Facility configuration file: " << MF_CFG_FILE << std::endl;
86 throw std::runtime_error(ss.str());
91 for(
auto &child:childrenMap)
93 child.second.getNode(COL_STATUS ).getValue(status);
97 child.second.getNode(COL_ENABLE_FWD ).getValue(enableFwd);
99 child.second.getNode(COL_USE_WEB ).getValue(useWeb);
100 child.second.getNode(COL_USE_QT ).getValue(useQT);
105 __SS__ <<
"Illegal Message Facility configuration: " <<
106 "Can only enable Web Console or QT Viewer, not both." << std::endl;
107 throw std::runtime_error(ss.str());
112 bfs.open(USE_WEB_BOOL_FILE, std::fstream::out | std::fstream::trunc);
116 __SS__ <<
"Failed to open boolean Use of Web Console configuration file: " <<
117 USE_WEB_BOOL_FILE << std::endl;
118 throw std::runtime_error(ss.str());
124 bfs.open(USE_QT_BOOL_FILE, std::fstream::out | std::fstream::trunc);
128 __SS__ <<
"Failed to open boolean Use of QT Viewer configuration file: " <<
129 USE_QT_BOOL_FILE << std::endl;
130 throw std::runtime_error(ss.str());
143 child.second.getNode(COL_WEB_PORT0 ).getValue(fwdPort);
144 child.second.getNode(COL_WEB_IP ).getValue(fwdIP);
147 fs <<
"\t" <<
"type: UDP\n";
148 fs <<
"\t" <<
"threshold: DEBUG\n";
149 fs <<
"\t" <<
"port: " << fwdPort <<
"\n";
150 fs <<
"\t" <<
"host: \"" << fwdIP <<
"\"\n";
155 qtfs.open(QUIET_CFG_FILE, std::fstream::out | std::fstream::trunc);
159 __SS__ <<
"Failed to open Web Console's 'Quiet Forwarder' configuration file: " <<
160 QUIET_CFG_FILE << std::endl;
161 throw std::runtime_error(ss.str());
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";
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 __COUT__ <<
"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";