1 #include "otsdaq/Macros/TablePluginMacros.h"
2 #include "otsdaq/TablePlugins/ARTDAQEventBuilderTable.h"
3 #include "otsdaq/TablePlugins/XDAQContextTable.h"
9 #define SLOWCONTROL_PV_FILE_PATH \
11 getenv("OTSDAQ_EPICS_DATA")? \
12 (std::string(getenv("OTSDAQ_EPICS_DATA")) + "/" + __ENV__("MU2E_OWNER") + "_otsdaq_artdaqEventBuilder-ai.dbg"): \
13 (EPICS_CONFIG_PATH + "/_otsdaq_artdaqEventBuilder-ai.dbg") )
18 ARTDAQEventBuilderTable::ARTDAQEventBuilderTable(
void)
26 __COUT__ <<
"ARTDAQEventBuilderTable Constructed." << __E__;
30 ARTDAQEventBuilderTable::~ARTDAQEventBuilderTable(
void) {}
35 lastConfigManager_ = configManager;
39 isFirstAppInContext_ = configManager->isOwnerFirstAppInContext();
42 if(!isFirstAppInContext_)
46 mkdir((ARTDAQTableBase::ARTDAQ_FCL_PATH).c_str(), 0755);
53 auto buiders = lastConfigManager_->getNode(ARTDAQTableBase::getTableName()).getChildren(
54 std::map<std::string /*relative-path*/, std::string /*value*/>(),
58 for(
auto& builder : buiders)
60 ARTDAQTableBase::outputDataReceiverFHICL(builder.second, ARTDAQTableBase::ARTDAQAppType::EventBuilder);
61 ARTDAQTableBase::flattenFHICL(ARTDAQAppType::EventBuilder, builder.second.getValue());
66 unsigned int ARTDAQEventBuilderTable::slowControlsHandlerConfig(std::stringstream& out,
68 std::vector<std::pair<std::string , std::vector<std::string>>>* channelList
74 std::string tabStr =
"";
75 std::string commentStr =
"";
78 std::vector<std::pair<std::string, ConfigurationTree>> artdaqRecords = configManager->getNode(
"ARTDAQSupervisorTable").getChildren();
80 unsigned int numberOfEventBuilders = 0;
81 unsigned int numberOfEventBuiderMetricParameters = 0;
83 for(
auto& artdaqPair : artdaqRecords)
85 if(artdaqPair.second.getNode(colARTDAQSupervisor_.colLinkToEventBuilders_).isDisconnected())
88 std::vector<std::pair<std::string, ConfigurationTree>> eventBuilderRecords =
89 artdaqPair.second.getNode(colARTDAQSupervisor_.colLinkToEventBuilders_).getChildren();
91 for(
auto& eventBuilderPair : eventBuilderRecords)
93 if(!eventBuilderPair.second.status())
96 numberOfEventBuilders++;
100 if(eventBuilderPair.second.getNode(
"daqLink").isDisconnected())
103 auto daqLink = eventBuilderPair.second.getNode(
"daqLink");
105 if(daqLink.getNode(
"daqMetricsLink").isDisconnected())
108 auto daqMetricsLinks = daqLink.getNode(
"daqMetricsLink").getChildren();
109 for(
auto& daqMetricsLink : daqMetricsLinks)
111 if(!daqMetricsLink.second.status())
114 if(daqMetricsLink.second.getNode(
"metricParametersLink").isDisconnected())
118 ConfigurationTree slowControlsLink = eventBuilderPair.second.getNode(
"MetricAlarmThresholdsLink");
120 auto metricParametersLinks = daqMetricsLink.second.getNode(
"metricParametersLink").getChildren();
121 for(
auto& metricParametersLink : metricParametersLinks)
123 if(!metricParametersLink.second.status())
126 std::string subsystem = metricParametersLink.second.getNode(
"metricParameterValue")
127 .getValueWithDefault<std::string>(std::string(
"TDAQ_") + __ENV__(
"MU2E_OWNER"));
128 if(subsystem.find(
"Mu2e:") != std::string::npos)
129 subsystem = subsystem.replace(subsystem.find(
"Mu2e:"), 5,
"");
130 while(subsystem.find(
"\"") != std::string::npos)
131 subsystem = subsystem.replace(subsystem.find(
"\""), 1,
"");
133 numberOfEventBuiderMetricParameters =
134 slowControlsHandler(out, tabStr, commentStr, subsystem, eventBuilderPair.first, slowControlsLink, channelList);
136 __COUT__ <<
"EventBuilder '" << eventBuilderPair.first
137 <<
"' number of metrics for slow controls: " << numberOfEventBuiderMetricParameters << __E__;
141 catch(
const std::runtime_error& e)
143 __COUT_ERR__ <<
"Ignoring EventBuilder error: " << e.what() << __E__;
148 return numberOfEventBuiderMetricParameters;
153 std::string ARTDAQEventBuilderTable::setFilePath()
const {
return SLOWCONTROL_PV_FILE_PATH; }