1 #include "otsdaq/TablePlugins/ARTDAQTableBase/ARTDAQTableBase.h"
8 #include "otsdaq/Macros/CoutMacros.h"
9 #define TRACE_NAME "ARTDAQTableBase"
11 #include <fhiclcpp/ParameterSet.h>
12 #include <fhiclcpp/detail/print_mode.h>
13 #include <fhiclcpp/intermediate_table.h>
14 #include <fhiclcpp/parse.h>
16 #include "otsdaq/ProgressBar/ProgressBar.h"
17 #include "otsdaq/TablePlugins/XDAQContextTable/XDAQContextTable.h"
22 #define __MF_SUBJECT__ "ARTDAQTableBase"
26 #define FCL_COMMENT_POSITION 65
30 #define OUTCF(X,C,F) { std::stringstream outSs; outSs << X; addCommentWhitespace(outSs, tabStr.size()*TABSZ + commentStr.size() + outSs.str().size()); outSs << (C) << (std::string(C).size()?" - ":"") << "from config-tree: " << parentPath << (std::string(F).size()?(std::string("/") + std::string(F)):std::string("")) << "\n"; OUT << outSs.str();}
32 #define OUTC(X,C) OUTCF(X,C,"")
34 #define OUTCLF(X,C,F) { std::stringstream outSs; outSs << X; addCommentWhitespace(outSs, tabStr.size()*TABSZ + commentStr.size() + outSs.str().size()); outSs << (C) << (std::string(C).size()?" - ":"") << "from config-tree: " << localParentPath << std::string(std::string(F).size()?("/" + std::string(F)):std::string("")) << "\n"; OUT << outSs.str();}
36 #define OUTCL(X,C) OUTCLF(X,C,"")
38 #define OUTCL2F(X,C,F) { std::stringstream outSs; outSs << X; addCommentWhitespace(outSs, tabStr.size()*TABSZ + commentStr.size() + outSs.str().size()); outSs << (C) << (std::string(C).size()?" - ":"") << "from config-tree: " << localParentPath2 << (std::string(F).size()?(std::string("/") + std::string(F)):std::string("")) << "\n"; OUT << outSs.str();}
40 #define OUTCL2(X,C) OUTCL2F(X,C,"")
45 const std::string ARTDAQTableBase::ARTDAQ_CONFIG_LAYOUTS_PATH =
46 (((getenv(
"SERVICE_DATA_PATH") == NULL)
47 ? (std::string(getenv(
"USER_DATA")) +
"/ServiceData")
48 : std::string(getenv(
"SERVICE_DATA_PATH")))) +
49 "/ConfigurationGUI_artdaqLayouts/";
50 const bool ARTDAQTableBase::ARTDAQ_DONOTWRITE_FCL = ((getenv(
"OTS_FCL_DONOTWRITE") == NULL) ?
false :
true);
52 const std::string ARTDAQTableBase::ARTDAQ_SUPERVISOR_CLASS =
"ots::ARTDAQSupervisor";
53 const std::string ARTDAQTableBase::ARTDAQ_SUPERVISOR_TABLE =
"ARTDAQSupervisorTable";
55 const std::string ARTDAQTableBase::ARTDAQ_READER_TABLE =
"ARTDAQBoardReaderTable";
56 const std::string ARTDAQTableBase::ARTDAQ_BUILDER_TABLE =
"ARTDAQEventBuilderTable";
57 const std::string ARTDAQTableBase::ARTDAQ_LOGGER_TABLE =
"ARTDAQDataLoggerTable";
58 const std::string ARTDAQTableBase::ARTDAQ_DISPATCHER_TABLE =
"ARTDAQDispatcherTable";
59 const std::string ARTDAQTableBase::ARTDAQ_MONITOR_TABLE =
"ARTDAQMonitorTable";
60 const std::string ARTDAQTableBase::ARTDAQ_ROUTER_TABLE =
"ARTDAQRoutingManagerTable";
62 const std::string ARTDAQTableBase::ARTDAQ_SUBSYSTEM_TABLE =
"ARTDAQSubsystemTable";
63 const std::string ARTDAQTableBase::ARTDAQ_DAQ_TABLE =
"ARTDAQDaqTable";
64 const std::string ARTDAQTableBase::ARTDAQ_DAQ_PARAMETER_TABLE =
"ARTDAQDaqParameterTable";
65 const std::string ARTDAQTableBase::ARTDAQ_ART_TABLE =
"ARTDAQArtTable";
67 const std::string ARTDAQTableBase::ARTDAQ_TYPE_TABLE_HOSTNAME =
"ExecutionHostname";
68 const std::string ARTDAQTableBase::ARTDAQ_TYPE_TABLE_ALLOWED_PROCESSORS =
"AllowedProcessors";
69 const std::string ARTDAQTableBase::ARTDAQ_TYPE_TABLE_SUBSYSTEM_LINK =
"SubsystemLink";
70 const std::string ARTDAQTableBase::ARTDAQ_TYPE_TABLE_SUBSYSTEM_LINK_UID =
"SubsystemLinkUID";
73 const int ARTDAQTableBase::NULL_SUBSYSTEM_DESTINATION = 0;
74 const std::string ARTDAQTableBase::NULL_SUBSYSTEM_DESTINATION_LABEL =
"nullDestinationSubsystem";
98 std::string* accumulatedExceptions )
99 :
TableBase(tableName, accumulatedExceptions)
111 std::cout <<
"ARTDAQTableBase Before traceTID=" << traceTID << __E__;
113 traceInit(trace_name(TRACE_NAME, __TRACE_FILE__, buf,
sizeof(buf)), 0);
114 std::cout <<
"ARTDAQTableBase After traceTID=" << traceTID << __E__;
115 __COUT__ <<
"ARTDAQTableBase TRACE reinit and Constructed." << __E__;
125 __SS__ <<
"Should not call void constructor, table type is lost!" << __E__;
130 ARTDAQTableBase::~ARTDAQTableBase(
void) {}
146 __COUT_INFO__ <<
"ARTDAQ Supervisor is disabled, so skipping fcl handling."
161 const std::string& ARTDAQTableBase::getTypeString(ARTDAQAppType type)
165 case ARTDAQAppType::EventBuilder:
167 case ARTDAQAppType::DataLogger:
169 case ARTDAQAppType::Dispatcher:
171 case ARTDAQAppType::BoardReader:
173 case ARTDAQAppType::Monitor:
175 case ARTDAQAppType::RoutingManager:
179 __SS__ <<
"Illegal translation attempt for type '" << (
unsigned int)type <<
"'"
185 std::string ARTDAQTableBase::getFHICLFilename(ARTDAQAppType type,
const std::string& name)
190 std::string uid = name;
191 for(
unsigned int i = 0; i < uid.size(); ++i)
192 if((uid[i] >=
'a' && uid[i] <=
'z') || (uid[i] >=
'A' && uid[i] <=
'Z') ||
193 (uid[i] >=
'0' && uid[i] <=
'9'))
204 std::string ARTDAQTableBase::getFlatFHICLFilename(ARTDAQAppType type,
205 const std::string& name)
210 std::string uid = name;
211 for(
unsigned int i = 0; i < uid.size(); ++i)
212 if((uid[i] >=
'a' && uid[i] <=
'z') || (uid[i] >=
'A' && uid[i] <=
'Z') ||
213 (uid[i] >=
'0' && uid[i] <=
'9'))
216 filename +=
"_flattened.fcl";
224 void ARTDAQTableBase::flattenFHICL(ARTDAQAppType type,
225 const std::string& name,
226 std::string* returnFcl )
228 std::chrono::steady_clock::time_point startClock = std::chrono::steady_clock::now();
229 __COUTS__(3) <<
"flattenFHICL()" << __ENV__(
"FHICL_FILE_PATH") << __E__;
233 std::string inFile = getFHICLFilename(type, name);
234 std::string outFile = getFlatFHICLFilename(type, name);
236 __COUTVS__(3, inFile);
237 __COUTVS__(3, outFile);
239 cet::filepath_lookup_nonabsolute policy(
"FHICL_FILE_PATH");
240 fhicl::ParameterSet pset;
244 __COUT_INFO__ <<
"parsing document: " << inFile;
247 pset = fhicl::ParameterSet::make(inFile, policy);
248 __COUTT__ <<
"document: " << inFile <<
" parsed";
249 __COUTT__ <<
"got pset from table:";
251 std::ofstream ofs{outFile};
254 __SS__ <<
"Failed to open fhicl output file '" << outFile <<
"!'" << __E__;
257 std::ostringstream out;
258 out << pset.to_indented_string(
262 *returnFcl = out.str();
263 __COUTVS__(21, returnFcl);
267 catch(cet::exception
const& e)
269 __SS__ <<
"Failed to parse fhicl into output file '" << outFile
270 <<
"' - here is the error: " << e.what() << __E__;
273 if(std::string(e.what()).find(
"TriggerEpilogs") != std::string::npos)
275 <<
"The Trigger Epilogs are located at "
276 "$USER_DATA/TriggerConfigurations/TriggerEpilogs. "
277 <<
"Please check that the Trigger Epilogs were properly generated, or "
278 "copy them from a previously working area."
284 <<
" Flatten Clock time = " << artdaq::TimeUtils::GetElapsedTime(startClock)
297 std::string& commentStr,
298 const std::string& parentPath,
300 const std::string& parameterPreamble,
301 bool onlyInsertAtTableParameters ,
302 bool includeAtTableParameters )
308 auto otherParameters = parameterGroupLink.
getChildren();
313 __COUTVS__(3, otherParameters.size());
314 __COUTVS__(3, onlyInsertAtTableParameters);
315 __COUTVS__(3, includeAtTableParameters);
317 size_t paramCount = 0;
318 for(
auto& parameter : otherParameters)
320 key = parameter.second.getNode(parameterPreamble +
"Key").getValue();
322 std::string localParentPath =
324 parameter.second.getTableName() +
":" +
326 parameterGroupLink.
getParentLinkID() +
"/" + parameter.second.getValue();
330 if(key.find(
"@table::") != std::string::npos)
333 if(onlyInsertAtTableParameters || includeAtTableParameters)
336 if(!parameter.second.status())
339 __COUTT__ <<
"Inserting parameter... " << localParentPath << __E__;
342 OUTCL(key << parameter.second.getNode(parameterPreamble +
"Value")
344 parameter.second.hasComment() ? parameter.second.getComment()
347 if(!parameter.second.status())
356 if(onlyInsertAtTableParameters)
360 if(!parameter.second.status())
363 __COUTT__ <<
"Inserting parameter... " << localParentPath << __E__;
366 if(key.size() && key.find(
"#include") == std::string::npos)
371 parameter.second.getNode(parameterPreamble +
"Value").getValue();
374 if(value.size() > 2 && value[0] ==
'@' && value[1] ==
'@')
377 <<
"Checking for getFclValueForARTDAQ @@ indicator from value = "
379 std::string potentialTable = value.substr(2);
380 __COUTTV__(potentialTable);
385 ->getFclValueForARTDAQ(cfgMgr, key);
387 catch(
const std::runtime_error& e)
389 __SS__ <<
"getFclValueForARTDAQ @@ indicator from value = "
390 << value <<
" corresponds to table '" << potentialTable
391 <<
"'... however fcl value failed to load: " << e.what();
395 __COUTT__ <<
"Value from getFclValueForARTDAQ: value = " << value
398 std::string localParentPath2 =
"/" + potentialTable;
399 OUTCL2(key <<
": " << value,
400 parameter.second.hasComment() ? parameter.second.getComment()
406 << parameter.second.getNode(parameterPreamble +
"Value")
408 parameter.second.hasComment() ? parameter.second.getComment()
414 OUTCL(parameter.second.getNode(parameterPreamble +
"Value").getValue(),
415 parameter.second.hasComment() ? parameter.second.getComment() :
"");
419 OUTCL(
"# comment for #include below:",
420 parameter.second.hasComment() ? parameter.second.getComment() :
"");
422 << parameter.second.getNode(parameterPreamble +
"Value").getValue()
426 if(!parameter.second.status())
432 __COUTS__(3) <<
"Empty parameter set found onlyInsertAtTableParameters="
433 << onlyInsertAtTableParameters << __E__;
434 std::string localParentPath =
437 if(onlyInsertAtTableParameters)
439 OUTCL(
"# no @table parameters found",
"" );
443 OUTCL(
"# empty parameter set found",
"" );
449 __COUTS__(3) <<
"No parameters found" << __E__;
450 std::string localParentPath =
452 OUTCL(
"# no parameters inserted",
"" );
462 std::string& commentStr,
463 const std::string& parentPath,
466 std::string value = moduleTypeNode.
getValue();
467 __COUTTV__(parentPath);
468 OUTCF((value.find(
"@table::") == std::string::npos ?
"module_type: " :
"") << value,
478 std::string& commentStr,
479 const std::string& parentPath,
482 auto metricsGroup = daqNode.
getNode(
"daqMetricsLink");
485 OUTCF(
"metrics: {",
"", metricsGroup.getParentLinkColumnName());
487 if(!metricsGroup.isDisconnected())
489 auto metrics = metricsGroup.getChildren();
490 bool sendSystemMetrics(
false), sendProcessMetrics(
false);
491 for(
auto& metric : metrics)
493 if(!metric.second.status())
496 __COUTT__ <<
"Inserting metric... " << parentPath << __E__;
497 std::string localParentPath =
498 parentPath +
"/" + metricsGroup.getParentLinkColumnName() +
":" +
499 metric.second.getTableName() +
":" + metricsGroup.getParentLinkIndex() +
500 ":" + metricsGroup.getParentLinkID() +
"/" + metric.second.getValue();
501 __COUTT__ <<
"Inserting metric... " << localParentPath << __E__;
503 OUTCL(metric.second.getNode(
"metricKey").getValue() <<
": {",
504 metric.second.hasComment() ? metric.second.getComment() :
"");
507 if(metric.second.getNode(
"sendSystemMetrics").getValue<
bool>())
509 sendSystemMetrics =
true;
511 if(metric.second.getNode(
"sendProcessMetrics").getValue<
bool>())
513 sendProcessMetrics =
true;
516 OUTCLF(
"metricPluginType: "
517 << metric.second.getNode(
"metricPluginType").getValue(),
521 "level_string: " << metric.second.getNode(
"metricLevelString").getValue(),
523 "metricLevelString");
525 auto metricParametersGroup = metric.second.getNode(
"metricParametersLink");
526 if(!metricParametersGroup.isDisconnected())
528 auto metricParameters = metricParametersGroup.getChildren();
529 for(
auto& metricParameter : metricParameters)
531 if(!metricParameter.second.status())
534 __COUTT__ <<
"Inserting metric... " << localParentPath << __E__;
535 std::string localParentPath2 =
536 localParentPath +
"/" +
537 metricParametersGroup.getParentLinkColumnName() +
":" +
538 metricParameter.second.getTableName() +
":" +
539 metricParametersGroup.getParentLinkIndex() +
":" +
540 metricParametersGroup.getParentLinkID() +
"/" +
541 metricParameter.second.getValue();
542 __COUTT__ <<
"Inserting metric... " << localParentPath2 << __E__;
543 OUTCL2(metricParameter.second.getNode(
"metricParameterKey").getValue()
545 << metricParameter.second.getNode(
"metricParameterValue")
547 metricParameter.second.hasComment()
548 ? metricParameter.second.getComment()
551 if(!metricParameter.second.status())
556 OUT <<
"} # end " << metric.second.getNode(
"metricKey").getValue()
559 if(!metric.second.status())
563 __COUTT__ <<
"Inserting metric send... " << parentPath << __E__;
564 std::string localParentPath =
565 parentPath +
"/" + metricsGroup.getParentLinkColumnName() +
":" +
566 metricsGroup.getTableName() +
":" + metricsGroup.getParentLinkIndex() +
":" +
567 metricsGroup.getParentLinkID();
568 if(sendSystemMetrics)
570 __COUTT__ <<
"Inserting send_system_metrics... " << localParentPath << __E__;
571 OUTCLF(
"send_system_metrics: true ",
572 "true, if any children are true",
573 "*/sendSystemMetrics");
576 OUTCLF(
"# send_system_metrics: false ",
577 "true, if any children are true",
578 "*/sendSystemMetrics");
580 if(sendProcessMetrics)
582 __COUTT__ <<
"Inserting send_process_metrics... " << localParentPath << __E__;
583 OUTCLF(
"send_process_metrics: true ",
584 "true, if any children are true",
585 "*/sendProcessMetrics");
588 OUTCLF(
"# send_process_metrics: false ",
589 "true, if any children are true",
590 "*/sendProcessMetrics");
594 __COUTS__(3) <<
"No metrics found" << __E__;
595 std::string localParentPath =
596 parentPath +
"/" + metricsGroup.getParentLinkColumnName();
597 OUTCL(
"# no metrics found",
"" );
601 OUT <<
"} # end metrics\n\n";
605 void ARTDAQTableBase::outputBoardReaderFHICL(
608 size_t routingTimeoutMs ,
609 size_t routingRetryCount )
611 if(ARTDAQ_DONOTWRITE_FCL)
613 __COUT__ <<
"Skipping fcl generation." << __E__;
742 std::string filename =
743 getFHICLFilename(ARTDAQAppType::BoardReader, boardReaderNode.
getValue());
749 std::string tabStr =
"";
750 std::string commentStr =
"";
753 out.open(filename, std::fstream::out | std::fstream::trunc);
756 __SS__ <<
"Failed to open ARTDAQ BoardReader fcl file: " << filename << __E__;
764 OUT <<
"###########################################################" << __E__;
766 OUT <<
"# artdaq " << getTypeString(ARTDAQAppType::BoardReader)
767 <<
" fcl configuration file produced by otsdaq." << __E__;
770 OUT <<
"# Original filename: \t" << filename << __E__;
771 OUT <<
"# otsdaq-ARTDAQ " << getTypeString(ARTDAQAppType::BoardReader)
772 <<
" UID:\t" << boardReaderNode.
getValue() << __E__;
774 OUT <<
"###########################################################" << __E__;
788 catch(
const std::runtime_error&)
790 __COUTT__ <<
"Ignoring error, assume this a valid UID node." << __E__;
795 std::string parentPath =
798 OUTC(
"# start of " << getTypeString(ARTDAQAppType::BoardReader) <<
" '"
799 << boardReaderNode.
getValue() <<
"' fcl",
804 __COUTT__ <<
"Inserting " << getTypeString(ARTDAQAppType::BoardReader)
805 <<
" preamble parameters... " << parentPath << __E__;
811 boardReaderNode.
getNode(
"preambleParametersLink"),
818 __COUTT__ <<
"Generating daq block..." << __E__;
825 OUT <<
"fragment_receiver: {\n";
832 "daq generator plug-in type" ,
833 "daqGeneratorPluginType" );
834 OUTCF(
"fragment_type"
837 "generator data fragment type" ,
838 "daqGeneratorFragmentType" );
840 __COUTT__ <<
"Inserting " << getTypeString(ARTDAQAppType::BoardReader)
841 <<
" DAQ Parameters... " << parentPath << __E__;
847 boardReaderNode.
getNode(
"daqParametersLink"),
852 auto fragmentId = boardReaderNode.
getNode(
"daqFragmentIDs");
853 std::string value = fragmentId.
getValue();
854 if(value.size() < 2 || value[0] !=
'[' || value[value.size() - 1] !=
']')
856 __SS__ <<
"Invalid 'daqFragmentIDs' - the value must be a valid fcl "
857 "array with starting and ending square brackets: [ ]"
861 __COUTS__(20) <<
"fragment_ids: " << fragmentId.getValue() << __E__;
862 OUTCF(
"fragment_ids: " << fragmentId.getValue(),
869 <<
"Ignoring missing fragment_id column associated with Board Reader."
872 OUTCF(
"# fragment_ids not specified, but could be",
"",
"daqFragmentIDs");
878 OUT <<
"destinations: { # empty placeholder, '"
879 << getTypeString(ARTDAQAppType::BoardReader)
880 <<
"' destinations handled by artdaq interface\n";
883 OUT <<
"routing_table_config: {\n";
886 auto readerSubsystemID = 1;
887 auto readerSubsystemLink = boardReaderNode.
getNode(
"SubsystemLink");
888 if(!readerSubsystemLink.isDisconnected())
890 readerSubsystemID = getSubsytemId(readerSubsystemLink);
892 if(info_.subsystems[readerSubsystemID].hasRoutingManager)
894 std::string localParentPath =
895 parentPath +
"/" + readerSubsystemLink.getParentLinkColumnName() +
":" +
896 readerSubsystemLink.getTableName() +
"/" + readerSubsystemLink.getValue();
897 __COUTT__ <<
"Inserting routing manager... " << localParentPath << __E__;
898 OUTCL(
"use_routing_manager: true",
899 "auto-generated because subsystem '" +
900 std::to_string(readerSubsystemID) +
"' has Routing Manager added");
902 OUTCLF(
"routing_manager_hostname: \""
903 << info_.subsystems[readerSubsystemID].routingManagerHost <<
"\"",
905 ARTDAQTableBase::ARTDAQ_TYPE_TABLE_HOSTNAME);
906 OUT <<
"table_update_port: 0\n";
907 OUT <<
"table_update_address: \"0.0.0.0\"\n";
908 OUT <<
"table_update_multicast_interface: \"0.0.0.0\"\n";
909 OUT <<
"table_acknowledge_port : 0\n";
910 OUT <<
"routing_timeout_ms: " << routingTimeoutMs <<
"\n";
911 OUT <<
"routing_retry_count: " << routingRetryCount <<
"\n";
915 OUTCF(
"use_routing_manager: false",
916 "auto-generated if subsystem '" + std::to_string(readerSubsystemID) +
917 "' has Routing Manager added",
918 readerSubsystemLink.getParentLinkColumnName());
925 OUT <<
"} # end fragment_receiver\n";
930 OUT <<
"} # end daq\n\n";
935 __COUTT__ <<
"Inserting " << getTypeString(ARTDAQAppType::BoardReader)
936 <<
" add-on parameters... " << parentPath << __E__;
941 boardReaderNode.
getNode(
"addOnParametersLink"),
946 OUTC(
"# end of " << getTypeString(ARTDAQAppType::BoardReader) <<
" '"
947 << boardReaderNode.
getValue() <<
"' fcl",
949 __COUTT__ <<
"outputBoardReaderFHICL DONE" << __E__;
953 __SS__ <<
"\n\nError while generating FHiCL for "
954 << getTypeString(ARTDAQAppType::BoardReader) <<
" node at filename '"
955 << filename <<
"'" << __E__;
960 catch(
const std::runtime_error& e)
962 ss <<
" Here is the error: " << e.what() << __E__;
964 catch(
const std::exception& e)
966 ss <<
" Here is the error: " << e.what() << __E__;
982 ARTDAQAppType appType,
984 size_t routingTimeoutMs ,
985 size_t routingRetryCount ,
986 std::string* returnFcl )
988 if(ARTDAQ_DONOTWRITE_FCL)
990 __COUT__ <<
"Skipping fcl generation." << __E__;
994 std::string filename = getFHICLFilename(appType, receiverNode.
getValue());
999 std::ostringstream out;
1001 std::string tabStr =
"";
1002 std::string commentStr =
"";
1004 __COUTV__(filename);
1005 outf.open(filename, std::fstream::out | std::fstream::trunc);
1008 __SS__ <<
"Failed to open ARTDAQ fcl file: " << filename << __E__;
1016 OUT <<
"###########################################################" << __E__;
1017 OUT <<
"#" << __E__;
1018 OUT <<
"# artdaq " << getTypeString(appType)
1019 <<
" fcl configuration file produced by otsdaq." << __E__;
1020 OUT <<
"# Creation time: \t"
1022 OUT <<
"# Original filename: \t" << filename << __E__;
1023 OUT <<
"# otsdaq-ARTDAQ " << getTypeString(appType) <<
" UID:\t"
1024 << receiverNode.
getValue() << __E__;
1025 OUT <<
"#" << __E__;
1026 OUT <<
"###########################################################" << __E__;
1038 *returnFcl = out.str();
1039 __COUTVS__(21, *returnFcl);
1046 catch(
const std::runtime_error&)
1048 __COUTT__ <<
"Ignoring error, assume this a valid UID node." << __E__;
1053 std::string parentPath =
1056 OUTC(
"# start of " << getTypeString(appType) <<
" '" << receiverNode.
getValue()
1062 __COUTT__ <<
"Inserting " << getTypeString(appType) <<
" preamble parameters... "
1063 << parentPath << __E__;
1069 receiverNode.
getNode(
"preambleParametersLink"),
1076 __COUTT__ <<
"Generating daq block..." << __E__;
1078 auto daq = receiverNode.
getNode(
"daqLink");
1079 if(!daq.isDisconnected())
1082 OUTCF(
"daq: {",
"" , daq.getParentLinkColumnName());
1085 if(appType == ARTDAQAppType::EventBuilder)
1086 OUT <<
"event_builder: {\n";
1088 OUT <<
"aggregator: {\n";
1093 std::stringstream outSs;
1094 if(appType == ARTDAQAppType::DataLogger)
1095 outSs <<
"is_datalogger: true";
1096 else if(appType == ARTDAQAppType::Dispatcher)
1097 outSs <<
"is_dispatcher: true";
1098 if(outSs.str().size())
1100 addCommentWhitespace(
1102 tabStr.size() * TABSZ + commentStr.size() + outSs.str().size());
1103 outSs <<
"auto-generated based on app type '"
1104 << getTypeString(appType) <<
"'\n";
1111 std::string parentPath = daq.getParentTableName() +
"/" +
1112 daq.getParentRecordName() +
"/" +
1113 daq.getParentLinkColumnName() +
":" +
1114 daq.getTableName() +
"/" + daq.getValue();
1115 __COUTT__ <<
"Inserting " << getTypeString(appType) <<
" DAQ Parameters... "
1116 << parentPath << __E__;
1121 daq.getNode(
"daqParametersLink"),
1126 if(appType == ARTDAQAppType::EventBuilder)
1129 OUT <<
"routing_token_config: {\n";
1132 auto builderSubsystemID = 1;
1133 auto builderSubsystemLink = receiverNode.
getNode(
"SubsystemLink");
1134 if(!builderSubsystemLink.isDisconnected())
1136 builderSubsystemID = getSubsytemId(builderSubsystemLink);
1138 if(info_.subsystems[builderSubsystemID].hasRoutingManager)
1140 std::string localParentPath =
1142 builderSubsystemLink.getParentLinkColumnName() +
":" +
1143 builderSubsystemLink.getTableName() +
"/" +
1144 builderSubsystemLink.getValue();
1145 __COUTT__ <<
"Inserting routing manager... " << localParentPath
1147 OUTCL(
"use_routing_manager: true",
1148 "auto-generated because subsystem '" +
1149 std::to_string(builderSubsystemID) +
1150 "' has Routing Manager added");
1152 OUTCLF(
"routing_manager_hostname: \""
1153 << info_.subsystems[builderSubsystemID].routingManagerHost
1156 ARTDAQTableBase::ARTDAQ_TYPE_TABLE_HOSTNAME);
1157 OUT <<
"routing_token_port: 0\n";
1161 OUTCF(
"use_routing_manager: false",
1162 "auto-generated if subsystem '" +
1163 std::to_string(builderSubsystemID) +
1164 "' has Routing Manager added",
1165 builderSubsystemLink.getParentLinkColumnName());
1171 __COUTT__ <<
"Adding sources placeholder" << __E__;
1173 OUT <<
"sources: { # empty placeholder, '" << getTypeString(appType)
1174 <<
"' sources handled by artdaq interface\n";
1179 if(appType == ARTDAQAppType::EventBuilder)
1180 OUT <<
"} # end event_builder\n";
1182 OUT <<
"} # end aggregator\n";
1187 OUT <<
"} # end daq\n\n";
1191 __COUTS__(3) <<
"No daq found" << __E__;
1192 std::string localParentPath =
1193 parentPath +
"/" + daq.getParentLinkColumnName();
1194 OUTCL(
"# no daq found",
"" );
1199 __COUTT__ <<
"Filling art block..." << __E__;
1202 receiverNode.
getNode(ARTDAQTableBase::colARTDAQNotReader_.colLinkToArt_);
1203 if(!art.isDisconnected())
1205 std::string localParentPath = parentPath +
"/" +
1207 art.getTableName() +
"/" + art.getValue();
1208 OUTCF(
"art: {",
"" , art.getParentLinkColumnName());
1217 receiverNode.
getNode(
"SubsystemLink"),
1222 OUT <<
"} # end art\n\n";
1226 __COUTS__(3) <<
"No art found" << __E__;
1227 std::string localParentPath =
1228 parentPath +
"/" + art.getParentLinkColumnName();
1229 OUTCL(
"# no art found",
"" );
1234 __COUTT__ <<
"Inserting " << getTypeString(appType) <<
" add-on parameters... "
1235 << parentPath << __E__;
1240 receiverNode.
getNode(
"addOnParametersLink"),
1246 OUTC(
"# end of " << getTypeString(appType) <<
" '" << receiverNode.
getValue()
1249 __COUTT__ <<
"outputDataReceiverFHICL DONE" << __E__;
1253 __SS__ <<
"\n\nError while generating FHiCL for " << getTypeString(appType)
1254 <<
" node at filename '" << filename <<
"'" << __E__;
1259 catch(
const std::runtime_error& e)
1261 ss <<
" Here is the error: " << e.what() << __E__;
1263 catch(
const std::exception& e)
1265 ss <<
" Here is the error: " << e.what() << __E__;
1270 *returnFcl = out.str();
1271 __COUTVS__(21, *returnFcl);
1280 *returnFcl = out.str();
1281 __COUTVS__(21, *returnFcl);
1292 if(ARTDAQ_DONOTWRITE_FCL)
1294 __COUT__ <<
"Skipping fcl generation." << __E__;
1298 std::string filename =
1299 getFHICLFilename(ARTDAQAppType::Monitor, monitorNode.
getValue());
1305 std::string tabStr =
"";
1306 std::string commentStr =
"";
1308 __COUTV__(filename);
1309 out.open(filename, std::fstream::out | std::fstream::trunc);
1312 __SS__ <<
"Failed to open ARTDAQ fcl file: " << filename << __E__;
1320 OUT <<
"###########################################################" << __E__;
1321 OUT <<
"#" << __E__;
1322 OUT <<
"# artdaq " << getTypeString(ARTDAQAppType::Monitor)
1323 <<
" fcl configuration file produced by otsdaq." << __E__;
1324 OUT <<
"# Creation time: \t"
1326 OUT <<
"# Original filename: \t" << filename << __E__;
1327 OUT <<
"# otsdaq-ARTDAQ " << getTypeString(ARTDAQAppType::Monitor) <<
" UID:\t"
1328 << monitorNode.
getValue() << __E__;
1329 OUT <<
"#" << __E__;
1330 OUT <<
"###########################################################" << __E__;
1344 catch(
const std::runtime_error&)
1346 __COUTT__ <<
"Ignoring error, assume this a valid UID node." << __E__;
1353 std::string parentPath =
1357 __COUTT__ <<
"Inserting " << getTypeString(ARTDAQAppType::Monitor)
1358 <<
" preamble parameters... " << parentPath << __E__;
1363 monitorNode.
getNode(
"preambleParametersLink"),
1372 monitorNode.
getNode(ARTDAQTableBase::colARTDAQNotReader_.colLinkToArt_);
1373 if(!art.isDisconnected())
1376 OUT <<
"services.message: { "
1377 << artdaq::generateMessageFacilityConfiguration(
1378 mf::GetApplicationName().c_str(),
true,
false)
1380 OUT <<
"services.message.destinations.file: {type: \"GenFile\" threshold: "
1381 "\"INFO\" seperator: \"-\""
1382 <<
" pattern: \"" << monitorNode.
getValue() <<
"-%?H%t-%p.log"
1384 <<
" timestamp_pattern: \"%Y%m%d%H%M%S\""
1385 <<
" directory: \"" << __ENV__(
"OTSDAQ_LOG_ROOT") <<
"/"
1387 <<
" append : false }\n";
1390 auto dispatcherLink = monitorNode.
getNode(
"dispatcherLink");
1391 if(!dispatcherLink.isDisconnected())
1393 std::string monitorHost =
1394 monitorNode.
getNode(ARTDAQTableBase::ARTDAQ_TYPE_TABLE_HOSTNAME)
1396 std::string dispatcherHost =
1397 dispatcherLink.getNode(ARTDAQTableBase::ARTDAQ_TYPE_TABLE_HOSTNAME)
1398 .getValueWithDefault(
"localhost");
1399 OUT <<
"source.dispatcherHost: \"" << dispatcherHost <<
"\"\n";
1400 int dispatcherPort = dispatcherLink.getNode(
"DispatcherPort").getValue<
int>();
1401 OUT <<
"source.dispatcherPort: " << dispatcherPort <<
"\n";
1402 OUT <<
"source.commanderPluginType: xmlrpc\n";
1405 int om_tcp_listen_port =
1407 int disp_fake_rank =
1408 dispatcherLink.getNode(
"DispatcherID").getValueWithDefault<
int>(200);
1410 size_t max_fragment_size = monitorNode.
getNode(
"max_fragment_size_words")
1412 std::string transfer_plugin_type = monitorNode.
getNode(
"transfer_plugin_type")
1415 OUT <<
"TransferPluginConfig: {\n";
1417 OUT <<
"transferPluginType: " << transfer_plugin_type <<
"\n";
1418 OUT <<
"host_map: [{ rank: " << disp_fake_rank <<
" host: \""
1419 << dispatcherHost <<
"\"}, { rank: " << om_rank <<
" host: \""
1420 << monitorHost <<
"\"}]\n";
1421 OUT <<
"max_fragment_size_words: " << max_fragment_size <<
"\n";
1422 OUT <<
"source_rank: " << disp_fake_rank <<
"\n";
1423 OUT <<
"destination_rank: " << om_rank <<
"\n";
1424 OUT <<
"port: " << om_tcp_listen_port <<
"\n";
1425 OUT <<
"unique_label: " << monitorNode.
getValue() <<
"_to_"
1426 << dispatcherLink.getValue() <<
"\n";
1429 OUT <<
"source.transfer_plugin: @local::TransferPluginConfig \n";
1430 auto dispatcherArt = monitorNode.
getNode(
"dispatcherArtLink");
1431 if(!dispatcherArt.isDisconnected())
1433 OUT <<
"source.dispatcher_config: {\n";
1439 OUT <<
"filter_paths: [\n";
1443 auto filterPathsLink = monitorNode.
getNode(
"filterPathsLink");
1444 if(!filterPathsLink.isDisconnected())
1451 for(
auto& filterPath : filterPaths)
1457 if(!filterPath.second.status())
1460 OUT <<
"name: " << filterPath.second.getNode(
"Name").getValue()
1462 OUT <<
"path: " << filterPath.second.getNode(
"Path").getValue()
1466 if(!filterPath.second.status())
1475 OUT <<
"unique_label: " << monitorNode.
getValue() <<
"\n";
1489 __COUTT__ <<
"Inserting " << getTypeString(ARTDAQAppType::Monitor)
1490 <<
" add-on parameters... " << parentPath << __E__;
1495 monitorNode.
getNode(
"addOnParametersLink"),
1500 __COUTT__ <<
"outputOnlineMonitorFHICL DONE" << __E__;
1504 __SS__ <<
"\n\nError while generating FHiCL for "
1505 << getTypeString(ARTDAQAppType::Monitor) <<
" node at filename '"
1506 << filename <<
"'" << __E__;
1511 catch(
const std::runtime_error& e)
1513 ss <<
" Here is the error: " << e.what() << __E__;
1515 catch(
const std::exception& e)
1517 ss <<
" Here is the error: " << e.what() << __E__;
1531 std::string& tabStr,
1532 std::string& commentStr,
1533 const std::string& parentPath,
1536 size_t routingTimeoutMs,
1537 size_t routingRetryCount)
1541 __COUTT__ <<
"Filling art.services parentPath =" << parentPath << __E__;
1542 auto services = art.
getNode(
"servicesLink");
1543 if(!services.isDisconnected())
1545 std::string localParentPath =
1547 services.getTableName() +
"/" +
1548 services.getValue();
1549 __COUTT__ <<
"Inserting services... " << localParentPath << __E__;
1550 OUTCL(
"services: {", services.hasComment() ? services.getComment() :
"");
1555 __COUTT__ <<
"Inserting services parameters... " << localParentPath << __E__;
1560 services.getNode(
"ServicesParametersLink"),
1566 OUT <<
"ArtdaqSharedMemoryServiceInterface: {\n";
1568 OUT <<
"service_provider: "
1569 "ArtdaqSharedMemoryService \n";
1571 OUTCLF(
"waiting_time: " << services.getNode(
"sharedMemoryWaitingTime").getValue(),
1573 "sharedMemoryWaitingTime");
1574 OUTCLF(
"resume_after_timeout: "
1575 << (services.getNode(
"sharedMemoryResumeAfterTimeout").getValue<
bool>()
1579 "sharedMemoryResumeAfterTimeout");
1581 OUT <<
"} # end ArtdaqSharedMemoryServiceInterface\n\n";
1583 OUT <<
"ArtdaqFragmentNamingServiceInterface: {\n";
1585 OUT <<
"service_provider: "
1586 "ArtdaqFragmentNamingService \n";
1587 OUTCLF(
"helper_plugin: "
1588 << services.getNode(
"fragmentNamingServiceProvider").getValue(),
1590 "fragmentNamingServiceProvider");
1592 OUT <<
"} # end ArtdaqFragmentNamingServiceInterface\n\n";
1596 __COUTT__ <<
"Inserting services parameters... " << localParentPath << __E__;
1601 services.getNode(
"ServicesParametersLink"),
1607 OUT <<
"} # end services\n\n";
1611 __COUTS__(3) <<
"No services found" << __E__;
1612 std::string localParentPath =
1613 parentPath +
"/" + services.getParentLinkColumnName();
1614 OUTCL(
"# no services found",
"" );
1619 __COUTT__ <<
"Filling art.outputs parentPath =" << parentPath << __E__;
1620 auto outputs = art.
getNode(
"outputsLink");
1621 if(!outputs.isDisconnected())
1623 std::string localParentPath =
1626 __COUTT__ <<
"Inserting output... " << localParentPath << __E__;
1627 OUTCL(
"outputs: {",
"" );
1630 auto outputPlugins = outputs.getChildren();
1631 for(
auto& outputPlugin : outputPlugins)
1633 if(!outputPlugin.second.status())
1636 __COUTT__ <<
"Inserting output parameters... " << localParentPath << __E__;
1637 std::string localParentPath2 =
1638 localParentPath +
":" + outputPlugin.second.getTableName() +
":" +
1639 outputs.getParentLinkIndex() +
":" + outputs.getParentLinkID() +
"/" +
1640 outputPlugin.second.getValue();
1641 __COUTT__ <<
"Inserting output... " << localParentPath2 << __E__;
1643 outputPlugin.second.getNode(
"outputKey").getValue() <<
": {",
1644 outputPlugin.second.hasComment() ? outputPlugin.second.getComment() :
"",
1648 __COUTT__ <<
"insertModuleType... " << localParentPath2 << __E__;
1649 std::string moduleType =
1654 outputPlugin.second.getNode(
"outputModuleType"));
1658 __COUTT__ <<
"Inserting output parameters... " << localParentPath << __E__;
1663 outputPlugin.second.getNode(
"outputModuleParameterLink"),
1668 if(outputPlugin.second.getNode(
"outputModuleType").getValue() ==
1669 "BinaryNetOutput" ||
1670 outputPlugin.second.getNode(
"outputModuleType").getValue() ==
1673 OUT <<
"destinations: { # empty placeholder, '"
1674 << outputPlugin.second.getNode(
"outputModuleType").getValue()
1675 <<
"' destinations handled by artdaq interface\n";
1678 OUT <<
"routing_table_config: {\n";
1681 auto mySubsystemID = 1;
1682 auto destinationSubsystemID = 1;
1685 mySubsystemID = getSubsytemId(subsystemLink);
1687 destinationSubsystemID = info_.subsystems[mySubsystemID].destination;
1688 if(info_.subsystems[destinationSubsystemID].hasRoutingManager)
1690 std::string localParentPath =
1693 __COUTT__ <<
"Inserting routing manager... " << localParentPath
1695 OUTCL(
"use_routing_manager: true",
1696 "auto-generated because subsystem '" +
1697 std::to_string(destinationSubsystemID) +
1698 "' has Routing Manager added");
1701 "routing_manager_hostname: \""
1702 << info_.subsystems[destinationSubsystemID].routingManagerHost
1705 ARTDAQTableBase::ARTDAQ_TYPE_TABLE_HOSTNAME);
1706 OUT <<
"table_update_port: 0\n";
1707 OUT <<
"table_update_address: \"0.0.0.0\"\n";
1708 OUT <<
"table_update_multicast_interface: \"0.0.0.0\"\n";
1709 OUT <<
"table_acknowledge_port : 0\n";
1710 OUT <<
"routing_timeout_ms: " << routingTimeoutMs <<
"\n";
1711 OUT <<
"routing_retry_count: " << routingRetryCount <<
"\n";
1715 OUTCF(
"use_routing_manager: false",
1716 "auto-generated if subsystem '" +
1717 std::to_string(destinationSubsystemID) +
1718 "' has Routing Manager added",
1722 if(outputPlugin.second.getNode(
"outputModuleType").getValue() ==
1725 info_.subsystems[mySubsystemID].eventMode =
true;
1731 if(outputPlugin.second.getNode(
"outputModuleType").getValue() ==
1733 outputPlugin.second.getNode(
"outputModuleType").getValue() ==
1734 "TransferOutputReliable")
1736 OUT <<
"transfer_plugin: @local::TransferPluginConfig \n";
1740 OUT <<
"} # end " << outputPlugin.second.getNode(
"outputKey").getValue()
1743 if(!outputPlugin.second.status())
1748 OUT <<
"} # end outputs\n\n";
1752 __COUTS__(3) <<
"No outputs found" << __E__;
1753 std::string localParentPath =
1754 parentPath +
"/" + outputs.getParentLinkColumnName();
1755 OUTCL(
"# no outputs found",
"" );
1760 __COUTT__ <<
"Filling art.physics parentPath =" << parentPath << __E__;
1761 auto physics = art.
getNode(
"physicsLink");
1762 if(!physics.isDisconnected())
1764 __COUTT__ <<
"Inserting physics... " << parentPath << __E__;
1765 std::string localParentPath = parentPath +
"/" +
1766 physics.getParentLinkColumnName() +
":" +
1767 physics.getTableName() +
"/" +
1771 OUTCL(
"physics: {", physics.hasComment() ? services.getComment() :
"");
1777 __COUTT__ <<
"Inserting physics other parameters... " << localParentPath << __E__;
1782 physics.getNode(
"physicsOtherParametersLink"),
1783 "physicsParameter" ,
1787 auto analyzers = physics.getNode(
"analyzersLink");
1788 if(!analyzers.isDisconnected())
1790 __COUTT__ <<
"Inserting art.physics.analyzers... " << localParentPath
1792 std::string localParentPath2 =
1793 localParentPath +
"/" + analyzers.getParentLinkColumnName();
1794 __COUTT__ <<
"Inserting art.physics.analyzers... " << localParentPath2
1799 OUTCL2(
"analyzers: {",
"" );
1803 auto modules = analyzers.getChildren();
1804 for(
auto& module : modules)
1806 if(!module.second.status())
1813 auto analyzerNodeParameterLink =
1814 module.second.getNode(
"analyzerModuleParameterLink");
1817 __COUTT__ <<
"Inserting analyzer @table parameters... "
1818 << localParentPath2 << __E__;
1819 std::string localParentPath3 =
1820 localParentPath2 +
":" + module.second.getTableName() +
":" +
1821 analyzers.getParentLinkIndex() +
":" + analyzers.getParentLinkID() +
1822 "/" + module.second.getValue();
1823 __COUTT__ <<
"Inserting analyzer @table parameters... "
1824 << localParentPath3 << __E__;
1829 analyzerNodeParameterLink,
1830 "analyzerParameter" ,
1834 OUT << module.second.getNode(
"analyzerKey").getValue() <<
": {\n";
1840 module.second.getNode(
"analyzerModuleType"));
1844 __COUTT__ <<
"Inserting analayzer not @table parameters... "
1845 << localParentPath3 << __E__;
1850 analyzerNodeParameterLink,
1851 "analyzerParameter" ,
1858 if(!module.second.status())
1862 OUT <<
"} # end physics.analyzers\n\n";
1866 __COUTS__(3) <<
"No analyzers found" << __E__;
1867 std::string localParentPath2 =
1868 localParentPath +
"/" + analyzers.getParentLinkColumnName();
1869 OUTCL2(
"# no analyzers found",
"" );
1872 auto producers = physics.getNode(
"producersLink");
1873 if(!producers.isDisconnected())
1875 __COUTT__ <<
"Inserting art.physics.producers... " << localParentPath
1877 std::string localParentPath2 =
1878 localParentPath +
"/" + producers.getParentLinkColumnName();
1882 OUTCL2(
"producers: {",
"" );
1886 auto modules = producers.getChildren();
1887 for(
auto& module : modules)
1889 if(!module.second.status())
1896 auto producerNodeParameterLink =
1897 module.second.getNode(
"producerModuleParameterLink");
1900 __COUTT__ <<
"Inserting producer @table parameters... "
1901 << localParentPath2 << __E__;
1902 std::string localParentPath3 =
1903 localParentPath2 +
":" + module.second.getTableName() +
":" +
1904 producers.getParentLinkIndex() +
":" + producers.getParentLinkID() +
1905 "/" + module.second.getValue();
1906 __COUTT__ <<
"Inserting producer @table parameters... "
1907 << localParentPath3 << __E__;
1912 producerNodeParameterLink,
1913 "producerParameter" ,
1917 if(module.second.status() &&
1918 module.second.getNode(
"producerModuleType").getValue() ==
"")
1920 std::string tmp = localParentPath2;
1921 localParentPath2 = localParentPath3;
1922 OUTCL2F(
"# skipping '" << module.second.getValue()
1923 <<
"' with empty module type",
1925 "producerModuleType");
1926 localParentPath2 = tmp;
1930 OUT << module.second.getNode(
"producerKey").getValue() <<
": {\n";
1937 module.second.getNode(
"producerModuleType"));
1941 __COUTT__ <<
"Inserting producer not @table parameters... "
1942 << localParentPath3 << __E__;
1947 producerNodeParameterLink,
1948 "producerParameter" ,
1955 if(!module.second.status())
1959 OUT <<
"} # end physics.producers\n\n";
1963 __COUTS__(3) <<
"No producers found" << __E__;
1964 std::string localParentPath2 =
1965 localParentPath +
"/" + producers.getParentLinkColumnName();
1966 OUTCL2(
"# no producers found",
"" );
1969 auto filters = physics.getNode(
"filtersLink");
1970 if(!filters.isDisconnected())
1972 __COUTT__ <<
"Inserting art.physics.filters... " << localParentPath << __E__;
1973 std::string localParentPath2 =
1974 localParentPath +
"/" + filters.getParentLinkColumnName();
1978 OUTCL2(
"filters: {",
"" );
1982 auto modules = filters.getChildren();
1983 for(
auto& module : modules)
1985 if(!module.second.status())
1992 auto filterNodeParameterLink =
1993 module.second.getNode(
"filterModuleParameterLink");
1996 __COUTT__ <<
"Inserting filter @table parameters... " << localParentPath2
1998 std::string localParentPath3 =
1999 localParentPath2 +
":" + module.second.getTableName() +
":" +
2000 filters.getParentLinkIndex() +
":" + filters.getParentLinkID() +
"/" +
2001 module.second.getValue();
2002 __COUTT__ <<
"Inserting filter @table parameters... " << localParentPath3
2008 filterNodeParameterLink,
2012 if(module.second.status() &&
2013 module.second.getNode(
"filterModuleType").getValue() ==
"")
2015 std::string tmp = localParentPath2;
2016 localParentPath2 = localParentPath3;
2017 OUTCL2F(
"# skipping '" << module.second.getValue()
2018 <<
"' with empty module type",
2020 "filterModuleType");
2021 localParentPath2 = tmp;
2025 OUT << module.second.getNode(
"filterKey").getValue() <<
": {\n";
2032 module.second.getNode(
"filterModuleType"));
2036 __COUTT__ <<
"Inserting filter not @table parameters... "
2037 << localParentPath3 << __E__;
2042 filterNodeParameterLink,
2050 if(!module.second.status())
2054 OUT <<
"} # end physics.filters\n\n";
2058 __COUTS__(3) <<
"No filters found" << __E__;
2059 std::string localParentPath2 =
2060 localParentPath +
"/" + services.getParentLinkColumnName();
2061 OUTCL2(
"# no filters found",
"" );
2066 __COUTT__ <<
"Inserting art.physics not @table parameters... " << localParentPath
2072 physics.getNode(
"physicsOtherParametersLink"),
2073 "physicsParameter" ,
2078 OUT <<
"} # end physics\n\n";
2082 __COUTS__(3) <<
"No physics found" << __E__;
2083 std::string localParentPath =
2084 parentPath +
"/" + physics.getParentLinkColumnName();
2085 OUTCL(
"# no physics found",
"" );
2090 __COUTT__ <<
"Filling art.source" << __E__;
2091 auto source = art.
getNode(
"sourceLink");
2092 if(!source.isDisconnected())
2094 __COUTT__ <<
"Inserting source... " << parentPath << __E__;
2095 std::string localParentPath = parentPath +
"/" +
2096 source.getParentLinkColumnName() +
":" +
2097 source.getTableName() +
"/" +
2099 OUTCL(
"source: {", source.hasComment() ? source.getComment() :
"");
2102 out, tabStr, commentStr, parentPath, source.getNode(
"sourceModuleType"));
2108 std::string localParentPath = parentPath +
"/" + source.getParentLinkColumnName();
2109 OUTCL(
"source: { # auto-generated default, to change provide a source link",
2112 OUT <<
"module_type: ArtdaqInput";
2119 __COUTT__ <<
"Writing art.process_name" << __E__;
2120 OUTCF(
"process_name: " << art.
getNode(ARTDAQTableBase::colARTDAQArt_.colProcessName_),
2122 ARTDAQTableBase::colARTDAQArt_.colProcessName_);
2126 __COUTT__ <<
"Inserting art @table parameters... " << parentPath << __E__;
2131 art.
getNode(
"AddOnParametersLink"),
2139 void ARTDAQTableBase::outputRoutingManagerFHICL(
2141 size_t routingTimeoutMs ,
2142 size_t routingRetryCount )
2144 if(ARTDAQ_DONOTWRITE_FCL)
2146 __COUT__ <<
"Skipping fcl generation." << __E__;
2150 std::string filename =
2151 getFHICLFilename(ARTDAQAppType::RoutingManager, routingManagerNode.
getValue());
2157 std::string tabStr =
"";
2158 std::string commentStr =
"";
2160 __COUTV__(filename);
2161 out.open(filename, std::fstream::out | std::fstream::trunc);
2164 __SS__ <<
"Failed to open ARTDAQ RoutingManager fcl file: " << filename << __E__;
2172 OUT <<
"###########################################################" << __E__;
2173 OUT <<
"#" << __E__;
2174 OUT <<
"# artdaq " << getTypeString(ARTDAQAppType::RoutingManager)
2175 <<
" fcl configuration file produced by otsdaq." << __E__;
2176 OUT <<
"# Creation time: \t"
2178 OUT <<
"# Original filename: \t" << filename << __E__;
2179 OUT <<
"# otsdaq-ARTDAQ RoutingManager UID:\t" << routingManagerNode.
getValue()
2181 OUT <<
"#" << __E__;
2182 OUT <<
"###########################################################" << __E__;
2196 catch(
const std::runtime_error&)
2208 OUT <<
"policy: {\n";
2212 if(policyName ==
"DEFAULT")
2213 policyName =
"NoOp";
2214 OUT <<
"policy: " << policyName <<
"\n";
2215 OUT <<
"receiver_ranks: []\n";
2218 auto parametersLink = routingManagerNode.
getNode(
"routingPolicyParametersLink");
2219 if(!parametersLink.isDisconnected())
2222 for(
auto& parameter : parameters)
2224 if(!parameter.second.status())
2235 parameter.second.getNode(TableViewColumnInfo::COL_NAME_COMMENT);
2236 OUT << parameter.second.getNode(
"daqParameterKey").getValue() <<
": "
2237 << parameter.second.getNode(
"daqParameterValue").getValue()
2238 << (comment.isDefaultValue() ?
"" : (
"\t # " + comment.getValue()))
2241 if(!parameter.second.status())
2249 OUT <<
"use_routing_manager: true\n";
2251 auto routingManagerSubsystemID = 1;
2252 auto routingManagerSubsystemLink = routingManagerNode.
getNode(
"SubsystemLink");
2253 std::string rmHost =
"localhost";
2254 if(!routingManagerSubsystemLink.isDisconnected())
2256 routingManagerSubsystemID = getSubsytemId(routingManagerSubsystemLink);
2257 rmHost = info_.subsystems[routingManagerSubsystemID].routingManagerHost;
2259 if(rmHost ==
"localhost" || rmHost ==
"127.0.0.1")
2261 char hostbuf[HOST_NAME_MAX + 1];
2262 gethostname(hostbuf, HOST_NAME_MAX);
2263 rmHost = std::string(hostbuf);
2267 OUT <<
"routing_manager_hostname: \"" << rmHost <<
"\"\n";
2268 OUT <<
"sender_ranks: []\n";
2269 OUT <<
"table_update_port: 0\n";
2270 OUT <<
"table_update_address: \"0.0.0.0\"\n";
2271 OUT <<
"table_acknowledge_port: 0\n";
2272 OUT <<
"token_receiver: {\n";
2275 OUT <<
"routing_token_port: 0\n";
2281 auto tableUpdateIntervalMs =
2283 if(tableUpdateIntervalMs !=
"DEFAULT")
2285 OUT <<
"table_update_interval_ms: " << tableUpdateIntervalMs <<
"\n";
2287 auto tableAckRetryCount =
2289 if(tableAckRetryCount !=
"DEFAULT")
2291 OUT <<
"table_ack_retry_count: " << tableAckRetryCount <<
"\n";
2294 OUT <<
"routing_timeout_ms: " << routingTimeoutMs <<
"\n";
2295 OUT <<
"routing_retry_count: " << routingRetryCount <<
"\n";
2306 __COUTT__ <<
"outputReaderFHICL DONE" << __E__;
2310 __SS__ <<
"\n\nError while generating FHiCL for "
2311 << getTypeString(ARTDAQAppType::RoutingManager) <<
" node at filename '"
2312 << filename <<
"'" << __E__;
2317 catch(
const std::runtime_error& e)
2319 ss <<
" Here is the error: " << e.what() << __E__;
2321 catch(
const std::exception& e)
2323 ss <<
" Here is the error: " << e.what() << __E__;
2335 bool getStatusFalseNodes ,
2337 size_t maxFragmentSizeBytes ,
2338 size_t routingTimeoutMs ,
2339 size_t routingRetryCount ,
2343 progressBar->
step();
2346 info_.subsystems.clear();
2347 info_.processes.clear();
2350 progressBar->
step();
2352 info_.subsystems[NULL_SUBSYSTEM_DESTINATION].id = NULL_SUBSYSTEM_DESTINATION;
2353 info_.subsystems[NULL_SUBSYSTEM_DESTINATION].label = NULL_SUBSYSTEM_DESTINATION_LABEL;
2358 __COUT__ <<
"artdaqSupervisorNode is disconnected." << __E__;
2363 extractRoutingManagersInfo(artdaqSupervisorNode,
2364 getStatusFalseNodes,
2368 __COUT__ <<
"artdaqSupervisorNode RoutingManager size: "
2369 << info_.processes.at(ARTDAQAppType::RoutingManager).size() << __E__;
2372 progressBar->
step();
2374 extractBoardReadersInfo(artdaqSupervisorNode,
2375 getStatusFalseNodes,
2377 maxFragmentSizeBytes,
2380 __COUT__ <<
"artdaqSupervisorNode BoardReader size: "
2381 << info_.processes.at(ARTDAQAppType::BoardReader).size() << __E__;
2384 progressBar->
step();
2386 extractEventBuildersInfo(
2387 artdaqSupervisorNode, getStatusFalseNodes, doWriteFHiCL, maxFragmentSizeBytes);
2388 __COUT__ <<
"artdaqSupervisorNode EventBuilder size: "
2389 << info_.processes.at(ARTDAQAppType::EventBuilder).size() << __E__;
2392 progressBar->
step();
2394 extractDataLoggersInfo(
2395 artdaqSupervisorNode, getStatusFalseNodes, doWriteFHiCL, maxFragmentSizeBytes);
2396 __COUT__ <<
"artdaqSupervisorNode DataLogger size: "
2397 << info_.processes.at(ARTDAQAppType::DataLogger).size() << __E__;
2400 progressBar->
step();
2402 extractDispatchersInfo(
2403 artdaqSupervisorNode, getStatusFalseNodes, doWriteFHiCL, maxFragmentSizeBytes);
2404 __COUT__ <<
"artdaqSupervisorNode Dispatcher size: "
2405 << info_.processes.at(ARTDAQAppType::Dispatcher).size() << __E__;
2408 progressBar->
step();
2414 void ARTDAQTableBase::extractRoutingManagersInfo(
ConfigurationTree artdaqSupervisorNode,
2415 bool getStatusFalseNodes,
2417 size_t routingTimeoutMs,
2418 size_t routingRetryCount)
2420 __COUT__ <<
"Checking for Routing Managers..." << __E__;
2421 info_.processes[ARTDAQAppType::RoutingManager].clear();
2424 artdaqSupervisorNode.
getNode(colARTDAQSupervisor_.colLinkToRoutingManagers_);
2427 std::vector<std::pair<std::string, ConfigurationTree>> routingManagers =
2430 __COUT__ <<
"There are " << routingManagers.size()
2431 <<
" configured Routing Managers" << __E__;
2433 for(
auto& routingManager : routingManagers)
2435 const std::string& rmUID = routingManager.first;
2437 if(getStatusFalseNodes || routingManager.second.status())
2439 std::string rmHost =
2440 routingManager.second
2441 .getNode(ARTDAQTableBase::ARTDAQ_TYPE_TABLE_HOSTNAME)
2442 .getValueWithDefault(
"localhost");
2443 if(rmHost ==
"localhost" || rmHost ==
"127.0.0.1")
2445 char hostbuf[HOST_NAME_MAX + 1];
2446 gethostname(hostbuf, HOST_NAME_MAX);
2447 rmHost = std::string(hostbuf);
2451 routingManager.second
2452 .getNode(ARTDAQTableBase::ARTDAQ_TYPE_TABLE_ALLOWED_PROCESSORS)
2453 .getValueWithDefault(
"");
2455 int routingManagerSubsystemID = 1;
2457 routingManager.second.
getNode(
2458 ARTDAQTableBase::ARTDAQ_TYPE_TABLE_SUBSYSTEM_LINK);
2461 routingManagerSubsystemID =
2462 getSubsytemId(routingManagerSubsystemLink);
2465 info_.subsystems[routingManagerSubsystemID].id =
2466 routingManagerSubsystemID;
2468 const std::string& routingManagerSubsystemName =
2472 info_.subsystems[routingManagerSubsystemID].label =
2473 routingManagerSubsystemName;
2475 if(info_.subsystems[routingManagerSubsystemID].hasRoutingManager)
2477 __SS__ <<
"Error: You cannot have multiple Routing Managers in a "
2483 auto routingManagerSubsystemDestinationLink =
2484 routingManagerSubsystemLink.
getNode(
2485 colARTDAQSubsystem_.colLinkToDestination_);
2486 if(routingManagerSubsystemDestinationLink.isDisconnected())
2489 info_.subsystems[routingManagerSubsystemID].destination = 0;
2494 info_.subsystems[routingManagerSubsystemID].destination =
2495 getSubsytemId(routingManagerSubsystemDestinationLink);
2501 if(!info_.subsystems.count(
2502 info_.subsystems[routingManagerSubsystemID].destination) ||
2504 .subsystems[info_.subsystems[routingManagerSubsystemID]
2506 .sources.count(routingManagerSubsystemID))
2509 .subsystems[info_.subsystems[routingManagerSubsystemID]
2511 .sources.insert(routingManagerSubsystemID);
2516 __COUT__ <<
"Found Routing Manager with UID " << rmUID
2517 <<
", DAQInterface Hostname " << rmHost <<
", and Subsystem "
2518 << routingManagerSubsystemID << __E__;
2519 info_.processes[ARTDAQAppType::RoutingManager].emplace_back(
2523 routingManagerSubsystemID,
2524 ARTDAQAppType::RoutingManager,
2525 routingManager.second.status());
2527 info_.subsystems[routingManagerSubsystemID].hasRoutingManager =
true;
2528 info_.subsystems[routingManagerSubsystemID].routingManagerHost = rmHost;
2532 outputRoutingManagerFHICL(
2533 routingManager.second, routingTimeoutMs, routingRetryCount);
2535 flattenFHICL(ARTDAQAppType::RoutingManager,
2536 routingManager.second.getValue());
2541 __COUT__ <<
"Routing Manager " << rmUID <<
" is disabled." << __E__;
2548 void ARTDAQTableBase::extractBoardReadersInfo(
ConfigurationTree artdaqSupervisorNode,
2549 bool getStatusFalseNodes,
2551 size_t maxFragmentSizeBytes,
2552 size_t routingTimeoutMs,
2553 size_t routingRetryCount)
2555 __COUT__ <<
"Checking for Board Readers..." << __E__;
2556 info_.processes[ARTDAQAppType::BoardReader].clear();
2559 artdaqSupervisorNode.
getNode(colARTDAQSupervisor_.colLinkToBoardReaders_);
2562 std::vector<std::pair<std::string, ConfigurationTree>> readers =
2564 __COUT__ <<
"There are " << readers.size() <<
" configured Board Readers."
2567 for(
auto& reader : readers)
2569 const std::string& readerUID = reader.first;
2571 if(getStatusFalseNodes || reader.second.status())
2573 std::string readerHost =
2574 reader.second.getNode(ARTDAQTableBase::ARTDAQ_TYPE_TABLE_HOSTNAME)
2575 .getValueWithDefault(
"localhost");
2576 std::string readerAP =
2578 .getNode(ARTDAQTableBase::ARTDAQ_TYPE_TABLE_ALLOWED_PROCESSORS)
2579 .getValueWithDefault(
"");
2581 int readerSubsystemID = 1;
2583 reader.second.
getNode(ARTDAQ_TYPE_TABLE_SUBSYSTEM_LINK);
2586 readerSubsystemID = getSubsytemId(readerSubsystemLink);
2588 info_.subsystems[readerSubsystemID].id = readerSubsystemID;
2590 const std::string& readerSubsystemName =
2594 info_.subsystems[readerSubsystemID].label = readerSubsystemName;
2596 auto readerSubsystemDestinationLink = readerSubsystemLink.
getNode(
2597 colARTDAQSubsystem_.colLinkToDestination_);
2598 if(readerSubsystemDestinationLink.isDisconnected())
2601 info_.subsystems[readerSubsystemID].destination = 0;
2606 info_.subsystems[readerSubsystemID].destination =
2607 getSubsytemId(readerSubsystemDestinationLink);
2613 if(!info_.subsystems.count(
2614 info_.subsystems[readerSubsystemID].destination) ||
2615 !info_.subsystems[info_.subsystems[readerSubsystemID].destination]
2616 .sources.count(readerSubsystemID))
2618 info_.subsystems[info_.subsystems[readerSubsystemID].destination]
2619 .sources.insert(readerSubsystemID);
2624 __COUT__ <<
"Found Board Reader with UID " << readerUID
2625 <<
", DAQInterface Hostname " << readerHost <<
", and Subsystem "
2626 << readerSubsystemID << __E__;
2627 info_.processes[ARTDAQAppType::BoardReader].emplace_back(
2632 ARTDAQAppType::BoardReader,
2633 reader.second.status());
2637 outputBoardReaderFHICL(reader.second,
2638 maxFragmentSizeBytes,
2642 flattenFHICL(ARTDAQAppType::BoardReader, reader.second.getValue());
2647 __COUT__ <<
"Board Reader " << readerUID <<
" is disabled." << __E__;
2653 __COUT_WARN__ <<
"There should be at least one Board Reader!";
2660 void ARTDAQTableBase::extractEventBuildersInfo(
ConfigurationTree artdaqSupervisorNode,
2661 bool getStatusFalseNodes,
2663 size_t maxFragmentSizeBytes)
2665 __COUT__ <<
"Checking for Event Builders..." << __E__;
2666 info_.processes[ARTDAQAppType::EventBuilder].clear();
2669 artdaqSupervisorNode.
getNode(colARTDAQSupervisor_.colLinkToEventBuilders_);
2672 std::vector<std::pair<std::string, ConfigurationTree>> builders =
2675 std::string lastBuilderFcl[2],
2676 flattenedLastFclParts
2678 for(
auto& builder : builders)
2680 const std::string& builderUID = builder.first;
2681 __COUTV__(builderUID);
2683 if(getStatusFalseNodes || builder.second.status())
2685 std::string builderHost =
2686 builder.second.getNode(ARTDAQTableBase::ARTDAQ_TYPE_TABLE_HOSTNAME)
2687 .getValueWithDefault(
"localhost");
2688 std::string builderAP =
2690 .getNode(ARTDAQTableBase::ARTDAQ_TYPE_TABLE_ALLOWED_PROCESSORS)
2691 .getValueWithDefault(
"");
2693 int builderSubsystemID = 1;
2695 builder.second.
getNode(ARTDAQ_TYPE_TABLE_SUBSYSTEM_LINK);
2698 builderSubsystemID = getSubsytemId(builderSubsystemLink);
2701 info_.subsystems[builderSubsystemID].id = builderSubsystemID;
2703 const std::string& builderSubsystemName =
2707 info_.subsystems[builderSubsystemID].label = builderSubsystemName;
2709 auto builderSubsystemDestinationLink = builderSubsystemLink.
getNode(
2710 colARTDAQSubsystem_.colLinkToDestination_);
2711 if(builderSubsystemDestinationLink.isDisconnected())
2714 info_.subsystems[builderSubsystemID].destination = 0;
2719 info_.subsystems[builderSubsystemID].destination =
2720 getSubsytemId(builderSubsystemDestinationLink);
2726 if(!info_.subsystems.count(
2727 info_.subsystems[builderSubsystemID].destination) ||
2728 !info_.subsystems[info_.subsystems[builderSubsystemID].destination]
2729 .sources.count(builderSubsystemID))
2731 info_.subsystems[info_.subsystems[builderSubsystemID].destination]
2732 .sources.insert(builderSubsystemID);
2737 __COUT__ <<
"Found Event Builder with UID " << builderUID
2738 <<
", on Hostname " << builderHost <<
", in Subsystem "
2739 << builderSubsystemID << __E__;
2740 info_.processes[ARTDAQAppType::EventBuilder].emplace_back(
2745 ARTDAQAppType::EventBuilder,
2746 builder.second.status());
2750 std::string returnFcl, processName;
2751 bool needToFlatten =
true;
2752 bool captureAsLastFcl =
2755 (&builder != &builders.back());
2757 ARTDAQAppType::EventBuilder,
2758 maxFragmentSizeBytes,
2759 DEFAULT_ROUTING_TIMEOUT_MS,
2760 DEFAULT_ROUTING_RETRY_COUNT,
2761 captureAsLastFcl ? &returnFcl :
nullptr);
2768 auto cmi = returnFcl.find(
2769 "# otsdaq-ARTDAQ builder UID:");
2770 if(cmi != std::string::npos)
2771 cmi = returnFcl.find(
'\n', cmi);
2772 if(cmi != std::string::npos)
2774 size_t pnj = std::string::npos;
2776 returnFcl.find(
"\tprocess_name: ", cmi);
2777 if(pni != std::string::npos)
2779 pni += std::string(
"\tprocess_name: ")
2781 pnj = returnFcl.find(
'\n', pni);
2783 if(pnj != std::string::npos)
2785 processName = returnFcl.substr(pni, pnj - pni);
2786 __COUT__ <<
"Found process name = " << processName << __E__;
2788 bool sameFirst =
false;
2790 std::string newPiece = returnFcl.substr(cmi, pni - cmi);
2791 if(flattenedLastFclParts[0].size() &&
2792 lastBuilderFcl[0].size() && lastBuilderFcl[0] == newPiece)
2794 __COUT__ <<
"Same first fcl" << __E__;
2799 __COUTVS__(20, lastBuilderFcl[0]);
2800 __COUTVS__(20, newPiece);
2801 for(
size_t i = 0, j = 0;
2802 i < lastBuilderFcl[0].size() && j < newPiece.size();
2805 if(lastBuilderFcl[0][i] != newPiece[j])
2809 __COUTVS__(20, lastBuilderFcl[0].substr(i, 30));
2810 __COUTVS__(20, newPiece.substr(j, 30));
2815 if(captureAsLastFcl)
2816 lastBuilderFcl[0] = newPiece;
2819 newPiece = returnFcl.substr(pnj);
2820 if(lastBuilderFcl[0].size() && lastBuilderFcl[1] == newPiece)
2822 __COUT__ <<
"Same second fcl" << __E__;
2825 std::chrono::steady_clock::time_point startClock =
2826 std::chrono::steady_clock::now();
2827 __COUT__ <<
"Found fcl match! Reuse for "
2828 << builderUID << __E__;
2831 needToFlatten =
false;
2834 std::string outFile = getFlatFHICLFilename(
2835 ARTDAQAppType::EventBuilder, builderUID);
2836 __COUTVS__(3, outFile);
2837 std::ofstream ofs{outFile};
2840 __SS__ <<
"Failed to open fhicl output file '"
2841 << outFile <<
"!'" << __E__;
2844 ofs << flattenedLastFclParts[0] <<
"process_name: \""
2845 << processName <<
"\""
2846 << flattenedLastFclParts[1];
2848 << builderUID <<
" Flatten Clock time = "
2849 << artdaq::TimeUtils::GetElapsedTime(startClock)
2854 if(captureAsLastFcl)
2855 lastBuilderFcl[1] = newPiece;
2860 ARTDAQTableBase::flattenFHICL(
2861 ARTDAQAppType::EventBuilder,
2863 captureAsLastFcl ? &returnFcl :
nullptr);
2865 __COUT__ <<
"Skipping full flatten for " << builderUID << __E__;
2868 __COUTV__(captureAsLastFcl);
2869 if(captureAsLastFcl)
2871 size_t pnj = std::string::npos;
2872 auto pni = returnFcl.find(
"process_name:");
2873 if(pni != std::string::npos)
2877 (returnFcl[pni - 1] ==
' ' || returnFcl[pni - 1] ==
'\n' ||
2878 returnFcl[pni - 1] ==
'\t'))
2879 pnj = returnFcl.find(
'\n', pni);
2881 if(pnj != std::string::npos)
2884 <<
"Found flattened '"
2885 << returnFcl.substr(pni, pnj - pni) <<
"' at pos " << pni
2886 <<
" of " << returnFcl.size() << __E__;
2887 flattenedLastFclParts[0] = returnFcl.substr(0, pni);
2888 flattenedLastFclParts[1] = returnFcl.substr(pnj);
2892 __COUT_WARN__ <<
"Failed to capture fcl for " << processName
2900 __COUT__ <<
"Event Builder " << builderUID <<
" is disabled." << __E__;
2906 __COUT_WARN__ <<
"There should be at least one Event Builder!";
2913 void ARTDAQTableBase::extractDataLoggersInfo(
ConfigurationTree artdaqSupervisorNode,
2914 bool getStatusFalseNodes,
2916 size_t maxFragmentSizeBytes)
2918 __COUT__ <<
"Checking for Data Loggers..." << __E__;
2919 info_.processes[ARTDAQAppType::DataLogger].clear();
2922 artdaqSupervisorNode.
getNode(colARTDAQSupervisor_.colLinkToDataLoggers_);
2925 std::vector<std::pair<std::string, ConfigurationTree>> dataloggers =
2928 for(
auto& datalogger : dataloggers)
2930 const std::string& loggerUID = datalogger.first;
2932 if(getStatusFalseNodes || datalogger.second.status())
2934 std::string loggerHost =
2935 datalogger.second.getNode(ARTDAQTableBase::ARTDAQ_TYPE_TABLE_HOSTNAME)
2936 .getValueWithDefault(
"localhost");
2937 std::string loggerAP =
2939 .getNode(ARTDAQTableBase::ARTDAQ_TYPE_TABLE_ALLOWED_PROCESSORS)
2940 .getValueWithDefault(
"");
2942 int loggerSubsystemID = 1;
2944 datalogger.second.
getNode(ARTDAQ_TYPE_TABLE_SUBSYSTEM_LINK);
2947 loggerSubsystemID = getSubsytemId(loggerSubsystemLink);
2949 info_.subsystems[loggerSubsystemID].id = loggerSubsystemID;
2951 const std::string& loggerSubsystemName =
2955 info_.subsystems[loggerSubsystemID].label = loggerSubsystemName;
2957 auto loggerSubsystemDestinationLink = loggerSubsystemLink.
getNode(
2958 colARTDAQSubsystem_.colLinkToDestination_);
2959 if(loggerSubsystemDestinationLink.isDisconnected())
2962 info_.subsystems[loggerSubsystemID].destination = 0;
2967 info_.subsystems[loggerSubsystemID].destination =
2968 getSubsytemId(loggerSubsystemDestinationLink);
2974 if(!info_.subsystems.count(
2975 info_.subsystems[loggerSubsystemID].destination) ||
2976 !info_.subsystems[info_.subsystems[loggerSubsystemID].destination]
2977 .sources.count(loggerSubsystemID))
2979 info_.subsystems[info_.subsystems[loggerSubsystemID].destination]
2980 .sources.insert(loggerSubsystemID);
2985 __COUT__ <<
"Found Data Logger with UID " << loggerUID
2986 <<
", DAQInterface Hostname " << loggerHost <<
", and Subsystem "
2987 << loggerSubsystemID << __E__;
2988 info_.processes[ARTDAQAppType::DataLogger].emplace_back(
2993 ARTDAQAppType::DataLogger,
2994 datalogger.second.status());
2999 ARTDAQAppType::DataLogger,
3000 maxFragmentSizeBytes);
3002 flattenFHICL(ARTDAQAppType::DataLogger, datalogger.second.getValue());
3007 __COUT__ <<
"Data Logger " << loggerUID <<
" is disabled." << __E__;
3013 __COUT_WARN__ <<
"There were no Data Loggers found!";
3018 void ARTDAQTableBase::extractDispatchersInfo(
ConfigurationTree artdaqSupervisorNode,
3019 bool getStatusFalseNodes,
3021 size_t maxFragmentSizeBytes)
3023 __COUT__ <<
"Checking for Dispatchers..." << __E__;
3024 info_.processes[ARTDAQAppType::Dispatcher].clear();
3027 artdaqSupervisorNode.
getNode(colARTDAQSupervisor_.colLinkToDispatchers_);
3030 std::vector<std::pair<std::string, ConfigurationTree>> dispatchers =
3033 for(
auto& dispatcher : dispatchers)
3035 const std::string& dispatcherUID = dispatcher.first;
3037 if(getStatusFalseNodes || dispatcher.second.status())
3039 std::string dispatcherHost =
3040 dispatcher.second.getNode(ARTDAQTableBase::ARTDAQ_TYPE_TABLE_HOSTNAME)
3041 .getValueWithDefault(
"localhost");
3042 std::string dispatcherAP =
3044 .getNode(ARTDAQTableBase::ARTDAQ_TYPE_TABLE_ALLOWED_PROCESSORS)
3045 .getValueWithDefault(
"");
3046 int dispatcherPort =
3047 dispatcher.second.getNode(
"DispatcherPort").getValue<
int>();
3049 auto dispatcherSubsystemID = 1;
3051 dispatcher.second.
getNode(ARTDAQ_TYPE_TABLE_SUBSYSTEM_LINK);
3054 dispatcherSubsystemID = getSubsytemId(dispatcherSubsystemLink);
3056 info_.subsystems[dispatcherSubsystemID].id = dispatcherSubsystemID;
3058 const std::string& dispatcherSubsystemName =
3062 info_.subsystems[dispatcherSubsystemID].label =
3063 dispatcherSubsystemName;
3065 auto dispatcherSubsystemDestinationLink =
3066 dispatcherSubsystemLink.
getNode(
3067 colARTDAQSubsystem_.colLinkToDestination_);
3068 if(dispatcherSubsystemDestinationLink.isDisconnected())
3071 info_.subsystems[dispatcherSubsystemID].destination = 0;
3076 info_.subsystems[dispatcherSubsystemID].destination =
3077 getSubsytemId(dispatcherSubsystemDestinationLink);
3083 if(!info_.subsystems.count(
3084 info_.subsystems[dispatcherSubsystemID].destination) ||
3086 .subsystems[info_.subsystems[dispatcherSubsystemID]
3088 .sources.count(dispatcherSubsystemID))
3091 .subsystems[info_.subsystems[dispatcherSubsystemID]
3093 .sources.insert(dispatcherSubsystemID);
3097 __COUT__ <<
"Found Dispatcher with UID " << dispatcherUID
3098 <<
", DAQInterface Hostname " << dispatcherHost
3099 <<
", and Subsystem " << dispatcherSubsystemID << __E__;
3100 info_.processes[ARTDAQAppType::Dispatcher].emplace_back(
3104 dispatcherSubsystemID,
3105 ARTDAQAppType::Dispatcher,
3106 dispatcher.second.status(),
3112 ARTDAQAppType::Dispatcher,
3113 maxFragmentSizeBytes);
3115 flattenFHICL(ARTDAQAppType::Dispatcher, dispatcher.second.getValue());
3120 __COUT__ <<
"Dispatcher " << dispatcherUID <<
" is disabled." << __E__;
3126 __COUT_WARN__ <<
"There were no Dispatchers found!";
3136 for(
auto context : contexts)
3138 if(!context.second.isEnabled())
3141 auto apps = context.second
3142 .getNode(XDAQContextTable::colContext_.colLinkToApplicationTable_)
3144 for(
auto app : apps)
3147 if(app.second.getNode(XDAQContextTable::colApplication_.colClass_)
3148 .getValue() == ARTDAQ_SUPERVISOR_CLASS &&
3149 app.second.isEnabled())
3167 std::map<std::string ,
3168 std::map<std::string , std::vector<std::string /*property*/>>>&
3169 nodeTypeToObjectMap,
3170 std::map<std::string /*subsystemName*/, std::string /*destinationSubsystemName*/>&
3172 std::vector<std::string /*property*/>& artdaqSupervisoInfo)
3174 __COUT__ <<
"getARTDAQSystem()" << __E__;
3176 artdaqSupervisoInfo.clear();
3187 return ARTDAQTableBase::info_;
3189 __COUTV__(artdaqContext->contextUID_);
3190 __COUTV__(artdaqContext->applications_.size());
3193 std::map<std::string , std::set<std::string >> nodeLayoutNames;
3195 const std::string& finalContextGroupName =
3196 cfgMgr->getActiveGroupName(ConfigurationManager::GroupType::CONTEXT_TYPE);
3198 cfgMgr->getActiveGroupKey(ConfigurationManager::GroupType::CONTEXT_TYPE);
3199 const std::string& finalConfigGroupName = cfgMgr->getActiveGroupName(
3200 ConfigurationManager::GroupType::CONFIGURATION_TYPE);
3201 const TableGroupKey& finalConfigGroupKey = cfgMgr->getActiveGroupKey(
3202 ConfigurationManager::GroupType::CONFIGURATION_TYPE);
3207 std::stringstream layoutPath;
3208 layoutPath << ARTDAQTableBase::ARTDAQ_CONFIG_LAYOUTS_PATH
3209 << finalContextGroupName <<
"_" << finalContextGroupKey <<
"."
3210 << finalConfigGroupName <<
"_" << finalConfigGroupKey <<
".dat";
3212 fp = fopen(layoutPath.str().c_str(),
"r");
3215 __COUT__ <<
"Layout file not found for '" << finalContextGroupName <<
"("
3216 << finalContextGroupKey <<
") + " << finalConfigGroupName <<
"("
3217 << finalConfigGroupKey <<
")': " << layoutPath.
str() << __E__;
3221 __COUTV__(layoutPath.str());
3225 std::stringstream layoutPath;
3226 layoutPath << ARTDAQTableBase::ARTDAQ_CONFIG_LAYOUTS_PATH
3227 << finalContextGroupName <<
"_" << finalContextGroupKey <<
".dat";
3228 __COUTV__(layoutPath.str());
3230 fp = fopen(layoutPath.str().c_str(),
"r");
3233 __COUT__ <<
"Layout file not found for '" << finalContextGroupName <<
"("
3234 << finalContextGroupKey <<
")': " << layoutPath.str() << __E__;
3237 __COUTV__(layoutPath.str());
3243 struct dirent* entry;
3248 float bestScore = 0, score;
3249 std::string bestName =
"";
3251 if(!(pDIR = opendir((ARTDAQTableBase::ARTDAQ_CONFIG_LAYOUTS_PATH).c_str())))
3253 __SS__ <<
"Path '" << ARTDAQTableBase::ARTDAQ_CONFIG_LAYOUTS_PATH
3254 <<
"' could not be opened!" << __E__;
3259 while((entry = readdir(pDIR)))
3261 name = std::string(entry->d_name);
3262 type = int(entry->d_type);
3264 __COUTS__(2) << type <<
" " << name <<
"\n" << std::endl;
3266 if(name[0] !=
'.' &&
3276 if(type == 0 || type == 10)
3279 DIR* pTmpDIR = opendir(
3280 (ARTDAQTableBase::ARTDAQ_CONFIG_LAYOUTS_PATH +
"/" + name)
3288 __COUTS__(2) <<
"Unable to open path as directory: "
3289 << (ARTDAQTableBase::ARTDAQ_CONFIG_LAYOUTS_PATH +
3301 __COUTS__(2) <<
"Directory: " << type <<
" " << name << __E__;
3305 __COUTS__(2) <<
"File: " << type <<
" " << name <<
"\n"
3307 if(name.find(
".dat") !=
3311 __COUTS__(2) <<
"Contender: " << name <<
"\n" << std::endl;
3316 if(nameSplit.size() > 1)
3319 auto keyi = nameSplit[1].rfind(
'_');
3320 if(keyi != std::string::npos)
3324 .substr(keyi, nameSplit[1].size() - 4 - keyi)
3328 finalConfigGroupKey.key() -
3334 __COUTVS__(2, tmpscore);
3338 __COUTVS__(2, tmpscore);
3341 std::string nameToCompare = nameSplit[1].substr(0, keyi);
3342 __COUTVS__(2, nameToCompare);
3343 size_t i = 0, j = 0;
3345 for(; i < nameToCompare.size() &&
3346 j < finalConfigGroupName.size();
3349 if(nameToCompare[i] == finalConfigGroupName[j])
3355 __COUTVS__(2, tmpscore);
3357 for(; i < nameToCompare.size() &&
3358 j < finalConfigGroupName.size();
3361 if(nameToCompare[i] == finalConfigGroupName[j])
3367 __COUTVS__(2, tmpscore);
3370 __COUTVS__(2, score);
3372 if(nameSplit.size() > 0)
3375 auto keyi = nameSplit[0].rfind(
'_');
3376 if(keyi != std::string::npos)
3380 .substr(keyi, nameSplit[0].size() - 4 - keyi)
3384 finalContextGroupKey.key() -
3390 __COUTVS__(2, tmpscore);
3394 __COUTVS__(2, tmpscore);
3397 std::string nameToCompare = nameSplit[0].substr(0, keyi);
3398 __COUTVS__(2, nameToCompare);
3399 size_t i = 0, j = 0;
3401 for(; i < nameToCompare.size() &&
3402 j < finalContextGroupName.size();
3405 if(nameToCompare[i] == finalContextGroupName[j])
3411 __COUTVS__(2, tmpscore);
3413 for(; i < nameToCompare.size() &&
3414 j < finalContextGroupName.size();
3417 if(nameToCompare[i] == finalContextGroupName[j])
3423 __COUTVS__(2, tmpscore);
3426 __COUTVS__(2, score);
3429 if(score > bestScore)
3433 __COUTVS__(2, bestName);
3441 __COUT__ <<
"Found closest layout file name: " << bestName <<
".dat"
3443 std::stringstream layoutPath;
3444 layoutPath << ARTDAQTableBase::ARTDAQ_CONFIG_LAYOUTS_PATH << bestName
3446 __COUTV__(layoutPath.str());
3447 fp = fopen(layoutPath.str().c_str(),
"r");
3450 __COUT__ <<
"Closest layout file not found for '" << bestName <<
"'"
3460 __COUT__ <<
"Extract info from layout file.." << __E__;
3466 const size_t maxLineSz = 1000;
3467 char line[maxLineSz];
3468 if(!fgets(line, maxLineSz, fp))
3471 __COUT__ <<
"No layout naming info found." << __E__;
3477 char name[maxLineSz];
3478 char type[maxLineSz];
3480 while(fgets(line, maxLineSz, fp))
3483 sscanf(line,
"%s %s %u %u", type, name, &x, &y);
3484 nodeLayoutNames[type].emplace(name);
3499 for(
auto& artdaqApp : artdaqContext->applications_)
3501 if(artdaqApp.class_ != ARTDAQ_SUPERVISOR_CLASS)
3504 __COUTV__(artdaqApp.applicationUID_);
3505 artdaqSupervisoInfo.push_back(artdaqApp.applicationUID_);
3506 artdaqSupervisoInfo.push_back(
3507 (artdaqContext->status_ && artdaqApp.status_) ?
"1" :
"0");
3508 artdaqSupervisoInfo.push_back(artdaqContext->address_);
3509 artdaqSupervisoInfo.push_back(std::to_string(artdaqContext->port_));
3512 XDAQContextTable::getSupervisorConfigNode(
3514 artdaqContext->contextUID_,
3515 artdaqApp.applicationUID_),
3518 __COUT__ <<
"========== "
3519 <<
"Found " << info.subsystems.size() <<
" subsystems." << __E__;
3522 for(
auto& subsystem : info.subsystems)
3523 subsystemObjectMap.emplace(std::make_pair(
3524 subsystem.second.label, std::to_string(subsystem.second.destination)));
3526 __COUT__ <<
"========== "
3527 <<
"Found " << info.processes.size() <<
" process types." << __E__;
3531 const std::string& typeString = nameTypePair.first;
3532 __COUTV__(typeString);
3534 nodeTypeToObjectMap.emplace(
3535 std::make_pair(typeString,
3536 std::map<std::string ,
3537 std::vector<std::string /*property*/>>()));
3539 auto it = info.processes.find(nameTypePair.second);
3540 if(it == info.processes.end())
3543 <<
"Found 0 " << typeString << __E__;
3547 <<
"Found " << it->second.size() <<
" " << typeString <<
"(s)"
3553 __SS__ <<
"Invalid artdaq node type '" << typeString <<
"' attempted!"
3557 __COUTV__(tableIt->second);
3560 std::stringstream ss;
3561 cfgMgr->getTableByName(tableIt->second)->getView().print(ss);
3562 __COUT_MULTI__(1, ss.str());
3572 const std::set<std::string > skipColumns(
3573 {ARTDAQ_TYPE_TABLE_HOSTNAME,
3574 ARTDAQ_TYPE_TABLE_ALLOWED_PROCESSORS,
3575 ARTDAQ_TYPE_TABLE_SUBSYSTEM_LINK,
3577 .colDaqFragmentIDs_,
3578 TableViewColumnInfo::COL_NAME_COMMENT,
3579 TableViewColumnInfo::COL_NAME_AUTHOR,
3580 TableViewColumnInfo::
3581 COL_NAME_CREATION});
3583 if(TTEST(1) && nodeLayoutNames.find(typeString) != nodeLayoutNames.end())
3589 for(
auto& artdaqNode : it->second)
3592 if(skipSet.find(StringMacros::encodeURIComponent(artdaqNode.label)) !=
3597 <<
"Found '" << artdaqNode.label <<
"' " << typeString << __E__;
3599 std::string nodeName = artdaqNode.label;
3600 bool status = artdaqNode.status;
3601 std::string hostname = artdaqNode.hostname;
3602 std::string subsystemId = std::to_string(artdaqNode.subsystem);
3603 std::string subsystemName =
3604 info.subsystems.at(artdaqNode.subsystem).label;
3615 std::vector<std::string> multiNodeNames, hostnameArray;
3620 StringMacros::encodeURIComponent(nodeName));
3622 __COUTV__(allNodes.size());
3623 for(
auto& otherNode : allNodes)
3625 if(skipSet.find(StringMacros::encodeURIComponent(otherNode.first)) !=
3627 otherNode.second.status() != status)
3634 otherNode.second.getNode(ARTDAQ_TYPE_TABLE_SUBSYSTEM_LINK_UID)
3643 auto otherNodeColumns = otherNode.second.getChildren();
3645 bool isMultiNode =
true;
3646 for(
unsigned int i = 0;
3647 i < thisNodeColumns.size() && i < otherNodeColumns.size();
3651 if(skipColumns.find(thisNodeColumns[i].first) !=
3652 skipColumns.end() ||
3653 thisNodeColumns[i].second.isLinkNode())
3664 if(thisNodeColumns[i].second.getValue() !=
3665 otherNodeColumns[i].second.getValue())
3667 __COUT__ <<
"Mismatch, not multi-node member." << __E__;
3668 isMultiNode =
false;
3675 __COUT__ <<
"Found '" << nodeName
3676 <<
"' multi-node member candidate '"
3677 << otherNode.first <<
"'" << __E__;
3680 if(!multiNodeNames.size())
3682 multiNodeNames.push_back(
3683 StringMacros::encodeURIComponent(nodeName));
3684 hostnameArray.push_back(
3685 StringMacros::encodeURIComponent(hostname));
3687 multiNodeNames.push_back(
3688 StringMacros::encodeURIComponent(otherNode.first));
3689 hostnameArray.push_back(StringMacros::encodeURIComponent(
3690 otherNode.second.getNode(ARTDAQ_TYPE_TABLE_HOSTNAME)
3693 __COUTV__(hostnameArray.back());
3695 StringMacros::encodeURIComponent(otherNode.first));
3700 unsigned int nodeFixedWildcardLength = 0, hostFixedWildcardLength = 0;
3701 std::string multiNodeString =
"", hostArrayString =
"";
3703 __COUTV__(nodeName);
3705 if(multiNodeNames.size() > 1)
3707 __COUT__ <<
"Handling multi-node printer syntax" << __E__;
3714 if(nodeLayoutNames.find(typeString) != nodeLayoutNames.end())
3722 std::string bestNodeLayoutName =
"";
3723 size_t bestNodeLayoutMatchCount =
3724 multiNodeNames.size() + 1;
3726 for(
const auto& layoutNameFull : nodeLayoutNames.at(typeString))
3728 __COUTTV__(layoutNameFull);
3729 size_t statusPos = layoutNameFull.find(
";status=");
3730 std::string layoutName = layoutNameFull.substr(0, statusPos);
3731 bool layoutStatus =
true;
3735 layoutStatus = status;
3737 layoutNameFull.substr(statusPos +
3738 std::string(
";status=").size()))
3739 layoutStatus =
false;
3741 __COUTTV__(layoutStatus);
3743 if(layoutStatus != status)
3745 __COUTT__ <<
"Status mismatch for template" << __E__;
3753 bool exactMatch =
true;
3755 for(
const auto& layoutSeg : layoutSplit)
3756 if((pos = nodeName.find(layoutSeg, pos)) ==
3759 __COUTT__ <<
"Did not find '" << layoutSeg <<
"' in '"
3760 << nodeName <<
"'" << __E__;
3765 __COUTTV__(exactMatch);
3768 size_t nodeLayoutMatchCount = 1;
3770 __COUT__ <<
"Found layout template name match! '"
3771 << layoutName <<
"' for node '" << nodeName
3772 <<
".' Trimming multinode candidates to match..."
3775 for(
unsigned int i = 1; i < multiNodeNames.size(); ++i)
3777 __COUTTV__(multiNodeNames[i]);
3778 std::string multiNodeName =
3781 __COUTTV__(multiNodeName);
3782 bool exactMatch =
true;
3784 for(
const auto& layoutSeg : layoutSplit)
3785 if((pos = multiNodeName.find(layoutSeg, pos)) ==
3788 __COUTT__ <<
"Did not find '" << layoutSeg
3789 <<
"' in '" << multiNodeName <<
"'"
3797 ++nodeLayoutMatchCount;
3798 __COUTT__ <<
"Found '" << layoutName <<
"' in '"
3799 << multiNodeName <<
"'" << __E__;
3804 __COUTTV__(nodeLayoutMatchCount);
3805 if(nodeLayoutMatchCount < bestNodeLayoutMatchCount)
3807 bestNodeLayoutName = layoutNameFull;
3808 bestNodeLayoutMatchCount = nodeLayoutMatchCount;
3809 __COUTTV__(bestNodeLayoutName);
3810 __COUTTV__(bestNodeLayoutMatchCount);
3815 __COUTV__(nodeName);
3821 if(bestNodeLayoutMatchCount > 0)
3823 __COUTV__(bestNodeLayoutName);
3824 std::string layoutNameFull = bestNodeLayoutName;
3825 __COUTTV__(layoutNameFull);
3826 size_t statusPos = layoutNameFull.find(
";status=");
3827 std::string layoutName = layoutNameFull.substr(0, statusPos);
3833 __COUT__ <<
"Found layout template name match! '"
3834 << layoutName <<
"' for node '" << nodeName
3835 <<
".' Trimming multinode candidates to match..."
3838 for(
unsigned int i = 1; i < multiNodeNames.size(); ++i)
3840 __COUTTV__(multiNodeNames[i]);
3841 std::string multiNodeName =
3843 __COUTTV__(multiNodeName);
3844 bool exactMatch =
true;
3846 for(
const auto& layoutSeg : layoutSplit)
3847 if((pos = multiNodeName.find(layoutSeg, pos)) ==
3850 __COUTT__ <<
"Did not find '" << layoutSeg
3851 <<
"' in '" << multiNodeName <<
"'"
3859 __COUT__ <<
"Trimming multinode candidate '"
3860 << multiNodeName <<
"'" << __E__;
3861 skipSet.erase(multiNodeNames[i]);
3862 multiNodeNames.erase(multiNodeNames.begin() + i);
3863 hostnameArray.erase(hostnameArray.begin() + i);
3870 __COUTV__(nodeName);
3877 unsigned int maxScore = 0;
3879 unsigned int minScore = -1;
3880 std::vector<unsigned int> scoreVector;
3881 scoreVector.push_back(-1);
3882 for(
unsigned int i = 1; i < multiNodeNames.size(); ++i)
3886 __COUTS__(3) << multiNodeNames[0] <<
" vs "
3887 << multiNodeNames[i] << __E__;
3890 for(
unsigned int j = 0, k = 0; j < multiNodeNames[0].size() &&
3891 k < multiNodeNames[i].size();
3894 while(j < multiNodeNames[0].size() &&
3895 !(multiNodeNames[0][j] >=
'a' &&
3896 multiNodeNames[0][j] <=
'z') &&
3897 !(multiNodeNames[0][j] >=
'A' &&
3898 multiNodeNames[0][j] <=
'Z'))
3900 while(k < multiNodeNames[i].size() &&
3901 !(multiNodeNames[i][k] >=
'a' &&
3902 multiNodeNames[i][k] <=
'z') &&
3903 !(multiNodeNames[i][k] >=
'A' &&
3904 multiNodeNames[i][k] <=
'Z'))
3907 while(k < multiNodeNames[i].size() &&
3908 multiNodeNames[0][j] != multiNodeNames[i][k])
3912 << j <<
"-" << k <<
" of " << multiNodeNames[0].size()
3913 <<
"-" << multiNodeNames[i].size() << __E__;
3915 if(j < multiNodeNames[0].size() &&
3916 k < multiNodeNames[i].size())
3920 __COUTVS__(3, score);
3923 for(
unsigned int j = multiNodeNames[0].size() - 1,
3924 k = multiNodeNames[i].size() - 1;
3925 j < multiNodeNames[0].size() &&
3926 k < multiNodeNames[i].size();
3929 while(j < multiNodeNames[0].size() &&
3930 !(multiNodeNames[0][j] >=
'a' &&
3931 multiNodeNames[0][j] <=
'z') &&
3932 !(multiNodeNames[0][j] >=
'A' &&
3933 multiNodeNames[0][j] <=
'Z'))
3935 while(k < multiNodeNames[i].size() &&
3936 !(multiNodeNames[i][k] >=
'a' &&
3937 multiNodeNames[i][k] <=
'z') &&
3938 !(multiNodeNames[i][k] >=
'A' &&
3939 multiNodeNames[i][k] <=
'Z'))
3942 while(k < multiNodeNames[i].size() &&
3943 multiNodeNames[0][j] != multiNodeNames[i][k])
3946 __COUTS__(3) <<
"BACK" << j <<
"-" << k <<
" of "
3947 << multiNodeNames[0].size() <<
"-"
3948 << multiNodeNames[i].size() << __E__;
3950 if(j < multiNodeNames[0].size() &&
3951 k < multiNodeNames[i].size())
3955 __COUTVS__(3, score / 2.0);
3957 scoreVector.push_back(score);
3959 if(score > maxScore)
3964 if(score < minScore)
3971 __COUTVS__(2, minScore);
3972 __COUTVS__(2, maxScore);
3974 __COUT__ <<
"Trimming multi-node members with low match score..."
3979 for(
unsigned int i = multiNodeNames.size() - 1;
3980 i > 0 && i < multiNodeNames.size();
3985 if(maxScore > multiNodeNames[0].size() &&
3986 scoreVector[i] >= maxScore)
3990 __COUT__ <<
"Trimming low score match " << multiNodeNames[i]
3991 <<
" for node name " << nodeName << __E__;
3993 skipSet.erase(multiNodeNames[i]);
3994 multiNodeNames.erase(multiNodeNames.begin() + i);
3995 hostnameArray.erase(hostnameArray.begin() + i);
4001 __COUTV__(nodeName);
4008 __COUT__ <<
"Reorganizing multinode '" << nodeName
4009 <<
"' alphabetically..." << __E__;
4011 std::pair<std::string , std::string >>
4013 for(
unsigned int i = 0; i < multiNodeNames.size(); ++i)
4015 std::make_pair(multiNodeNames[i], hostnameArray[i]));
4020 multiNodeNames.clear();
4021 hostnameArray.clear();
4022 for(
const auto& orderedPair : reorderSet)
4024 multiNodeNames.push_back(orderedPair.first);
4025 hostnameArray.push_back(orderedPair.second);
4029 __COUTV__(nodeName);
4035 if(multiNodeNames.size() > 1)
4037 std::vector<std::string> commonChunks;
4038 std::vector<std::string> wildcards;
4042 bool wildcardsNeeded =
4046 nodeFixedWildcardLength);
4048 if(!wildcardsNeeded || wildcards.size() != multiNodeNames.size())
4051 <<
"Impossible extractCommonChunks result! Please notify "
4052 "admins or try to simplify record naming convention."
4062 for(
auto& commonChunk : commonChunks)
4064 nodeName += (!first ?
"*" :
"") + commonChunk;
4068 if(commonChunks.size() == 1)
4071 __COUTV__(nodeName);
4078 bool allIntegers =
true;
4079 for(
auto& wildcard : wildcards)
4082 else if(wildcard.size() == 0)
4084 allIntegers =
false;
4088 for(
unsigned int i = 0; i < wildcard.size(); ++i)
4089 if(!(wildcard[i] >=
'0' && wildcard[i] <=
'9'))
4091 allIntegers =
false;
4095 __COUTV__(allIntegers);
4101 std::vector<unsigned int> intWildcards;
4102 for(
auto& wildcard : wildcards)
4103 intWildcards.push_back(strtol(wildcard.c_str(), 0, 10));
4107 unsigned int hyphenLo = -1;
4108 bool isFirst =
true;
4109 for(
unsigned int i = 0; i < intWildcards.size(); ++i)
4111 if(i + 1 < intWildcards.size() &&
4112 intWildcards[i] + 1 == intWildcards[i + 1])
4124 (isFirst ?
"" :
",") +
4125 std::to_string(intWildcards[i]);
4130 if(intWildcards[hyphenLo] + 1 == intWildcards[i])
4132 (isFirst ?
"" :
",") +
4133 std::to_string(intWildcards[hyphenLo]) +
4134 "," + std::to_string(intWildcards[i]);
4137 (isFirst ?
"" :
",") +
4138 std::to_string(intWildcards[hyphenLo]) +
4139 "-" + std::to_string(intWildcards[i]);
4149 nodeFixedWildcardLength =
4153 __COUTV__(multiNodeString);
4154 __COUTV__(nodeFixedWildcardLength);
4157 if(hostnameArray.size() > 1)
4159 std::vector<std::string> commonChunks;
4160 std::vector<std::string> wildcards;
4164 bool wildcardsNeeded =
4168 hostFixedWildcardLength);
4170 __COUTV__(wildcardsNeeded);
4176 for(
auto& commonChunk : commonChunks)
4178 hostname += (!first ?
"*" :
"") + commonChunk;
4182 if(wildcardsNeeded && commonChunks.size() == 1)
4185 __COUTV__(hostname);
4195 bool allIntegers =
true;
4196 for(
auto& wildcard : wildcards)
4197 for(
unsigned int i = 0; i < wildcard.size(); ++i)
4198 if(!(wildcard[i] >=
'0' && wildcard[i] <=
'9'))
4200 allIntegers =
false;
4204 __COUTV__(allIntegers);
4211 std::vector<unsigned int> intWildcards;
4212 for(
auto& wildcard : wildcards)
4213 intWildcards.push_back(
4214 strtol(wildcard.c_str(), 0, 10));
4218 unsigned int hyphenLo = -1;
4219 bool isFirst =
true;
4220 for(
unsigned int i = 0; i < intWildcards.size(); ++i)
4222 if(i + 1 < intWildcards.size() &&
4223 intWildcards[i] + 1 == intWildcards[i + 1])
4235 (isFirst ?
"" :
",") +
4236 std::to_string(intWildcards[i]);
4241 if(intWildcards[hyphenLo] + 1 ==
4244 (isFirst ?
"" :
",") +
4246 intWildcards[hyphenLo]) +
4247 "," + std::to_string(intWildcards[i]);
4250 (isFirst ?
"" :
",") +
4252 intWildcards[hyphenLo]) +
4253 "-" + std::to_string(intWildcards[i]);
4263 hostFixedWildcardLength =
4267 __COUTV__(hostArrayString);
4268 __COUTV__(hostFixedWildcardLength);
4278 auto result = nodeTypeToObjectMap.at(typeString)
4279 .emplace(std::make_pair(
4280 nodeName, std::vector<std::string /*property*/>()));
4283 __SS__ <<
"Impossible printer syntax handling result! Collision of "
4284 "base names. Please notify "
4285 "admins or try to simplify record naming convention."
4290 nodeTypeToObjectMap.at(typeString)
4292 .push_back(status ?
"1" :
"0");
4294 nodeTypeToObjectMap.at(typeString).at(nodeName).push_back(hostname);
4296 nodeTypeToObjectMap.at(typeString).at(nodeName).push_back(subsystemId);
4297 if(multiNodeNames.size() > 1)
4299 nodeTypeToObjectMap.at(typeString)
4301 .push_back(multiNodeString);
4303 nodeTypeToObjectMap.at(typeString)
4305 .push_back(std::to_string(nodeFixedWildcardLength));
4307 if(hostnameArray.size() > 1)
4309 nodeTypeToObjectMap.at(typeString)
4311 .push_back(hostArrayString);
4313 nodeTypeToObjectMap.at(typeString)
4315 .push_back(std::to_string(hostFixedWildcardLength));
4319 __COUTV__(multiNodeString);
4321 __COUTV__(hostArrayString);
4322 __COUT__ <<
"Done with extraction of node '" << nodeName <<
"'" << __E__;
4328 __COUT__ <<
"Done getting artdaq nodes." << __E__;
4330 return ARTDAQTableBase::info_;
4344 const std::map<std::string ,
4345 std::map<std::string ,
4346 std::vector<std::string /*property*/>>>& nodeTypeToObjectMap,
4347 const std::map<std::string ,
4348 std::string >& subsystemObjectMap)
4350 __COUT__ <<
"setAndActivateARTDAQSystem()" << __E__;
4352 const std::string& author = cfgMgr->
getUsername();
4363 GroupEditStruct configGroupEdit(ConfigurationManager::GroupType::CONFIGURATION_TYPE,
4366 unsigned int artdaqSupervisorRow = TableView::INVALID;
4373 bool needArtdaqSupervisorParents =
true;
4374 bool needArtdaqSupervisorCreation =
false;
4376 __COUTV__(artdaqContext);
4381 const std::string& activeContextGroupName =
4382 cfgMgr->getActiveGroupName(ConfigurationManager::GroupType::CONTEXT_TYPE);
4384 cfgMgr->getActiveGroupKey(ConfigurationManager::GroupType::CONTEXT_TYPE);
4385 const std::string& activeConfigGroupName = cfgMgr->getActiveGroupName(
4386 ConfigurationManager::GroupType::CONFIGURATION_TYPE);
4387 const TableGroupKey& activeConfigGroupKey = cfgMgr->getActiveGroupKey(
4388 ConfigurationManager::GroupType::CONFIGURATION_TYPE);
4390 __COUTV__(activeContextGroupName);
4391 __COUTV__(activeContextGroupKey);
4392 __COUTV__(activeConfigGroupName);
4393 __COUTV__(activeConfigGroupKey);
4394 __COUTV__(cfgMgr->
getNode(ConfigurationManager::XDAQ_CONTEXT_TABLE_NAME)
4395 .
getNode(artdaqContext->contextUID_)
4398 cfgMgr->
getNode(ConfigurationManager::XDAQ_CONTEXT_TABLE_NAME)
4399 .
getNode(artdaqContext->contextUID_)
4400 .
getNode(XDAQContextTable::colContext_.colLinkToApplicationTable_)
4403 cfgMgr->
getNode(ConfigurationManager::XDAQ_CONTEXT_TABLE_NAME)
4404 .
getNode(artdaqContext->contextUID_)
4405 .
getNode(XDAQContextTable::colContext_.colLinkToApplicationTable_)
4406 .
getNode(artdaqContext->applications_[0].applicationUID_)
4408 __COUTV__(artdaqContext->applications_[0].applicationUID_);
4409 __COUTV__(XDAQContextTable::colApplication_.colLinkToSupervisorTable_);
4411 cfgMgr->
getNode(ConfigurationManager::XDAQ_CONTEXT_TABLE_NAME)
4412 .
getNode(artdaqContext->contextUID_)
4413 .
getNode(XDAQContextTable::colContext_.colLinkToApplicationTable_)
4414 .
getNode(artdaqContext->applications_[0].applicationUID_)
4415 .
getNode(XDAQContextTable::colApplication_.colLinkToSupervisorTable_)
4419 cfgMgr->
getNode(ConfigurationManager::XDAQ_CONTEXT_TABLE_NAME)
4420 .
getNode(artdaqContext->contextUID_)
4421 .
getNode(XDAQContextTable::colContext_.colLinkToApplicationTable_)
4422 .
getNode(artdaqContext->applications_[0].applicationUID_)
4423 .
getNode(XDAQContextTable::colApplication_.colLinkToSupervisorTable_);
4428 needArtdaqSupervisorCreation =
true;
4430 artdaqSupervisorRow = artdaqSupervisorNode.
getRow();
4432 needArtdaqSupervisorParents =
false;
4436 needArtdaqSupervisorCreation =
true;
4438 __COUTV__(needArtdaqSupervisorCreation);
4441 if(!artdaqContext || needArtdaqSupervisorCreation)
4443 __COUT__ <<
"No artdaq Supervisor found! Creating..." << __E__;
4444 __COUTV__(needArtdaqSupervisorParents);
4446 std::string artdaqSupervisorUID;
4455 ARTDAQ_SUPERVISOR_TABLE,
true );
4459 std::stringstream ss;
4460 artdaqSupervisorTable.tableView_->print(ss);
4461 __COUT_MULTI__(0, ss.str());
4465 row = artdaqSupervisorTable.tableView_->
addRow(
4466 author,
true ,
"artdaqSupervisor");
4469 artdaqSupervisorUID =
4470 artdaqSupervisorTable.tableView_
4471 ->getDataView()[row][artdaqSupervisorTable.tableView_->
getColUID()];
4472 artdaqSupervisorRow = row;
4474 __COUTV__(artdaqSupervisorRow);
4475 __COUTV__(artdaqSupervisorUID);
4481 artdaqSupervisorTable.tableView_->
findCol(
4482 colARTDAQSupervisor_.colDAQInterfaceDebugLevel_));
4485 "${MRB_BUILDDIR}/../setup_ots.sh",
4487 artdaqSupervisorTable.tableView_->
findCol(
4488 colARTDAQSupervisor_.colDAQSetupScript_));
4492 ARTDAQ_READER_TABLE,
4494 artdaqSupervisorTable.tableView_->
findCol(
4495 colARTDAQSupervisor_.colLinkToBoardReaders_));
4499 artdaqSupervisorTable.tableView_->
findCol(
4500 colARTDAQSupervisor_.colLinkToBoardReadersGroupID_),
4501 artdaqSupervisorUID +
4505 ARTDAQ_BUILDER_TABLE,
4507 artdaqSupervisorTable.tableView_->
findCol(
4508 colARTDAQSupervisor_.colLinkToEventBuilders_));
4511 artdaqSupervisorTable.tableView_->
findCol(
4512 colARTDAQSupervisor_.colLinkToEventBuildersGroupID_),
4513 artdaqSupervisorUID +
4517 ARTDAQ_LOGGER_TABLE,
4519 artdaqSupervisorTable.tableView_->
findCol(
4520 colARTDAQSupervisor_.colLinkToDataLoggers_));
4523 artdaqSupervisorTable.tableView_->
findCol(
4524 colARTDAQSupervisor_.colLinkToDataLoggersGroupID_),
4525 artdaqSupervisorUID +
4529 ARTDAQ_DISPATCHER_TABLE,
4531 artdaqSupervisorTable.tableView_->
findCol(
4532 colARTDAQSupervisor_.colLinkToDispatchers_));
4535 artdaqSupervisorTable.tableView_->
findCol(
4536 colARTDAQSupervisor_.colLinkToDispatchersGroupID_),
4537 artdaqSupervisorUID +
4542 ARTDAQ_ROUTER_TABLE,
4544 artdaqSupervisorTable.tableView_->
findCol(
4545 colARTDAQSupervisor_.colLinkToRoutingManagers_));
4548 artdaqSupervisorTable.tableView_->
findCol(
4549 colARTDAQSupervisor_.colLinkToRoutingManagersGroupID_),
4550 artdaqSupervisorUID +
4555 std::stringstream ss;
4556 artdaqSupervisorTable.tableView_->print(ss);
4557 __COUT_MULTI__(0, ss.str());
4564 ConfigurationManager::GroupType::CONTEXT_TYPE, cfgMgr);
4567 ConfigurationManager::XDAQ_CONTEXT_TABLE_NAME,
true );
4569 ConfigurationManager::XDAQ_APPLICATION_TABLE_NAME,
true );
4571 ConfigurationManager::XDAQ_APP_PROPERTY_TABLE_NAME,
4578 std::string contextUID;
4579 std::string contextAppGroupID;
4581 if(needArtdaqSupervisorParents)
4584 row = contextTable.tableView_->
addRow(
4585 author,
true ,
"artdaqContext");
4591 contextTable.tableView_
4592 ->getDataView()[row][contextTable.tableView_->
getColUID()];
4595 __COUTV__(contextUID);
4599 "http://${HOSTNAME}",
4601 contextTable.tableView_->
findCol(
4602 XDAQContextTable::colContext_.colAddress_));
4605 contextTable.tableView_->
findCol(
4606 XDAQContextTable::colContext_.colPort_),
4612 ConfigurationManager::XDAQ_APPLICATION_TABLE_NAME,
4614 contextTable.tableView_->
findCol(
4615 XDAQContextTable::colContext_.colLinkToApplicationTable_));
4618 contextTable.tableView_->
findCol(
4619 XDAQContextTable::colContext_.colLinkToApplicationGroupID_),
4620 "artdaqContextApps");
4622 __COUTV__(contextAppGroupID);
4626 std::string appPropertiesGroupID;
4632 if(needArtdaqSupervisorParents)
4636 unsigned int c = appTable.tableView_->
findCol(
4637 XDAQContextTable::colApplication_.colClass_);
4638 for(
unsigned int r = 0;
4639 r < appTable.tableView_->getNumberOfRows();
4641 if(appTable.tableView_->getDataView()[r][c] ==
4642 ARTDAQ_SUPERVISOR_CLASS)
4645 <<
"Found partially existing artdaq Supervisor "
4647 << appTable.tableView_->getDataView()
4649 <<
"'... Disabling it." << __E__;
4656 row = appTable.tableView_->
addRow(
4657 author,
true ,
"artdaqSupervisor");
4664 ->getDataView()[row][appTable.tableView_->
getColUID()];
4671 ARTDAQ_SUPERVISOR_CLASS,
4674 XDAQContextTable::colApplication_.colClass_));
4677 "${OTSDAQ_LIB}/libARTDAQSupervisor.so",
4680 XDAQContextTable::colApplication_.colModule_));
4685 appTable.tableView_->
findCol(XDAQContextTable::colApplication_
4686 .colApplicationGroupID_));
4690 ConfigurationManager::XDAQ_APP_PROPERTY_TABLE_NAME,
4692 appTable.tableView_->
findCol(XDAQContextTable::colApplication_
4693 .colLinkToPropertyTable_));
4696 appTable.tableView_->
findCol(XDAQContextTable::colApplication_
4697 .colLinkToPropertyGroupID_),
4698 appUID +
"Properties");
4700 __COUTV__(appPropertiesGroupID);
4704 __COUT__ <<
"Getting row of existing parent supervisor." << __E__;
4708 cfgMgr->
getNode(ConfigurationManager::XDAQ_CONTEXT_TABLE_NAME)
4709 .
getNode(artdaqContext->contextUID_)
4710 .
getNode(XDAQContextTable::colContext_
4711 .colLinkToApplicationTable_)
4712 .
getNode(artdaqContext->applications_[0].applicationUID_)
4721 ARTDAQ_SUPERVISOR_TABLE,
4724 XDAQContextTable::colApplication_.colLinkToSupervisorTable_));
4726 artdaqSupervisorUID,
4729 XDAQContextTable::colApplication_.colLinkToSupervisorUID_));
4734 if(needArtdaqSupervisorParents)
4738 const std::vector<std::string> propertyUIDs = {
"Partition0",
4741 "BoardReaderTimeout",
4742 "EventBuilderTimeout",
4743 "DataLoggerTimeout",
4744 "DispatcherTimeout"};
4745 const std::vector<std::string> propertyNames = {
4747 "productsdir_for_bash_scripts",
4748 "max_fragment_size_bytes",
4749 "boardreader_timeout",
4750 "eventbuilder_timeout",
4751 "datalogger_timeout",
4752 "dispatcher_timeout"
4754 const std::vector<std::string> propertyValues = {
4764 for(
unsigned int i = 0; i < propertyNames.size(); ++i)
4767 row = appPropertyTable.tableView_->
addRow(
4770 appUID + propertyUIDs[i]);
4773 "1", row, appPropertyTable.tableView_->
getColStatus());
4777 "ots::SupervisorProperty",
4779 appPropertyTable.tableView_->
findCol(
4780 XDAQContextTable::colAppProperty_.colPropertyType_));
4785 appPropertyTable.tableView_->
findCol(
4786 XDAQContextTable::colAppProperty_.colPropertyName_));
4791 appPropertyTable.tableView_->
findCol(
4792 XDAQContextTable::colAppProperty_.colPropertyValue_));
4795 appPropertiesGroupID,
4797 appPropertyTable.tableView_->
findCol(
4798 XDAQContextTable::colAppProperty_.colPropertyGroupID_));
4803 std::stringstream ss;
4804 contextTable.tableView_->print(ss);
4805 __COUT_MULTI__(0, ss.str());
4808 std::stringstream ss;
4809 appTable.tableView_->print(ss);
4810 __COUT_MULTI__(0, ss.str());
4813 std::stringstream ss;
4814 appPropertyTable.tableView_->print(ss);
4815 __COUT_MULTI__(0, ss.str());
4818 contextTable.tableView_
4820 appTable.tableView_->
init();
4821 appPropertyTable.tableView_
4827 <<
"Table errors while creating ARTDAQ Supervisor. Erasing all newly "
4828 "created table versions."
4833 __COUT_INFO__ <<
"Edits complete for new artdaq Supervisor! Created '"
4834 << appUID <<
"'" << __E__;
4838 __SS__ <<
"DEBUG blocking artdaq supervisor save!" << __E__;
4842 contextGroupEdit.saveChanges(contextGroupEdit.originalGroupName_,
4854 artdaqSupervisorRow =
4855 cfgMgr->
getNode(ConfigurationManager::XDAQ_CONTEXT_TABLE_NAME)
4856 .
getNode(artdaqContext->contextUID_)
4857 .
getNode(XDAQContextTable::colContext_.colLinkToApplicationTable_)
4858 .
getNode(artdaqContext->applications_[0].applicationUID_)
4859 .
getNode(XDAQContextTable::colApplication_.colLinkToSupervisorTable_)
4863 __COUT__ <<
"------------------------- artdaq nodes to save:" << __E__;
4864 for(
auto& subsystemPair : subsystemObjectMap)
4866 __COUTV__(subsystemPair.first);
4870 for(
auto& nodeTypePair : nodeTypeToObjectMap)
4872 __COUTV__(nodeTypePair.first);
4874 for(
auto& nodePair : nodeTypePair.second)
4876 __COUTV__(nodePair.first);
4880 __COUT__ <<
"------------------------- end artdaq nodes to save." << __E__;
4884 __COUTV__(artdaqSupervisorRow);
4885 if(artdaqSupervisorRow >= TableView::INVALID)
4887 __SS__ <<
"Invalid artdaq Supervisor row " << artdaqSupervisorRow <<
" found!"
4902 ARTDAQ_SUPERVISOR_TABLE,
true );
4906 std::string artdaqSupervisorUID =
4907 artdaqSupervisorTable.tableView_
4908 ->getDataView()[artdaqSupervisorRow]
4909 [artdaqSupervisorTable.tableView_->
getColUID()];
4912 if(artdaqSupervisorTable.tableView_
4913 ->getDataView()[artdaqSupervisorRow]
4914 [artdaqSupervisorTable.tableView_->
findCol(
4915 colARTDAQSupervisor_.colLinkToBoardReaders_)] ==
4916 TableViewColumnInfo::DATATYPE_LINK_DEFAULT)
4918 __COUT__ <<
"Fixing missing link to Readers" << __E__;
4920 ARTDAQ_READER_TABLE,
4921 artdaqSupervisorRow,
4922 artdaqSupervisorTable.tableView_->
findCol(
4923 colARTDAQSupervisor_.colLinkToBoardReaders_));
4925 artdaqSupervisorRow,
4926 artdaqSupervisorTable.tableView_->
findCol(
4927 colARTDAQSupervisor_.colLinkToBoardReadersGroupID_),
4928 artdaqSupervisorUID +
4933 if(artdaqSupervisorTable.tableView_
4934 ->getDataView()[artdaqSupervisorRow]
4935 [artdaqSupervisorTable.tableView_->
findCol(
4936 colARTDAQSupervisor_.colLinkToEventBuilders_)] ==
4937 TableViewColumnInfo::DATATYPE_LINK_DEFAULT)
4939 __COUT__ <<
"Fixing missing link to Builders" << __E__;
4941 ARTDAQ_BUILDER_TABLE,
4942 artdaqSupervisorRow,
4943 artdaqSupervisorTable.tableView_->
findCol(
4944 colARTDAQSupervisor_.colLinkToEventBuilders_));
4946 artdaqSupervisorRow,
4947 artdaqSupervisorTable.tableView_->
findCol(
4948 colARTDAQSupervisor_.colLinkToEventBuildersGroupID_),
4949 artdaqSupervisorUID +
4954 if(artdaqSupervisorTable.tableView_
4955 ->getDataView()[artdaqSupervisorRow]
4956 [artdaqSupervisorTable.tableView_->
findCol(
4957 colARTDAQSupervisor_.colLinkToDataLoggers_)] ==
4958 TableViewColumnInfo::DATATYPE_LINK_DEFAULT)
4960 __COUT__ <<
"Fixing missing link to Loggers" << __E__;
4962 ARTDAQ_LOGGER_TABLE,
4963 artdaqSupervisorRow,
4964 artdaqSupervisorTable.tableView_->
findCol(
4965 colARTDAQSupervisor_.colLinkToDataLoggers_));
4967 artdaqSupervisorRow,
4968 artdaqSupervisorTable.tableView_->
findCol(
4969 colARTDAQSupervisor_.colLinkToDataLoggersGroupID_),
4970 artdaqSupervisorUID +
4975 if(artdaqSupervisorTable.tableView_
4976 ->getDataView()[artdaqSupervisorRow]
4977 [artdaqSupervisorTable.tableView_->
findCol(
4978 colARTDAQSupervisor_.colLinkToDispatchers_)] ==
4979 TableViewColumnInfo::DATATYPE_LINK_DEFAULT)
4981 __COUT__ <<
"Fixing missing link to Dispatchers" << __E__;
4983 ARTDAQ_DISPATCHER_TABLE,
4984 artdaqSupervisorRow,
4985 artdaqSupervisorTable.tableView_->
findCol(
4986 colARTDAQSupervisor_.colLinkToDispatchers_));
4988 artdaqSupervisorRow,
4989 artdaqSupervisorTable.tableView_->
findCol(
4990 colARTDAQSupervisor_.colLinkToDispatchersGroupID_),
4991 artdaqSupervisorUID +
4996 if(artdaqSupervisorTable.tableView_
4997 ->getDataView()[artdaqSupervisorRow]
4998 [artdaqSupervisorTable.tableView_->
findCol(
4999 colARTDAQSupervisor_.colLinkToRoutingManagers_)] ==
5000 TableViewColumnInfo::DATATYPE_LINK_DEFAULT)
5002 __COUT__ <<
"Fixing missing link to Routers" << __E__;
5004 ARTDAQ_ROUTER_TABLE,
5005 artdaqSupervisorRow,
5006 artdaqSupervisorTable.tableView_->
findCol(
5007 colARTDAQSupervisor_.colLinkToRoutingManagers_));
5009 artdaqSupervisorRow,
5010 artdaqSupervisorTable.tableView_->
findCol(
5011 colARTDAQSupervisor_.colLinkToRoutingManagersGroupID_),
5012 artdaqSupervisorUID +
5017 std::stringstream ss;
5018 artdaqSupervisorTable.tableView_->print(ss);
5019 __COUT_MULTI__(0, ss.str());
5025 ARTDAQ_SUBSYSTEM_TABLE,
true );
5028 artdaqSubsystemTable.tableView_->deleteAllRows();
5030 for(
auto& subsystemPair : subsystemObjectMap)
5032 __COUTV__(subsystemPair.first);
5033 __COUTV__(subsystemPair.second);
5036 row = artdaqSubsystemTable.tableView_->
addRow(
5037 author,
true , subsystemPair.first);
5039 if(subsystemPair.second !=
"" &&
5040 subsystemPair.second != TableViewColumnInfo::DATATYPE_STRING_DEFAULT &&
5041 subsystemPair.second != NULL_SUBSYSTEM_DESTINATION_LABEL)
5045 ARTDAQ_SUBSYSTEM_TABLE,
5047 artdaqSubsystemTable.tableView_->
findCol(
5048 colARTDAQSubsystem_.colLinkToDestination_));
5050 subsystemPair.second,
5052 artdaqSubsystemTable.tableView_->
findCol(
5053 colARTDAQSubsystem_.colLinkToDestinationUID_));
5060 for(
auto& nodeTypePair : nodeTypeToObjectMap)
5062 __COUTV__(nodeTypePair.first);
5066 auto it =
processTypes_.mapToTable_.find(nodeTypePair.first);
5069 __SS__ <<
"Invalid artdaq node type '" << nodeTypePair.first
5070 <<
"' attempted!" << __E__;
5073 __COUTV__(it->second);
5083 if(nodeTypePair.second.size())
5086 __COUT__ <<
"Ignoring missing table '" << it->second
5087 <<
"' since there were no user records attempted of type '"
5088 << nodeTypePair.first <<
".'" << __E__;
5095 bool hasArtProcessName =
false;
5096 unsigned int artProcessNameCol = -1;
5100 __COUT__ <<
"Identified non-Reader, no-Router type '"
5101 << nodeTypePair.first
5102 <<
"' that has an art link and thus Process Name, so creating "
5103 "table edit structure to ART table."
5106 ARTDAQTableBase::ARTDAQ_ART_TABLE,
true );
5109 std::stringstream ss;
5110 artTable->tableView_->print(ss);
5111 __COUT_MULTI__(1, ss.str());
5113 artProcessNameCol = artTable->tableView_->
findCol(
5114 ARTDAQTableBase::colARTDAQArt_.colProcessName_);
5115 __COUTTV__(artProcessNameCol);
5117 hasArtProcessName =
true;
5119 __COUTV__(hasArtProcessName);
5121 const unsigned int commentCol =
5122 typeTable.tableView_->
findColByType(TableViewColumnInfo::TYPE_COMMENT);
5123 const unsigned int authorCol =
5124 typeTable.tableView_->
findColByType(TableViewColumnInfo::TYPE_AUTHOR);
5125 const unsigned int timestampCol =
5126 typeTable.tableView_->
findColByType(TableViewColumnInfo::TYPE_TIMESTAMP);
5129 std::map<
unsigned int ,
bool > deleteRecordMap;
5130 unsigned int maxRowToDelete = typeTable.tableView_->getNumberOfRows();
5131 for(
unsigned int r = 0; r < typeTable.tableView_->getNumberOfRows(); ++r)
5132 deleteRecordMap.emplace(std::make_pair(
5135 __COUTTV__(maxRowToDelete);
5141 const unsigned int ORIG_MAP_ART_PROC_NAME_COL = -1;
5142 std::map<std::string ,
5143 std::map<
unsigned int , std::string >>
5144 originalMultinodeValues;
5145 std::map<std::string ,
5146 std::map<
unsigned int ,
5149 originalMultinodeSameSiblingValues;
5152 std::map<
unsigned int ,
5154 std::vector<std::string >>>>
5155 originalMultinodeAllSiblingEmbeddedName;
5158 std::map<
unsigned int ,
5160 std::vector<std::string >>>>
5161 originalMultinodeAllSiblingEmbeddedPrinterIndex;
5164 for(
auto& nodePair : nodeTypePair.second)
5166 __COUTV__(nodePair.first);
5169 std::vector<std::string> nodeIndices, hostnameIndices;
5170 unsigned int hostnameFixedWidth = 0, nodeNameFixedWidth = 0;
5171 std::string hostname;
5178 for(
unsigned int i = 0; i < nodePair.second.size(); ++i)
5180 __COUTV__(nodePair.second[i]);
5184 std::string nodeName;
5190 if(nodePair.second[i][0] ==
':')
5192 __COUT__ <<
"Handling original multi-node." << __E__;
5197 std::string lastOriginalName;
5198 std::vector<std::string> originalParameterArr =
5200 &(nodePair.second[i].c_str()[1]),
5203 if(originalParameterArr.size() != 3)
5205 __SS__ <<
"Illegal original name parameter string '"
5206 << nodePair.second[i] <<
"!'" << __E__;
5212 unsigned int fixedWidth;
5213 sscanf(originalParameterArr[0].c_str(),
"%u", &fixedWidth);
5214 __COUTV__(fixedWidth);
5216 std::vector<std::string> printerSyntaxArr =
5221 std::vector<std::string> originalNodeIndices;
5222 for(
auto& printerSyntaxValue : printerSyntaxArr)
5224 __COUTV__(printerSyntaxValue);
5226 std::vector<std::string> printerSyntaxRange =
5228 printerSyntaxValue, {
'-'} );
5230 if(printerSyntaxRange.size() == 0 ||
5231 printerSyntaxRange.size() > 2)
5233 __SS__ <<
"Illegal multi-node printer syntax string '"
5234 << printerSyntaxValue <<
"!'" << __E__;
5237 else if(printerSyntaxRange.size() == 1)
5239 __COUTV__(printerSyntaxRange[0]);
5240 originalNodeIndices.push_back(printerSyntaxRange[0]);
5244 unsigned int lo, hi;
5245 sscanf(printerSyntaxRange[0].c_str(),
"%u", &lo);
5246 sscanf(printerSyntaxRange[1].c_str(),
"%u", &hi);
5250 sscanf(printerSyntaxRange[0].c_str(),
"%u", &hi);
5252 for(; lo <= hi; ++lo)
5255 originalNodeIndices.push_back(std::to_string(lo));
5260 __COUTTV__(originalParameterArr[2]);
5262 originalParameterArr[2] = originalParameterArr[2].substr(
5263 0, originalParameterArr[2].find(
";status="));
5264 __COUTV__(originalParameterArr[2]);
5265 std::vector<std::string> originalNamePieces =
5270 if(originalNamePieces.size() < 2)
5272 __SS__ <<
"Illegal original multi-node name template - "
5273 "please use * to indicate where the multi-node "
5274 "index should be inserted!"
5281 std::stringstream ss;
5282 typeTable.tableView_->print(ss);
5283 __COUT_MULTI__(1, ss.str());
5288 <<
"originalMultinodeSameSiblingValues init col map for "
5289 << nodePair.first << __E__;
5290 originalMultinodeSameSiblingValues.emplace(std::make_pair(
5296 __COUT__ <<
"originalMultinodeAllSiblingEmbeddedName init "
5298 << nodePair.first << __E__;
5299 originalMultinodeAllSiblingEmbeddedName.emplace(std::make_pair(
5308 __COUT__ <<
"originalMultinodeAllSiblingEmbeddedPrinterIndex "
5310 << nodePair.first << __E__;
5311 originalMultinodeAllSiblingEmbeddedPrinterIndex.emplace(
5324 unsigned int originalRow = TableView::INVALID,
5325 lastOriginalRow = TableView::INVALID,
5326 lastArtProcessRow = TableView::INVALID;
5327 for(
unsigned int i = 0; i < originalNodeIndices.size(); ++i)
5329 std::string originalName = originalNamePieces[0];
5330 std::string nodeNameIndex;
5331 for(
unsigned int p = 1; p < originalNamePieces.size();
5334 nodeNameIndex = originalNodeIndices[i];
5337 if(nodeNameIndex.size() > fixedWidth)
5339 __SS__ <<
"Illegal original node name index '"
5341 <<
"' - length is longer than fixed "
5342 "width requirement of "
5343 << fixedWidth <<
"!" << __E__;
5348 while(nodeNameIndex.size() < fixedWidth)
5349 nodeNameIndex =
"0" + nodeNameIndex;
5352 originalName += nodeNameIndex + originalNamePieces[p];
5354 __COUTTV__(originalName);
5355 originalRow = typeTable.tableView_->
findRow(
5360 __COUTTV__(originalRow);
5364 auto result = originalMultinodeValues.emplace(
5365 std::make_pair(originalName,
5366 std::map<
unsigned int ,
5370 <<
"originalName '" << originalName
5371 <<
"' already in original multinode value cache."
5375 __COUT__ <<
"Saving multinode value " << originalName
5376 <<
"[" << originalRow
5377 <<
"][*] with row count = "
5378 << typeTable.tableView_->getNumberOfRows()
5382 for(
unsigned int col = 0;
5383 col < typeTable.tableView_->getNumberOfColumns();
5386 if(typeTable.tableView_->getColumnInfo(col)
5389 ARTDAQ_TYPE_TABLE_SUBSYSTEM_LINK ||
5390 typeTable.tableView_->getColumnInfo(col)
5393 ARTDAQ_TYPE_TABLE_SUBSYSTEM_LINK_UID ||
5394 typeTable.tableView_->getColumnInfo(col)
5397 ARTDAQ_TYPE_TABLE_HOSTNAME ||
5398 typeTable.tableView_->getColumnInfo(col)
5401 typeTable.tableView_->getColumnInfo(col)
5403 col == timestampCol ||
5410 <<
"Caching node value: " << originalName
5411 <<
"[" << originalRow <<
"][" << col
5413 << typeTable.tableView_
5414 ->getColumnInfo(col)
5417 << typeTable.tableView_
5418 ->getDataView()[originalRow][col]
5420 originalMultinodeValues.at(originalName)
5421 .emplace(std::make_pair(
5423 typeTable.tableView_
5424 ->getDataView()[originalRow]
5429 for(
const auto& pair :
5430 originalMultinodeSameSiblingValues)
5431 __COUTT__ <<
"originalMultinodeSameSiblin"
5433 << pair.first <<
"]" << __E__;
5435 originalMultinodeSameSiblingValues
5437 .emplace(std::make_pair(
5442 typeTable.tableView_
5444 [originalRow][col])));
5446 for(
const auto& pair :
5447 originalMultinodeAllSiblingEmbeddedName)
5448 __COUTT__ <<
"originalMultinodeAllSibling"
5450 << pair.first <<
"]" << __E__;
5451 originalMultinodeAllSiblingEmbeddedName
5453 .emplace(std::make_pair(
5456 typeTable.tableView_
5459 .find(originalName) !=
5462 std::vector<std::string>())));
5464 for(
const auto& pair :
5465 originalMultinodeAllSiblingEmbeddedPrinterIndex)
5466 __COUTT__ <<
"originalMultinodeAllSibling"
5467 "EmbeddedPrinterIndex["
5468 << pair.first <<
"]" << __E__;
5469 originalMultinodeAllSiblingEmbeddedPrinterIndex
5471 .emplace(std::make_pair(
5474 typeTable.tableView_
5477 .find(nodeNameIndex) !=
5480 std::vector<std::string>())));
5486 originalMultinodeSameSiblingValues
5492 originalMultinodeAllSiblingEmbeddedName
5496 if(originalMultinodeAllSiblingEmbeddedName
5502 <<
"Determine string splits for "
5505 const std::string& val =
5506 typeTable.tableView_
5507 ->getDataView()[originalRow]
5509 size_t pos = val.find(originalName);
5510 originalMultinodeAllSiblingEmbeddedName
5514 val.substr(0, pos));
5515 originalMultinodeAllSiblingEmbeddedName
5518 .second.push_back(val.substr(
5519 pos + originalName.size()));
5521 originalMultinodeAllSiblingEmbeddedName
5527 originalMultinodeAllSiblingEmbeddedPrinterIndex
5531 if(originalMultinodeAllSiblingEmbeddedPrinterIndex
5536 __COUTT__ <<
"Determine string "
5537 "splits for embedded "
5538 "printer syntax index: "
5539 << nodeNameIndex << __E__;
5540 const std::string& val =
5541 typeTable.tableView_
5542 ->getDataView()[originalRow]
5544 size_t pos = val.find(nodeNameIndex);
5545 originalMultinodeAllSiblingEmbeddedPrinterIndex
5549 val.substr(0, pos));
5550 originalMultinodeAllSiblingEmbeddedPrinterIndex
5553 .second.push_back(val.substr(
5554 pos + nodeNameIndex.size()));
5556 originalMultinodeAllSiblingEmbeddedPrinterIndex
5564 if(originalMultinodeSameSiblingValues
5569 __COUTT__ <<
"Checking sibling same "
5571 << nodePair.first << __E__;
5572 if(typeTable.tableView_
5573 ->getDataView()[originalRow]
5575 typeTable.tableView_->getDataView()
5576 [lastOriginalRow][col])
5579 <<
"Found different sibling "
5582 << nodePair.first << __E__;
5583 originalMultinodeSameSiblingValues
5589 if(originalMultinodeAllSiblingEmbeddedName
5594 __COUTT__ <<
"Checking sibling "
5595 "embedded name... for "
5596 << nodePair.first <<
":"
5597 << originalName << __E__;
5598 if(typeTable.tableView_
5599 ->getDataView()[originalRow]
5601 .find(originalName) ==
5604 __COUT__ <<
"Found no embedded "
5606 << col <<
" looking for "
5607 << originalName << __E__;
5608 originalMultinodeAllSiblingEmbeddedName
5614 if(originalMultinodeAllSiblingEmbeddedPrinterIndex
5620 <<
"Checking sibling embedded "
5621 "printer syntax index... for "
5622 << nodePair.first <<
":"
5623 << nodeNameIndex << __E__;
5624 if(typeTable.tableView_
5625 ->getDataView()[originalRow]
5627 .find(nodeNameIndex) ==
5630 __COUT__ <<
"Found no embedded "
5633 << col <<
" looking for "
5636 originalMultinodeAllSiblingEmbeddedPrinterIndex
5645 <<
"originalMultinodeSameSiblingValues["
5646 << nodePair.first <<
"][" << col <<
"] = "
5647 << originalMultinodeSameSiblingValues
5653 <<
"originalMultinodeAllSiblingEmbeddedNa"
5655 << nodePair.first <<
"][" << col <<
"] = "
5656 << originalMultinodeAllSiblingEmbeddedName
5662 <<
"originalMultinodeAllSiblingEmbeddedPr"
5664 << nodePair.first <<
"][" << col <<
"] = "
5665 << originalMultinodeAllSiblingEmbeddedPrinterIndex
5671 if(hasArtProcessName && artTable &&
5672 typeTable.tableView_->getColumnInfo(col)
5674 ARTDAQTableBase::colARTDAQNotReader_
5679 <<
"Checking ART Process Name... for "
5681 << originalName <<
"' / "
5682 << typeTable.tableView_
5683 ->getDataView()[originalRow]
5686 unsigned int artRow =
5687 artTable->tableView_->
findRow(
5690 typeTable.tableView_
5691 ->getDataView()[originalRow]
5696 <<
"Found ART Process Name = "
5697 << artTable->tableView_->getDataView()
5698 [artRow][artProcessNameCol]
5702 originalMultinodeValues.at(originalName)
5703 .emplace(std::make_pair(
5704 ORIG_MAP_ART_PROC_NAME_COL,
5705 artTable->tableView_
5708 [artProcessNameCol]));
5710 originalMultinodeValues
5712 .at(ORIG_MAP_ART_PROC_NAME_COL));
5715 originalMultinodeSameSiblingValues
5717 .emplace(std::make_pair(
5718 ORIG_MAP_ART_PROC_NAME_COL,
5722 artTable->tableView_
5725 [artProcessNameCol])));
5726 originalMultinodeAllSiblingEmbeddedName
5728 .emplace(std::make_pair(
5729 ORIG_MAP_ART_PROC_NAME_COL,
5731 artTable->tableView_
5735 .find(originalName) !=
5738 std::vector<std::string>())));
5739 originalMultinodeAllSiblingEmbeddedPrinterIndex
5741 .emplace(std::make_pair(
5742 ORIG_MAP_ART_PROC_NAME_COL,
5744 artTable->tableView_
5752 std::vector<std::string>())));
5758 originalMultinodeSameSiblingValues
5760 .at(ORIG_MAP_ART_PROC_NAME_COL)
5764 originalMultinodeAllSiblingEmbeddedName
5766 .at(ORIG_MAP_ART_PROC_NAME_COL)
5768 if(originalMultinodeAllSiblingEmbeddedName
5770 .at(ORIG_MAP_ART_PROC_NAME_COL)
5774 <<
"Determine string splits "
5777 const std::string& val =
5778 artTable->tableView_
5781 [artProcessNameCol];
5783 val.find(originalName);
5784 originalMultinodeAllSiblingEmbeddedName
5786 .at(ORIG_MAP_ART_PROC_NAME_COL)
5788 val.substr(0, pos));
5789 originalMultinodeAllSiblingEmbeddedName
5791 .at(ORIG_MAP_ART_PROC_NAME_COL)
5792 .second.push_back(val.substr(
5794 originalName.size()));
5796 originalMultinodeAllSiblingEmbeddedName
5798 .at(ORIG_MAP_ART_PROC_NAME_COL)
5802 originalMultinodeAllSiblingEmbeddedPrinterIndex
5804 .at(ORIG_MAP_ART_PROC_NAME_COL)
5806 if(originalMultinodeAllSiblingEmbeddedPrinterIndex
5808 .at(ORIG_MAP_ART_PROC_NAME_COL)
5812 <<
"Determine string splits "
5813 "for embedded printer "
5815 << nodeNameIndex << __E__;
5816 const std::string& val =
5817 artTable->tableView_
5820 [artProcessNameCol];
5822 val.find(nodeNameIndex);
5823 originalMultinodeAllSiblingEmbeddedPrinterIndex
5825 .at(ORIG_MAP_ART_PROC_NAME_COL)
5827 val.substr(0, pos));
5828 originalMultinodeAllSiblingEmbeddedPrinterIndex
5830 .at(ORIG_MAP_ART_PROC_NAME_COL)
5831 .second.push_back(val.substr(
5833 nodeNameIndex.size()));
5835 originalMultinodeAllSiblingEmbeddedPrinterIndex
5837 .at(ORIG_MAP_ART_PROC_NAME_COL)
5843 if(originalMultinodeSameSiblingValues
5845 .at(ORIG_MAP_ART_PROC_NAME_COL)
5848 __COUTT__ <<
"Checking sibling "
5849 "same values... for "
5852 if(artTable->tableView_
5855 [artProcessNameCol] !=
5856 artTable->tableView_
5859 [artProcessNameCol])
5862 <<
"Found different "
5864 "at artProcessNameCol="
5865 << artProcessNameCol
5869 originalMultinodeSameSiblingValues
5871 .at(ORIG_MAP_ART_PROC_NAME_COL)
5875 if(originalMultinodeAllSiblingEmbeddedName
5877 .at(ORIG_MAP_ART_PROC_NAME_COL)
5881 <<
"Checking sibling "
5882 "embedded name... for "
5883 << nodePair.first <<
":"
5884 << originalName << __E__;
5885 if(artTable->tableView_
5889 .find(originalName) ==
5893 <<
"Found no embedded "
5895 "artProcessNameCol="
5896 << artProcessNameCol
5898 << originalName << __E__;
5899 originalMultinodeAllSiblingEmbeddedName
5901 .at(ORIG_MAP_ART_PROC_NAME_COL)
5905 if(originalMultinodeAllSiblingEmbeddedPrinterIndex
5907 .at(ORIG_MAP_ART_PROC_NAME_COL)
5911 <<
"Checking sibling "
5912 "embedded printer syntax "
5914 << nodePair.first <<
":"
5915 << nodeNameIndex << __E__;
5916 if(artTable->tableView_
5920 .find(nodeNameIndex) ==
5924 <<
"Found no embedded "
5925 "printer syntax index "
5926 "at artProcessNameCol="
5927 << artProcessNameCol
5929 << nodeNameIndex << __E__;
5930 originalMultinodeAllSiblingEmbeddedPrinterIndex
5932 .at(ORIG_MAP_ART_PROC_NAME_COL)
5939 <<
"originalMultinodeSameSiblingValue"
5941 << nodePair.first <<
"]["
5942 << ORIG_MAP_ART_PROC_NAME_COL
5944 << originalMultinodeSameSiblingValues
5946 .at(ORIG_MAP_ART_PROC_NAME_COL)
5950 <<
"originalMultinodeAllSiblingEmbedd"
5952 << nodePair.first <<
"]["
5953 << ORIG_MAP_ART_PROC_NAME_COL
5955 << originalMultinodeAllSiblingEmbeddedName
5957 .at(ORIG_MAP_ART_PROC_NAME_COL)
5961 <<
"originalMultinodeAllSiblingEmbedd"
5963 << nodePair.first <<
"]["
5964 << ORIG_MAP_ART_PROC_NAME_COL
5966 << originalMultinodeAllSiblingEmbeddedPrinterIndex
5968 .at(ORIG_MAP_ART_PROC_NAME_COL)
5973 <<
"Checking ART Process Name "
5974 "complete for originalName='"
5975 << originalName <<
"' / "
5976 << typeTable.tableView_
5977 ->getDataView()[originalRow]
5991 lastOriginalRow = originalRow;
5993 __COUTTV__(lastOriginalRow);
5994 lastOriginalName = originalName;
5997 for(
const auto& pair :
5998 originalMultinodeSameSiblingValues.at(nodePair.first))
5999 __COUTT__ <<
"originalMultinodeSameSiblingValues["
6000 << nodePair.first <<
"][" << pair.first
6001 <<
"] = " << pair.second.first << __E__;
6002 for(
const auto& pair :
6003 originalMultinodeAllSiblingEmbeddedName.at(
6005 __COUTT__ <<
"originalMultinodeAllSiblingEmbeddedName["
6006 << nodePair.first <<
"][" << pair.first
6007 <<
"] = " << pair.second.first << __E__;
6008 for(
const auto& pair :
6009 originalMultinodeAllSiblingEmbeddedPrinterIndex.at(
6012 <<
"originalMultinodeAllSiblingEmbeddedPrinterIndex["
6013 << nodePair.first <<
"][" << pair.first
6014 <<
"] = " << pair.second.first << __E__;
6016 __COUTTV__(lastOriginalRow);
6017 row = lastOriginalRow;
6022 std::string originalName = nodePair.second[i].substr(
6023 0, nodePair.second[i].find(
";status="));
6024 __COUTV__(originalName);
6027 row = typeTable.tableView_->
findRow(
6037 nodeName = nodePair.first;
6038 __COUTV__(nodeName);
6040 nodeName = nodeName.substr(0, nodeName.find(
";status="));
6043 std::string tmpNodeName = nodeName;
6045 for(
size_t c = 0; c < tmpNodeName.size(); ++c)
6046 if(tmpNodeName[c] !=
'*')
6047 nodeName += tmpNodeName[c];
6050 __COUTV__(nodeName);
6051 if(row == TableView::INVALID)
6054 row = typeTable.tableView_->
addRow(
6055 author,
true , nodeName);
6060 __COUT__ <<
"Handling new " << nodeTypePair.first
6061 <<
" defaults!" << __E__;
6064 ARTDAQTableBase::ARTDAQ_DAQ_PARAMETER_TABLE,
6069 ARTDAQTableBase::ARTDAQ_DAQ_PARAMETER_TABLE,
6071 typeTable.tableView_->
findCol(
6072 ARTDAQTableBase::colARTDAQReader_
6073 .colLinkToDaqParameters_));
6074 std::string daqParameterGroupID =
6077 typeTable.tableView_->
findCol(
6078 ARTDAQTableBase::colARTDAQReader_
6079 .colLinkToDaqParametersGroupID_),
6080 nodeName +
"DaqParameters");
6083 std::stringstream ss;
6084 typeTable.tableView_->print(ss);
6085 __COUT_MULTI__(1, ss.str());
6089 const std::vector<std::string> parameterUIDs = {
6090 "BoardID",
"FragmentID"};
6092 const std::vector<std::string> parameterNames = {
6096 const std::vector<std::string> parameterValues = {
6101 unsigned int parameterRow;
6102 for(
unsigned int i = 0; i < parameterNames.size(); ++i)
6105 parameterRow = daqParameterTable.tableView_->
addRow(
6108 nodeName + parameterUIDs[i]);
6119 daqParameterTable.tableView_->
findCol(
6120 ARTDAQTableBase::colARTDAQDaqParameter_
6121 .colDaqParameterKey_));
6126 daqParameterTable.tableView_->
findCol(
6127 ARTDAQTableBase::colARTDAQDaqParameter_
6128 .colDaqParameterValue_));
6131 daqParameterGroupID,
6133 daqParameterTable.tableView_->
findCol(
6134 ARTDAQTableBase::colARTDAQDaqParameter_
6135 .colDaqParameterGroupID_));
6139 daqParameterTable.tableView_
6147 __COUT__ <<
"Handling new " << nodeTypePair.first
6148 <<
" defaults!" << __E__;
6153 ARTDAQTableBase::ARTDAQ_DAQ_TABLE,
6156 unsigned int daqRecordRow = daqTable.tableView_->
addRow(
6160 std::string daqRecordUID =
6162 ->getDataView()[daqRecordRow]
6167 ARTDAQTableBase::ARTDAQ_DAQ_TABLE,
6169 typeTable.tableView_->
findCol(
6170 ARTDAQTableBase::colARTDAQNotReader_
6175 typeTable.tableView_->
findCol(
6176 ARTDAQTableBase::colARTDAQNotReader_
6177 .colLinkToDaqUID_));
6181 ARTDAQTableBase::ARTDAQ_DAQ_PARAMETER_TABLE,
6185 ARTDAQTableBase::ARTDAQ_DAQ_PARAMETER_TABLE,
6188 ARTDAQTableBase::colARTDAQDaq_
6189 .colLinkToDaqParameters_));
6190 std::string daqParameterGroupID =
6194 ARTDAQTableBase::colARTDAQDaq_
6195 .colLinkToDaqParametersGroupID_),
6196 nodeName +
"DaqParameters");
6199 const std::vector<std::string> parameterUIDs = {
6200 "BufferCount",
"FragmentsPerEvent"};
6202 const std::vector<std::string> parameterNames = {
6204 "expected_fragments_per_event"
6206 const std::vector<std::string> parameterValues = {
6211 unsigned int parameterRow;
6212 for(
unsigned int i = 0; i < parameterNames.size(); ++i)
6215 parameterRow = daqParameterTable.tableView_->
addRow(
6218 nodeName + parameterUIDs[i]);
6229 daqParameterTable.tableView_->
findCol(
6230 ARTDAQTableBase::colARTDAQDaqParameter_
6231 .colDaqParameterKey_));
6236 daqParameterTable.tableView_->
findCol(
6237 ARTDAQTableBase::colARTDAQDaqParameter_
6238 .colDaqParameterValue_));
6241 daqParameterGroupID,
6243 daqParameterTable.tableView_->
findCol(
6244 ARTDAQTableBase::colARTDAQDaqParameter_
6245 .colDaqParameterGroupID_));
6251 daqParameterTable.tableView_
6259 <<
"Reusing row " << row <<
" current-UID="
6260 << typeTable.tableView_
6261 ->getDataView()[row]
6263 <<
" as (temporarily to basename if multinode) new-UID="
6264 << nodeName << __E__;
6265 typeTable.tableView_
6274 if(row < maxRowToDelete)
6275 deleteRecordMap[row] =
false;
6282 artdaqSupervisorTable.tableView_
6283 ->getDataView()[artdaqSupervisorRow]
6284 [artdaqSupervisorTable.tableView_->
findCol(
6286 .at(nodeTypePair.first))],
6288 typeTable.tableView_->
findCol(
6290 nodeTypePair.first)));
6303 hostname = nodePair.second[i];
6307 typeTable.tableView_->
findCol(ARTDAQ_TYPE_TABLE_HOSTNAME));
6312 if(nodePair.second[i] !=
"" &&
6313 nodePair.second[i] !=
6314 TableViewColumnInfo::DATATYPE_STRING_DEFAULT)
6317 if(subsystemObjectMap.find(nodePair.second[i]) ==
6318 subsystemObjectMap.end())
6320 __SS__ <<
"Illegal subsystem '" << nodePair.second[i]
6321 <<
"' mismatch!" << __E__;
6326 ARTDAQ_SUBSYSTEM_TABLE,
6328 typeTable.tableView_->
findCol(
6329 ARTDAQ_TYPE_TABLE_SUBSYSTEM_LINK));
6333 typeTable.tableView_->
findCol(
6334 ARTDAQ_TYPE_TABLE_SUBSYSTEM_LINK_UID));
6339 TableViewColumnInfo::DATATYPE_LINK_DEFAULT,
6341 typeTable.tableView_->
findCol(
6342 ARTDAQ_TYPE_TABLE_SUBSYSTEM_LINK));
6346 i == 4 || i == 5 || i == 6 ||
6353 __COUT__ <<
"Handling printer syntax i=" << i << __E__;
6355 std::vector<std::string> printerSyntaxArr =
6359 if(printerSyntaxArr.size() == 2)
6361 if(printerSyntaxArr[0] ==
6364 sscanf(printerSyntaxArr[1].c_str(),
6366 &nodeNameFixedWidth);
6367 __COUTV__(nodeNameFixedWidth);
6370 else if(printerSyntaxArr[0] ==
6373 sscanf(printerSyntaxArr[1].c_str(),
6375 &hostnameFixedWidth);
6376 __COUTV__(hostnameFixedWidth);
6382 for(
auto& printerSyntaxValue : printerSyntaxArr)
6384 __COUTV__(printerSyntaxValue);
6386 std::vector<std::string> printerSyntaxRange =
6389 if(printerSyntaxRange.size() == 0 ||
6390 printerSyntaxRange.size() > 2)
6392 __SS__ <<
"Illegal multi-node printer syntax string '"
6393 << printerSyntaxValue <<
"!'" << __E__;
6396 else if(printerSyntaxRange.size() == 1)
6399 __COUTV__(printerSyntaxRange[0]);
6404 nodeIndices.push_back(printerSyntaxRange[0]);
6406 hostnameIndices.push_back(printerSyntaxRange[0]);
6410 unsigned int lo, hi;
6411 sscanf(printerSyntaxRange[0].c_str(),
"%u", &lo);
6412 sscanf(printerSyntaxRange[1].c_str(),
"%u", &hi);
6416 sscanf(printerSyntaxRange[0].c_str(),
"%u", &hi);
6418 for(; lo <= hi; ++lo)
6422 nodeIndices.push_back(std::to_string(lo));
6424 hostnameIndices.push_back(std::to_string(lo));
6431 __SS__ <<
"Unexpected parameter[" << i <<
" '"
6432 << nodePair.second[i] <<
"' for node " << nodePair.first
6438 __COUTV__(nodeIndices.size());
6439 __COUTV__(hostnameIndices.size());
6441 if(hostnameIndices.size())
6443 if(hostnameIndices.size() != nodeIndices.size())
6445 __SS__ <<
"Illegal associated hostname array has count "
6446 << hostnameIndices.size()
6447 <<
" which is not equal to the node count "
6448 << nodeIndices.size() <<
"!" << __E__;
6453 if(nodeIndices.size())
6455 unsigned int hostnameCol =
6456 typeTable.tableView_->
findCol(ARTDAQ_TYPE_TABLE_HOSTNAME);
6461 std::vector<std::string> namePieces =
6463 nodePair.first.substr(0, nodePair.first.find(
";status=")),
6467 if(namePieces.size() < 2)
6470 <<
"Illegal multi-node name template - please use * to "
6471 "indicate where the multi-node index should be inserted!"
6476 std::vector<std::string> hostnamePieces;
6477 if(hostnameIndices.size())
6483 if(hostnamePieces.size() < 2)
6486 <<
"Illegal hostname array template - please use * to "
6487 "indicate where the hostname index should be inserted!"
6493 bool isFirst =
true;
6494 unsigned int lastArtRow = TableView::INVALID;
6495 for(
unsigned int i = 0; i < nodeIndices.size(); ++i)
6497 std::string name = namePieces[0];
6498 std::string nodeNameIndex;
6499 for(
unsigned int p = 1; p < namePieces.size(); ++p)
6501 nodeNameIndex = nodeIndices[i];
6502 if(nodeNameFixedWidth > 1)
6504 if(nodeNameIndex.size() > nodeNameFixedWidth)
6506 __SS__ <<
"Illegal node name index '" << nodeNameIndex
6507 <<
"' - length is longer than fixed width "
6509 << nodeNameFixedWidth <<
"!" << __E__;
6514 while(nodeNameIndex.size() < nodeNameFixedWidth)
6515 nodeNameIndex =
"0" + nodeNameIndex;
6518 name += nodeNameIndex + namePieces[p];
6522 if(hostnamePieces.size())
6524 hostname = hostnamePieces[0];
6525 std::string hostnameIndex;
6526 for(
unsigned int p = 1; p < hostnamePieces.size(); ++p)
6528 hostnameIndex = hostnameIndices[i];
6529 if(hostnameFixedWidth > 1)
6531 if(hostnameIndex.size() > hostnameFixedWidth)
6533 __SS__ <<
"Illegal hostname index '"
6535 <<
"' - length is longer than fixed width "
6537 << hostnameFixedWidth <<
"!" << __E__;
6542 while(hostnameIndex.size() < hostnameFixedWidth)
6543 hostnameIndex =
"0" + hostnameIndex;
6546 hostname += hostnameIndex + hostnamePieces[p];
6548 __COUTV__(hostname);
6555 << author <<
"... Replacing row UID '"
6556 << typeTable.tableView_
6557 ->getDataView()[row]
6559 <<
"' with UID '" << name <<
"'" << __E__;
6562 if(row < maxRowToDelete)
6563 deleteRecordMap[row] =
false;
6568 << author <<
"... Copying row UID '"
6569 << typeTable.tableView_
6570 ->getDataView()[row]
6572 <<
"' to UID '" << name <<
"'" << __E__;
6573 unsigned int copyRow = typeTable.tableView_->
copyRows(
6575 *(typeTable.tableView_),
6582 if(row < maxRowToDelete)
6583 deleteRecordMap[copyRow] =
false;
6588 name, row, typeTable.tableView_->
getColUID());
6590 hostname, row, hostnameCol);
6593 TableViewColumnInfo::DATATYPE_COMMENT_DEFAULT,
6597 typeTable.tableView_->
setValue(time(0), row, timestampCol);
6599 __COUTTV__(typeTable
6601 ->getDataView()[row][commentCol]);
6602 __COUTTV__(typeTable
6604 ->getDataView()[row][authorCol]);
6605 __COUTTV__(typeTable
6607 ->getDataView()[row][timestampCol]);
6617 <<
"Looking for best original node match for row=" << row
6618 <<
" UID='" << name <<
"'" << __E__;
6619 size_t bestScore = 0;
6620 std::string bestOriginalNodeName;
6621 for(
const auto& originalNodePair : originalMultinodeValues)
6623 if(originalNodePair.second.find(
6624 ORIG_MAP_ART_PROC_NAME_COL) !=
6625 originalNodePair.second.end())
6626 __COUTTV__(originalNodePair.second.at(
6627 ORIG_MAP_ART_PROC_NAME_COL));
6629 for(
size_t c = 0, d = 0;
6630 c < originalNodePair.first.size() && d < name.size();
6633 if(name[d] == originalNodePair.first[c])
6635 else if(d + 1 < name.size() &&
6636 name[d + 1] == originalNodePair.first[c])
6638 else if(c + 1 < originalNodePair.first.size() &&
6639 name[d] == originalNodePair.first[c + 1])
6642 if(originalNodePair.first.size() == name.size())
6644 __COUTVS__(2, score);
6645 if(score > bestScore)
6647 bestOriginalNodeName = originalNodePair.first;
6649 __COUTVS__(2, bestOriginalNodeName);
6650 __COUTVS__(2, bestScore);
6654 bool exactMatch = (bestOriginalNodeName == name);
6655 bool needToHandleArtProcessName =
false;
6656 std::string artProcessName;
6659 originalMultinodeValues.find(bestOriginalNodeName) !=
6660 originalMultinodeValues.end())
6662 __COUT__ <<
"Populating original multinode value from '"
6663 << bestOriginalNodeName <<
"' into '" << name
6666 for(
const auto& valuePair :
6667 originalMultinodeValues.at(bestOriginalNodeName))
6670 if(!exactMatch && (valuePair.first == commentCol ||
6671 valuePair.first == authorCol ||
6672 valuePair.first == timestampCol))
6675 <<
"Not exact node name match, so keeping "
6676 "default meta info for node: "
6677 << name <<
"[" << row <<
"]["
6679 <<
"] /= " << valuePair.second <<
" keep= "
6680 << typeTable.tableView_
6681 ->getDataView()[row][valuePair.first]
6686 __COUTT__ <<
"Customizing node: " << name <<
"["
6687 << row <<
"][" << valuePair.first
6688 <<
"] = " << valuePair.second << __E__;
6690 if(valuePair.first == ORIG_MAP_ART_PROC_NAME_COL)
6692 __COUTT__ <<
"NEED Special art Process Name "
6694 << valuePair.second << __E__;
6695 needToHandleArtProcessName =
true;
6696 artProcessName = valuePair.second;
6699 valuePair.second, row, artProcessNameCol);
6703 valuePair.second, row, valuePair.first);
6707 __COUT__ <<
"Did not find '" << name
6708 <<
"' in original value cache. Looking for "
6709 "bestOriginalNodeName="
6710 << bestOriginalNodeName << __E__;
6712 __COUTV__(exactMatch);
6715 if(originalMultinodeSameSiblingValues.find(
6717 originalMultinodeSameSiblingValues.end())
6719 __COUT__ <<
"Applying multinode sibling same value "
6721 << row <<
" UID='" << name <<
"'" << __E__;
6722 for(
const auto& sameValuePair :
6723 originalMultinodeSameSiblingValues.at(
6726 if(!sameValuePair.second.first)
6729 <<
"Found originalMultinodeSameSiblingValues["
6730 << nodePair.first <<
"]["
6731 << sameValuePair.first <<
"] = "
6732 << sameValuePair.second.first <<
" --> "
6733 << sameValuePair.second.second << __E__;
6736 if(sameValuePair.first ==
6737 ORIG_MAP_ART_PROC_NAME_COL)
6739 __COUTT__ <<
"NEED Special art Process Name "
6741 << sameValuePair.second.second
6743 needToHandleArtProcessName =
true;
6744 artProcessName = sameValuePair.second.second;
6747 sameValuePair.second.second,
6753 sameValuePair.second.second,
6755 sameValuePair.first);
6760 if(originalMultinodeAllSiblingEmbeddedPrinterIndex.find(
6762 originalMultinodeAllSiblingEmbeddedPrinterIndex.end())
6764 __COUT__ <<
"Applying multinode sibling embbeded "
6765 "printer syntax index rules for row="
6766 << row <<
" UID='" << name
6767 <<
"' and printer index='" << nodeNameIndex
6769 for(
const auto& embedValuePair :
6770 originalMultinodeAllSiblingEmbeddedPrinterIndex
6771 .at(nodePair.first))
6773 if(!embedValuePair.second.first ||
6774 embedValuePair.second.second.size() < 2)
6778 "originalMultinodeAllSiblingEmbeddedPrinte"
6780 << nodePair.first <<
"]["
6781 << embedValuePair.first <<
"] = "
6782 << embedValuePair.second.first <<
" --> "
6784 embedValuePair.second.second)
6786 std::string embedValue =
6788 embedValuePair.second.second,
6790 __COUTTV__(embedValue);
6793 if(embedValuePair.first ==
6794 ORIG_MAP_ART_PROC_NAME_COL)
6796 __COUTT__ <<
"NEED Special art Process Name "
6798 << embedValue << __E__;
6799 needToHandleArtProcessName =
true;
6800 artProcessName = embedValue;
6803 embedValue, row, artProcessNameCol);
6807 embedValue, row, embedValuePair.first);
6811 if(originalMultinodeAllSiblingEmbeddedName.find(
6813 originalMultinodeAllSiblingEmbeddedName.end())
6815 __COUT__ <<
"Applying multinode sibling embbeded "
6816 "name rules for row="
6817 << row <<
" UID='" << name <<
"'" << __E__;
6818 for(
const auto& embedValuePair :
6819 originalMultinodeAllSiblingEmbeddedName.at(
6822 if(!embedValuePair.second.first ||
6823 embedValuePair.second.second.size() < 2)
6827 "originalMultinodeAllSiblingEmbeddedName["
6828 << nodePair.first <<
"]["
6829 << embedValuePair.first <<
"] = "
6830 << embedValuePair.second.first <<
" --> "
6832 embedValuePair.second.second)
6834 std::string embedValue =
6836 embedValuePair.second.second, name);
6837 __COUTTV__(embedValue);
6840 if(embedValuePair.first ==
6841 ORIG_MAP_ART_PROC_NAME_COL)
6843 __COUTT__ <<
"NEED Special art Process Name "
6845 << embedValue << __E__;
6846 needToHandleArtProcessName =
true;
6847 artProcessName = embedValue;
6850 embedValue, row, artProcessNameCol);
6854 embedValue, row, embedValuePair.first);
6858 __COUTV__(needToHandleArtProcessName);
6859 if(needToHandleArtProcessName)
6861 __COUTT__ <<
"Special art Process Name column value: "
6862 << artProcessName << __E__;
6864 std::string artRecord =
6865 typeTable.tableView_->getDataView()
6866 [row][typeTable.tableView_->
findCol(
6867 ARTDAQTableBase::colARTDAQNotReader_
6868 .colLinkToArtUID_)];
6869 __COUTTV__(artRecord);
6871 const unsigned int artCommentCol =
6873 TableViewColumnInfo::TYPE_COMMENT);
6874 const unsigned int artAuthorCol =
6876 TableViewColumnInfo::TYPE_AUTHOR);
6877 const unsigned int artTimestampCol =
6879 TableViewColumnInfo::TYPE_TIMESTAMP);
6881 unsigned int artRow = artTable->tableView_->
findRow(
6887 if(artRow == TableView::INVALID)
6889 __COUTT__ <<
"Need to make art Process record... "
6891 << artRecord << __E__;
6895 __COUTTV__(bestOriginalNodeName);
6896 const unsigned int bestMatchRow =
6897 typeTable.tableView_->
findRow(
6899 bestOriginalNodeName);
6900 __COUTTV__(bestMatchRow);
6902 std::string bestMatchArtRecord =
6903 typeTable.tableView_->getDataView()
6905 [typeTable.tableView_->
findCol(
6908 .colLinkToArtUID_)];
6909 __COUTTV__(bestMatchArtRecord);
6911 unsigned int bestMatchArtRow =
6912 artTable->tableView_->
findRow(
6917 __COUTTV__(bestMatchArtRow);
6918 if(bestMatchArtRow !=
6923 __COUTTV__(lastArtRow);
6926 if(lastArtRow != TableView::INVALID)
6928 __COUTT__ <<
"Copying art Process record... "
6930 << lastArtRow << __E__;
6931 unsigned int copyRow =
6934 *(artTable->tableView_),
6948 DATATYPE_COMMENT_DEFAULT,
6952 author, artRow, artAuthorCol);
6954 time(0), artRow, artTimestampCol);
6958 __COUTT__ <<
"Creating art Process record... "
6960 << artRecord << __E__;
6962 artRow = artTable->tableView_->
addRow(
6968 <<
"Made art Process record... artRecord="
6969 << artRecord << __E__;
6972 __COUTT__ <<
"Modify art Process record based on "
6973 "sibling rules... artRecord="
6975 <<
" artProcessName=" << artProcessName
6979 artProcessName, artRow, artProcessNameCol);
6980 lastArtRow = artRow;
6984 needToHandleArtProcessName)
6986 std::string artRecord =
6987 typeTable.tableView_->getDataView()
6988 [row][typeTable.tableView_->
findCol(
6989 ARTDAQTableBase::colARTDAQNotReader_
6990 .colLinkToArtUID_)];
6991 __COUTTV__(artRecord);
6992 unsigned int artRow = artTable->tableView_->
findRow(
7000 lastArtRow = artRow;
7003 __COUTTV__(lastArtRow);
7008 if(row < maxRowToDelete)
7009 __COUTTV__(deleteRecordMap[row]);
7011 __COUTTV__(typeTable
7013 ->getDataView()[row][commentCol]);
7014 __COUTTV__(typeTable
7016 ->getDataView()[row][authorCol]);
7017 __COUTTV__(typeTable
7019 ->getDataView()[row][timestampCol]);
7029 __COUT__ <<
"Deleting '" << nodeTypePair.first
7030 <<
"' records not specified..." << __E__;
7033 std::set<unsigned int> orderedRowSet;
7034 for(
auto& deletePair : deleteRecordMap)
7036 if(!deletePair.second)
7038 __COUTT__ <<
"Row keep = " << deletePair.first << __E__;
7042 __COUTT__ <<
"Row delete = " << deletePair.first << __E__;
7043 orderedRowSet.emplace(deletePair.first);
7047 for(std::set<unsigned int>::reverse_iterator rit = orderedRowSet.rbegin();
7048 rit != orderedRowSet.rend();
7054 if(TTEST(1) && artTable)
7056 std::stringstream ss;
7057 artTable->tableView_->print(ss);
7058 __COUT_MULTI__(1, ss.str());
7061 if(hasArtProcessName && artTable)
7062 artTable->tableView_
7067 std::stringstream ss;
7068 typeTable.tableView_->print(ss);
7069 __COUT_MULTI__(1, ss.str());
7072 typeTable.tableView_->
init();
7079 std::stringstream ss;
7080 artdaqSupervisorTable.tableView_->print(ss);
7081 __COUT_MULTI__(1, ss.str());
7084 std::stringstream ss;
7085 artdaqSubsystemTable.tableView_->print(ss);
7086 __COUT_MULTI__(1, ss.str());
7090 artdaqSupervisorTable.tableView_
7092 artdaqSubsystemTable.tableView_
7097 __COUT__ <<
"Table errors while creating ARTDAQ nodes. Erasing all newly "
7098 "created table versions."
7103 __COUT__ <<
"Edits complete for artdaq nodes and subsystems.. now save and activate "
7104 "groups, and update aliases!"
7110 __SS__ <<
"DEBUG blocking save!" << __E__;
7114 std::string localAccumulatedWarnings;
7115 configGroupEdit.saveChanges(configGroupEdit.originalGroupName_,
7116 newConfigurationGroupKey,
7123 &localAccumulatedWarnings);
7139 void ARTDAQTableBase::addCommentWhitespace(std::ostream& os,
size_t lineLength)
7141 for(
size_t i = 0;
true; i += 20)
7143 if(lineLength < FCL_COMMENT_POSITION + i)
7145 os << std::string(FCL_COMMENT_POSITION + i - lineLength,
' ');
7153 std::string ARTDAQTableBase::getStructureAsJSON(
7156 if(fclMap_.size() == 0)
7158 std::stringstream oss;
7160 oss <<
"{" << __E__;
7162 if(fclMap_.size() > 1)
7165 bool firstType =
true;
7166 for(
const auto& typePairMap : fclMap_)
7170 oss <<
"\t\"" << getTypeString(typePairMap.first) <<
"\": {" << __E__;
7172 bool firstEntry =
true;
7173 for(
const auto& fclPair : typePairMap.second)
7177 oss <<
"\t\t\"" << fclPair.first <<
"\": \""
7183 oss <<
"\t}" << __E__;
7190 bool firstEntry =
true;
7191 for(
const auto& typePairMap : fclMap_)
7193 for(
const auto& fclPair : typePairMap.second)
7197 oss <<
"\t\"" << fclPair.first <<
"\": \""
7205 oss <<
"}" << __E__;
7214 size_t maxFragmentSizeBytes,
7215 size_t routingTimeoutMs,
7216 size_t routingRetryCount,
7221 __SS__ <<
"ARTDAQ Supervisor node is disconnected while generating boot.txt "
7222 <<
"content." << __E__;
7226 const ARTDAQInfo& info = extractARTDAQInfo(artdaqSupervisorNode,
7229 maxFragmentSizeBytes,
7235 artdaqSupervisorNode.
getNode(colARTDAQSupervisor_.colDAQInterfaceDebugLevel_)
7237 std::string setupScript =
7238 artdaqSupervisorNode.
getNode(colARTDAQSupervisor_.colDAQSetupScript_).
getValue();
7247 const std::string& setupScript,
7250 std::stringstream o;
7252 o <<
"DAQ setup script: " << setupScript << std::endl;
7253 o <<
"debug level: " << debugLevel << std::endl;
7256 if(info.subsystems.size() > 1)
7258 for(
auto& ss : info.subsystems)
7262 o <<
"Subsystem id: " << ss.first << std::endl;
7263 if(ss.second.destination != 0)
7265 o <<
"Subsystem destination: " << ss.second.destination << std::endl;
7267 for(
auto& sss : ss.second.sources)
7269 o <<
"Subsystem source: " << sss << std::endl;
7271 if(ss.second.eventMode)
7273 o <<
"Subsystem fragmentMode: False" << std::endl;
7279 for(
auto& builder : info.processes.at(ARTDAQAppType::EventBuilder))
7281 o <<
"EventBuilder host: " << builder.hostname << std::endl;
7282 o <<
"EventBuilder label: " << builder.label << std::endl;
7283 if(builder.subsystem != 1)
7285 o <<
"EventBuilder subsystem: " << builder.subsystem << std::endl;
7287 if(builder.allowed_processors !=
"")
7289 o <<
"EventBuilder allowed_processors: " << builder.allowed_processors
7295 for(
auto& logger : info.processes.at(ARTDAQAppType::DataLogger))
7297 o <<
"DataLogger host: " << logger.hostname << std::endl;
7298 o <<
"DataLogger label: " << logger.label << std::endl;
7299 if(logger.subsystem != 1)
7301 o <<
"DataLogger subsystem: " << logger.subsystem << std::endl;
7303 if(logger.allowed_processors !=
"")
7305 o <<
"DataLogger allowed_processors: " << logger.allowed_processors
7311 for(
auto& dispatcher : info.processes.at(ARTDAQAppType::Dispatcher))
7313 o <<
"Dispatcher host: " << dispatcher.hostname << std::endl;
7314 o <<
"Dispatcher label: " << dispatcher.label << std::endl;
7315 if(dispatcher.subsystem != 1)
7317 o <<
"Dispatcher subsystem: " << dispatcher.subsystem << std::endl;
7319 if(dispatcher.allowed_processors !=
"")
7321 o <<
"Dispatcher allowed_processors: " << dispatcher.allowed_processors
7327 for(
auto& rm : info.processes.at(ARTDAQAppType::RoutingManager))
7329 o <<
"RoutingManager host: " << rm.hostname << std::endl;
7330 o <<
"RoutingManager label: " << rm.label << std::endl;
7331 if(rm.subsystem != 1)
7333 o <<
"RoutingManager subsystem: " << rm.subsystem << std::endl;
7335 if(rm.allowed_processors !=
"")
7337 o <<
"RoutingManager allowed_processors: " << rm.allowed_processors
<virtual so future plugins can inherit from multiple table base classes
static void outputDataReceiverFHICL(const ConfigurationTree &receiverNode, ARTDAQAppType appType, size_t maxFragmentSizeBytes=DEFAULT_MAX_FRAGMENT_SIZE, size_t routingTimeoutMs=DEFAULT_ROUTING_TIMEOUT_MS, size_t routingRetryCount=DEFAULT_ROUTING_RETRY_COUNT, std::string *returnFcl=nullptr)
static void insertArtProcessBlock(std::ostream &out, std::string &tabStr, std::string &commentStr, const std::string &parentPath, ConfigurationTree art, ConfigurationTree subsystemLink=ConfigurationTree(), size_t routingTimeoutMs=DEFAULT_ROUTING_TIMEOUT_MS, size_t routingRetryCount=DEFAULT_ROUTING_RETRY_COUNT)
static const std::string ARTDAQ_FCL_PATH
Tree-path rule is, if the last link in the path is a group link with a specified group ID,...
static std::string insertModuleType(std::ostream &out, std::string &tabStr, std::string &commentStr, const std::string &parentPath, ConfigurationTree moduleTypeNode)
static std::string getBootFileContentFromInfo(const ARTDAQInfo &info, const std::string &setupScript, int debugLevel)
static bool isARTDAQEnabled(const ConfigurationManager *cfgMgr)
isARTDAQEnabled
static void insertParameters(std::ostream &out, std::string &tabStr, std::string &commentStr, const std::string &parentPath, ConfigurationTree parameterLink, const std::string ¶meterPreamble, bool onlyInsertAtTableParameters=false, bool includeAtTableParameters=false)
static void setAndActivateARTDAQSystem(ConfigurationManagerRW *cfgMgr, const std::map< std::string, std::map< std::string, std::vector< std::string >>> &nodeTypeToObjectMap, const std::map< std::string, std::string > &subsystemObjectMap)
static struct ots::ARTDAQTableBase::ProcessTypes processTypes_
Note!!!! processTypes_ must be instantiate after the static artdaq table names (to construct map in c...
static void outputOnlineMonitorFHICL(const ConfigurationTree &onlineMonitorNode)
std::string getBootFileContent(ConfigurationTree artdaqSupervisorNode, size_t maxFragmentSizeBytes=DEFAULT_MAX_FRAGMENT_SIZE, size_t routingTimeoutMs=DEFAULT_ROUTING_TIMEOUT_MS, size_t routingRetryCount=DEFAULT_ROUTING_RETRY_COUNT, ProgressBar *progressBar=0)
static const ARTDAQInfo & getARTDAQSystem(ConfigurationManagerRW *cfgMgr, std::map< std::string, std::map< std::string, std::vector< std::string >>> &nodeTypeToObjectMap, std::map< std::string, std::string > &subsystemObjectMap, std::vector< std::string > &artdaqSupervisoInfo)
static void insertMetricsBlock(std::ostream &out, std::string &tabStr, std::string &commentStr, const std::string &parentPath, ConfigurationTree daqNode)
insertMetricsBlock
const std::string & getUsername(void) const
Getters.
bool isOwnerFirstAppInContext(void)
ConfigurationTree getNode(const std::string &nodeString, bool doNotThrowOnBrokenUIDLinks=false) const
"root/parent/parent/"
const TableBase * getTableByName(const std::string &configurationName) const
void initPrereqsForARTDAQ(void)
loadGroupHistory
const unsigned int & getRow(void) const
getRow
bool isDisconnected(void) const
ConfigurationTree getNode(const std::string &nodeName, bool doNotThrowOnBrokenUIDLinks=false) const
navigating between nodes
const std::string & getTableName(void) const
getTableName
T getValueWithDefault(const T &defaultValue) const
const std::string & getValueAsString(bool returnLinkTableValue=false) const
const ConfigurationManager * getConfigurationManager(void) const
extracting information from node
void getValue(T &value) const
std::vector< std::pair< std::string, ConfigurationTree > > getChildren(std::map< std::string, std::string > filterMap=std::map< std::string, std::string >(), bool byPriority=false, bool onlyStatusTrue=false) const
std::string getParentLinkIndex(void) const
getParentLinkIndex
const std::string & getUIDAsString(void) const
const unsigned int & getNodeRow(void) const
getNodeRow
const std::string & getFieldName(void) const
alias for getValueName
std::string getParentLinkID(void) const
getParentLinkID
const std::string & getParentTableName(void) const
getParentTableName
const std::string & getParentRecordName(void) const
getParentRecordName
const std::string & getParentLinkColumnName(void) const
getParentLinkColumnName
bool isFirstAppInContext_
for managing things that should only happen once per node (e.g., write files). If used,...
std::string str() const
alternative alias method
bool isUID(void) const
isUID
bool isGroupID(void) const
unsigned int findRow(unsigned int col, const T &value, unsigned int offsetRow=0, bool doNotThrow=false) const
< in included .icc source
void setValueAsString(const std::string &value, unsigned int row, unsigned int col)
unsigned int getColStatus(void) const
unsigned int findColByType(const std::string &type, unsigned int startingCol=0) const
unsigned int copyRows(const std::string &author, const TableView &src, unsigned int srcOffsetRow=0, unsigned int srcRowsToCopy=(unsigned int) -1, unsigned int destOffsetRow=(unsigned int) -1, unsigned char generateUniqueDataColumns=false, const std::string &baseNameAutoUID="")
const std::string & setUniqueColumnValue(unsigned int row, unsigned int col, std::string baseValueAsString="", bool doMathAppendStrategy=false, std::string childLinkIndex="", std::string groupId="")
unsigned int getColUID(void) const
unsigned int findCol(const std::string &name) const
void setValue(const T &value, unsigned int row, unsigned int col)
< in included .icc source
unsigned int addRow(const std::string &author="", unsigned char incrementUniqueData=false, const std::string &baseNameAutoUID="", unsigned int rowToAdd=(unsigned int) -1, std::string childLinkIndex="", std::string groupId="")
const XDAQContext * getTheARTDAQSupervisorContext(void) const
artdaq specific get methods
defines used also by OtsConfigurationWizardSupervisor
ARTDAQ DAQ Parameter Column names.
ARTDAQ Builder/Logger/Dispatcher Column names.
ARTDAQ Reader Column names.
ARTDAQ Subsystem Column names.
ARTDAQ Supervisor Column names.
TableEditStruct & getTableEditStruct(const std::string &tableName, bool markModified=false)
Note: if markModified, and table not found in group, this function will try to add it to group.
static std::string getTimestampString(const std::string &linuxTimeInSeconds)
static const std::string & trim(std::string &s)
static void getVectorFromString(const std::string &inputString, std::vector< std::string > &listToReturn, const std::set< char > &delimiter={',', '|', '&'}, const std::set< char > &whitespace={' ', '\t', '\n', '\r'}, std::vector< char > *listOfDelimiters=0, bool decodeURIComponents=false)
static std::string setToString(const std::set< T > &setToReturn, const std::string &delimeter=", ")
setToString ~
static std::string vectorToString(const std::vector< T > &setToReturn, const std::string &delimeter=", ")
vectorToString ~
static std::string escapeJSONStringEntities(const std::string &str)
static bool extractCommonChunks(const std::vector< std::string > &haystack, std::vector< std::string > &commonChunksToReturn, std::vector< std::string > &wildcardStrings, unsigned int &fixedWildcardLength)
static std::string mapToString(const std::map< std::string, T > &mapToReturn, const std::string &primaryDelimeter=", ", const std::string &secondaryDelimeter=": ")
static std::string decodeURIComponent(const std::string &data)
static std::string stackTrace(void)