1 #include "otsdaq-core/ConfigurationPluginDataFormats/ARTDAQAggregatorConfiguration.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 "aggregator"
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 ARTDAQAggregatorConfiguration::ARTDAQAggregatorConfiguration(
void)
36 ARTDAQAggregatorConfiguration::~ARTDAQAggregatorConfiguration(
void)
43 mkdir((ARTDAQ_FCL_PATH).c_str(), 0755);
45 __COUT__ <<
"*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*" << std::endl;
46 __COUT__ << configManager->__SELF_NODE__ << std::endl;
49 std::vector<const XDAQContextConfiguration::XDAQContext *> aggContexts =
50 contextConfig->getAggregatorContexts();
54 for (
auto &aggContext : aggContexts)
56 ConfigurationTree aggConfigNode = contextConfig->getSupervisorConfigNode(configManager,
57 aggContext->contextUID_, aggContext->applications_[0].applicationUID_);
59 __COUT__ <<
"Path for this aggregator config is " <<
60 aggContext->contextUID_ <<
"/" <<
61 aggContext->applications_[0].applicationUID_ <<
"/" <<
62 aggConfigNode.getValueAsString() <<
65 outputFHICL(configManager,aggConfigNode,
66 contextConfig->getARTDAQAppRank(aggContext->contextUID_),
67 contextConfig->getContextAddress(aggContext->contextUID_),
68 contextConfig->getARTDAQDataPort(configManager,aggContext->contextUID_),
74 std::string ARTDAQAggregatorConfiguration::getFHICLFilename(
const ConfigurationTree &aggregatorNode)
76 __COUT__ <<
"ARTDAQ Aggregator UID: " << aggregatorNode.getValue() << std::endl;
77 std::string filename = ARTDAQ_FCL_PATH + ARTDAQ_FILE_PREAMBLE +
"-";
78 std::string uid = aggregatorNode.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 __COUT__ <<
"fcl: " << filename << std::endl;
95 unsigned int selfRank, std::string selfHost,
unsigned int selfPort,
241 std::string filename = getFHICLFilename(aggregatorNode);
243 __COUT__ <<
"selfRank = " << selfRank << std::endl;
250 std::string tabStr =
"";
251 std::string commentStr =
"";
253 out.open(filename, std::fstream::out | std::fstream::trunc);
256 __SS__ <<
"Failed to open ARTDAQ Aggregator fcl file: " << filename << std::endl;
257 throw std::runtime_error(ss.str());
261 if (aggregatorNode.isDisconnected())
271 auto services = aggregatorNode.getNode(
"servicesLink");
272 if (!services.isDisconnected())
274 OUT <<
"services: {\n";
278 OUT <<
"scheduler: {\n";
281 OUT <<
"fileMode: " << services.getNode(
"schedulerFileMode").getValue() <<
283 OUT <<
"errorOnFailureToPut: " <<
284 (services.getNode(
"schedulerErrorOnFailtureToPut").getValue<
bool>() ?
"true" :
"false") <<
292 OUT <<
"NetMonTransportServiceInterface: {\n";
295 OUT <<
"service_provider: " <<
297 services.getNode(
"NetMonTrasportServiceInterfaceServiceProvider").getValue()
310 auto daq = aggregatorNode.getNode(
"daqLink");
311 if (!daq.isDisconnected())
317 OUT <<
"aggregator: {\n";
320 auto parametersLink = daq.getNode(
"daqAggregatorParametersLink");
321 if (!parametersLink.isDisconnected())
324 auto parameters = parametersLink.getChildren();
325 for (
auto ¶meter : parameters)
327 if (!parameter.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
330 auto comment = parameter.second.getNode(
"CommentDescription");
331 OUT << parameter.second.getNode(
"daqParameterKey").getValue() <<
333 parameter.second.getNode(
"daqParameterValue").getValue()
335 (comment.isDefaultValue() ?
"" : (
"\t # " + comment.getValue())) <<
338 if (!parameter.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
344 OUT <<
"sources: {\n";
347 auto sourcesGroup = daq.getNode(
"daqAggregatorSourcesLink");
348 if (!sourcesGroup.isDisconnected())
352 auto sources = sourcesGroup.getChildren();
353 for (
auto &source : sources)
355 std::string sourceContextUID = source.second.getNode(
"sourceARTDAQContextLink").getValueAsString();
357 std::string host = contextConfig->getContextAddress(sourceContextUID);
358 unsigned int sourceRank = contextConfig->getARTDAQAppRank(sourceContextUID);
359 unsigned int port = contextConfig->getARTDAQDataPort(configManager, sourceContextUID);
361 OUT << source.second.getNode(
"sourceKey").getValue() <<
363 " transferPluginType: " <<
364 source.second.getNode(
"transferPluginType").getValue() <<
367 " max_fragment_size_words: " <<
368 source.second.getNode(
"ARTDAQGlobalConfigurationLink/maxFragmentSizeWords").getValue<
unsigned int>() <<
369 " host_map: [{rank: " << sourceRank <<
" host: \"" << host <<
"\" portOffset: " << std::to_string(port) <<
"}, " <<
370 "{rank: " << selfRank <<
" host: \"" << selfHost <<
"\" portOffset: " << std::to_string(selfPort) <<
"}]" <<
374 catch (
const std::runtime_error& e)
376 __SS__ <<
"Are the DAQ sources valid? Error occurred looking for Aggregator DAQ sources for UID '" <<
377 aggregatorNode.getValue() <<
"': " << e.what() << std::endl;
378 __COUT_ERR__ << ss.str() << std::endl;
379 throw std::runtime_error(ss.str());
389 OUT <<
"metrics: {\n";
392 auto metricsGroup = daq.getNode(
"daqMetricsLink");
393 if (!metricsGroup.isDisconnected())
395 auto metrics = metricsGroup.getChildren();
397 for (
auto &metric : metrics)
399 if (!metric.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
402 OUT << metric.second.getNode(
"metricKey").getValue() <<
406 OUT <<
"metricPluginType: " <<
407 metric.second.getNode(
"metricPluginType").getValue()
410 metric.second.getNode(
"metricLevel").getValue()
413 auto metricParametersGroup = metric.second.getNode(
"metricParametersLink");
414 if (!metricParametersGroup.isDisconnected())
416 auto metricParameters = metricParametersGroup.getChildren();
417 for (
auto &metricParameter : metricParameters)
419 if (!metricParameter.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
422 auto comment = metricParameter.second.getNode(
"CommentDescription");
423 OUT << metricParameter.second.getNode(
"metricParameterKey").getValue() <<
425 metricParameter.second.getNode(
"metricParameterValue").getValue()
427 (comment.isDefaultValue() ?
"" : (
"\t # " + comment.getValue())) <<
430 if (!metricParameter.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
438 if (!metric.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
445 OUT <<
"destinations: {\n";
449 auto destinationsGroup = daq.getNode(
"daqAggregatorDestinationsLink");
450 if (!destinationsGroup.isDisconnected())
454 auto destinations = destinationsGroup.getChildren();
455 for (
auto &destination : destinations)
457 auto destinationContextUID = destination.second.getNode(
"destinationARTDAQContextLink").getValueAsString();
459 unsigned int destinationRank = contextConfig->getARTDAQAppRank(destinationContextUID);
460 std::string host = contextConfig->getContextAddress(destinationContextUID);
461 unsigned int port = contextConfig->getARTDAQDataPort(configManager,destinationContextUID);
463 OUT << destination.second.getNode(
"destinationKey").getValue() <<
465 " transferPluginType: " <<
466 destination.second.getNode(
"transferPluginType").getValue() <<
469 " destination_rank: " <<
471 " max_fragment_size_words: " <<
472 destination.second.getNode(
"ARTDAQGlobalConfigurationLink/maxFragmentSizeWords").getValue<
unsigned int>() <<
473 " host_map: [{rank: " << destinationRank <<
" host: \"" << host <<
"\" portOffset: " << std::to_string(port) <<
"}, " <<
474 "{rank: " << selfRank <<
" host: \"" << selfHost <<
"\" portOffset: " << std::to_string(selfPort) <<
"}]" <<
478 catch (
const std::runtime_error& e)
480 __SS__ <<
"Are the DAQ destinations valid? Error occurred looking for Aggregator DAQ destinations for UID '" <<
481 aggregatorNode.getValue() <<
"': " << e.what() << std::endl;
482 __COUT_ERR__ << ss.str() << std::endl;
483 throw std::runtime_error(ss.str());
496 auto source = aggregatorNode.getNode(
"sourceLink");
497 if (!source.isDisconnected())
499 OUT <<
"source: {\n";
502 OUT <<
"module_type: " << source.getNode(
"sourceModuleType").getValue() <<
510 auto outputs = aggregatorNode.getNode(
"outputsLink");
511 if (!outputs.isDisconnected())
513 OUT <<
"outputs: {\n";
517 auto outputPlugins = outputs.getChildren();
518 for (
auto &outputPlugin : outputPlugins)
520 if (!outputPlugin.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
523 OUT << outputPlugin.second.getNode(
"outputKey").getValue() <<
526 OUT <<
"module_type: " <<
527 outputPlugin.second.getNode(
"outputModuleType").getValue() <<
529 auto pluginParameterLink = outputPlugin.second.getNode(
"outputModuleParameterLink");
530 if (!pluginParameterLink.isDisconnected())
532 auto pluginParameters = pluginParameterLink.getChildren();
533 for (
auto &pluginParameter : pluginParameters)
535 if (!pluginParameter.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
538 auto comment = pluginParameter.second.getNode(
"CommentDescription");
539 OUT << pluginParameter.second.getNode(
"outputParameterKey").getValue() <<
541 pluginParameter.second.getNode(
"outputParameterValue").getValue()
543 (comment.isDefaultValue() ?
"" : (
"\t # " + comment.getValue())) <<
546 if (!pluginParameter.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
553 if (!outputPlugin.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
564 auto physics = aggregatorNode.getNode(
"physicsLink");
565 if (!physics.isDisconnected())
568 OUT <<
"physics: {\n";
572 auto analyzers = physics.getNode(
"analyzersLink");
573 if (!analyzers.isDisconnected())
576 OUT <<
"analyzers: {\n";
579 auto modules = analyzers.getChildren();
580 for (
auto &module : modules)
582 if (!module.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
585 OUT << module.second.getNode(
"analyzerKey").getValue() <<
588 OUT <<
"module_type: " <<
589 module.second.getNode(
"analyzerModuleType").getValue() <<
591 auto moduleParameterLink = module.second.getNode(
"analyzerModuleParameterLink");
592 if (!moduleParameterLink.isDisconnected())
594 auto moduleParameters = moduleParameterLink.getChildren();
595 for (
auto &moduleParameter : moduleParameters)
597 if (!moduleParameter.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
600 auto comment = moduleParameter.second.getNode(
"CommentDescription");
601 OUT << moduleParameter.second.getNode(
"analyzerParameterKey").getValue() <<
603 moduleParameter.second.getNode(
"analyzerParameterValue").getValue()
605 (comment.isDefaultValue() ?
"" : (
"\t # " + comment.getValue())) <<
608 if (!moduleParameter.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
615 if (!module.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
622 auto producers = physics.getNode(
"producersLink");
623 if (!producers.isDisconnected())
626 OUT <<
"producers: {\n";
629 auto modules = producers.getChildren();
630 for (
auto &module : modules)
632 if (!module.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
635 OUT << module.second.getNode(
"producerKey").getValue() <<
638 OUT <<
"module_type: " <<
639 module.second.getNode(
"producerModuleType").getValue() <<
641 auto moduleParameterLink = module.second.getNode(
"producerModuleParameterLink");
642 if (!moduleParameterLink.isDisconnected())
644 auto moduleParameters = moduleParameterLink.getChildren();
645 for (
auto &moduleParameter : moduleParameters)
647 if (!moduleParameter.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
650 auto comment = moduleParameter.second.getNode(
"CommentDescription");
651 OUT << moduleParameter.second.getNode(
"producerParameterKey").getValue() <<
653 moduleParameter.second.getNode(
"producerParameterValue").getValue()
655 (comment.isDefaultValue() ?
"" : (
"\t # " + comment.getValue())) <<
658 if (!moduleParameter.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
665 if (!module.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
673 auto filters = physics.getNode(
"filtersLink");
674 if (!filters.isDisconnected())
677 OUT <<
"filters: {\n";
680 auto modules = filters.getChildren();
681 for (
auto &module : modules)
683 if (!module.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
686 OUT << module.second.getNode(
"filterKey").getValue() <<
689 OUT <<
"module_type: " <<
690 module.second.getNode(
"filterModuleType").getValue() <<
692 auto moduleParameterLink = module.second.getNode(
"filterModuleParameterLink");
693 if (!moduleParameterLink.isDisconnected())
695 auto moduleParameters = moduleParameterLink.getChildren();
696 for (
auto &moduleParameter : moduleParameters)
698 if (!moduleParameter.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
701 auto comment = moduleParameter.second.getNode(
"CommentDescription");
702 OUT << moduleParameter.second.getNode(
"filterParameterKey").getValue()
704 moduleParameter.second.getNode(
"filterParameterValue").getValue()
706 (comment.isDefaultValue() ?
"" : (
"\t # " + comment.getValue())) <<
709 if (!moduleParameter.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
716 if (!module.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
724 auto otherParameterLink = physics.getNode(
"physicsOtherParametersLink");
725 if (!otherParameterLink.isDisconnected())
728 auto physicsParameters = otherParameterLink.getChildren();
729 for (
auto ¶meter : physicsParameters)
731 if (!parameter.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
734 auto comment = parameter.second.getNode(
"CommentDescription");
735 OUT << parameter.second.getNode(
"physicsParameterKey").getValue() <<
737 parameter.second.getNode(
"physicsParameterValue").getValue()
739 (comment.isDefaultValue() ?
"" : (
"\t # " + comment.getValue())) <<
742 if (!parameter.second.getNode(ViewColumnInfo::COL_NAME_STATUS).getValue<
bool>())
753 OUT <<
"process_name: " <<
754 aggregatorNode.getNode(
"ARTDAQGlobalConfigurationForProcessNameLink/processNameForAggregators")