1 #include "otsdaq-core/ConfigurationPluginDataFormats/ARTDAQBoardReaderConfiguration.h"
2 #include "otsdaq-core/Macros/ConfigurationPluginMacros.h"
3 #include "otsdaq-core/ConfigurationInterface/ConfigurationManager.h"
4 #include "otsdaq-core/ConfigurationPluginDataFormats/XDAQContextConfiguration.h"
14 #define ARTDAQ_FCL_PATH std::string(getenv("USER_DATA")) + "/"+ "ARTDAQConfigurations/"
15 #define ARTDAQ_FILE_PREAMBLE "boardReader"
18 #define OUT out << tabStr << commentStr
19 #define PUSHTAB tabStr += "\t"
20 #define POPTAB tabStr.resize(tabStr.size()-1)
21 #define PUSHCOMMENT commentStr += "# "
22 #define POPCOMMENT commentStr.resize(commentStr.size()-2)
26 ARTDAQBoardReaderConfiguration::ARTDAQBoardReaderConfiguration(
void)
36 ARTDAQBoardReaderConfiguration::~ARTDAQBoardReaderConfiguration(
void)
43 mkdir((ARTDAQ_FCL_PATH).c_str(), 0755);
45 __MOUT__ <<
"*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*" << std::endl;
46 __MOUT__ << configManager->__SELF_NODE__ << std::endl;
52 auto childrenMap = configManager->__SELF_NODE__.getChildren();
54 std::string appUID, buffUID, consumerUID;
55 for(
auto &child:childrenMap)
56 if(child.second.getNode(
"Status").getValue<
bool>())
60 outputFHICL(child.second, contextConfig);
74 std::string ARTDAQBoardReaderConfiguration::getFHICLFilename(
const ConfigurationTree &boardReaderNode)
76 __MOUT__ <<
"ARTDAQ BoardReader UID: " << boardReaderNode.getValue() << std::endl;
77 std::string filename = ARTDAQ_FCL_PATH + ARTDAQ_FILE_PREAMBLE +
"-";
78 std::string uid = boardReaderNode.getValue();
79 for(
unsigned int i=0;i<uid.size();++i)
80 if((uid[i] >=
'a' && uid[i] <=
'z') ||
81 (uid[i] >=
'A' && uid[i] <=
'Z') ||
82 (uid[i] >=
'0' && uid[i] <=
'9'))
87 __MOUT__ <<
"fcl: " << filename << std::endl;
93 void ARTDAQBoardReaderConfiguration::outputFHICL(
const ConfigurationTree &boardReaderNode,
189 std::string filename = getFHICLFilename(boardReaderNode);
195 std::string tabStr =
"";
196 std::string commentStr =
"";
198 out.open(filename, std::fstream::out | std::fstream::trunc);
201 __SS__ <<
"Failed to open ARTDAQ Builder fcl file: " << filename << std::endl;
202 throw std::runtime_error(ss.str());
212 OUT <<
"fragment_receiver: {\n";
216 auto parametersLink = boardReaderNode.getNode(
"daqSharedParametersLink");
217 if(!parametersLink.isDisconnected())
220 auto parameters = parametersLink.getChildren();
221 for(
auto ¶meter:parameters)
223 if(!parameter.second.getNode(
"Enabled").getValue<
bool>())
226 auto comment = parameter.second.getNode(
"CommentDescription");
227 OUT << parameter.second.getNode(
"daqParameterKey").getValue() <<
229 parameter.second.getNode(
"daqParameterValue").getValue()
231 (comment.isDefaultValue()?
"":(
"\t # " + comment.getValue())) <<
234 if(!parameter.second.getNode(
"Enabled").getValue<
bool>())
241 auto parametersLink = boardReaderNode.getNode(
"daqUniqueParametersLink");
242 if(!parametersLink.isDisconnected())
245 auto parameters = parametersLink.getChildren();
246 for(
auto ¶meter:parameters)
248 if(!parameter.second.getNode(
"Enabled").getValue<
bool>())
251 auto comment = parameter.second.getNode(
"CommentDescription");
252 OUT << parameter.second.getNode(
"daqParameterKey").getValue() <<
254 parameter.second.getNode(
"daqParameterValue").getValue()
256 (comment.isDefaultValue()?
"":(
"\t # " + comment.getValue())) <<
259 if(!parameter.second.getNode(
"Enabled").getValue<
bool>())
266 OUT <<
"destinations: {\n";
269 auto destinationsGroup = boardReaderNode.getNode(
"daqDestinationsLink");
270 if(!destinationsGroup.isDisconnected())
272 auto destinations = destinationsGroup.getChildren();
273 for(
auto &destination:destinations)
275 unsigned int destinationRank =
276 contextConfig->getARTDAQAppRank(
277 destination.second.getNode(
"destinationARTDAQContextLink").getValue());
278 OUT << destination.second.getNode(
"destinationKey").getValue() <<
280 " transferPluginType: " <<
281 destination.second.getNode(
"transferPluginType").getValue() <<
282 " destination_rank: " <<
284 " max_fragment_size_words: " <<
285 destination.second.getNode(
"ARTDAQGlobalConfigurationLink/maxFragmentSizeWords").getValue<
unsigned int>() <<
296 OUT <<
"metrics: {\n";
299 auto metricsGroup = boardReaderNode.getNode(
"daqMetricsLink");
300 if(!metricsGroup.isDisconnected())
302 auto metrics = metricsGroup.getChildren();
304 for(
auto &metric:metrics)
306 if(!metric.second.getNode(
"Status").getValue<
bool>())
309 OUT << metric.second.getNode(
"metricKey").getValue() <<
313 OUT <<
"metricPluginType: " <<
314 metric.second.getNode(
"metricPluginType").getValue()
317 metric.second.getNode(
"metricLevel").getValue()
320 auto metricParametersGroup = metric.second.getNode(
"metricParametersLink");
321 if(!metricParametersGroup.isDisconnected())
323 auto metricParameters = metricParametersGroup.getChildren();
324 for(
auto &metricParameter:metricParameters)
326 if(!metricParameter.second.getNode(
"Enabled").getValue<
bool>())
329 OUT << metricParameter.second.getNode(
"metricParameterKey").getValue() <<
331 metricParameter.second.getNode(
"metricParameterValue").getValue()
334 if(!metricParameter.second.getNode(
"Enabled").getValue<
bool>())
342 if(!metric.second.getNode(
"Status").getValue<
bool>())