otsdaq  v2_04_02
ARTDAQDataLoggerTable_table.cc
1 #include "otsdaq/ConfigurationInterface/ConfigurationManager.h"
2 #include "otsdaq/Macros/TablePluginMacros.h"
3 #include "otsdaq/TablePlugins/ARTDAQDataLoggerTable.h"
4 #include "otsdaq/TablePlugins/XDAQContextTable.h"
5 
6 #include <stdio.h>
7 #include <sys/stat.h> //for mkdir
8 #include <fstream> // std::fstream
9 #include <iostream>
10 
11 using namespace ots;
12 
13 #define ARTDAQ_FCL_PATH std::string(__ENV__("USER_DATA")) + "/" + "ARTDAQConfigurations/"
14 #define ARTDAQ_FILE_PREAMBLE "datalogger"
15 
16 // helpers
17 #define OUT out << tabStr << commentStr
18 #define PUSHTAB tabStr += "\t"
19 #define POPTAB tabStr.resize(tabStr.size() - 1)
20 #define PUSHCOMMENT commentStr += "# "
21 #define POPCOMMENT commentStr.resize(commentStr.size() - 2)
22 
23 //========================================================================================================================
24 ARTDAQDataLoggerTable::ARTDAQDataLoggerTable(void)
25  : ARTDAQTableBase("ARTDAQDataLoggerTable")
26 {
28  // WARNING: the names used in C++ MUST match the Table INFO //
30 }
31 
32 //========================================================================================================================
33 ARTDAQDataLoggerTable::~ARTDAQDataLoggerTable(void) {}
34 
35 //========================================================================================================================
36 void ARTDAQDataLoggerTable::init(ConfigurationManager* configManager)
37 {
38  // // use isFirstAppInContext to only run once per context, for example to avoid
39  // // generating files on local disk multiple times.
40  // bool isFirstAppInContext = configManager->isOwnerFirstAppInContext();
41  //
42  // //__COUTV__(isFirstAppInContext);
43  // if(!isFirstAppInContext)
44  // return;
45  //
46  // // make directory just in case
47  // mkdir((ARTDAQ_FCL_PATH).c_str(), 0755);
48  //
49  // __COUT__ << "*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*" << std::endl;
50  // __COUT__ << configManager->__SELF_NODE__ << std::endl;
51  //
52  // const XDAQContextTable* contextConfig =
53  // configManager->__GET_CONFIG__(XDAQContextTable);
54  // std::vector<const XDAQContextTable::XDAQContext*> loggerContexts =
55  // contextConfig->getDataLoggerContexts();
56  //
57  // // for each datalogger context
58  // // output associated fcl config file
59  // for(auto& loggerContext : loggerContexts)
60  // {
61  // ConfigurationTree aggConfigNode = contextConfig->getSupervisorConfigNode(
62  // configManager,
63  // loggerContext->contextUID_,
64  // loggerContext->applications_[0].applicationUID_);
65  //
66  // __COUT__ << "Path for this DataLogger config is " <<
67  //loggerContext->contextUID_
68  // << "/" << loggerContext->applications_[0].applicationUID_ << "/"
69  // << aggConfigNode.getValueAsString() << std::endl;
70  //
71  // outputFHICL(
72  // configManager,
73  // aggConfigNode,
74  // contextConfig->getARTDAQAppRank(loggerContext->contextUID_),
75  // contextConfig->getContextAddress(loggerContext->contextUID_),
76  // contextConfig->getARTDAQDataPort(configManager,
77  //loggerContext->contextUID_), contextConfig, 0);
78  // }
79 }
80 
82 // void ARTDAQDataLoggerTable::outputFHICL(ConfigurationManager* configManager,
83 // const ConfigurationTree& dataLoggerNode,
84 // unsigned int selfRank,
85 // std::string selfHost,
86 // unsigned int selfPort,
87 // const XDAQContextTable* contextConfig,
88 // size_t maxFragmentSizeBytes)
89 //{
90 // outputDataReceiverFHICL(configManager,
91 // dataLoggerNode,
92 // selfRank,
93 // selfHost,
94 // selfPort,
95 // DataReceiverAppType::DataLogger,
96 // maxFragmentSizeBytes);
97 //}
98 
99 DEFINE_OTS_TABLE(ARTDAQDataLoggerTable)