1 #include <fhiclcpp/ParameterSet.h>
2 #include <fhiclcpp/detail/print_mode.h>
3 #include <fhiclcpp/intermediate_table.h>
4 #include <fhiclcpp/make_ParameterSet.h>
5 #include <fhiclcpp/parse.h>
7 #include "otsdaq/TablePlugins/ARTDAQTableBase/ARTDAQTableBase.h"
8 #include "otsdaq/TablePlugins/XDAQContextTable.h"
14 #include "otsdaq/ProgressBar/ProgressBar.h"
19 #define __MF_SUBJECT__ "ARTDAQTableBase"
23 const std::string ARTDAQTableBase::ARTDAQ_FCL_PATH = std::string(__ENV__(
"USER_DATA")) +
"/" +
"ARTDAQConfigurations/";
26 const std::string ARTDAQTableBase::ARTDAQ_SUPERVISOR_CLASS =
"ots::ARTDAQSupervisor";
27 const std::string ARTDAQTableBase::ARTDAQ_SUPERVISOR_TABLE =
"ARTDAQSupervisorTable";
29 const std::string ARTDAQTableBase::ARTDAQ_READER_TABLE =
"ARTDAQBoardReaderTable";
30 const std::string ARTDAQTableBase::ARTDAQ_BUILDER_TABLE =
"ARTDAQEventBuilderTable";
31 const std::string ARTDAQTableBase::ARTDAQ_LOGGER_TABLE =
"ARTDAQDataLoggerTable";
32 const std::string ARTDAQTableBase::ARTDAQ_DISPATCHER_TABLE =
"ARTDAQDispatcherTable";
33 const std::string ARTDAQTableBase::ARTDAQ_MONITOR_TABLE =
"ARTDAQMonitorTable";
34 const std::string ARTDAQTableBase::ARTDAQ_ROUTER_TABLE =
"ARTDAQRoutingMasterTable";
36 const std::string ARTDAQTableBase::ARTDAQ_SUBSYSTEM_TABLE =
"ARTDAQSubsystemTable";
38 const std::string ARTDAQTableBase::ARTDAQ_TYPE_TABLE_HOSTNAME =
"ExecutionHostname";
39 const std::string ARTDAQTableBase::ARTDAQ_TYPE_TABLE_SUBSYSTEM_LINK =
"SubsystemLink";
40 const std::string ARTDAQTableBase::ARTDAQ_TYPE_TABLE_SUBSYSTEM_LINK_UID =
"SubsystemLinkUID";
43 const int ARTDAQTableBase::NULL_SUBSYSTEM_DESTINATION = 0;
44 const std::string ARTDAQTableBase::NULL_SUBSYSTEM_DESTINATION_LABEL =
"nullDestinationSubsystem";
62 ARTDAQTableBase::ARTDAQTableBase(std::string tableName, std::string* accumulatedExceptions ) :
TableBase(tableName, accumulatedExceptions)
65 mkdir((ARTDAQ_FCL_PATH).c_str(), 0755);
71 ARTDAQTableBase::ARTDAQTableBase(
void) :
TableBase(
"ARTDAQTableBase")
73 __SS__ <<
"Should not call void constructor, table type is lost!" << __E__;
78 ARTDAQTableBase::~ARTDAQTableBase(
void) {}
81 const std::string& ARTDAQTableBase::getTypeString(ARTDAQAppType type)
85 case ARTDAQAppType::EventBuilder:
86 return processTypes_.BUILDER;
87 case ARTDAQAppType::DataLogger:
88 return processTypes_.LOGGER;
89 case ARTDAQAppType::Dispatcher:
90 return processTypes_.DISPATCHER;
91 case ARTDAQAppType::BoardReader:
92 return processTypes_.READER;
93 case ARTDAQAppType::Monitor:
94 return processTypes_.MONITOR;
95 case ARTDAQAppType::RoutingMaster:
96 return processTypes_.ROUTER;
99 __SS__ <<
"Illegal translation attempt for type '" << (
unsigned int)type <<
"'" << __E__;
104 std::string ARTDAQTableBase::getFHICLFilename(ARTDAQAppType type,
const std::string& name)
108 std::string filename = ARTDAQ_FCL_PATH + getTypeString(type) +
"-";
109 std::string uid = name;
110 for(
unsigned int i = 0; i < uid.size(); ++i)
111 if((uid[i] >=
'a' && uid[i] <=
'z') || (uid[i] >=
'A' && uid[i] <=
'Z') || (uid[i] >=
'0' && uid[i] <=
'9'))
122 std::string ARTDAQTableBase::getFlatFHICLFilename(ARTDAQAppType type,
const std::string& name)
126 std::string filename = ARTDAQ_FCL_PATH + getTypeString(type) +
"-";
127 std::string uid = name;
128 for(
unsigned int i = 0; i < uid.size(); ++i)
129 if((uid[i] >=
'a' && uid[i] <=
'z') || (uid[i] >=
'A' && uid[i] <=
'Z') || (uid[i] >=
'0' && uid[i] <=
'9'))
132 filename +=
"_flattened.fcl";
140 void ARTDAQTableBase::flattenFHICL(ARTDAQAppType type,
const std::string& name)
144 std::string inFile = getFHICLFilename(type, name);
145 std::string outFile = getFlatFHICLFilename(type, name);
150 cet::filepath_lookup_nonabsolute policy(
"FHICL_FILE_PATH");
152 fhicl::ParameterSet pset;
156 fhicl::intermediate_table tbl;
157 fhicl::parse_document(inFile, policy, tbl);
158 fhicl::ParameterSet pset;
159 fhicl::make_ParameterSet(tbl, pset);
161 std::ofstream ofs{outFile};
162 ofs << pset.to_indented_string(0);
164 catch(cet::exception
const& e)
166 __SS__ <<
"Failed to parse fhicl: " << e.what() << __E__;
178 void ARTDAQTableBase::insertParameters(std::ostream& out,
180 std::string& commentStr,
182 const std::string& parameterPreamble,
183 bool onlyInsertAtTableParameters ,
184 bool includeAtTableParameters )
187 if(!parameterGroupLink.isDisconnected())
190 auto otherParameters = parameterGroupLink.getChildren();
194 for(
auto& parameter : otherParameters)
196 key = parameter.second.getNode(parameterPreamble +
"Key").getValue();
200 if(key.find(
"@table::") != std::string::npos)
203 if(onlyInsertAtTableParameters || includeAtTableParameters)
205 if(!parameter.second.status())
211 OUT << parameter.second.getNode(parameterPreamble +
"Value").getValue() <<
"\n";
213 if(!parameter.second.status())
222 if(onlyInsertAtTableParameters)
225 if(!parameter.second.status())
231 if(key.find(
"#include") == std::string::npos)
233 OUT << parameter.second.getNode(parameterPreamble +
"Value").getValue() <<
"\n";
235 if(!parameter.second.status())
247 std::string ARTDAQTableBase::insertModuleType(std::ostream& out, std::string& tabStr, std::string& commentStr,
ConfigurationTree moduleTypeNode)
249 std::string value = moduleTypeNode.getValue();
252 if(value.find(
"@table::") == std::string::npos)
253 out <<
"module_type: ";
254 out << value <<
"\n";
261 void ARTDAQTableBase::insertMetricsBlock(std::ostream& out, std::string& tabStr, std::string& commentStr,
ConfigurationTree daqNode)
263 OUT <<
"\n\nmetrics: {\n";
266 auto metricsGroup = daqNode.getNode(
"daqMetricsLink");
267 if(!metricsGroup.isDisconnected())
269 auto metrics = metricsGroup.getChildren();
271 for(
auto& metric : metrics)
273 if(!metric.second.status())
276 OUT << metric.second.getNode(
"metricKey").getValue() <<
": {\n";
279 OUT <<
"metricPluginType: " << metric.second.getNode(
"metricPluginType").getValue() <<
"\n";
280 OUT <<
"level: " << metric.second.getNode(
"metricLevel").getValue() <<
"\n";
282 auto metricParametersGroup = metric.second.getNode(
"metricParametersLink");
283 if(!metricParametersGroup.isDisconnected())
285 auto metricParameters = metricParametersGroup.getChildren();
286 for(
auto& metricParameter : metricParameters)
288 if(!metricParameter.second.status())
291 OUT << metricParameter.second.getNode(
"metricParameterKey").getValue() <<
": "
292 << metricParameter.second.getNode(
"metricParameterValue").getValue() <<
"\n";
294 if(!metricParameter.second.status())
301 if(!metric.second.status())
310 void ARTDAQTableBase::outputBoardReaderFHICL(
const ConfigurationTree& boardReaderNode,
311 size_t maxFragmentSizeBytes ,
312 size_t routingTimeoutMs ,
313 size_t routingRetryCount )
440 std::string filename = getFHICLFilename(ARTDAQAppType::BoardReader, boardReaderNode.getValue());
446 std::string tabStr =
"";
447 std::string commentStr =
"";
449 out.open(filename, std::fstream::out | std::fstream::trunc);
452 __SS__ <<
"Failed to open ARTDAQ BoardReader fcl file: " << filename << __E__;
458 OUT <<
"###########################################################" << __E__;
460 OUT <<
"# artdaq reader fcl configuration file produced by otsdaq." << __E__;
461 OUT <<
"# Creation time: \t" << StringMacros::getTimestampString() << __E__;
462 OUT <<
"# Original filename: \t" << filename << __E__;
463 OUT <<
"# otsdaq-ARTDAQ Reader UID:\t" << boardReaderNode.getValue() << __E__;
465 OUT <<
"###########################################################" << __E__;
471 if(boardReaderNode.isDisconnected())
479 catch(
const std::runtime_error&)
492 OUT <<
"fragment_receiver: {\n";
495 OUT <<
"max_fragment_size_bytes: " << maxFragmentSizeBytes <<
"\n";
499 <<
": " << boardReaderNode.getNode(
"daqGeneratorPluginType").getValue() << (
"\t #daq generator plug-in type") <<
"\n";
500 OUT <<
"fragment_type"
501 <<
": " << boardReaderNode.getNode(
"daqGeneratorFragmentType").getValue() << (
"\t #generator data fragment type") <<
"\n\n";
504 auto parametersLink = boardReaderNode.getNode(
"daqParametersLink");
505 if(!parametersLink.isDisconnected())
507 auto parameters = parametersLink.getChildren();
508 for(
auto& parameter : parameters)
510 if(!parameter.second.status())
520 auto comment = parameter.second.getNode(TableViewColumnInfo::COL_NAME_COMMENT);
521 OUT << parameter.second.getNode(
"daqParameterKey").getValue() <<
": " << parameter.second.getNode(
"daqParameterValue").getValue()
522 << (comment.isDefaultValue() ?
"" : (
"\t # " + comment.getValue())) <<
"\n";
524 if(!parameter.second.status())
531 OUT <<
"destinations: {\n";
535 OUT <<
"routing_table_config: {\n";
538 auto readerSubsystemID = 1;
539 auto readerSubsystemLink = boardReaderNode.getNode(
"SubsystemLink");
540 if(!readerSubsystemLink.isDisconnected())
542 readerSubsystemID = getSubsytemId(readerSubsystemLink);
544 if(info_.subsystems[readerSubsystemID].hasRoutingMaster)
546 OUT <<
"use_routing_master: true\n";
547 OUT <<
"routing_master_hostname: \"" << info_.subsystems[readerSubsystemID].routingMasterHost <<
"\"\n";
548 OUT <<
"table_update_port: 0\n";
549 OUT <<
"table_update_address: \"0.0.0.0\"\n";
550 OUT <<
"table_update_multicast_interface: \"0.0.0.0\"\n";
551 OUT <<
"table_acknowledge_port : 0\n";
552 OUT <<
"routing_timeout_ms: " << routingTimeoutMs <<
"\n";
553 OUT <<
"routing_retry_count: " << routingRetryCount <<
"\n";
557 OUT <<
"use_routing_master: false\n";
566 insertMetricsBlock(OUT, tabStr, commentStr, boardReaderNode);
577 void ARTDAQTableBase::outputDataReceiverFHICL(
const ConfigurationTree& receiverNode,
578 ARTDAQAppType appType,
579 size_t maxFragmentSizeBytes ,
580 size_t routingTimeoutMs ,
581 size_t routingRetryCount )
583 std::string filename = getFHICLFilename(appType, receiverNode.getValue());
589 std::string tabStr =
"";
590 std::string commentStr =
"";
592 out.open(filename, std::fstream::out | std::fstream::trunc);
595 __SS__ <<
"Failed to open ARTDAQ fcl file: " << filename << __E__;
601 OUT <<
"###########################################################" << __E__;
603 OUT <<
"# artdaq " << getTypeString(appType) <<
" fcl configuration file produced by otsdaq." << __E__;
604 OUT <<
"# Creation time: \t" << StringMacros::getTimestampString() << __E__;
605 OUT <<
"# Original filename: \t" << filename << __E__;
606 OUT <<
"# otsdaq-ARTDAQ " << getTypeString(appType) <<
" UID:\t" << receiverNode.getValue() << __E__;
608 OUT <<
"###########################################################" << __E__;
614 if(receiverNode.isDisconnected())
622 catch(
const std::runtime_error&)
632 insertParameters(out,
635 receiverNode.getNode(
"preambleParametersLink"),
643 auto daq = receiverNode.getNode(
"daqLink");
644 if(!daq.isDisconnected())
650 if(appType == ARTDAQAppType::EventBuilder)
653 OUT <<
"event_builder: {\n";
658 OUT <<
"aggregator: {\n";
663 OUT <<
"max_fragment_size_bytes: " << maxFragmentSizeBytes <<
"\n";
665 if(appType == ARTDAQAppType::DataLogger)
667 OUT <<
"is_datalogger: true\n";
669 else if(appType == ARTDAQAppType::Dispatcher)
671 OUT <<
"is_dispatcher: true\n";
677 insertParameters(out,
680 daq.getNode(
"daqParametersLink"),
685 if(appType == ARTDAQAppType::EventBuilder)
687 OUT <<
"routing_token_config: {\n";
690 auto builderSubsystemID = 1;
691 auto builderSubsystemLink = receiverNode.getNode(
"SubsystemLink");
692 if(!builderSubsystemLink.isDisconnected())
694 builderSubsystemID = getSubsytemId(builderSubsystemLink);
697 if(info_.subsystems[builderSubsystemID].hasRoutingMaster)
699 OUT <<
"use_routing_master: true\n";
700 OUT <<
"routing_master_hostname: \"" << info_.subsystems[builderSubsystemID].routingMasterHost <<
"\"\n";
701 OUT <<
"routing_token_port: 0\n";
705 OUT <<
"use_routing_master: false\n";
712 OUT <<
"sources: {\n"
718 insertMetricsBlock(OUT, tabStr, commentStr, daq);
727 auto art = receiverNode.getNode(
"artLink");
728 if(!art.isDisconnected())
737 auto services = art.getNode(
"servicesLink");
738 if(!services.isDisconnected())
740 OUT <<
"services: {\n";
746 insertParameters(out,
749 services.getNode(
"ServicesParametersLink"),
754 OUT <<
"ArtdaqSharedMemoryServiceInterface: { service_provider: ArtdaqSharedMemoryService \n";
756 OUT <<
"waiting_time: " << services.getNode(
"sharedMemoryWaitingTime").getValue() <<
"\n";
757 OUT <<
"resume_after_timeout: " << (services.getNode(
"sharedMemoryResumeAfterTimeout").getValue<
bool>() ?
"true" :
"false") <<
"\n";
760 OUT <<
"ArtdaqFragmentNamingServiceInterface: { service_provider: " << (services.getNode(
"fragmentNamingServiceProvider").getValue<std::string>())
766 insertParameters(out,
769 services.getNode(
"ServicesParametersLink"),
781 auto outputs = art.getNode(
"outputsLink");
782 if(!outputs.isDisconnected())
784 OUT <<
"outputs: {\n";
788 auto outputPlugins = outputs.getChildren();
789 for(
auto& outputPlugin : outputPlugins)
791 if(!outputPlugin.second.status())
794 OUT << outputPlugin.second.getNode(
"outputKey").getValue() <<
": {\n";
797 std::string moduleType = insertModuleType(out, tabStr, commentStr, outputPlugin.second.getNode(
"outputModuleType"));
801 insertParameters(out,
804 outputPlugin.second.getNode(
"outputModuleParameterLink"),
809 if(outputPlugin.second.getNode(
"outputModuleType").getValue() ==
"BinaryNetOutput" ||
810 outputPlugin.second.getNode(
"outputModuleType").getValue() ==
"RootNetOutput")
812 OUT <<
"destinations: {\n";
814 OUT <<
"routing_table_config: {\n";
817 auto builderSubsystemID = 1;
818 auto builderSubsystemLink = receiverNode.getNode(
"SubsystemLink");
819 if(!builderSubsystemLink.isDisconnected())
821 builderSubsystemID = getSubsytemId(builderSubsystemLink);
823 builderSubsystemID = info_.subsystems[builderSubsystemID].destination;
824 if(info_.subsystems[builderSubsystemID].hasRoutingMaster)
826 OUT <<
"use_routing_master: true\n";
827 OUT <<
"routing_master_hostname: \"" << info_.subsystems[builderSubsystemID].routingMasterHost <<
"\"\n";
828 OUT <<
"table_update_port: 0\n";
829 OUT <<
"table_update_address: \"0.0.0.0\"\n";
830 OUT <<
"table_update_multicast_interface: \"0.0.0.0\"\n";
831 OUT <<
"table_acknowledge_port : 0\n";
832 OUT <<
"routing_timeout_ms: " << routingTimeoutMs <<
"\n";
833 OUT <<
"routing_retry_count: " << routingRetryCount <<
"\n";
837 OUT <<
"use_routing_master: false\n";
847 if(!outputPlugin.second.status())
858 auto physics = art.getNode(
"physicsLink");
859 if(!physics.isDisconnected())
862 OUT <<
"physics: {\n";
868 insertParameters(out,
871 physics.getNode(
"physicsOtherParametersLink"),
876 auto analyzers = physics.getNode(
"analyzersLink");
877 if(!analyzers.isDisconnected())
880 OUT <<
"analyzers: {\n";
884 auto modules = analyzers.getChildren();
885 for(
auto& module : modules)
887 if(!module.second.status())
892 insertParameters(out,
895 module.second.getNode(
"analyzerModuleParameterLink"),
896 "analyzerParameter" ,
900 OUT << module.second.getNode(
"analyzerKey").getValue() <<
": {\n";
902 insertModuleType(out, tabStr, commentStr, module.second.getNode(
"analyzerModuleType"));
906 insertParameters(out,
909 module.second.getNode(
"analyzerModuleParameterLink"),
910 "analyzerParameter" ,
917 if(!module.second.status())
924 auto producers = physics.getNode(
"producersLink");
925 if(!producers.isDisconnected())
928 OUT <<
"producers: {\n";
932 auto modules = producers.getChildren();
933 for(
auto& module : modules)
935 if(!module.second.status())
940 insertParameters(out,
943 module.second.getNode(
"producerModuleParameterLink"),
944 "producerParameter" ,
948 OUT << module.second.getNode(
"producerKey").getValue() <<
": {\n";
951 insertModuleType(out, tabStr, commentStr, module.second.getNode(
"producerModuleType"));
955 insertParameters(out,
958 module.second.getNode(
"producerModuleParameterLink"),
959 "producerParameter" ,
966 if(!module.second.status())
973 auto filters = physics.getNode(
"filtersLink");
974 if(!filters.isDisconnected())
977 OUT <<
"filters: {\n";
981 auto modules = filters.getChildren();
982 for(
auto& module : modules)
984 if(!module.second.status())
989 insertParameters(out,
992 module.second.getNode(
"filterModuleParameterLink"),
997 OUT << module.second.getNode(
"filterKey").getValue() <<
": {\n";
1000 insertModuleType(out, tabStr, commentStr, module.second.getNode(
"filterModuleType"));
1004 insertParameters(out,
1007 module.second.getNode(
"filterModuleParameterLink"),
1015 if(!module.second.status())
1024 insertParameters(out,
1027 physics.getNode(
"physicsOtherParametersLink"),
1028 "physicsParameter" ,
1038 OUT <<
"source: {\n";
1040 OUT <<
"module_type: ArtdaqInput";
1047 OUT <<
"process_name: " << art.getNode(
"ProcessName") <<
"\n";
1051 insertParameters(out,
1054 art.getNode(
"AddOnParametersLink"),
1066 insertParameters(out,
1069 receiverNode.getNode(
"addOnParametersLink"),
1079 void ARTDAQTableBase::outputRoutingMasterFHICL(
const ConfigurationTree& routingMasterNode,
1080 size_t routingTimeoutMs ,
1081 size_t routingRetryCount )
1083 std::string filename = getFHICLFilename(ARTDAQAppType::RoutingMaster, routingMasterNode.getValue());
1089 std::string tabStr =
"";
1090 std::string commentStr =
"";
1092 out.open(filename, std::fstream::out | std::fstream::trunc);
1095 __SS__ <<
"Failed to open ARTDAQ RoutingMaster fcl file: " << filename << __E__;
1101 OUT <<
"###########################################################" << __E__;
1102 OUT <<
"#" << __E__;
1103 OUT <<
"# artdaq routingMaster fcl configuration file produced by otsdaq." << __E__;
1104 OUT <<
"# Creation time: \t" << StringMacros::getTimestampString() << __E__;
1105 OUT <<
"# Original filename: \t" << filename << __E__;
1106 OUT <<
"# otsdaq-ARTDAQ RoutingMaster UID:\t" << routingMasterNode.getValue() << __E__;
1107 OUT <<
"#" << __E__;
1108 OUT <<
"###########################################################" << __E__;
1114 if(routingMasterNode.isDisconnected())
1122 catch(
const std::runtime_error&)
1134 OUT <<
"policy: {\n";
1136 auto policyName = routingMasterNode.getNode(
"routingPolicyPluginType").getValue();
1137 if(policyName ==
"DEFAULT")
1138 policyName =
"NoOp";
1139 OUT <<
"policy: " << policyName <<
"\n";
1140 OUT <<
"receiver_ranks: []\n";
1143 auto parametersLink = routingMasterNode.getNode(
"routingPolicyParametersLink");
1144 if(!parametersLink.isDisconnected())
1146 auto parameters = parametersLink.getChildren();
1147 for(
auto& parameter : parameters)
1149 if(!parameter.second.status())
1159 auto comment = parameter.second.getNode(TableViewColumnInfo::COL_NAME_COMMENT);
1160 OUT << parameter.second.getNode(
"daqParameterKey").getValue() <<
": " << parameter.second.getNode(
"daqParameterValue").getValue()
1161 << (comment.isDefaultValue() ?
"" : (
"\t # " + comment.getValue())) <<
"\n";
1163 if(!parameter.second.status())
1171 OUT <<
"use_routing_master: true\n";
1173 auto routingMasterSubsystemID = 1;
1174 auto routingMasterSubsystemLink = routingMasterNode.getNode(
"SubsystemLink");
1175 std::string rmHost =
"localhost";
1176 if(!routingMasterSubsystemLink.isDisconnected())
1178 routingMasterSubsystemID = getSubsytemId(routingMasterSubsystemLink);
1179 rmHost = info_.subsystems[routingMasterSubsystemID].routingMasterHost;
1181 if(rmHost ==
"localhost" || rmHost ==
"127.0.0.1")
1183 char hostbuf[HOST_NAME_MAX + 1];
1184 gethostname(hostbuf, HOST_NAME_MAX);
1185 rmHost = std::string(hostbuf);
1189 OUT <<
"routing_master_hostname: \"" << rmHost <<
"\"\n";
1190 OUT <<
"sender_ranks: []\n";
1191 OUT <<
"table_update_port: 0\n";
1192 OUT <<
"table_update_address: \"0.0.0.0\"\n";
1193 OUT <<
"table_acknowledge_port: 0\n";
1194 OUT <<
"token_receiver: {\n";
1197 OUT <<
"routing_token_port: 0\n";
1203 auto tableUpdateIntervalMs = routingMasterNode.getNode(
"tableUpdateIntervalMs").getValue();
1204 if(tableUpdateIntervalMs !=
"DEFAULT")
1206 OUT <<
"table_update_interval_ms: " << tableUpdateIntervalMs <<
"\n";
1208 auto tableAckRetryCount = routingMasterNode.getNode(
"tableAckRetryCount").getValue();
1209 if(tableAckRetryCount !=
"DEFAULT")
1211 OUT <<
"table_ack_retry_count: " << tableAckRetryCount <<
"\n";
1214 OUT <<
"routing_timeout_ms: " << routingTimeoutMs <<
"\n";
1215 OUT <<
"routing_retry_count: " << routingRetryCount <<
"\n";
1217 insertMetricsBlock(OUT, tabStr, commentStr, routingMasterNode);
1227 bool getStatusFalseNodes ,
1229 size_t maxFragmentSizeBytes ,
1230 size_t routingTimeoutMs ,
1231 size_t routingRetryCount ,
1235 progressBar->step();
1238 info_.subsystems.clear();
1239 info_.processes.clear();
1242 progressBar->step();
1244 info_.subsystems[NULL_SUBSYSTEM_DESTINATION].id = NULL_SUBSYSTEM_DESTINATION;
1245 info_.subsystems[NULL_SUBSYSTEM_DESTINATION].label = NULL_SUBSYSTEM_DESTINATION_LABEL;
1248 if(artdaqSupervisorNode.isDisconnected())
1252 extractRoutingMastersInfo(artdaqSupervisorNode, getStatusFalseNodes, doWriteFHiCL, routingTimeoutMs, routingRetryCount);
1255 progressBar->step();
1257 extractBoardReadersInfo(artdaqSupervisorNode, getStatusFalseNodes, doWriteFHiCL, maxFragmentSizeBytes, routingTimeoutMs, routingRetryCount);
1260 progressBar->step();
1262 extractEventBuildersInfo(artdaqSupervisorNode, getStatusFalseNodes, doWriteFHiCL, maxFragmentSizeBytes);
1265 progressBar->step();
1267 extractDataLoggersInfo(artdaqSupervisorNode, getStatusFalseNodes, doWriteFHiCL, maxFragmentSizeBytes);
1270 progressBar->step();
1272 extractDispatchersInfo(artdaqSupervisorNode, getStatusFalseNodes, doWriteFHiCL, maxFragmentSizeBytes);
1275 progressBar->step();
1281 void ARTDAQTableBase::extractRoutingMastersInfo(
1282 ConfigurationTree artdaqSupervisorNode,
bool getStatusFalseNodes,
bool doWriteFHiCL,
size_t routingTimeoutMs,
size_t routingRetryCount)
1284 __COUT__ <<
"Checking for Routing Masters..." << __E__;
1285 ConfigurationTree rmsLink = artdaqSupervisorNode.getNode(colARTDAQSupervisor_.colLinkToRoutingMasters_);
1286 if(!rmsLink.isDisconnected() && rmsLink.getChildren().size() > 0)
1288 std::vector<std::pair<std::string, ConfigurationTree>> routingMasters = rmsLink.getChildren();
1290 __COUT__ <<
"There are " << routingMasters.size() <<
" configured Routing Masters" << __E__;
1292 for(
auto& routingMaster : routingMasters)
1294 const std::string& rmUID = routingMaster.first;
1296 if(getStatusFalseNodes || routingMaster.second.status())
1298 std::string rmHost = routingMaster.second.getNode(ARTDAQTableBase::ARTDAQ_TYPE_TABLE_HOSTNAME).getValueWithDefault(
"localhost");
1299 if(rmHost ==
"localhost" || rmHost ==
"127.0.0.1")
1301 char hostbuf[HOST_NAME_MAX + 1];
1302 gethostname(hostbuf, HOST_NAME_MAX);
1303 rmHost = std::string(hostbuf);
1306 int routingMasterSubsystemID = 1;
1307 ConfigurationTree routingMasterSubsystemLink = routingMaster.second.getNode(ARTDAQTableBase::ARTDAQ_TYPE_TABLE_SUBSYSTEM_LINK);
1308 if(!routingMasterSubsystemLink.isDisconnected())
1310 routingMasterSubsystemID = getSubsytemId(routingMasterSubsystemLink);
1313 info_.subsystems[routingMasterSubsystemID].id = routingMasterSubsystemID;
1315 const std::string& routingMasterSubsystemName = routingMasterSubsystemLink.getUIDAsString();
1318 info_.subsystems[routingMasterSubsystemID].label = routingMasterSubsystemName;
1320 if(info_.subsystems[routingMasterSubsystemID].hasRoutingMaster)
1322 __SS__ <<
"Error: You cannot have multiple Routing Masters in a subsystem!";
1327 auto routingMasterSubsystemDestinationLink = routingMasterSubsystemLink.getNode(colARTDAQSubsystem_.colLinkToDestination_);
1328 if(routingMasterSubsystemDestinationLink.isDisconnected())
1331 info_.subsystems[routingMasterSubsystemID].destination = 0;
1336 info_.subsystems[routingMasterSubsystemID].destination = getSubsytemId(routingMasterSubsystemDestinationLink);
1342 if(!info_.subsystems.count(info_.subsystems[routingMasterSubsystemID].destination) ||
1343 !info_.subsystems[info_.subsystems[routingMasterSubsystemID].destination].sources.count(routingMasterSubsystemID))
1345 info_.subsystems[info_.subsystems[routingMasterSubsystemID].destination].sources.insert(routingMasterSubsystemID);
1350 __COUT__ <<
"Found Routing Master with UID " << rmUID <<
", DAQInterface Hostname " << rmHost <<
", and Subsystem " << routingMasterSubsystemID
1352 info_.processes[ARTDAQAppType::RoutingMaster].emplace_back(
1353 rmUID, rmHost, routingMasterSubsystemID, ARTDAQAppType::RoutingMaster, routingMaster.second.status());
1355 info_.subsystems[routingMasterSubsystemID].hasRoutingMaster =
true;
1356 info_.subsystems[routingMasterSubsystemID].routingMasterHost = rmHost;
1360 outputRoutingMasterFHICL(routingMaster.second, routingTimeoutMs, routingRetryCount);
1362 flattenFHICL(ARTDAQAppType::RoutingMaster, routingMaster.second.getValue());
1367 __COUT__ <<
"Routing Master " << rmUID <<
" is disabled." << __E__;
1374 void ARTDAQTableBase::extractBoardReadersInfo(
ConfigurationTree artdaqSupervisorNode,
1375 bool getStatusFalseNodes,
1377 size_t maxFragmentSizeBytes,
1378 size_t routingTimeoutMs,
1379 size_t routingRetryCount)
1381 __COUT__ <<
"Checking for Board Readers..." << __E__;
1382 ConfigurationTree readersLink = artdaqSupervisorNode.getNode(colARTDAQSupervisor_.colLinkToBoardReaders_);
1383 if(!readersLink.isDisconnected() && readersLink.getChildren().size() > 0)
1385 std::vector<std::pair<std::string, ConfigurationTree>> readers = readersLink.getChildren();
1386 __COUT__ <<
"There are " << readers.size() <<
" configured Board Readers." << __E__;
1388 for(
auto& reader : readers)
1390 const std::string& readerUID = reader.first;
1392 if(getStatusFalseNodes || reader.second.status())
1394 std::string readerHost = reader.second.getNode(ARTDAQTableBase::ARTDAQ_TYPE_TABLE_HOSTNAME).getValueWithDefault(
"localhost");
1396 int readerSubsystemID = 1;
1397 ConfigurationTree readerSubsystemLink = reader.second.getNode(ARTDAQ_TYPE_TABLE_SUBSYSTEM_LINK);
1398 if(!readerSubsystemLink.isDisconnected())
1400 readerSubsystemID = getSubsytemId(readerSubsystemLink);
1402 info_.subsystems[readerSubsystemID].id = readerSubsystemID;
1404 const std::string& readerSubsystemName = readerSubsystemLink.getUIDAsString();
1407 info_.subsystems[readerSubsystemID].label = readerSubsystemName;
1409 auto readerSubsystemDestinationLink = readerSubsystemLink.getNode(colARTDAQSubsystem_.colLinkToDestination_);
1410 if(readerSubsystemDestinationLink.isDisconnected())
1413 info_.subsystems[readerSubsystemID].destination = 0;
1418 info_.subsystems[readerSubsystemID].destination = getSubsytemId(readerSubsystemDestinationLink);
1424 if(!info_.subsystems.count(info_.subsystems[readerSubsystemID].destination) ||
1425 !info_.subsystems[info_.subsystems[readerSubsystemID].destination].sources.count(readerSubsystemID))
1427 info_.subsystems[info_.subsystems[readerSubsystemID].destination].sources.insert(readerSubsystemID);
1432 __COUT__ <<
"Found Board Reader with UID " << readerUID <<
", DAQInterface Hostname " << readerHost <<
", and Subsystem " << readerSubsystemID
1434 info_.processes[ARTDAQAppType::BoardReader].emplace_back(
1435 readerUID, readerHost, readerSubsystemID, ARTDAQAppType::BoardReader, reader.second.status());
1439 outputBoardReaderFHICL(reader.second, maxFragmentSizeBytes, routingTimeoutMs, routingRetryCount);
1441 flattenFHICL(ARTDAQAppType::BoardReader, reader.second.getValue());
1446 __COUT__ <<
"Board Reader " << readerUID <<
" is disabled." << __E__;
1452 __COUT_WARN__ <<
"There should be at least one Board Reader!";
1459 void ARTDAQTableBase::extractEventBuildersInfo(
ConfigurationTree artdaqSupervisorNode,
bool getStatusFalseNodes,
bool doWriteFHiCL,
size_t maxFragmentSizeBytes)
1461 __COUT__ <<
"Checking for Event Builders..." << __E__;
1462 ConfigurationTree buildersLink = artdaqSupervisorNode.getNode(colARTDAQSupervisor_.colLinkToEventBuilders_);
1463 if(!buildersLink.isDisconnected() && buildersLink.getChildren().size() > 0)
1465 std::vector<std::pair<std::string, ConfigurationTree>> builders = buildersLink.getChildren();
1467 for(
auto& builder : builders)
1469 const std::string& builderUID = builder.first;
1471 if(getStatusFalseNodes || builder.second.status())
1473 std::string builderHost = builder.second.getNode(ARTDAQTableBase::ARTDAQ_TYPE_TABLE_HOSTNAME).getValueWithDefault(
"localhost");
1475 int builderSubsystemID = 1;
1476 ConfigurationTree builderSubsystemLink = builder.second.getNode(ARTDAQ_TYPE_TABLE_SUBSYSTEM_LINK);
1477 if(!builderSubsystemLink.isDisconnected())
1479 builderSubsystemID = getSubsytemId(builderSubsystemLink);
1482 info_.subsystems[builderSubsystemID].id = builderSubsystemID;
1484 const std::string& builderSubsystemName = builderSubsystemLink.getUIDAsString();
1487 info_.subsystems[builderSubsystemID].label = builderSubsystemName;
1489 auto builderSubsystemDestinationLink = builderSubsystemLink.getNode(colARTDAQSubsystem_.colLinkToDestination_);
1490 if(builderSubsystemDestinationLink.isDisconnected())
1493 info_.subsystems[builderSubsystemID].destination = 0;
1498 info_.subsystems[builderSubsystemID].destination = getSubsytemId(builderSubsystemDestinationLink);
1504 if(!info_.subsystems.count(info_.subsystems[builderSubsystemID].destination) ||
1505 !info_.subsystems[info_.subsystems[builderSubsystemID].destination].sources.count(builderSubsystemID))
1507 info_.subsystems[info_.subsystems[builderSubsystemID].destination].sources.insert(builderSubsystemID);
1512 __COUT__ <<
"Found Event Builder with UID " << builderUID <<
", on Hostname " << builderHost <<
", in Subsystem " << builderSubsystemID
1514 info_.processes[ARTDAQAppType::EventBuilder].emplace_back(
1515 builderUID, builderHost, builderSubsystemID, ARTDAQAppType::EventBuilder, builder.second.status());
1519 outputDataReceiverFHICL(builder.second, ARTDAQAppType::EventBuilder, maxFragmentSizeBytes);
1521 flattenFHICL(ARTDAQAppType::EventBuilder, builder.second.getValue());
1526 __COUT__ <<
"Event Builder " << builderUID <<
" is disabled." << __E__;
1532 __COUT_WARN__ <<
"There should be at least one Event Builder!";
1539 void ARTDAQTableBase::extractDataLoggersInfo(
ConfigurationTree artdaqSupervisorNode,
bool getStatusFalseNodes,
bool doWriteFHiCL,
size_t maxFragmentSizeBytes)
1541 __COUT__ <<
"Checking for Data Loggers..." << __E__;
1542 ConfigurationTree dataloggersLink = artdaqSupervisorNode.getNode(colARTDAQSupervisor_.colLinkToDataLoggers_);
1543 if(!dataloggersLink.isDisconnected())
1545 std::vector<std::pair<std::string, ConfigurationTree>> dataloggers = dataloggersLink.getChildren();
1547 for(
auto& datalogger : dataloggers)
1549 const std::string& loggerUID = datalogger.first;
1551 if(getStatusFalseNodes || datalogger.second.status())
1553 std::string loggerHost = datalogger.second.getNode(ARTDAQTableBase::ARTDAQ_TYPE_TABLE_HOSTNAME).getValueWithDefault(
"localhost");
1555 int loggerSubsystemID = 1;
1556 ConfigurationTree loggerSubsystemLink = datalogger.second.getNode(ARTDAQ_TYPE_TABLE_SUBSYSTEM_LINK);
1557 if(!loggerSubsystemLink.isDisconnected())
1559 loggerSubsystemID = getSubsytemId(loggerSubsystemLink);
1561 info_.subsystems[loggerSubsystemID].id = loggerSubsystemID;
1563 const std::string& loggerSubsystemName = loggerSubsystemLink.getUIDAsString();
1566 info_.subsystems[loggerSubsystemID].label = loggerSubsystemName;
1568 auto loggerSubsystemDestinationLink = loggerSubsystemLink.getNode(colARTDAQSubsystem_.colLinkToDestination_);
1569 if(loggerSubsystemDestinationLink.isDisconnected())
1572 info_.subsystems[loggerSubsystemID].destination = 0;
1577 info_.subsystems[loggerSubsystemID].destination = getSubsytemId(loggerSubsystemDestinationLink);
1583 if(!info_.subsystems.count(info_.subsystems[loggerSubsystemID].destination) ||
1584 !info_.subsystems[info_.subsystems[loggerSubsystemID].destination].sources.count(loggerSubsystemID))
1586 info_.subsystems[info_.subsystems[loggerSubsystemID].destination].sources.insert(loggerSubsystemID);
1591 __COUT__ <<
"Found Data Logger with UID " << loggerUID <<
", DAQInterface Hostname " << loggerHost <<
", and Subsystem " << loggerSubsystemID
1593 info_.processes[ARTDAQAppType::DataLogger].emplace_back(
1594 loggerUID, loggerHost, loggerSubsystemID, ARTDAQAppType::DataLogger, datalogger.second.status());
1598 outputDataReceiverFHICL(datalogger.second, ARTDAQAppType::DataLogger, maxFragmentSizeBytes);
1600 flattenFHICL(ARTDAQAppType::DataLogger, datalogger.second.getValue());
1605 __COUT__ <<
"Data Logger " << loggerUID <<
" is disabled." << __E__;
1611 __COUT_WARN__ <<
"There were no Data Loggers found!";
1616 void ARTDAQTableBase::extractDispatchersInfo(
ConfigurationTree artdaqSupervisorNode,
bool getStatusFalseNodes,
bool doWriteFHiCL,
size_t maxFragmentSizeBytes)
1618 __COUT__ <<
"Checking for Dispatchers..." << __E__;
1619 ConfigurationTree dispatchersLink = artdaqSupervisorNode.getNode(colARTDAQSupervisor_.colLinkToDispatchers_);
1620 if(!dispatchersLink.isDisconnected())
1622 std::vector<std::pair<std::string, ConfigurationTree>> dispatchers = dispatchersLink.getChildren();
1624 for(
auto& dispatcher : dispatchers)
1626 const std::string& dispatcherUID = dispatcher.first;
1628 if(getStatusFalseNodes || dispatcher.second.status())
1630 std::string dispatcherHost = dispatcher.second.getNode(ARTDAQTableBase::ARTDAQ_TYPE_TABLE_HOSTNAME).getValueWithDefault(
"localhost");
1632 auto dispatcherSubsystemID = 1;
1633 ConfigurationTree dispatcherSubsystemLink = dispatcher.second.getNode(ARTDAQ_TYPE_TABLE_SUBSYSTEM_LINK);
1634 if(!dispatcherSubsystemLink.isDisconnected())
1636 dispatcherSubsystemID = getSubsytemId(dispatcherSubsystemLink);
1638 info_.subsystems[dispatcherSubsystemID].id = dispatcherSubsystemID;
1640 const std::string& dispatcherSubsystemName = dispatcherSubsystemLink.getUIDAsString();
1643 info_.subsystems[dispatcherSubsystemID].label = dispatcherSubsystemName;
1645 auto dispatcherSubsystemDestinationLink = dispatcherSubsystemLink.getNode(colARTDAQSubsystem_.colLinkToDestination_);
1646 if(dispatcherSubsystemDestinationLink.isDisconnected())
1649 info_.subsystems[dispatcherSubsystemID].destination = 0;
1654 info_.subsystems[dispatcherSubsystemID].destination = getSubsytemId(dispatcherSubsystemDestinationLink);
1660 if(!info_.subsystems.count(info_.subsystems[dispatcherSubsystemID].destination) ||
1661 !info_.subsystems[info_.subsystems[dispatcherSubsystemID].destination].sources.count(dispatcherSubsystemID))
1663 info_.subsystems[info_.subsystems[dispatcherSubsystemID].destination].sources.insert(dispatcherSubsystemID);
1667 __COUT__ <<
"Found Dispatcher with UID " << dispatcherUID <<
", DAQInterface Hostname " << dispatcherHost <<
", and Subsystem "
1668 << dispatcherSubsystemID << __E__;
1669 info_.processes[ARTDAQAppType::Dispatcher].emplace_back(
1670 dispatcherUID, dispatcherHost, dispatcherSubsystemID, ARTDAQAppType::Dispatcher, dispatcher.second.status());
1674 outputDataReceiverFHICL(dispatcher.second, ARTDAQAppType::Dispatcher, maxFragmentSizeBytes);
1676 flattenFHICL(ARTDAQAppType::Dispatcher, dispatcher.second.getValue());
1681 __COUT__ <<
"Dispatcher " << dispatcherUID <<
" is disabled." << __E__;
1687 __COUT_WARN__ <<
"There were no Dispatchers found!";
1702 std::map<std::string , std::map<std::string , std::vector<std::string /*property*/>>>& nodeTypeToObjectMap,
1703 std::map<std::string /*subsystemName*/, std::string /*destinationSubsystemName*/>& subsystemObjectMap,
1704 std::vector<std::string /*property*/>& artdaqSupervisoInfo)
1706 __COUT__ <<
"getARTDAQSystem()" << __E__;
1708 artdaqSupervisoInfo.clear();
1718 return ARTDAQTableBase::info_;
1720 __COUTV__(artdaqContext->contextUID_);
1721 __COUTV__(artdaqContext->applications_.size());
1723 for(
auto& artdaqApp : artdaqContext->applications_)
1725 if(artdaqApp.class_ != ARTDAQ_SUPERVISOR_CLASS)
1728 __COUTV__(artdaqApp.applicationUID_);
1729 artdaqSupervisoInfo.push_back(artdaqApp.applicationUID_);
1730 artdaqSupervisoInfo.push_back((artdaqContext->status_ && artdaqApp.status_) ?
"1" :
"0");
1731 artdaqSupervisoInfo.push_back(artdaqContext->address_);
1732 artdaqSupervisoInfo.push_back(std::to_string(artdaqContext->port_));
1736 artdaqContext->contextUID_,
1737 artdaqApp.applicationUID_),
1740 __COUT__ <<
"========== "
1741 <<
"Found " << info.subsystems.size() <<
" subsystems." << __E__;
1744 for(
auto& subsystem : info.subsystems)
1745 subsystemObjectMap.emplace(std::make_pair(subsystem.second.label, std::to_string(subsystem.second.destination)));
1747 __COUT__ <<
"========== "
1748 <<
"Found " << info.processes.size() <<
" process types." << __E__;
1750 for(
auto& nameTypePair : ARTDAQTableBase::processTypes_.mapToType_)
1752 const std::string& typeString = nameTypePair.first;
1753 __COUTV__(typeString);
1755 nodeTypeToObjectMap.emplace(std::make_pair(typeString, std::map<std::string , std::vector<std::string /*property*/>>()));
1757 auto it = info.processes.find(nameTypePair.second);
1758 if(it == info.processes.end())
1761 <<
"Found 0 " << typeString << __E__;
1765 <<
"Found " << it->second.size() <<
" " << typeString <<
"(s)" << __E__;
1767 auto tableIt = processTypes_.mapToTable_.find(typeString);
1768 if(tableIt == processTypes_.mapToTable_.end())
1770 __SS__ <<
"Invalid artdaq node type '" << typeString <<
"' attempted!" << __E__;
1773 __COUTV__(tableIt->second);
1775 auto allNodes = cfgMgr->getNode(tableIt->second).getChildren();
1777 std::set<std::string > skipSet;
1779 const std::set<std::string > skipColumns({ARTDAQ_TYPE_TABLE_HOSTNAME,
1780 ARTDAQ_TYPE_TABLE_SUBSYSTEM_LINK,
1781 TableViewColumnInfo::COL_NAME_COMMENT,
1782 TableViewColumnInfo::COL_NAME_AUTHOR,
1783 TableViewColumnInfo::COL_NAME_CREATION});
1786 for(
auto& artdaqNode : it->second)
1789 if(skipSet.find(artdaqNode.label) != skipSet.end())
1793 <<
"Found '" << artdaqNode.label <<
"' " << typeString << __E__;
1795 std::string nodeName = artdaqNode.label;
1796 bool status = artdaqNode.status;
1797 std::string hostname = artdaqNode.hostname;
1798 std::string subsystemId = std::to_string(artdaqNode.subsystem);
1799 std::string subsystemName = info.subsystems.at(artdaqNode.subsystem).label;
1801 ConfigurationTree thisNode = cfgMgr->getNode(tableIt->second).getNode(nodeName);
1802 auto thisNodeColumns = thisNode.getChildren();
1808 std::vector<std::string> multiNodeNames, hostnameArray;
1811 __COUTV__(allNodes.size());
1812 for(
auto& otherNode : allNodes)
1814 if(otherNode.first == nodeName || skipSet.find(otherNode.first) != skipSet.end() ||
1815 otherNode.second.status() != status)
1821 if(subsystemName == otherNode.second.getNode(ARTDAQ_TYPE_TABLE_SUBSYSTEM_LINK_UID).getValue())
1829 auto otherNodeColumns = otherNode.second.getChildren();
1831 bool isMultiNode =
true;
1832 for(
unsigned int i = 0; i < thisNodeColumns.size() && i < otherNodeColumns.size(); ++i)
1835 if(skipColumns.find(thisNodeColumns[i].first) != skipColumns.end() || thisNodeColumns[i].second.isLinkNode())
1846 if(thisNodeColumns[i].second.getValue() != otherNodeColumns[i].second.getValue())
1848 __COUT__ <<
"Mismatch, not multi-node member." << __E__;
1849 isMultiNode =
false;
1856 __COUT__ <<
"Found '" << nodeName <<
"' multi-node member candidate '" << otherNode.first <<
"'" << __E__;
1858 if(!multiNodeNames.size())
1860 multiNodeNames.push_back(nodeName);
1861 hostnameArray.push_back(hostname);
1863 multiNodeNames.push_back(otherNode.first);
1864 hostnameArray.push_back(otherNode.second.getNode(ARTDAQ_TYPE_TABLE_HOSTNAME).getValue());
1865 skipSet.emplace(otherNode.first);
1870 unsigned int nodeFixedWildcardLength = 0, hostFixedWildcardLength = 0;
1871 std::string multiNodeString =
"", hostArrayString =
"";
1873 if(multiNodeNames.size() > 1)
1875 __COUT__ <<
"Handling multi-node printer syntax" << __E__;
1877 __COUTV__(StringMacros::vectorToString(multiNodeNames));
1878 __COUTV__(StringMacros::vectorToString(hostnameArray));
1879 __COUTV__(StringMacros::setToString(skipSet));
1883 unsigned int maxScore = 0;
1885 unsigned int numberAtMaxScore = 0;
1886 unsigned int minScore = -1;
1887 unsigned int numberAtMinScore = 0;
1888 std::vector<unsigned int> scoreVector;
1889 scoreVector.push_back(-1);
1890 for(
unsigned int i = 1; i < multiNodeNames.size(); ++i)
1897 for(
unsigned int j = 0, k = 0; j < multiNodeNames[0].size() && k < multiNodeNames[i].size(); ++j, ++k)
1899 while(j < multiNodeNames[0].size() && !(multiNodeNames[0][j] >=
'a' && multiNodeNames[0][j] <=
'z') &&
1900 !(multiNodeNames[0][j] >=
'A' && multiNodeNames[0][j] <=
'Z'))
1902 while(k < multiNodeNames[i].size() && !(multiNodeNames[i][k] >=
'a' && multiNodeNames[i][k] <=
'z') &&
1903 !(multiNodeNames[i][k] >=
'A' && multiNodeNames[i][k] <=
'Z'))
1906 while(k < multiNodeNames[i].size() && multiNodeNames[0][j] != multiNodeNames[i][k])
1913 if(j < multiNodeNames[0].size() && k < multiNodeNames[i].size())
1920 for(
unsigned int j = multiNodeNames[0].size() - 1, k = multiNodeNames[i].size() - 1;
1921 j < multiNodeNames[0].size() && k < multiNodeNames[i].size();
1924 while(j < multiNodeNames[0].size() && !(multiNodeNames[0][j] >=
'a' && multiNodeNames[0][j] <=
'z') &&
1925 !(multiNodeNames[0][j] >=
'A' && multiNodeNames[0][j] <=
'Z'))
1927 while(k < multiNodeNames[i].size() && !(multiNodeNames[i][k] >=
'a' && multiNodeNames[i][k] <=
'z') &&
1928 !(multiNodeNames[i][k] >=
'A' && multiNodeNames[i][k] <=
'Z'))
1931 while(k < multiNodeNames[i].size() && multiNodeNames[0][j] != multiNodeNames[i][k])
1938 if(j < multiNodeNames[0].size() && k < multiNodeNames[i].size())
1944 scoreVector.push_back(score);
1946 if(score > maxScore)
1949 numberAtMaxScore = 1;
1951 else if(score == maxScore)
1954 if(score < minScore)
1957 numberAtMinScore = 1;
1959 else if(score == minScore)
1969 __COUT__ <<
"Trimming multi-node members with low match score..." << __E__;
1973 for(
unsigned int i = multiNodeNames.size() - 1; i > 0 && i < multiNodeNames.size(); --i)
1977 if(maxScore > multiNodeNames[0].size() && scoreVector[i] >= maxScore)
1981 __COUT__ <<
"Trimming " << multiNodeNames[i] << __E__;
1983 skipSet.erase(multiNodeNames[i]);
1984 multiNodeNames.erase(multiNodeNames.begin() + i);
1985 hostnameArray.erase(hostnameArray.begin() + i);
1991 __COUTV__(StringMacros::vectorToString(multiNodeNames));
1992 __COUTV__(StringMacros::vectorToString(hostnameArray));
1993 __COUTV__(StringMacros::setToString(skipSet));
1996 if(multiNodeNames.size() > 1)
1998 std::vector<std::string> commonChunks;
1999 std::vector<std::string> wildcards;
2001 bool wildcardsNeeded = StringMacros::extractCommonChunks(multiNodeNames, commonChunks, wildcards, nodeFixedWildcardLength);
2003 if(!wildcardsNeeded)
2005 __SS__ <<
"Impossible extractCommonChunks result! Please notify admins or try to simplify record naming convention." << __E__;
2011 for(
auto& commonChunk : commonChunks)
2013 nodeName += (!first ?
"*" :
"") + commonChunk;
2017 if(commonChunks.size() == 1)
2020 __COUTV__(nodeName);
2027 bool allIntegers =
true;
2028 for(
auto& wildcard : wildcards)
2031 else if(wildcard.size() == 0)
2033 allIntegers =
false;
2037 for(
unsigned int i = 0; i < wildcard.size(); ++i)
2038 if(!(wildcard[i] >=
'0' && wildcard[i] <=
'9'))
2040 allIntegers =
false;
2044 __COUTV__(allIntegers);
2047 std::set<unsigned int> intSortWildcards;
2049 for(
auto& wildcard : wildcards)
2050 intSortWildcards.emplace(strtol(wildcard.c_str(), 0, 10));
2053 std::vector<unsigned int> intWildcards;
2054 for(
auto& wildcard : intSortWildcards)
2055 intWildcards.push_back(wildcard);
2057 __COUTV__(StringMacros::vectorToString(intWildcards));
2059 unsigned int hyphenLo = -1;
2060 bool isFirst =
true;
2061 for(
unsigned int i = 0; i < intWildcards.size(); ++i)
2063 if(i + 1 < intWildcards.size() && intWildcards[i] + 1 == intWildcards[i + 1])
2073 multiNodeString += (isFirst ?
"" :
",") + std::to_string(intWildcards[i]);
2079 (isFirst ?
"" :
",") + std::to_string(intWildcards[hyphenLo]) +
"-" + std::to_string(intWildcards[i]);
2088 multiNodeString = StringMacros::vectorToString(wildcards);
2091 __COUTV__(multiNodeString);
2092 __COUTV__(nodeFixedWildcardLength);
2095 if(hostnameArray.size() > 1)
2097 std::vector<std::string> commonChunks;
2098 std::vector<std::string> wildcards;
2100 bool wildcardsNeeded = StringMacros::extractCommonChunks(hostnameArray, commonChunks, wildcards, hostFixedWildcardLength);
2104 for(
auto& commonChunk : commonChunks)
2106 hostname += (!first ?
"*" :
"") + commonChunk;
2110 if(wildcardsNeeded && commonChunks.size() == 1)
2113 __COUTV__(hostname);
2123 bool allIntegers =
true;
2124 for(
auto& wildcard : wildcards)
2125 for(
unsigned int i = 0; i < wildcard.size(); ++i)
2126 if(!(wildcard[i] >=
'0' && wildcard[i] <=
'9'))
2128 allIntegers =
false;
2132 __COUTV__(allIntegers);
2136 std::set<unsigned int> intSortWildcards;
2138 for(
auto& wildcard : wildcards)
2139 intSortWildcards.emplace(strtol(wildcard.c_str(), 0, 10));
2142 std::vector<unsigned int> intWildcards;
2143 for(
auto& wildcard : intSortWildcards)
2144 intWildcards.push_back(wildcard);
2146 __COUTV__(StringMacros::vectorToString(intWildcards));
2148 unsigned int hyphenLo = -1;
2149 bool isFirst =
true;
2150 for(
unsigned int i = 0; i < intWildcards.size(); ++i)
2152 if(i + 1 < intWildcards.size() && intWildcards[i] + 1 == intWildcards[i + 1])
2162 hostArrayString += (isFirst ?
"" :
",") + std::to_string(intWildcards[i]);
2168 (isFirst ?
"" :
",") + std::to_string(intWildcards[hyphenLo]) +
"-" + std::to_string(intWildcards[i]);
2177 hostArrayString = StringMacros::vectorToString(wildcards);
2180 __COUTV__(hostArrayString);
2181 __COUTV__(hostFixedWildcardLength);
2186 nodeTypeToObjectMap.at(typeString).emplace(std::make_pair(nodeName, std::vector<std::string /*property*/>()));
2188 nodeTypeToObjectMap.at(typeString).at(nodeName).push_back(status ?
"1" :
"0");
2190 nodeTypeToObjectMap.at(typeString).at(nodeName).push_back(hostname);
2192 nodeTypeToObjectMap.at(typeString).at(nodeName).push_back(subsystemId);
2193 if(multiNodeNames.size() > 1)
2195 nodeTypeToObjectMap.at(typeString).at(nodeName).push_back(multiNodeString);
2197 nodeTypeToObjectMap.at(typeString).at(nodeName).push_back(std::to_string(nodeFixedWildcardLength));
2199 if(hostnameArray.size() > 1)
2201 nodeTypeToObjectMap.at(typeString).at(nodeName).push_back(hostArrayString);
2203 nodeTypeToObjectMap.at(typeString).at(nodeName).push_back(std::to_string(hostFixedWildcardLength));
2211 __COUT__ <<
"Done getting artdaq nodes." << __E__;
2213 return ARTDAQTableBase::info_;
2227 const std::map<std::string , std::map<std::string , std::vector<std::string /*property*/>>>& nodeTypeToObjectMap,
2228 const std::map<std::string /*subsystemName*/, std::string /*destinationSubsystemName*/>& subsystemObjectMap)
2230 __COUT__ <<
"setAndActivateARTDAQSystem()" << __E__;
2232 const std::string& author = cfgMgr->getUsername();
2243 GroupEditStruct configGroupEdit(ConfigurationManager::GroupType::CONFIGURATION_TYPE, cfgMgr);
2245 unsigned int artdaqSupervisorRow = TableView::INVALID;
2251 bool needArtdaqSupervisorParents =
true;
2252 bool needArtdaqSupervisorCreation =
false;
2258 ConfigurationTree artdaqSupervisorNode = cfgMgr->getNode(ConfigurationManager::XDAQ_CONTEXT_TABLE_NAME)
2259 .getNode(artdaqContext->contextUID_)
2260 .getNode(XDAQContextTable::colContext_.colLinkToApplicationTable_)
2261 .getNode(artdaqContext->applications_[0].applicationUID_)
2262 .getNode(XDAQContextTable::colApplication_.colLinkToSupervisorTable_);
2264 if(artdaqSupervisorNode.isDisconnected())
2265 needArtdaqSupervisorCreation =
true;
2267 artdaqSupervisorRow = artdaqSupervisorNode.getRow();
2269 needArtdaqSupervisorParents =
false;
2273 needArtdaqSupervisorCreation =
true;
2277 if(!artdaqContext || needArtdaqSupervisorCreation)
2279 __COUT__ <<
"No artdaq Supervisor found! Creating..." << __E__;
2280 __COUTV__(needArtdaqSupervisorParents);
2282 std::string artdaqSupervisorUID;
2290 TableEditStruct& artdaqSupervisorTable = configGroupEdit.getTableEditStruct(ARTDAQ_SUPERVISOR_TABLE,
true );
2293 row = artdaqSupervisorTable.tableView_->addRow(author,
true ,
"artdaqSupervisor");
2296 artdaqSupervisorUID = artdaqSupervisorTable.tableView_->getDataView()[row][artdaqSupervisorTable.tableView_->getColUID()];
2297 artdaqSupervisorRow = row;
2299 __COUTV__(artdaqSupervisorRow);
2300 __COUTV__(artdaqSupervisorUID);
2303 artdaqSupervisorTable.tableView_->setValueAsString(
2304 "1", row, artdaqSupervisorTable.tableView_->findCol(colARTDAQSupervisor_.colDAQInterfaceDebugLevel_));
2306 artdaqSupervisorTable.tableView_->setValueAsString(
2307 "${MRB_BUILDDIR}/../setup_ots.sh", row, artdaqSupervisorTable.tableView_->findCol(colARTDAQSupervisor_.colDAQSetupScript_));
2310 artdaqSupervisorTable.tableView_->setValueAsString(
2311 ARTDAQ_READER_TABLE, row, artdaqSupervisorTable.tableView_->findCol(colARTDAQSupervisor_.colLinkToBoardReaders_));
2312 artdaqSupervisorTable.tableView_->setUniqueColumnValue(
2315 artdaqSupervisorTable.tableView_->findCol(colARTDAQSupervisor_.colLinkToBoardReadersGroupID_),
2316 artdaqSupervisorUID + processTypes_.mapToGroupIDAppend_.at(processTypes_.READER));
2318 artdaqSupervisorTable.tableView_->setValueAsString(
2319 ARTDAQ_BUILDER_TABLE, row, artdaqSupervisorTable.tableView_->findCol(colARTDAQSupervisor_.colLinkToEventBuilders_));
2320 artdaqSupervisorTable.tableView_->setUniqueColumnValue(
2322 artdaqSupervisorTable.tableView_->findCol(colARTDAQSupervisor_.colLinkToEventBuildersGroupID_),
2323 artdaqSupervisorUID + processTypes_.mapToGroupIDAppend_.at(processTypes_.BUILDER));
2325 artdaqSupervisorTable.tableView_->setValueAsString(
2326 ARTDAQ_LOGGER_TABLE, row, artdaqSupervisorTable.tableView_->findCol(colARTDAQSupervisor_.colLinkToDataLoggers_));
2327 artdaqSupervisorTable.tableView_->setUniqueColumnValue(row,
2328 artdaqSupervisorTable.tableView_->findCol(colARTDAQSupervisor_.colLinkToDataLoggersGroupID_),
2329 artdaqSupervisorUID + processTypes_.mapToGroupIDAppend_.at(processTypes_.LOGGER));
2331 artdaqSupervisorTable.tableView_->setValueAsString(
2332 ARTDAQ_DISPATCHER_TABLE, row, artdaqSupervisorTable.tableView_->findCol(colARTDAQSupervisor_.colLinkToDispatchers_));
2333 artdaqSupervisorTable.tableView_->setUniqueColumnValue(row,
2334 artdaqSupervisorTable.tableView_->findCol(colARTDAQSupervisor_.colLinkToDispatchersGroupID_),
2335 artdaqSupervisorUID + processTypes_.mapToGroupIDAppend_.at(processTypes_.DISPATCHER));
2338 artdaqSupervisorTable.tableView_->setValueAsString(
2339 ARTDAQ_ROUTER_TABLE, row, artdaqSupervisorTable.tableView_->findCol(colARTDAQSupervisor_.colLinkToRoutingMasters_));
2340 artdaqSupervisorTable.tableView_->setUniqueColumnValue(
2342 artdaqSupervisorTable.tableView_->findCol(colARTDAQSupervisor_.colLinkToRoutingMastersGroupID_),
2343 artdaqSupervisorUID + processTypes_.mapToGroupIDAppend_.at(processTypes_.ROUTER));
2346 std::stringstream ss;
2347 artdaqSupervisorTable.tableView_->print(ss);
2348 __COUT__ << ss.str();
2354 GroupEditStruct contextGroupEdit(ConfigurationManager::GroupType::CONTEXT_TYPE, cfgMgr);
2356 TableEditStruct& contextTable = contextGroupEdit.getTableEditStruct(ConfigurationManager::XDAQ_CONTEXT_TABLE_NAME,
true );
2357 TableEditStruct& appTable = contextGroupEdit.getTableEditStruct(ConfigurationManager::XDAQ_APPLICATION_TABLE_NAME,
true );
2358 TableEditStruct& appPropertyTable = contextGroupEdit.getTableEditStruct(ConfigurationManager::XDAQ_APP_PROPERTY_TABLE_NAME,
true );
2363 std::string contextUID;
2364 std::string contextAppGroupID;
2366 if(needArtdaqSupervisorParents)
2369 row = contextTable.tableView_->addRow(author,
true ,
"artdaqContext");
2371 contextTable.tableView_->setValueAsString(
"1", row, contextTable.tableView_->getColStatus());
2373 contextUID = contextTable.tableView_->getDataView()[row][contextTable.tableView_->getColUID()];
2376 __COUTV__(contextUID);
2379 contextTable.tableView_->setValueAsString(
2380 "http://${HOSTNAME}", row, contextTable.tableView_->findCol(XDAQContextTable::colContext_.colAddress_));
2381 contextTable.tableView_->setUniqueColumnValue(
2382 row, contextTable.tableView_->findCol(XDAQContextTable::colContext_.colPort_),
"${OTS_MAIN_PORT}",
true );
2385 contextTable.tableView_->setValueAsString(ConfigurationManager::XDAQ_APPLICATION_TABLE_NAME,
2387 contextTable.tableView_->findCol(XDAQContextTable::colContext_.colLinkToApplicationTable_));
2388 contextAppGroupID = contextTable.tableView_->setUniqueColumnValue(
2389 row, contextTable.tableView_->findCol(XDAQContextTable::colContext_.colLinkToApplicationGroupID_),
"artdaqContextApps");
2391 __COUTV__(contextAppGroupID);
2396 std::string appPropertiesGroupID;
2402 if(needArtdaqSupervisorParents)
2406 unsigned int c = appTable.tableView_->findCol(XDAQContextTable::colApplication_.colClass_);
2407 for(
unsigned int r = 0; r < appTable.tableView_->getNumberOfRows(); ++r)
2408 if(appTable.tableView_->getDataView()[r][c] == ARTDAQ_SUPERVISOR_CLASS)
2410 __COUT_WARN__ <<
"Found partially existing artdaq Supervisor application '"
2411 << appTable.tableView_->getDataView()[r][appTable.tableView_->getColUID()] <<
"'... Disabling it." << __E__;
2412 appTable.tableView_->setValueAsString(
"0", r, appTable.tableView_->getColStatus());
2417 row = appTable.tableView_->addRow(author,
true ,
"artdaqSupervisor");
2419 appTable.tableView_->setValueAsString(
"1", row, appTable.tableView_->getColStatus());
2421 appUID = appTable.tableView_->getDataView()[row][appTable.tableView_->getColUID()];
2427 appTable.tableView_->setValueAsString(
2428 ARTDAQ_SUPERVISOR_CLASS, row, appTable.tableView_->findCol(XDAQContextTable::colApplication_.colClass_));
2430 appTable.tableView_->setValueAsString(
2431 "${OTSDAQ_LIB}/libARTDAQSupervisor.so", row, appTable.tableView_->findCol(XDAQContextTable::colApplication_.colModule_));
2433 appTable.tableView_->setValueAsString(
2434 contextAppGroupID, row, appTable.tableView_->findCol(XDAQContextTable::colApplication_.colApplicationGroupID_));
2437 appTable.tableView_->setValueAsString(ConfigurationManager::XDAQ_APP_PROPERTY_TABLE_NAME,
2439 appTable.tableView_->findCol(XDAQContextTable::colApplication_.colLinkToPropertyTable_));
2440 appPropertiesGroupID = appTable.tableView_->setUniqueColumnValue(
2441 row, appTable.tableView_->findCol(XDAQContextTable::colApplication_.colLinkToPropertyGroupID_), appUID +
"Properties");
2443 __COUTV__(appPropertiesGroupID);
2447 __COUT__ <<
"Getting row of existing parent supervisor." << __E__;
2450 row = cfgMgr->getNode(ConfigurationManager::XDAQ_CONTEXT_TABLE_NAME)
2451 .getNode(artdaqContext->contextUID_)
2452 .getNode(XDAQContextTable::colContext_.colLinkToApplicationTable_)
2453 .getNode(artdaqContext->applications_[0].applicationUID_)
2461 appTable.tableView_->setValueAsString(
2462 ARTDAQ_SUPERVISOR_TABLE, row, appTable.tableView_->findCol(XDAQContextTable::colApplication_.colLinkToSupervisorTable_));
2463 appTable.tableView_->setValueAsString(
2464 artdaqSupervisorUID, row, appTable.tableView_->findCol(XDAQContextTable::colApplication_.colLinkToSupervisorUID_));
2469 if(needArtdaqSupervisorParents)
2473 const std::vector<std::string> propertyUIDs = {
2474 "Partition0",
"ProductsDir",
"FragmentSize",
"BoardReaderTimeout",
"EventBuilderTimeout",
"DataLoggerTimeout",
"DispatcherTimeout"};
2475 const std::vector<std::string> propertyNames = {
2477 "productsdir_for_bash_scripts",
2478 "max_fragment_size_bytes",
2479 "boardreader_timeout",
2480 "eventbuilder_timeout",
2481 "datalogger_timeout",
2482 "dispatcher_timeout"
2484 const std::vector<std::string> propertyValues = {
2494 for(
unsigned int i = 0; i < propertyNames.size(); ++i)
2497 row = appPropertyTable.tableView_->addRow(author,
true , appUID + propertyUIDs[i]);
2499 appPropertyTable.tableView_->setValueAsString(
"1", row, appPropertyTable.tableView_->getColStatus());
2502 appPropertyTable.tableView_->setValueAsString(
2503 "ots::SupervisorProperty", row, appPropertyTable.tableView_->findCol(XDAQContextTable::colAppProperty_.colPropertyType_));
2505 appPropertyTable.tableView_->setValueAsString(
2506 propertyNames[i], row, appPropertyTable.tableView_->findCol(XDAQContextTable::colAppProperty_.colPropertyName_));
2508 appPropertyTable.tableView_->setValueAsString(
2509 propertyValues[i], row, appPropertyTable.tableView_->findCol(XDAQContextTable::colAppProperty_.colPropertyValue_));
2511 appPropertyTable.tableView_->setValueAsString(
2512 appPropertiesGroupID, row, appPropertyTable.tableView_->findCol(XDAQContextTable::colAppProperty_.colPropertyGroupID_));
2517 std::stringstream ss;
2518 contextTable.tableView_->print(ss);
2519 __COUT__ << ss.str();
2522 std::stringstream ss;
2523 appTable.tableView_->print(ss);
2524 __COUT__ << ss.str();
2527 std::stringstream ss;
2528 appPropertyTable.tableView_->print(ss);
2529 __COUT__ << ss.str();
2532 contextTable.tableView_->init();
2533 appTable.tableView_->init();
2534 appPropertyTable.tableView_->init();
2538 __COUT__ <<
"Table errors while creating ARTDAQ Supervisor. Erasing all newly "
2539 "created table versions."
2544 __COUT__ <<
"Edits complete for new artdaq Supervisor!" << __E__;
2547 contextGroupEdit.saveChanges(contextGroupEdit.originalGroupName_,
2559 artdaqSupervisorRow = cfgMgr->getNode(ConfigurationManager::XDAQ_CONTEXT_TABLE_NAME)
2560 .getNode(artdaqContext->contextUID_)
2561 .getNode(XDAQContextTable::colContext_.colLinkToApplicationTable_)
2562 .getNode(artdaqContext->applications_[0].applicationUID_)
2563 .getNode(XDAQContextTable::colApplication_.colLinkToSupervisorTable_)
2567 __COUT__ <<
"------------------------- artdaq nodes to save:" << __E__;
2568 for(
auto& subsystemPair : subsystemObjectMap)
2570 __COUTV__(subsystemPair.first);
2574 for(
auto& nodeTypePair : nodeTypeToObjectMap)
2576 __COUTV__(nodeTypePair.first);
2578 for(
auto& nodePair : nodeTypePair.second)
2580 __COUTV__(nodePair.first);
2584 __COUT__ <<
"------------------------- end artdaq nodes to save." << __E__;
2588 __COUTV__(artdaqSupervisorRow);
2589 if(artdaqSupervisorRow >= TableView::INVALID)
2591 __SS__ <<
"Invalid artdaq Supervisor row " << artdaqSupervisorRow <<
" found!" << __E__;
2604 TableEditStruct& artdaqSupervisorTable = configGroupEdit.getTableEditStruct(ARTDAQ_SUPERVISOR_TABLE,
true );
2608 std::string artdaqSupervisorUID =
2609 artdaqSupervisorTable.tableView_->getDataView()[artdaqSupervisorRow][artdaqSupervisorTable.tableView_->getColUID()];
2612 if(artdaqSupervisorTable.tableView_
2613 ->getDataView()[artdaqSupervisorRow][artdaqSupervisorTable.tableView_->findCol(colARTDAQSupervisor_.colLinkToBoardReaders_)] ==
2614 TableViewColumnInfo::DATATYPE_LINK_DEFAULT)
2616 __COUT__ <<
"Fixing missing link to Readers" << __E__;
2617 artdaqSupervisorTable.tableView_->setValueAsString(
2618 ARTDAQ_READER_TABLE, artdaqSupervisorRow, artdaqSupervisorTable.tableView_->findCol(colARTDAQSupervisor_.colLinkToBoardReaders_));
2619 artdaqSupervisorTable.tableView_->setUniqueColumnValue(
2620 artdaqSupervisorRow,
2621 artdaqSupervisorTable.tableView_->findCol(colARTDAQSupervisor_.colLinkToBoardReadersGroupID_),
2622 artdaqSupervisorUID + processTypes_.mapToGroupIDAppend_.at(processTypes_.READER));
2626 if(artdaqSupervisorTable.tableView_
2627 ->getDataView()[artdaqSupervisorRow][artdaqSupervisorTable.tableView_->findCol(colARTDAQSupervisor_.colLinkToEventBuilders_)] ==
2628 TableViewColumnInfo::DATATYPE_LINK_DEFAULT)
2630 __COUT__ <<
"Fixing missing link to Builders" << __E__;
2631 artdaqSupervisorTable.tableView_->setValueAsString(
2632 ARTDAQ_BUILDER_TABLE, artdaqSupervisorRow, artdaqSupervisorTable.tableView_->findCol(colARTDAQSupervisor_.colLinkToEventBuilders_));
2633 artdaqSupervisorTable.tableView_->setUniqueColumnValue(
2634 artdaqSupervisorRow,
2635 artdaqSupervisorTable.tableView_->findCol(colARTDAQSupervisor_.colLinkToEventBuildersGroupID_),
2636 artdaqSupervisorUID + processTypes_.mapToGroupIDAppend_.at(processTypes_.BUILDER));
2640 if(artdaqSupervisorTable.tableView_
2641 ->getDataView()[artdaqSupervisorRow][artdaqSupervisorTable.tableView_->findCol(colARTDAQSupervisor_.colLinkToDataLoggers_)] ==
2642 TableViewColumnInfo::DATATYPE_LINK_DEFAULT)
2644 __COUT__ <<
"Fixing missing link to Loggers" << __E__;
2645 artdaqSupervisorTable.tableView_->setValueAsString(
2646 ARTDAQ_LOGGER_TABLE, artdaqSupervisorRow, artdaqSupervisorTable.tableView_->findCol(colARTDAQSupervisor_.colLinkToDataLoggers_));
2647 artdaqSupervisorTable.tableView_->setUniqueColumnValue(
2648 artdaqSupervisorRow,
2649 artdaqSupervisorTable.tableView_->findCol(colARTDAQSupervisor_.colLinkToDataLoggersGroupID_),
2650 artdaqSupervisorUID + processTypes_.mapToGroupIDAppend_.at(processTypes_.LOGGER));
2654 if(artdaqSupervisorTable.tableView_
2655 ->getDataView()[artdaqSupervisorRow][artdaqSupervisorTable.tableView_->findCol(colARTDAQSupervisor_.colLinkToDispatchers_)] ==
2656 TableViewColumnInfo::DATATYPE_LINK_DEFAULT)
2658 __COUT__ <<
"Fixing missing link to Dispatchers" << __E__;
2659 artdaqSupervisorTable.tableView_->setValueAsString(
2660 ARTDAQ_DISPATCHER_TABLE, artdaqSupervisorRow, artdaqSupervisorTable.tableView_->findCol(colARTDAQSupervisor_.colLinkToDispatchers_));
2661 artdaqSupervisorTable.tableView_->setUniqueColumnValue(
2662 artdaqSupervisorRow,
2663 artdaqSupervisorTable.tableView_->findCol(colARTDAQSupervisor_.colLinkToDispatchersGroupID_),
2664 artdaqSupervisorUID + processTypes_.mapToGroupIDAppend_.at(processTypes_.DISPATCHER));
2668 if(artdaqSupervisorTable.tableView_
2669 ->getDataView()[artdaqSupervisorRow][artdaqSupervisorTable.tableView_->findCol(colARTDAQSupervisor_.colLinkToRoutingMasters_)] ==
2670 TableViewColumnInfo::DATATYPE_LINK_DEFAULT)
2672 __COUT__ <<
"Fixing missing link to Routers" << __E__;
2673 artdaqSupervisorTable.tableView_->setValueAsString(
2674 ARTDAQ_ROUTER_TABLE, artdaqSupervisorRow, artdaqSupervisorTable.tableView_->findCol(colARTDAQSupervisor_.colLinkToRoutingMasters_));
2675 artdaqSupervisorTable.tableView_->setUniqueColumnValue(
2676 artdaqSupervisorRow,
2677 artdaqSupervisorTable.tableView_->findCol(colARTDAQSupervisor_.colLinkToRoutingMastersGroupID_),
2678 artdaqSupervisorUID + processTypes_.mapToGroupIDAppend_.at(processTypes_.ROUTER));
2682 std::stringstream ss;
2683 artdaqSupervisorTable.tableView_->print(ss);
2684 __COUT__ << ss.str();
2689 TableEditStruct& artdaqSubsystemTable = configGroupEdit.getTableEditStruct(ARTDAQ_SUBSYSTEM_TABLE,
true );
2692 artdaqSubsystemTable.tableView_->deleteAllRows();
2694 for(
auto& subsystemPair : subsystemObjectMap)
2696 __COUTV__(subsystemPair.first);
2697 __COUTV__(subsystemPair.second);
2700 row = artdaqSubsystemTable.tableView_->addRow(author,
true , subsystemPair.first);
2702 if(subsystemPair.second !=
"" && subsystemPair.second != TableViewColumnInfo::DATATYPE_STRING_DEFAULT &&
2703 subsystemPair.second != NULL_SUBSYSTEM_DESTINATION_LABEL)
2706 artdaqSubsystemTable.tableView_->setValueAsString(
2707 ARTDAQ_SUBSYSTEM_TABLE, row, artdaqSubsystemTable.tableView_->findCol(colARTDAQSubsystem_.colLinkToDestination_));
2708 artdaqSubsystemTable.tableView_->setValueAsString(
2709 subsystemPair.second, row, artdaqSubsystemTable.tableView_->findCol(colARTDAQSubsystem_.colLinkToDestinationUID_));
2716 for(
auto& nodeTypePair : nodeTypeToObjectMap)
2718 __COUTV__(nodeTypePair.first);
2722 auto it = processTypes_.mapToTable_.find(nodeTypePair.first);
2723 if(it == processTypes_.mapToTable_.end())
2725 __SS__ <<
"Invalid artdaq node type '" << nodeTypePair.first <<
"' attempted!" << __E__;
2728 __COUTV__(it->second);
2733 configGroupEdit.getTableEditStruct(it->second,
true );
2737 if(nodeTypePair.second.size())
2740 __COUT__ <<
"Ignoring missing table '" << it->second <<
"' since there were no user records attempted of type '" << nodeTypePair.first <<
".'"
2744 TableEditStruct& typeTable = configGroupEdit.getTableEditStruct(it->second,
true );
2747 std::map<
unsigned int ,
bool > deleteRecordMap;
2748 for(
unsigned int r = 0; r < typeTable.tableView_->getNumberOfRows(); ++r)
2749 deleteRecordMap.emplace(std::make_pair(r,
2753 for(
auto& nodePair : nodeTypePair.second)
2755 __COUTV__(nodePair.first);
2758 std::vector<std::string> nodeIndices, hostnameIndices;
2759 unsigned int hostnameFixedWidth = 0, nodeNameFixedWidth = 0;
2760 std::string hostname;
2764 std::map<std::string , std::map<
unsigned int , std::string >> originalMultinodeValues;
2771 for(
unsigned int i = 0; i < nodePair.second.size(); ++i)
2773 __COUTV__(nodePair.second[i]);
2777 std::string nodeName;
2783 if(nodePair.second[i][0] ==
':')
2785 __COUT__ <<
"Handling original multi-node." << __E__;
2790 std::vector<std::string> originalParameterArr =
2791 StringMacros::getVectorFromString(&(nodePair.second[i].c_str()[1]), {
':'} );
2793 if(originalParameterArr.size() != 3)
2795 __SS__ <<
"Illegal original name parameter string '" << nodePair.second[i] <<
"!'" << __E__;
2799 unsigned int fixedWidth;
2800 sscanf(originalParameterArr[0].c_str(),
"%u", &fixedWidth);
2801 __COUTV__(fixedWidth);
2803 std::vector<std::string> printerSyntaxArr = StringMacros::getVectorFromString(originalParameterArr[1], {
','} );
2806 std::vector<std::string> originalNodeIndices;
2807 for(
auto& printerSyntaxValue : printerSyntaxArr)
2809 __COUTV__(printerSyntaxValue);
2811 std::vector<std::string> printerSyntaxRange = StringMacros::getVectorFromString(printerSyntaxValue, {
'-'} );
2813 if(printerSyntaxRange.size() == 0 || printerSyntaxRange.size() > 2)
2815 __SS__ <<
"Illegal multi-node printer syntax string '" << printerSyntaxValue <<
"!'" << __E__;
2818 else if(printerSyntaxRange.size() == 1)
2820 __COUTV__(printerSyntaxRange[0]);
2821 originalNodeIndices.push_back(printerSyntaxRange[0]);
2825 unsigned int lo, hi;
2826 sscanf(printerSyntaxRange[0].c_str(),
"%u", &lo);
2827 sscanf(printerSyntaxRange[1].c_str(),
"%u", &hi);
2831 sscanf(printerSyntaxRange[0].c_str(),
"%u", &hi);
2833 for(; lo <= hi; ++lo)
2836 originalNodeIndices.push_back(std::to_string(lo));
2841 std::vector<std::string> originalNamePieces = StringMacros::getVectorFromString(originalParameterArr[2], {
'*'} );
2842 __COUTV__(StringMacros::vectorToString(originalNamePieces));
2844 if(originalNamePieces.size() < 2)
2846 __SS__ <<
"Illegal original multi-node name template - please use * to indicate where the multi-node index should be inserted!"
2852 unsigned int originalRow = TableView::INVALID, lastOriginalRow = TableView::INVALID;
2853 for(
unsigned int i = 0; i < originalNodeIndices.size(); ++i)
2855 std::string originalName = originalNamePieces[0];
2856 std::string nodeNameIndex;
2857 for(
unsigned int p = 1; p < originalNamePieces.size(); ++p)
2859 nodeNameIndex = originalNodeIndices[i];
2862 if(nodeNameIndex.size() > fixedWidth)
2864 __SS__ <<
"Illegal original node name index '" << nodeNameIndex
2865 <<
"' - length is longer than fixed width requirement of " << fixedWidth <<
"!" << __E__;
2870 while(nodeNameIndex.size() < fixedWidth)
2871 nodeNameIndex =
"0" + nodeNameIndex;
2874 originalName += nodeNameIndex + originalNamePieces[p];
2876 __COUTV__(originalName);
2878 typeTable.tableView_->findRow(typeTable.tableView_->getColUID(), originalName, 0 ,
true );
2879 __COUTV__(originalRow);
2882 if(originalRow != TableView::INVALID && lastOriginalRow != TableView::INVALID)
2885 originalMultinodeValues.emplace(std::make_pair(nodeName, std::map<unsigned int /*col*/, std::string /*value*/>()));
2887 __COUT__ <<
"Saving multinode value " << nodeName <<
"[" << lastOriginalRow
2888 <<
"][*] with row count = " << typeTable.tableView_->getNumberOfRows() << __E__;
2891 for(
unsigned int col = 0; col < typeTable.tableView_->getNumberOfColumns(); ++col)
2892 if(typeTable.tableView_->getColumnInfo(col).getName() == ARTDAQTableBase::ARTDAQ_TYPE_TABLE_SUBSYSTEM_LINK ||
2893 typeTable.tableView_->getColumnInfo(col).getName() == ARTDAQTableBase::ARTDAQ_TYPE_TABLE_SUBSYSTEM_LINK_UID)
2895 else if(typeTable.tableView_->getColumnInfo(col).isChildLink() ||
2896 typeTable.tableView_->getColumnInfo(col).isChildLinkGroupID() ||
2897 typeTable.tableView_->getColumnInfo(col).isChildLinkUID())
2898 originalMultinodeValues.at(nodeName).emplace(
2899 std::make_pair(col, typeTable.tableView_->getDataView()[lastOriginalRow][col]));
2901 typeTable.tableView_->deleteRow(lastOriginalRow);
2902 if(originalRow > lastOriginalRow)
2906 if(originalRow != TableView::INVALID)
2908 lastOriginalRow = originalRow;
2909 nodeName = originalName;
2914 row = lastOriginalRow;
2916 __COUTV__(nodeName);
2923 row = typeTable.tableView_->findRow(typeTable.tableView_->getColUID(), nodePair.second[i], 0 ,
true );
2926 nodeName = nodePair.first;
2929 __COUTV__(nodeName);
2930 if(row == TableView::INVALID)
2933 row = typeTable.tableView_->addRow(author,
true , nodeName);
2936 if(nodeTypePair.first == processTypes_.READER)
2938 __COUT__ <<
"Handling new " << processTypes_.READER <<
" defaults!" << __E__;
2943 typeTable.tableView_->setValueAsString(nodeName, row, typeTable.tableView_->getColUID());
2948 deleteRecordMap[row] =
false;
2950 __COUTV__(StringMacros::mapToString(processTypes_.mapToLinkGroupIDColumn_));
2953 typeTable.tableView_->setValueAsString(
2954 artdaqSupervisorTable.tableView_->getDataView()[artdaqSupervisorRow][artdaqSupervisorTable.tableView_->findCol(
2955 processTypes_.mapToLinkGroupIDColumn_.at(nodeTypePair.first))],
2957 typeTable.tableView_->findCol(processTypes_.mapToGroupIDColumn_.at(nodeTypePair.first)));
2962 typeTable.tableView_->setValueAsString(nodePair.second[i], row, typeTable.tableView_->getColStatus());
2967 hostname = nodePair.second[i];
2968 typeTable.tableView_->setValueAsString(hostname, row, typeTable.tableView_->findCol(ARTDAQ_TYPE_TABLE_HOSTNAME));
2973 if(nodePair.second[i] !=
"" && nodePair.second[i] != TableViewColumnInfo::DATATYPE_STRING_DEFAULT)
2976 if(subsystemObjectMap.find(nodePair.second[i]) == subsystemObjectMap.end())
2978 __SS__ <<
"Illegal subsystem '" << nodePair.second[i] <<
"' mismatch!" << __E__;
2982 typeTable.tableView_->setValueAsString(
2983 ARTDAQ_SUBSYSTEM_TABLE, row, typeTable.tableView_->findCol(ARTDAQ_TYPE_TABLE_SUBSYSTEM_LINK));
2984 typeTable.tableView_->setValueAsString(
2985 nodePair.second[i], row, typeTable.tableView_->findCol(ARTDAQ_TYPE_TABLE_SUBSYSTEM_LINK_UID));
2989 typeTable.tableView_->setValueAsString(
2990 TableViewColumnInfo::DATATYPE_LINK_DEFAULT, row, typeTable.tableView_->findCol(ARTDAQ_TYPE_TABLE_SUBSYSTEM_LINK));
2993 else if(i == 4 || i == 5 || i == 6 || i == 7)
2998 __COUT__ <<
"Handling printer syntax i=" << i << __E__;
3000 std::vector<std::string> printerSyntaxArr = StringMacros::getVectorFromString(nodePair.second[i], {
','} );
3002 if(printerSyntaxArr.size() == 2)
3004 if(printerSyntaxArr[0] ==
"nnfw")
3006 sscanf(printerSyntaxArr[1].c_str(),
"%u", &nodeNameFixedWidth);
3007 __COUTV__(nodeNameFixedWidth);
3010 else if(printerSyntaxArr[0] ==
"hnfw")
3012 sscanf(printerSyntaxArr[1].c_str(),
"%u", &hostnameFixedWidth);
3013 __COUTV__(hostnameFixedWidth);
3019 for(
auto& printerSyntaxValue : printerSyntaxArr)
3021 __COUTV__(printerSyntaxValue);
3023 std::vector<std::string> printerSyntaxRange = StringMacros::getVectorFromString(printerSyntaxValue, {
'-'} );
3024 if(printerSyntaxRange.size() == 0 || printerSyntaxRange.size() > 2)
3026 __SS__ <<
"Illegal multi-node printer syntax string '" << printerSyntaxValue <<
"!'" << __E__;
3029 else if(printerSyntaxRange.size() == 1)
3032 __COUTV__(printerSyntaxRange[0]);
3037 nodeIndices.push_back(printerSyntaxRange[0]);
3039 hostnameIndices.push_back(printerSyntaxRange[0]);
3043 unsigned int lo, hi;
3044 sscanf(printerSyntaxRange[0].c_str(),
"%u", &lo);
3045 sscanf(printerSyntaxRange[1].c_str(),
"%u", &hi);
3049 sscanf(printerSyntaxRange[0].c_str(),
"%u", &hi);
3051 for(; lo <= hi; ++lo)
3055 nodeIndices.push_back(std::to_string(lo));
3057 hostnameIndices.push_back(std::to_string(lo));
3064 __SS__ <<
"Unexpected parameter[" << i <<
" '" << nodePair.second[i] <<
"' for node " << nodePair.first <<
"!" << __E__;
3069 __COUTV__(nodeIndices.size());
3070 __COUTV__(hostnameIndices.size());
3072 if(hostnameIndices.size())
3074 if(hostnameIndices.size() != nodeIndices.size())
3076 __SS__ <<
"Illegal associated hostname array has count " << hostnameIndices.size() <<
" which is not equal to the node count "
3077 << nodeIndices.size() <<
"!" << __E__;
3082 if(nodeIndices.size())
3084 unsigned int hostnameCol = typeTable.tableView_->findCol(ARTDAQ_TYPE_TABLE_HOSTNAME);
3089 std::vector<std::string> namePieces = StringMacros::getVectorFromString(nodePair.first, {
'*'} );
3090 __COUTV__(StringMacros::vectorToString(namePieces));
3092 if(namePieces.size() < 2)
3094 __SS__ <<
"Illegal multi-node name template - please use * to indicate where the multi-node index should be inserted!" << __E__;
3098 std::vector<std::string> hostnamePieces;
3099 if(hostnameIndices.size())
3101 hostnamePieces = StringMacros::getVectorFromString(hostname, {
'*'} );
3102 __COUTV__(StringMacros::vectorToString(hostnamePieces));
3104 if(hostnamePieces.size() < 2)
3106 __SS__ <<
"Illegal hostname array template - please use * to indicate where the hostname index should be inserted!" << __E__;
3111 bool isFirst =
true;
3112 for(
unsigned int i = 0; i < nodeIndices.size(); ++i)
3114 std::string name = namePieces[0];
3115 std::string nodeNameIndex;
3116 for(
unsigned int p = 1; p < namePieces.size(); ++p)
3118 nodeNameIndex = nodeIndices[i];
3119 if(nodeNameFixedWidth > 1)
3121 if(nodeNameIndex.size() > nodeNameFixedWidth)
3123 __SS__ <<
"Illegal node name index '" << nodeNameIndex <<
"' - length is longer than fixed width requirement of "
3124 << nodeNameFixedWidth <<
"!" << __E__;
3129 while(nodeNameIndex.size() < nodeNameFixedWidth)
3130 nodeNameIndex =
"0" + nodeNameIndex;
3133 name += nodeNameIndex + namePieces[p];
3137 if(hostnamePieces.size())
3139 hostname = hostnamePieces[0];
3140 std::string hostnameIndex;
3141 for(
unsigned int p = 1; p < hostnamePieces.size(); ++p)
3143 hostnameIndex = hostnameIndices[i];
3144 if(hostnameFixedWidth > 1)
3146 if(hostnameIndex.size() > hostnameFixedWidth)
3148 __SS__ <<
"Illegal hostname index '" << hostnameIndex <<
"' - length is longer than fixed width requirement of "
3149 << hostnameFixedWidth <<
"!" << __E__;
3154 while(hostnameIndex.size() < hostnameFixedWidth)
3155 hostnameIndex =
"0" + hostnameIndex;
3158 hostname += hostnameIndex + hostnamePieces[p];
3160 __COUTV__(hostname);
3166 typeTable.tableView_->setValueAsString(name, row, typeTable.tableView_->getColUID());
3168 typeTable.tableView_->setValueAsString(hostname, row, hostnameCol);
3171 deleteRecordMap[row] =
false;
3175 unsigned int copyRow = typeTable.tableView_->copyRows(
3176 author, *(typeTable.tableView_), row, 1 , -1 ,
true );
3177 typeTable.tableView_->setValueAsString(name, copyRow, typeTable.tableView_->getColUID());
3178 typeTable.tableView_->setValueAsString(hostname, copyRow, hostnameCol);
3181 if(originalMultinodeValues.find(name) != originalMultinodeValues.end())
3183 for(
const auto& valuePair : originalMultinodeValues.at(name))
3185 __COUT__ <<
"Customizing node: " << name <<
"[" << copyRow <<
"][" << valuePair.first <<
"] = " << valuePair.second
3187 typeTable.tableView_->setValueAsString(valuePair.second, copyRow, valuePair.first);
3192 deleteRecordMap[copyRow] =
false;
3201 __COUT__ <<
"Deleting '" << nodeTypePair.first <<
"' records not specified..." << __E__;
3204 std::set<unsigned int> orderedRowSet;
3205 for(
auto& deletePair : deleteRecordMap)
3207 __COUTV__(deletePair.first);
3208 if(!deletePair.second)
3211 __COUTV__(deletePair.first);
3212 orderedRowSet.emplace(deletePair.first);
3216 for(std::set<unsigned int>::reverse_iterator rit = orderedRowSet.rbegin(); rit != orderedRowSet.rend(); rit++)
3217 typeTable.tableView_->deleteRow(*rit);
3222 std::stringstream ss;
3223 typeTable.tableView_->print(ss);
3224 __COUT__ << ss.str();
3227 typeTable.tableView_->init();
3232 std::stringstream ss;
3233 artdaqSupervisorTable.tableView_->print(ss);
3234 __COUT__ << ss.str();
3237 std::stringstream ss;
3238 artdaqSubsystemTable.tableView_->print(ss);
3239 __COUT__ << ss.str();
3242 artdaqSupervisorTable.tableView_->init();
3243 artdaqSubsystemTable.tableView_->init();
3247 __COUT__ <<
"Table errors while creating ARTDAQ nodes. Erasing all newly "
3248 "created table versions."
3253 __COUT__ <<
"Edits complete for artdaq nodes and subsystems.. now save and activate groups, and update aliases!" << __E__;
3257 std::string localAccumulatedWarnings;
3258 configGroupEdit.saveChanges(configGroupEdit.originalGroupName_,
3259 newConfigurationGroupKey,
3266 &localAccumulatedWarnings);
3277 return subsystemNode.getNodeRow() + 2;
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)