otsdaq  v2_04_02
ARTDAQDispatcherTable_table.cc
1 #include "otsdaq/ConfigurationInterface/ConfigurationManager.h"
2 #include "otsdaq/Macros/TablePluginMacros.h"
3 #include "otsdaq/TablePlugins/ARTDAQDispatcherTable.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 "dispatcher"
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 ARTDAQDispatcherTable::ARTDAQDispatcherTable(void)
25  : ARTDAQTableBase("ARTDAQDispatcherTable")
26 {
28  // WARNING: the names used in C++ MUST match the Table INFO //
30 }
31 
32 //========================================================================================================================
33 ARTDAQDispatcherTable::~ARTDAQDispatcherTable(void) {}
34 
35 //========================================================================================================================
36 void ARTDAQDispatcherTable::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*> dispContexts =
55  // contextConfig->getDispatcherContexts();
56  //
57  // // for each dispatcher context
58  // // output associated fcl config file
59  // for(auto& dispContext : dispContexts)
60  // {
61  // ConfigurationTree dispConfigNode = contextConfig->getSupervisorConfigNode(
62  // configManager,
63  // dispContext->contextUID_,
64  // dispContext->applications_[0].applicationUID_);
65  //
66  // __COUT__ << "Path for this dispatcher config is " << dispContext->contextUID_
67  // << "/" << dispContext->applications_[0].applicationUID_ << "/"
68  // << dispConfigNode.getValueAsString() << std::endl;
69  //
70  // outputFHICL(
71  // configManager,
72  // dispConfigNode,
73  // contextConfig->getARTDAQAppRank(dispContext->contextUID_),
74  // contextConfig->getContextAddress(dispContext->contextUID_),
75  // contextConfig->getARTDAQDataPort(configManager, dispContext->contextUID_),
76  // contextConfig, 0);
77  // }
78 } // end init()
79 
81 // void ARTDAQDispatcherTable::outputFHICL(ConfigurationManager* configManager,
82 // const ConfigurationTree& dispatcherNode,
83 // unsigned int selfRank,
84 // const std::string& selfHost,
85 // unsigned int selfPort,
86 // const XDAQContextTable* contextConfig,
87 // size_t maxFragmentSizeBytes)
88 //{
89 // ARTDAQTableBase::outputDataReceiverFHICL(configManager,
90 // dispatcherNode,
91 // selfRank,
92 // selfHost,
93 // selfPort,
94 // DataReceiverAppType::Dispatcher,
95 // maxFragmentSizeBytes);
96 //} //end outputFHICL()
97 
98 DEFINE_OTS_TABLE(ARTDAQDispatcherTable)