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 enableFwd = 
true, useWeb = 
true,
 
   58     int         fwdPort, destFwdPort;
 
   60     std::string parseFilename = 
"/src";
 
   65         fwdPort = atoi(__ENV__(
"OTS_MAIN_PORT")) + 30000;
 
   72         destFwdPort = atoi(__ENV__(
"OTS_MAIN_PORT")) + 30001;
 
   79         fwdIP = __ENV__(
"HOSTNAME");
 
   87             std::string(
"/") + __ENV__(
"OTS_ENV") + 
"/";  
 
   89         parseFilename = __ENV__(
"OTS_FILE_PARSE_PATTERN");  
 
   95     __COUTTV__(parseFilename);
 
   98         __COUTTV__(__ENV__(
"TRACE_TIME_FMT"));
 
  104     auto childrenMap = configManager->__SELF_NODE__.
getChildren();
 
  106     std::stringstream fclSs;
 
  110     for(
auto& child : childrenMap)
 
  113         child.second.getNode(COL_STATUS).getValue(status);
 
  118         child.second.getNode(COL_ENABLE_FWD).getValue(enableFwd);
 
  120         child.second.getNode(COL_USE_WEB).getValue(useWeb);
 
  121         child.second.getNode(COL_USE_QT).getValue(useQT);
 
  123         if(!child.second.getNode(COL_WEB_PORT0).isDefaultValue())
 
  124             child.second.getNode(COL_WEB_PORT0).getValue(fwdPort);
 
  126         if(!child.second.getNode(COL_WEB_IP).isDefaultValue())
 
  127             child.second.getNode(COL_WEB_IP).getValue(fwdIP);
 
  129         if(!child.second.getNode(COL_WEB_PORT1).isDefaultValue())
 
  130             child.second.getNode(COL_WEB_PORT1).getValue(destFwdPort);
 
  134             if(!child.second.getNode(COL_QT_IP).isDefaultValue())
 
  135                 child.second.getNode(COL_QT_IP).getValue(fwdIP);
 
  137             if(!child.second.getNode(COL_QT_PORT).isDefaultValue())
 
  138                 child.second.getNode(COL_QT_PORT).getValue(fwdPort);
 
  141         __COUTT__ << 
"Found FWD/WEB/QT " << (COL_ENABLE_FWD ? 
"true" : 
"false") << 
"/" 
  142                   << (COL_USE_WEB ? 
"true" : 
"false") << 
"/" 
  143                   << (COL_USE_QT ? 
"true" : 
"false") << 
" and IP:Port:FwdPort " << fwdIP
 
  144                   << 
":" << fwdPort << 
":" << destFwdPort << 
" in MesageFacility table." 
  151         __SS__ << 
"Illegal Message Facility table: " 
  152                << 
"Can only enable Web Console or QT Viewer, not both." << std::endl;
 
  158     bfs.open(USE_WEB_BOOL_FILE, std::fstream::out | std::fstream::trunc);
 
  161         __SS__ << 
"Failed to open boolean Use of Web Console table file: " 
  162                << USE_WEB_BOOL_FILE << std::endl;
 
  165     bfs << (useWeb ? 1 : 0);
 
  169     bfs.open(USE_QT_BOOL_FILE, std::fstream::out | std::fstream::trunc);
 
  172         __SS__ << 
"Failed to open boolean Use of QT Viewer table file: " 
  173                << USE_QT_BOOL_FILE << std::endl;
 
  176     bfs << (useQT ? 1 : 0);
 
  184             __COUTT__ << 
"Forwarding to Web GUI at IP:Port:FwdPort " << fwdIP << 
":" 
  185                       << fwdPort << 
":" << destFwdPort
 
  186                       << 
" with UDP forward MesageFacility." << __E__;
 
  188             fclSs << 
"otsConsole: {\n";
 
  192                   << 
"threshold: DEBUG\n";
 
  194                   << 
"filename_delimit: \"" << parseFilename << 
"\"\n";
 
  196                   << 
"port: " << fwdPort << 
"\n";
 
  198                   << 
"host: \"" << fwdIP << 
"\"\n";
 
  201             fclSs << 
"console: {\n";
 
  203                   << 
"type: \"OTS\"\n";
 
  205                   << 
"threshold: \"DEBUG\"\n";
 
  207                   << 
"filename_delimit: \"" << parseFilename << 
"\"\n";
 
  209                   << 
"format_string: \"|%T:%L:%N: %f:%u |\t%m\"\n";
 
  214             std::stringstream qtSs;
 
  215             qtSs << 
"RECEIVE_PORT \t " << fwdPort << 
"\n";
 
  216             qtSs << 
"DESTINATION_PORT \t " << destFwdPort << 
"\n";
 
  217             qtSs << 
"DESTINATION_IP \t " << fwdIP << 
"\n";
 
  220             qtfs.open(QUIET_CFG_FILE, std::fstream::out | std::fstream::trunc);
 
  223                 __SS__ << 
"Failed to open Web Console's 'Quiet Forwarder' " 
  225                        << QUIET_CFG_FILE << std::endl;
 
  230             __COUTT__ << 
"Wrote " << QUIET_CFG_FILE << 
":" << __E__ << qtSs.str()
 
  237             __COUTT__ << 
"Forwarding to QT GUI  at IP:Port " << fwdIP << 
":" << fwdPort
 
  238                       << 
" with UDP forward MesageFacility." << __E__;
 
  240             fclSs << 
"otsViewer: {\n";
 
  244                   << 
"threshold: DEBUG\n";
 
  246                   << 
"filename_delimit: \"" << parseFilename << 
"\"\n";
 
  248                   << 
"port: " << fwdPort << 
"\n";
 
  250                   << 
"host: \"" << fwdIP << 
"\"\n";
 
  255             qtfs.open(QT_CFG_FILE, std::fstream::out | std::fstream::trunc);
 
  258                 __SS__ << 
"Failed to open QT Message Viewer table file: " << QT_CFG_FILE
 
  262             qtfs << 
"receivers: \n{\n";
 
  270                  << 
"port: " << fwdPort << 
"\n";
 
  274             qtfs << 
"threshold: " 
  282         __COUTT__ << 
"Using cout-only MesageFacility table." << std::endl;
 
  283         fclSs << 
"console: {\n";
 
  285               << 
"type: \"OTS\"\n";
 
  287               << 
"threshold: \"DEBUG\"\n";
 
  289               << 
"filename_delimit: \"" << parseFilename << 
"\"\n";
 
  291               << 
"format_string: \"|%T:%L:%N: %f:%u |\t%m\"\n";
 
  298     fs.open(MF_CFG_FILE, std::fstream::out | std::fstream::trunc);
 
  301         __SS__ << 
"Failed to open Message Facility table file: " << MF_CFG_FILE << __E__;
 
  305         __COUTT__ << 
"Opened.. " << MF_CFG_FILE << __E__;
 
  308     std::fstream artdaqfs;
 
  309     artdaqfs.open(MF_ARTDAQ_INTERFACE_CFG_FILE, std::fstream::out | std::fstream::trunc);
 
  312         __SS__ << 
"Failed to open artdaq interface Message Facility table file: " 
  313                << MF_ARTDAQ_INTERFACE_CFG_FILE << __E__;
 
  317         __COUTT__ << 
"Opened for artdaq.. " << MF_ARTDAQ_INTERFACE_CFG_FILE << __E__;
 
  320     artdaqfs << fclSs.str();
 
  322     fs << fclSs.str() << 
"\nfile: \"\"\n";
 
  326     __COUTT__ << 
"Wrote " << __E__ << fclSs.str() << __E__;
 
std::vector< std::pair< std::string, ConfigurationTree > > getChildren(std::map< std::string, TableVersion > *memberMap=0, std::string *accumulatedTreeErrors=0) const
void init(ConfigurationManager *configManager)
Methods.