From fab07db057a3aa2e9b20de3d2a096df6a16ba966 Mon Sep 17 00:00:00 2001 From: Eric Flumerfelt Date: Mon, 29 Jun 2026 15:14:36 -0500 Subject: [PATCH 01/15] Add DataflowStatusModule configuration objects. oks-format schema file --- schema/appmodel/application.schema.xml | 56 ++++++++++++++++---------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/schema/appmodel/application.schema.xml b/schema/appmodel/application.schema.xml index a75dba2..f22a3d6 100644 --- a/schema/appmodel/application.schema.xml +++ b/schema/appmodel/application.schema.xml @@ -80,7 +80,7 @@ - + @@ -171,6 +171,16 @@ + + + + + + + + + + @@ -191,16 +201,6 @@ - - - - - - - - - - @@ -239,6 +239,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -414,16 +438,6 @@ - - - - - - - - - - From 832772c647e33c06a36dfc31a387583c78b4b029 Mon Sep 17 00:00:00 2001 From: Eric Flumerfelt Date: Mon, 6 Jul 2026 09:57:24 -0500 Subject: [PATCH 02/15] Add more attributes to DataflowStatusModuleConf --- schema/appmodel/application.schema.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/schema/appmodel/application.schema.xml b/schema/appmodel/application.schema.xml index f22a3d6..0ae85d2 100644 --- a/schema/appmodel/application.schema.xml +++ b/schema/appmodel/application.schema.xml @@ -80,7 +80,7 @@ - + @@ -251,6 +251,8 @@ + + From dd856ba6d98526b7e1ddfd22fac3037089b20df9 Mon Sep 17 00:00:00 2001 From: Eric Flumerfelt Date: Mon, 13 Jul 2026 07:59:38 -0500 Subject: [PATCH 03/15] Remove trigger_record_output from TRBModule configuration --- schema/appmodel/application.schema.xml | 4 ++-- src/DFApplication.cpp | 17 ++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/schema/appmodel/application.schema.xml b/schema/appmodel/application.schema.xml index 0ae85d2..5fab32b 100644 --- a/schema/appmodel/application.schema.xml +++ b/schema/appmodel/application.schema.xml @@ -80,7 +80,7 @@ - + @@ -607,6 +607,7 @@ + @@ -615,7 +616,6 @@ - diff --git a/src/DFApplication.cpp b/src/DFApplication.cpp index 399ca46..cc04049 100644 --- a/src/DFApplication.cpp +++ b/src/DFApplication.cpp @@ -37,7 +37,7 @@ namespace dunedaq { namespace appmodel { - + static inline void fill_sourceid_object(const ConfigObjectFactory& obj_fac, const conffwk::ConfigObject* netConn, @@ -266,13 +266,13 @@ DFApplication::generate_modules( if (processed_apps.contains(uid)) { continue; } - + for ( const auto & [uid, rel_sources] : helper->get_all_app_source_ids(ctb_type) ) { for ( auto [rel, id] : rel_sources ) { std::string local_uid = uid; local_uid += rel.find("LLT")!=std::string::npos ? "_LLT" : "_HLT"; - + dreqNetObjs.emplace_back(obj_fac.create_net_obj(descriptor, local_uid)); sidObjs.push_back(std::make_shared(id->config_object())); @@ -280,18 +280,18 @@ DFApplication::generate_modules( sidNetObjs.emplace_back(obj_fac.create("SourceIDToNetworkConnection", sidToNetUid)); sidNetObjs.back().set_objs("source_ids", {sidObjs.back().get()}); sidNetObjs.back().set_obj("netconn", &dreqNetObjs.back()); - + } // loop on relational sources - + processed_apps.insert(uid); - } // loop over CTB apps + } // loop over CTB apps } // loop over descriptors for the CTB apps auto app_sources = helper->get_app_source_ids(); // Now look at all Smart apps that are not Readout, FakeData or DF for (auto [uid, descriptor]: helper->get_netdescriptors("DataRequest")) { - + if (processed_apps.contains(uid)) { continue; } @@ -342,7 +342,6 @@ DFApplication::generate_modules( trbObj.set_obj("configuration", &trbConfObj); trbObj.set_objs("inputs", trbInputObjs); trbObj.set_objs("outputs", trbOutputObjs); - trbObj.set_obj("trigger_record_output", &trQueueObj); trbObj.set_objs("request_connections", trbSidNetObjs); // Push TRB Module Object from confdb modules.push_back(obj_fac.get_dal(trbUid)); @@ -373,5 +372,5 @@ DFApplication::generate_modules( obj_fac.update_modules(modules); } -} // namespace appmodel +} // namespace appmodel } // namespace dunedaq From 5dfc5f7d046eea417d73c23b2162d68e2dcc33f4 Mon Sep 17 00:00:00 2001 From: Eric Flumerfelt Date: Tue, 14 Jul 2026 14:20:39 -0500 Subject: [PATCH 04/15] Add more timeout and reallocation configuration to DFOConf. Remove deprecated parameters --- schema/appmodel/application.schema.xml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/schema/appmodel/application.schema.xml b/schema/appmodel/application.schema.xml index 5fab32b..b0bfcb1 100644 --- a/schema/appmodel/application.schema.xml +++ b/schema/appmodel/application.schema.xml @@ -80,7 +80,7 @@ - + @@ -126,11 +126,14 @@ - - + + + - - + + + + From d0bac4bad8edecdaae7110370c8325f98e3dbcf2 Mon Sep 17 00:00:00 2001 From: Eric Flumerfelt Date: Wed, 15 Jul 2026 15:43:03 -0500 Subject: [PATCH 05/15] Update DFApplication and DFOApplication to correctly generate applications using the DataflowStatus-based DFO Protocol --- schema/appmodel/application.schema.xml | 5 +- src/DFApplication.cpp | 161 +++++++++++++++---------- src/DFOApplication.cpp | 30 +++-- 3 files changed, 113 insertions(+), 83 deletions(-) diff --git a/schema/appmodel/application.schema.xml b/schema/appmodel/application.schema.xml index b0bfcb1..a3e7a06 100644 --- a/schema/appmodel/application.schema.xml +++ b/schema/appmodel/application.schema.xml @@ -80,7 +80,7 @@ - + @@ -105,7 +105,8 @@ - + + diff --git a/src/DFApplication.cpp b/src/DFApplication.cpp index cc04049..717e30a 100644 --- a/src/DFApplication.cpp +++ b/src/DFApplication.cpp @@ -8,12 +8,14 @@ * received with this code. */ +#include "appmodel/DFApplication.hpp" #include "ConfigObjectFactory.hpp" #include "appmodel/ConfigurationHelper.hpp" -#include "appmodel/DFApplication.hpp" #include "appmodel/DataStoreConf.hpp" #include "appmodel/DataWriterConf.hpp" #include "appmodel/DataWriterModule.hpp" +#include "appmodel/DataflowStatusModule.hpp" +#include "appmodel/DataflowStatusModuleConf.hpp" #include "appmodel/FilenameParams.hpp" #include "appmodel/NetworkConnectionDescriptor.hpp" #include "appmodel/NetworkConnectionRule.hpp" @@ -37,7 +39,6 @@ namespace dunedaq { namespace appmodel { - static inline void fill_sourceid_object(const ConfigObjectFactory& obj_fac, const conffwk::ConfigObject* netConn, @@ -75,7 +76,6 @@ fill_sourceid_object(const ConfigObjectFactory& obj_fac, sidNetObj.set_objs("source_ids", source_id_objs); } - inline void fill_replay_sourceid_object(const ConfigObjectFactory& obj_fac, const std::string& uid, @@ -98,8 +98,7 @@ fill_replay_sourceid_object(const ConfigObjectFactory& obj_fac, // set Network connections std::string dreqNetUid(uid + ext); - netConn->emplace_back( - obj_fac.create_net_obj(descriptor, dreqNetUid)); + netConn->emplace_back(obj_fac.create_net_obj(descriptor, dreqNetUid)); netConn->back().set_by_val("data_type", descriptor->get_data_type()); netConn->back().set_by_val("connection_type", descriptor->get_connection_type()); auto serviceObj = descriptor->get_associated_service()->config_object(); @@ -107,8 +106,7 @@ fill_replay_sourceid_object(const ConfigObjectFactory& obj_fac, // set SourceID to Network connections std::string sidToNetUid(uid + ext + "-sids"); - sidNetObj->emplace_back( - obj_fac.create("SourceIDToNetworkConnection", sidToNetUid)); + sidNetObj->emplace_back(obj_fac.create("SourceIDToNetworkConnection", sidToNetUid)); sidNetObj->back().set_obj("netconn", &netConn->back()); // set SourceID objs @@ -117,11 +115,9 @@ fill_replay_sourceid_object(const ConfigObjectFactory& obj_fac, } } - - void -DFApplication::generate_modules( - std::shared_ptr helper) const { +DFApplication::generate_modules(std::shared_ptr helper) const +{ ConfigObjectFactory obj_fac(this); @@ -131,31 +127,60 @@ DFApplication::generate_modules( // Prepare TRB output objects std::vector trbInputObjs; std::vector trbOutputObjs; + std::vector dfsInputObjs; + std::vector dfsOutputObjs; std::vector trbSidNetObjs; // -- First, we process expected Queue and Network connections and create their objects. // Process the queue rules looking for the TriggerRecord queue between TRB and DataWriterModule const QueueDescriptor* trQDesc = nullptr; + const QueueDescriptor* tdQDesc = nullptr; + const QueueDescriptor* trbcQDesc = nullptr; + const QueueDescriptor* tokenQDesc = nullptr; for (auto rule : get_queue_rules()) { auto destination_class = rule->get_destination_class(); + if (destination_class == "TRBModule") { + tdQDesc = rule->get_descriptor(); + } if (destination_class == "DataWriterModule") { trQDesc = rule->get_descriptor(); } + if (destination_class == "DataflowStatusModule") { + auto descriptor = rule->get_descriptor(); + if (descriptor->get_data_type() == "TriggerDecisionToken") { + tokenQDesc = descriptor; + } else if (descriptor->get_data_type() == "TRBCompletion") { + trbcQDesc = descriptor; + } + } + } + if (tdQDesc == nullptr) { // BadConf if no descriptor between DataflowStatus and TRB + throw(BadConf(ERS_HERE, "Could not find queue descriptor rule for TriggerDecisions!")); } if (trQDesc == nullptr) { // BadConf if no descriptor between TRB and DataWriterModule throw(BadConf(ERS_HERE, "Could not find queue descriptor rule for TriggerRecords!")); } + if (tokenQDesc == nullptr) { // BadConf if no descriptor between DataWriterModule and DataflowStatus + throw(BadConf(ERS_HERE, "Could not find queue descriptor rule for TriggerDecisionTokens!")); + } + if (trbcQDesc == nullptr) { // BadConf if no descriptor between TRB and DataflowStatus + throw(BadConf(ERS_HERE, "Could not find queue descriptor rule for TRBCompletions!")); + } // Create queue connection config object auto trQueueObj = obj_fac.create_queue_obj(trQDesc, UID()); + auto tdQueueObj = obj_fac.create_queue_obj(tdQDesc, UID()); + auto trbcQueueObj = obj_fac.create_queue_obj(trbcQDesc, UID()); + auto tokenQueueObj = obj_fac.create_queue_obj(tokenQDesc, UID()); // Place trigger record queue object into vector of output objs of TRB module trbOutputObjs.push_back(&trQueueObj); + trbOutputObjs.push_back(&trbcQueueObj); // Process the network rules looking for the Fragments and TriggerDecision inputs for TRB const NetworkConnectionDescriptor* fragNetDesc = nullptr; const NetworkConnectionDescriptor* trigdecNetDesc = nullptr; - const NetworkConnectionDescriptor* tokenNetDesc = nullptr; + const NetworkConnectionDescriptor* statusReqNetDesc = nullptr; const NetworkConnectionDescriptor* trmonReqNetDesc = nullptr; const NetworkConnectionDescriptor* trmonTRNetDesc = nullptr; for (auto rule : get_network_rules()) { @@ -165,30 +190,30 @@ DFApplication::generate_modules( fragNetDesc = rule->get_descriptor(); } else if (data_type == "TriggerDecision") { trigdecNetDesc = rule->get_descriptor(); - } else if (data_type == "TriggerDecisionToken") { - tokenNetDesc = rule->get_descriptor(); } else if (data_type == "TRMonRequest") { trmonReqNetDesc = rule->get_descriptor(); } else if (data_type == "TriggerRecord") { trmonTRNetDesc = rule->get_descriptor(); + } else if (data_type == "DataflowStatusRequest") { + statusReqNetDesc = rule->get_descriptor(); } } if (fragNetDesc == nullptr) { // BadConf if no descriptor for Fragments into TRB throw(BadConf(ERS_HERE, "Could not find network descriptor rule for input Fragments!")); } - if (trigdecNetDesc == nullptr) { // BadCond if no descriptor for TriggerDecisions into TRB + if (trigdecNetDesc == nullptr) { // BadConf if no descriptor for TriggerDecisions into TRB throw(BadConf(ERS_HERE, "Could not find network descriptor rule for input TriggerDecisions!")); } - if (tokenNetDesc == nullptr) { // BadCond if no descriptor for Tokens out of DataWriterModule - throw(BadConf(ERS_HERE, "Could not find network descriptor rule for output TriggerDecisionTokens!")); + if (statusReqNetDesc == nullptr) { // BadConf if no descriptor for DataflowStatusRequest output + throw(BadConf(ERS_HERE, "Could not find network descriptor rule for output DataflowStatusRequests!")); } if (get_source_id() == nullptr) { throw(BadConf(ERS_HERE, "Could not retrieve SourceIDConf")); } // Create network connection config object auto fragNetObj = obj_fac.create_net_obj(fragNetDesc, UID()); - auto trigdecNetObj = obj_fac.create_net_obj(trigdecNetDesc, UID()); - auto tokenNetObj = obj_fac.create_net_obj(tokenNetDesc, ""); + auto trigdecNetObj = obj_fac.create_net_obj(trigdecNetDesc, UID()); + auto statusReqNetObj = obj_fac.create_net_obj(statusReqNetDesc, UID()); conffwk::ConfigObject trmonReqNetObj; conffwk::ConfigObject trmonTRNetObj; if (trmonReqNetDesc != nullptr) { @@ -204,47 +229,30 @@ DFApplication::generate_modules( std::vector sidNetObjs; std::vector> sidObjs; std::set processed_apps; - for (auto uid: helper->get_app_uids("DFApplication")) { + for (auto uid : helper->get_app_uids("DFApplication")) { processed_apps.insert(uid); } auto stream_src_ids = helper->get_stream_source_ids(); auto tp_src_ids = helper->get_tp_source_ids(); - for (auto [uid, descriptor]: - helper->get_netdescriptors("DataRequest", "ReadoutApplication")) { - dreqNetObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid)); + for (auto [uid, descriptor] : helper->get_netdescriptors("DataRequest", "ReadoutApplication")) { + dreqNetObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid)); std::string sidToNetUid(descriptor->get_uid_base() + uid + "-sids"); sidNetObjs.emplace_back(obj_fac.create("SourceIDToNetworkConnection", sidToNetUid)); - fill_sourceid_object(obj_fac, - &dreqNetObjs.back(), - uid, - stream_src_ids.at(uid), - tp_src_ids.at(uid), - sidNetObjs.back(), - sidObjs); + fill_sourceid_object( + obj_fac, &dreqNetObjs.back(), uid, stream_src_ids.at(uid), tp_src_ids.at(uid), sidNetObjs.back(), sidObjs); processed_apps.insert(uid); } - for (auto [uid, descriptor]: - helper->get_netdescriptors("DataRequest", "TPReplayApplication")) { - fill_replay_sourceid_object(obj_fac, - uid, - tp_src_ids.at(uid), - &dreqNetObjs, - &sidNetObjs, - descriptor, - sidObjs); + for (auto [uid, descriptor] : helper->get_netdescriptors("DataRequest", "TPReplayApplication")) { + fill_replay_sourceid_object(obj_fac, uid, tp_src_ids.at(uid), &dreqNetObjs, &sidNetObjs, descriptor, sidObjs); processed_apps.insert(uid); } - - - - for (auto [uid, descriptor]: - helper->get_netdescriptors("DataRequest", "FakeDataApplication")) { - dreqNetObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid)); + for (auto [uid, descriptor] : helper->get_netdescriptors("DataRequest", "FakeDataApplication")) { + dreqNetObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid)); std::string sidToNetUid(descriptor->get_uid_base() + uid + "-sids"); sidNetObjs.emplace_back(obj_fac.create("SourceIDToNetworkConnection", sidToNetUid)); @@ -261,25 +269,24 @@ DFApplication::generate_modules( // now we treat the CTB which has 2 connections related to source IDs const auto ctb_type = "CTBApplication"; - for (auto [uid, descriptor]: helper->get_netdescriptors("DataRequest", ctb_type)) { + for (auto [uid, descriptor] : helper->get_netdescriptors("DataRequest", ctb_type)) { if (processed_apps.contains(uid)) { continue; } - for ( const auto & [uid, rel_sources] : - helper->get_all_app_source_ids(ctb_type) ) { - for ( auto [rel, id] : rel_sources ) { - std::string local_uid = uid; - local_uid += rel.find("LLT")!=std::string::npos ? "_LLT" : "_HLT"; + for (const auto& [uid, rel_sources] : helper->get_all_app_source_ids(ctb_type)) { + for (auto [rel, id] : rel_sources) { + std::string local_uid = uid; + local_uid += rel.find("LLT") != std::string::npos ? "_LLT" : "_HLT"; - dreqNetObjs.emplace_back(obj_fac.create_net_obj(descriptor, local_uid)); - sidObjs.push_back(std::make_shared(id->config_object())); + dreqNetObjs.emplace_back(obj_fac.create_net_obj(descriptor, local_uid)); + sidObjs.push_back(std::make_shared(id->config_object())); - std::string sidToNetUid(descriptor->get_uid_base() + local_uid); - sidNetObjs.emplace_back(obj_fac.create("SourceIDToNetworkConnection", sidToNetUid)); - sidNetObjs.back().set_objs("source_ids", {sidObjs.back().get()}); - sidNetObjs.back().set_obj("netconn", &dreqNetObjs.back()); + std::string sidToNetUid(descriptor->get_uid_base() + local_uid); + sidNetObjs.emplace_back(obj_fac.create("SourceIDToNetworkConnection", sidToNetUid)); + sidNetObjs.back().set_objs("source_ids", { sidObjs.back().get() }); + sidNetObjs.back().set_obj("netconn", &dreqNetObjs.back()); } // loop on relational sources @@ -289,8 +296,7 @@ DFApplication::generate_modules( auto app_sources = helper->get_app_source_ids(); // Now look at all Smart apps that are not Readout, FakeData or DF - for (auto [uid, descriptor]: helper->get_netdescriptors("DataRequest")) { - + for (auto [uid, descriptor] : helper->get_netdescriptors("DataRequest")) { if (processed_apps.contains(uid)) { continue; @@ -298,19 +304,17 @@ DFApplication::generate_modules( if (app_sources.contains(uid)) { dreqNetObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid)); - sidObjs.push_back(std::make_shared( - app_sources.at(uid)->config_object())); + sidObjs.push_back(std::make_shared(app_sources.at(uid)->config_object())); std::string sidToNetUid(descriptor->get_uid_base() + uid + "-sids"); sidNetObjs.emplace_back(obj_fac.create("SourceIDToNetworkConnection", sidToNetUid)); - sidNetObjs.back().set_objs("source_ids", {sidObjs.back().get()}); + sidNetObjs.back().set_objs("source_ids", { sidObjs.back().get() }); sidNetObjs.back().set_obj("netconn", &dreqNetObjs.back()); processed_apps.insert(uid); } } - // Get pointers to objects here, after vector has been filled so they don't move on us for (auto& obj : dreqNetObjs) { trbOutputObjs.push_back(&obj); @@ -329,7 +333,7 @@ DFApplication::generate_modules( } auto trbConfObj = trbConf->config_object(); trbConfObj.set_by_val("source_id", get_source_id()->get_sid()); - trbInputObjs = { &trigdecNetObj, &fragNetObj }; + trbInputObjs = { &tdQueueObj, &fragNetObj }; if (trmonReqNetDesc != nullptr) { trbInputObjs.push_back(&trmonReqNetObj); } @@ -363,12 +367,39 @@ DFApplication::generate_modules( dwrObj.set_by_val("writer_identifier", fmt::format("{}_dw_{}", UID(), dw_idx)); dwrObj.set_obj("configuration", &dwrConfObj); dwrObj.set_objs("inputs", { &trQueueObj }); - dwrObj.set_objs("outputs", { &tokenNetObj }); + dwrObj.set_objs("outputs", { &tokenQueueObj }); // Push DataWriterModule Module Object from confdb modules.push_back(obj_fac.get_dal(dwrUid)); ++dw_idx; } + // Get DataflowStatusModule Config Object + auto dfsConf = get_dfs(); + if (dfsConf == nullptr) { + throw(BadConf(ERS_HERE, "No DataflowStatusModule configuration given")); + } + + std::vector dfsOutputs; + for (auto [uid, descriptor] : helper->get_netdescriptors("DataflowStatus", "DFOApplication")) { + dfsOutputs.push_back(obj_fac.create_net_obj(descriptor, uid)); + } + + for (auto& dfsOut : dfsOutputs) { + dfsOutputObjs.push_back(&dfsOut); + } + + auto dfsConfObj = dfsConf->config_object(); + dfsInputObjs = { &trigdecNetObj, &statusReqNetObj, &trbcQueueObj, &tokenQueueObj }; + dfsOutputObjs.push_back(&tdQueueObj); + // Prepare TRB Module Object and assign its Config Object. + std::string dfsUid(UID() + "-dfs"); + conffwk::ConfigObject dfsObj = obj_fac.create("DataflowStatusModule", dfsUid); + dfsObj.set_obj("configuration", &dfsConfObj); + dfsObj.set_objs("inputs", dfsInputObjs); + dfsObj.set_objs("outputs", dfsOutputObjs); + // Push TRB Module Object from confdb + modules.push_back(obj_fac.get_dal(dfsUid)); + obj_fac.update_modules(modules); } diff --git a/src/DFOApplication.cpp b/src/DFOApplication.cpp index 3d2b5ba..2a5f9e9 100644 --- a/src/DFOApplication.cpp +++ b/src/DFOApplication.cpp @@ -8,10 +8,9 @@ * received with this code. */ - +#include "appmodel/DFOApplication.hpp" #include "ConfigObjectFactory.hpp" #include "appmodel/ConfigurationHelper.hpp" -#include "appmodel/DFOApplication.hpp" #include "appmodel/DFOConf.hpp" #include "appmodel/DFOModule.hpp" #include "appmodel/NetworkConnectionDescriptor.hpp" @@ -39,7 +38,6 @@ DFOApplication::generate_modules(std::shared_ptr ConfigObjectFactory obj_fac(this); - std::string dfoUid("DFO-" + UID()); TLOG_DEBUG(7) << "creating OKS configuration object for DFOModule class "; auto dfoObj = obj_fac.create("DFOModule", dfoUid); @@ -55,7 +53,8 @@ DFOApplication::generate_modules(std::shared_ptr std::vector input_conns; conffwk::ConfigObject tdInObj; conffwk::ConfigObject busyOutObj; - conffwk::ConfigObject tokenInObj; + conffwk::ConfigObject statusInObj; + conffwk::ConfigObject statusReqOutObj; for (auto rule : get_network_rules()) { auto endpoint_class = rule->get_endpoint_class(); @@ -68,14 +67,14 @@ DFOApplication::generate_modules(std::shared_ptr tdInObj = connObj; input_conns.push_back(&tdInObj); } - } else if (descriptor->get_data_type() == "TriggerDecisionToken") { - tokenInObj = connObj; - input_conns.push_back(&tokenInObj); - } - - else if (descriptor->get_data_type() == "TriggerInhibit") { + } else if (descriptor->get_data_type() == "TriggerInhibit") { busyOutObj = connObj; output_conns.push_back(&busyOutObj); + } else if (descriptor->get_data_type() == "DataflowStatus") { + if (endpoint_class == "DFOModule") { + statusInObj = obj_fac.create_net_obj(descriptor, UID()); + input_conns.push_back(&statusInObj); + } } } @@ -85,14 +84,13 @@ DFOApplication::generate_modules(std::shared_ptr if (busyOutObj == nullptr) { throw(BadConf(ERS_HERE, "No TriggerInhibit output connection descriptor given")); } - if (tokenInObj == nullptr) { - throw(BadConf(ERS_HERE, "No TriggerDecisionToken input connection descriptor given")); - } // Process special Network rules! std::vector tdOutObjs; - for (auto [uid, descriptor]: - helper->get_netdescriptors("TriggerDecision", "DFApplication")) { + for (auto [uid, descriptor] : helper->get_netdescriptors("TriggerDecision", "DFApplication")) { + tdOutObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid)); + } + for (auto [uid, descriptor] : helper->get_netdescriptors("DataflowStatusRequest", "DFApplication")) { tdOutObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid)); } @@ -109,5 +107,5 @@ DFOApplication::generate_modules(std::shared_ptr obj_fac.update_modules(modules); } -} // namespace appmodel +} // namespace appmodel } // namespace dunedaq From ed1c9a9995730869f3c31f83345452034b67f10d Mon Sep 17 00:00:00 2001 From: Eric Flumerfelt Date: Thu, 16 Jul 2026 09:05:43 -0500 Subject: [PATCH 06/15] Fix direction for requests, add check on DataflowStatus in DFO --- src/DFApplication.cpp | 4 ++-- src/DFOApplication.cpp | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/DFApplication.cpp b/src/DFApplication.cpp index 717e30a..fefc5b3 100644 --- a/src/DFApplication.cpp +++ b/src/DFApplication.cpp @@ -204,8 +204,8 @@ DFApplication::generate_modules(std::shared_ptr h if (trigdecNetDesc == nullptr) { // BadConf if no descriptor for TriggerDecisions into TRB throw(BadConf(ERS_HERE, "Could not find network descriptor rule for input TriggerDecisions!")); } - if (statusReqNetDesc == nullptr) { // BadConf if no descriptor for DataflowStatusRequest output - throw(BadConf(ERS_HERE, "Could not find network descriptor rule for output DataflowStatusRequests!")); + if (statusReqNetDesc == nullptr) { // BadConf if no descriptor for DataflowStatusRequest input + throw(BadConf(ERS_HERE, "Could not find network descriptor rule for input DataflowStatusRequests!")); } if (get_source_id() == nullptr) { throw(BadConf(ERS_HERE, "Could not retrieve SourceIDConf")); diff --git a/src/DFOApplication.cpp b/src/DFOApplication.cpp index 2a5f9e9..a82605b 100644 --- a/src/DFOApplication.cpp +++ b/src/DFOApplication.cpp @@ -84,6 +84,9 @@ DFOApplication::generate_modules(std::shared_ptr if (busyOutObj == nullptr) { throw(BadConf(ERS_HERE, "No TriggerInhibit output connection descriptor given")); } + if (statusInObj == nullptr) { + throw(BadConf(ERS_HERE, "No DataflowStatus input connection descriptor given")); + } // Process special Network rules! std::vector tdOutObjs; From 5eae6422c435be5132ca62f3703d14c62cc59015 Mon Sep 17 00:00:00 2001 From: Eric Flumerfelt Date: Thu, 16 Jul 2026 09:42:50 -0500 Subject: [PATCH 07/15] Make DFOApplication a Resource so it can be disabled in Sessions --- schema/appmodel/application.schema.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/schema/appmodel/application.schema.xml b/schema/appmodel/application.schema.xml index a3e7a06..170bd05 100644 --- a/schema/appmodel/application.schema.xml +++ b/schema/appmodel/application.schema.xml @@ -80,7 +80,7 @@ - + @@ -120,6 +120,7 @@ + From 926c4523d0caa55aabbe208cdb81b05478935f10 Mon Sep 17 00:00:00 2001 From: Eric Flumerfelt Date: Mon, 3 Aug 2026 15:09:18 -0500 Subject: [PATCH 08/15] Update schema header --- schema/appmodel/application.schema.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema/appmodel/application.schema.xml b/schema/appmodel/application.schema.xml index 008348c..a6970e2 100644 --- a/schema/appmodel/application.schema.xml +++ b/schema/appmodel/application.schema.xml @@ -80,7 +80,7 @@ - + From fa82b253fbeef4dbe4230b57184e1a26d6e32be5 Mon Sep 17 00:00:00 2001 From: Eric Flumerfelt Date: Tue, 4 Aug 2026 14:20:04 -0500 Subject: [PATCH 09/15] Label DFO TriggerDecision input with application name. Pass all TriggerDecision inputs to MLT --- src/DFOApplication.cpp | 6 ++---- src/MLTApplication.cpp | 38 ++++++++++++++++++-------------------- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/src/DFOApplication.cpp b/src/DFOApplication.cpp index a82605b..9f9d3d6 100644 --- a/src/DFOApplication.cpp +++ b/src/DFOApplication.cpp @@ -60,15 +60,13 @@ DFOApplication::generate_modules(std::shared_ptr auto endpoint_class = rule->get_endpoint_class(); auto descriptor = rule->get_descriptor(); - auto connObj = obj_fac.create_net_obj(descriptor, ""); - if (descriptor->get_data_type() == "TriggerDecision") { if (endpoint_class == "DFOModule") { - tdInObj = connObj; + tdInObj = obj_fac.create_net_obj(descriptor, UID()); input_conns.push_back(&tdInObj); } } else if (descriptor->get_data_type() == "TriggerInhibit") { - busyOutObj = connObj; + busyOutObj = obj_fac.create_net_obj(descriptor, ""); output_conns.push_back(&busyOutObj); } else if (descriptor->get_data_type() == "DataflowStatus") { if (endpoint_class == "DFOModule") { diff --git a/src/MLTApplication.cpp b/src/MLTApplication.cpp index 79d700d..7002884 100644 --- a/src/MLTApplication.cpp +++ b/src/MLTApplication.cpp @@ -101,7 +101,6 @@ MLTApplication::generate_modules(std::shared_ptr const NetworkConnectionDescriptor* req_net_desc = nullptr; const NetworkConnectionDescriptor* tc_net_desc = nullptr; const NetworkConnectionDescriptor* ti_net_desc = nullptr; - const NetworkConnectionDescriptor* td_net_desc = nullptr; const NetworkConnectionDescriptor* timesync_net_desc = nullptr; for (auto rule : get_network_rules()) { @@ -111,9 +110,6 @@ MLTApplication::generate_modules(std::shared_ptr if (data_type == "TriggerInhibit") { ti_net_desc = rule->get_descriptor(); } - if (data_type == "TriggerDecision") { - td_net_desc = rule->get_descriptor(); - } if (data_type == "TriggerCandidate") { tc_net_desc = rule->get_descriptor(); } @@ -127,9 +123,6 @@ MLTApplication::generate_modules(std::shared_ptr TLOG_DEBUG(3) << "Endpoint class (currently not used in for networkconnections): data_type: " << data_type; } - if (!td_net_desc) { - throw(BadConf(ERS_HERE, "No MLT network connection for the output TriggerDecision given")); - } if (!ti_net_desc) { throw(BadConf(ERS_HERE, "No MLT network connection for the output TriggerInhibit given")); } @@ -147,10 +140,6 @@ MLTApplication::generate_modules(std::shared_ptr conffwk::ConfigObject tc_net_obj = obj_fac.create_net_obj(tc_net_desc, ".*"); - // Network connection for output TriggerDecision - conffwk::ConfigObject td_net_obj = - obj_fac.create_net_obj(td_net_desc, ""); - // Network conection for the input Data Requests conffwk::ConfigObject dr_net_obj = obj_fac.create_net_obj(req_net_desc, UID()); @@ -237,7 +226,7 @@ MLTApplication::generate_modules(std::shared_ptr sourceIds.push_back(tcSourceIdConf); } } - + for (auto app_class: {"TriggerApplication", "FakeHSIApplication", "DTSHSIApplication", "CIBApplication"}) { for (auto [uid, src_id]: helper->get_app_source_ids(app_class)) { @@ -249,9 +238,9 @@ MLTApplication::generate_modules(std::shared_ptr tcSourceIdConf->set_by_val("subsystem", src_id->get_subsystem()); sourceIds.push_back(tcSourceIdConf); - } - } - + } + } + // Get mandatory links std::vector mandatory_sids; const TCDataProcessor* tc_dp = tch_conf->get_data_processor()->cast(); @@ -260,7 +249,7 @@ MLTApplication::generate_modules(std::shared_ptr mandatory_sids.push_back(&m->config_object()); } } - + /************************************************************** * Create the TC handler **************************************************************/ @@ -298,7 +287,7 @@ MLTApplication::generate_modules(std::shared_ptr for (auto [uid, descriptor]: helper->get_netdescriptors("Fragment", "DFApplication")) { fragOutObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid)); - } + } // build up the full list of outputs std::vector ti_output_objs; @@ -329,15 +318,24 @@ MLTApplication::generate_modules(std::shared_ptr * Instantiate the MLTModule module **************************************************************/ + std::vector tdOutObjs; + for (auto [uid, descriptor] : helper->get_netdescriptors("TriggerDecision", "DFOApplication")) { + tdOutObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid)); + } + + std::vector output_conns; + for (auto& tdOut : tdOutObjs) { + output_conns.push_back(&tdOut); + } conffwk::ConfigObject mlt_obj = obj_fac.create(mlt_conf->get_template_for(), mlt_conf->UID()); mlt_obj.set_obj("configuration", &(mlt_conf->config_object())); mlt_obj.set_objs("inputs", { &output_queue_obj, &ti_net_obj }); - mlt_obj.set_objs("outputs", { &td_net_obj }); + mlt_obj.set_objs("outputs", output_conns); modules.push_back(obj_fac.get_dal(mlt_conf->UID())); obj_fac.update_modules(modules); } - -} // namespace appmodel + +} // namespace appmodel } // namespace dunedaq From bc340652005dfc27a360702e76ebd353c5b76bfe Mon Sep 17 00:00:00 2001 From: Eric Flumerfelt Date: Fri, 28 Aug 2026 13:38:37 -0500 Subject: [PATCH 10/15] Linting updates --- src/DFApplication.cpp | 2 +- src/MLTApplication.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DFApplication.cpp b/src/DFApplication.cpp index fefc5b3..d73d64e 100644 --- a/src/DFApplication.cpp +++ b/src/DFApplication.cpp @@ -401,7 +401,7 @@ DFApplication::generate_modules(std::shared_ptr h modules.push_back(obj_fac.get_dal(dfsUid)); obj_fac.update_modules(modules); -} +} // NOLINT(readability/fn_size) } // namespace appmodel } // namespace dunedaq diff --git a/src/MLTApplication.cpp b/src/MLTApplication.cpp index 7002884..981469f 100644 --- a/src/MLTApplication.cpp +++ b/src/MLTApplication.cpp @@ -335,7 +335,7 @@ MLTApplication::generate_modules(std::shared_ptr modules.push_back(obj_fac.get_dal(mlt_conf->UID())); obj_fac.update_modules(modules); -} +} // NOLINT(readability/fn_size) } // namespace appmodel } // namespace dunedaq From b1aa1847151aa66737af557fa2df6dff0b0d3b05 Mon Sep 17 00:00:00 2001 From: Eric Flumerfelt Date: Thu, 10 Sep 2026 09:21:14 -0500 Subject: [PATCH 11/15] Update DFOApplication excludability --- schema/appmodel/application.schema.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schema/appmodel/application.schema.xml b/schema/appmodel/application.schema.xml index 483bed2..a4a8a98 100644 --- a/schema/appmodel/application.schema.xml +++ b/schema/appmodel/application.schema.xml @@ -120,7 +120,7 @@ - + From 032b833d03813ea95cd2aed509d92745be9857d9 Mon Sep 17 00:00:00 2001 From: Eric Flumerfelt Date: Thu, 24 Sep 2026 15:49:19 -0500 Subject: [PATCH 12/15] Apply clang-format and lint suggestions --- include/appmodel/ConfigurationHelper.hpp | 248 +++++++++++------------ include/appmodel/appmodelIssues.hpp | 70 +++---- pybindsrc/dal_methods.cpp | 52 ++--- src/CIBApplication.cpp | 102 +++++----- src/CRTFrameBuilderApplication.cpp | 66 +++--- src/CTBApplication.cpp | 247 +++++++++++----------- src/ConfigObjectFactory.cpp | 129 ++++++------ src/ConfigObjectFactory.hpp | 53 +++-- src/ConfigurationHelper.cpp | 121 +++++------ src/DFApplication.cpp | 124 ++++-------- src/DFOApplication.cpp | 20 +- src/DTSHSIApplication.cpp | 39 ++-- src/DaphneApplication.cpp | 234 +++++++++++---------- src/FakeDataApplication.cpp | 22 +- src/FakeHSIApplication.cpp | 43 ++-- src/FelixDetectorToDaqConnection.cpp | 20 +- src/HSIEventToTCApplication.cpp | 37 ++-- src/MLTApplication.cpp | 100 ++++----- src/NP02ReadoutApplication.cpp | 185 +++++++++-------- src/NetworkDetectorToDaqConnection.cpp | 19 +- src/ReadoutApplication.cpp | 166 ++++++++------- src/SNBBookkeeperApplication.cpp | 15 +- src/SNBTransferApplication.cpp | 15 +- src/TDECrateApplication.cpp | 44 ++-- src/TPReplayApplication.cpp | 20 +- src/TPWriterApplication.cpp | 50 +++-- src/TRMonReqApplication.cpp | 14 +- src/TriggerApplication.cpp | 91 ++++----- src/WIECApplication.cpp | 99 +++++---- test/apps/generate_modules_test.cxx | 52 ++--- test/apps/print_detailed_config_info.cxx | 68 ++++--- 31 files changed, 1275 insertions(+), 1290 deletions(-) mode change 100755 => 100644 src/TRMonReqApplication.cpp diff --git a/include/appmodel/ConfigurationHelper.hpp b/include/appmodel/ConfigurationHelper.hpp index abb1a28..b5f7c7c 100644 --- a/include/appmodel/ConfigurationHelper.hpp +++ b/include/appmodel/ConfigurationHelper.hpp @@ -7,8 +7,14 @@ * Licensing/copyright details are in the COPYING file that you should have * received with this code. */ -#ifndef APPMODEL_INCLUDE_CONFIGURATIONHELPER_HPP_ -#define APPMODEL_INCLUDE_CONFIGURATIONHELPER_HPP_ +#ifndef APPMODEL_INCLUDE_APPMODEL_CONFIGURATIONHELPER_HPP_ +#define APPMODEL_INCLUDE_APPMODEL_CONFIGURATIONHELPER_HPP_ + +#include "appmodel/NetworkConnectionDescriptor.hpp" +#include "appmodel/SourceIDConf.hpp" +#include "conffwk/DalObject.hpp" +#include "confmodel/Service.hpp" +#include "confmodel/Session.hpp" #include #include @@ -16,134 +22,112 @@ #include #include -namespace dunedaq::confmodel { - class Session; - class Service; -} //namespace dunedaq::confmodel -namespace dunedaq::conffwk { - class DalObject; -} // namespace dunedaq::conffwk - namespace dunedaq::appmodel { - class NetworkConnectionDescriptor; - class SourceIDConf; - - /// Helper class to extract information from Session object without - /// exposing the Session to user code - /// - /// Provides methods that loop over all applications in the session - /// to get source IDs etc. avoiding the need for individual - /// application's code to access configuration objects of other - /// applications. - class ConfigurationHelper { - public: - explicit ConfigurationHelper(const confmodel::Session* ses) - : m_session(ses) {} - - - /// @brief Get the exposed Services of all network connections - /// with given data_type from all smart daq applications of given - /// class - /// - /// @param app_class Dal class of applications to match - /// @param data_type Data type of network descriptor to match - /// - /// @returns A vector of pointers to matching Services - std::vector get_services(std::string app_class, - std::string data_type); - - - /// @brief Get all NetworkConnectionDescriptors with given - /// data_type from all applications of given type - /// - /// @param data_type Data type to match in network descriptor - /// @param app_class Optional dal class name to match - /// - /// @returns a vector of application uid / network descriptor pairs - std::vector> - get_netdescriptors ( - const std::string& data_type, - const std::string& app_class=""); - - - /// @brief Get the source ids of all DetectorStreams in the Session - /// - /// @returns A map of application uids to vectors of streams that - /// they contain - std::map> get_stream_source_ids(); - - - /// @brief Get the source ids of all the TP streams in all - /// ReadoutApplications and TriggerApplications - /// - /// @returns A map of application uids to vectors of contained - /// TP source ids - std::map> - get_tp_source_ids(); - - - /// @brief Get list of uids of applications that match given type - /// - /// @param app_class Class name to select applications by. Empty - /// string implies no selection by class - /// - /// @returns A vector of uids of matching applications - std::vector get_app_uids(std::string app_class=""); - - - /// @brief Get list of source ids for applications that match - /// given type - /// - /// Gather the content of the SmartDaqApplication::source_id - /// relationship for all enabled SmartDaqApplications (or those - /// that match the given class) - /// - /// @param app_class Class name to select applications by. Empty - /// string implies no selection by class - /// - /// @returns A map of application uids to application source ids - std::map get_app_source_ids( - std::string app_class=""); - - - /// @brief Get list of all source ids for applications that match - /// given type. Follows any single value SourceIDConf relationship - /// - /// Examine all relationships of applications checking for type - /// SourceIDConf generating a map of relationship name to - /// SourceIDConf object pointers - /// - /// NB: Does not look at multi-value SourceIDConf relationships - /// - /// @param app_class Class name to select applications by. Empty - /// string implies no selection by class - /// - /// @returns A map of application uids to maps relationship to contained - /// source ids - std::map> - get_all_app_source_ids(std::string app_class=""); - - - /// @brief Check the include/exclude state of the given item - /// - /// @param item The item to be checked. - /// - /// @returns True if the object is included - inline bool is_included(const conffwk::DalObject* item) { - return !is_excluded(item); - } - - /// @brief Check the include/exclude state of the given item - /// - /// @param item The item to be checked. - /// - /// @returns True if the object is excluded - bool is_excluded(const conffwk::DalObject* item); - - private: - const confmodel::Session* m_session; - }; - -} //namespace dunedaq::appmodel - -#endif // APPMODEL_INCLUDE_CONFIGURATIONHELPER_HPP_ + +/// Helper class to extract information from Session object without +/// exposing the Session to user code +/// +/// Provides methods that loop over all applications in the session +/// to get source IDs etc. avoiding the need for individual +/// application's code to access configuration objects of other +/// applications. +class ConfigurationHelper +{ +public: + explicit ConfigurationHelper(const confmodel::Session* ses) + : m_session(ses) + { + } + + /// @brief Get the exposed Services of all network connections + /// with given data_type from all smart daq applications of given + /// class + /// + /// @param app_class Dal class of applications to match + /// @param data_type Data type of network descriptor to match + /// + /// @returns A vector of pointers to matching Services + std::vector get_services(std::string app_class, std::string data_type); + + /// @brief Get all NetworkConnectionDescriptors with given + /// data_type from all applications of given type + /// + /// @param data_type Data type to match in network descriptor + /// @param app_class Optional dal class name to match + /// + /// @returns a vector of application uid / network descriptor pairs + std::vector> get_netdescriptors( + const std::string& data_type, + const std::string& app_class = ""); + + /// @brief Get the source ids of all DetectorStreams in the Session + /// + /// @returns A map of application uids to vectors of streams that + /// they contain + std::map> get_stream_source_ids(); // NOLINT(build/unsigned) + + /// @brief Get the source ids of all the TP streams in all + /// ReadoutApplications and TriggerApplications + /// + /// @returns A map of application uids to vectors of contained + /// TP source ids + std::map> get_tp_source_ids(); + + /// @brief Get list of uids of applications that match given type + /// + /// @param app_class Class name to select applications by. Empty + /// string implies no selection by class + /// + /// @returns A vector of uids of matching applications + std::vector get_app_uids(std::string app_class = ""); + + /// @brief Get list of source ids for applications that match + /// given type + /// + /// Gather the content of the SmartDaqApplication::source_id + /// relationship for all enabled SmartDaqApplications (or those + /// that match the given class) + /// + /// @param app_class Class name to select applications by. Empty + /// string implies no selection by class + /// + /// @returns A map of application uids to application source ids + std::map get_app_source_ids(std::string app_class = ""); + + /// @brief Get list of all source ids for applications that match + /// given type. Follows any single value SourceIDConf relationship + /// + /// Examine all relationships of applications checking for type + /// SourceIDConf generating a map of relationship name to + /// SourceIDConf object pointers + /// + /// NB: Does not look at multi-value SourceIDConf relationships + /// + /// @param app_class Class name to select applications by. Empty + /// string implies no selection by class + /// + /// @returns A map of application uids to maps relationship to contained + /// source ids + std::map> get_all_app_source_ids(std::string app_class = ""); + + /// @brief Check the include/exclude state of the given item + /// + /// @param item The item to be checked. + /// + /// @returns True if the object is included + inline bool is_included(const conffwk::DalObject* item) { return !is_excluded(item); } + + /// @brief Check the include/exclude state of the given item + /// + /// @param item The item to be checked. + /// + /// @returns True if the object is excluded + bool is_excluded(const conffwk::DalObject* item); + +private: + const confmodel::Session* m_session; +}; + +} // namespace dunedaq::appmodel + +#endif // APPMODEL_INCLUDE_APPMODEL_CONFIGURATIONHELPER_HPP_ diff --git a/include/appmodel/appmodelIssues.hpp b/include/appmodel/appmodelIssues.hpp index 9836848..1b04b82 100644 --- a/include/appmodel/appmodelIssues.hpp +++ b/include/appmodel/appmodelIssues.hpp @@ -1,43 +1,43 @@ - -#ifndef APPDALISSUES_HPP -#define APPDALISSUES_HPP +/** + * @file appmodelIssues.hpp + * + * Define common ERS issues for the appmodel package + * + * This is part of the DUNE DAQ Software Suite, copyright 2023. + * Licensing/copyright details are in the COPYING file that you should have + * received with this code. + */ +#ifndef APPMODEL_INCLUDE_APPMODEL_APPMODELISSUES_HPP_ +#define APPMODEL_INCLUDE_APPMODEL_APPMODELISSUES_HPP_ #include "ers/Issue.hpp" #include "logging/Logging.hpp" // NOTE: if ISSUES ARE DECLARED BEFORE include logging/Logging.hpp, TLOG_DEBUG< + namespace dunedaq { - ERS_DECLARE_ISSUE(appmodel, BadConf, what, ((std::string)what)) - ERS_DECLARE_ISSUE(appmodel, BadStreamConf, - "Failed to cast stream parameters " << id << " to " << stype, - ((std::string)id) ((std::string)stype)) - - ERS_DECLARE_ISSUE(appmodel, - MissingDaphne, - "Daphne configuration has no board " << id, - ((std::string)id)) - - ERS_DECLARE_ISSUE(appmodel, - MissingAFE, - "Board " << board << "uses afe " << afe << "but it's not available", - ((std::string)board)((std::size_t)afe)) - - ERS_DECLARE_ISSUE(appmodel, - UnimplementedMethodCalled, - "Method '" << method_name << "' was called but is not implemented in this class", - ((std::string)method_name)) - - - ERS_DECLARE_ISSUE(appmodel, - NotSmart, - "Object is not a SmartDaqApplication: " << obj, - ((std::string)obj)) - - ERS_DECLARE_ISSUE(appmodel, - BadD2d, - "Contained object is not a DetectorToDaqConnection: " << obj, - ((std::string)obj)) +ERS_DECLARE_ISSUE(appmodel, BadConf, what, ((std::string)what)) +ERS_DECLARE_ISSUE(appmodel, + BadStreamConf, + "Failed to cast stream parameters " << id << " to " << stype, + ((std::string)id)((std::string)stype)) -} // namespace dunedaq +ERS_DECLARE_ISSUE(appmodel, MissingDaphne, "Daphne configuration has no board " << id, ((std::string)id)) + +ERS_DECLARE_ISSUE(appmodel, + MissingAFE, + "Board " << board << "uses afe " << afe << "but it's not available", + ((std::string)board)((std::size_t)afe)) +ERS_DECLARE_ISSUE(appmodel, + UnimplementedMethodCalled, + "Method '" << method_name << "' was called but is not implemented in this class", + ((std::string)method_name)) + +ERS_DECLARE_ISSUE(appmodel, NotSmart, "Object is not a SmartDaqApplication: " << obj, ((std::string)obj)) + +ERS_DECLARE_ISSUE(appmodel, BadD2d, "Contained object is not a DetectorToDaqConnection: " << obj, ((std::string)obj)) + +} // namespace dunedaq -#endif // APPDALISSUES_HPP +#endif // APPMODEL_INCLUDE_APPMODEL_APPMODELISSUES_HPP_ diff --git a/pybindsrc/dal_methods.cpp b/pybindsrc/dal_methods.cpp index 27ad375..44ad3b7 100644 --- a/pybindsrc/dal_methods.cpp +++ b/pybindsrc/dal_methods.cpp @@ -15,37 +15,42 @@ #include "appmodel/SmartDaqApplication.hpp" +#include #include +#include +#include namespace py = pybind11; namespace dunedaq::appmodel::python { - struct ObjectLocator { - ObjectLocator(const std::string& id_arg, const std::string& class_name_arg) : - id(id_arg), class_name(class_name_arg) - {} - const std::string id; - const std::string class_name; - }; - - std::vector - smart_daq_application_generate_modules(const conffwk::Configuration& confdb, const std::string& app_id, const std::string& session_id) +struct ObjectLocator +{ + ObjectLocator(const std::string& id_arg, const std::string& class_name_arg) + : id(id_arg) + , class_name(class_name_arg) { - auto app = - const_cast(confdb).get(app_id); - auto session = - const_cast(confdb).get(session_id); - - auto helper = std::make_shared(session); - app->generate_modules(helper); - std::vector mods; - for (auto mod : app->get_modules()) { - mods.push_back({mod->UID(),mod->class_name()}); - } - return mods; } + const std::string id; + const std::string class_name; +}; + +std::vector +smart_daq_application_generate_modules(const conffwk::Configuration& confdb, + const std::string& app_id, + const std::string& session_id) +{ + auto app = const_cast(confdb).get(app_id); // NOLINT + auto session = const_cast(confdb).get(session_id); // NOLINT + auto helper = std::make_shared(session); + app->generate_modules(helper); + std::vector mods; + for (auto mod : app->get_modules()) { + mods.emplace_back(mod->UID(), mod->class_name()); + } + return mods; +} void register_dal_methods(py::module& m) @@ -53,8 +58,7 @@ register_dal_methods(py::module& m) py::class_(m, "ObjectLocator") .def(py::init()) .def_readonly("id", &ObjectLocator::id) - .def_readonly("class_name", &ObjectLocator::class_name) - ; + .def_readonly("class_name", &ObjectLocator::class_name); m.def("smart_daq_application_generate_modules", &smart_daq_application_generate_modules, "Generate DaqModules"); } diff --git a/src/CIBApplication.cpp b/src/CIBApplication.cpp index eb90268..7c929de 100644 --- a/src/CIBApplication.cpp +++ b/src/CIBApplication.cpp @@ -9,73 +9,74 @@ */ #include "conffwk/Configuration.hpp" -#include "oks/kernel.hpp" #include "logging/Logging.hpp" +#include "oks/kernel.hpp" -#include "confmodel/DetectorToDaqConnection.hpp" #include "confmodel/DetDataSender.hpp" +#include "confmodel/DetectorToDaqConnection.hpp" #include "ConfigObjectFactory.hpp" -#include "appmodel/appmodelIssues.hpp" #include "appmodel/CIBApplication.hpp" -#include "appmodel/CIBoardConf.hpp" #include "appmodel/CIBConf.hpp" #include "appmodel/CIBModule.hpp" +#include "appmodel/CIBoardConf.hpp" +#include "appmodel/appmodelIssues.hpp" +#include "appmodel/DFApplication.hpp" #include "appmodel/DataHandlerConf.hpp" -#include "appmodel/QueueConnectionRule.hpp" -#include "appmodel/QueueDescriptor.hpp" +#include "appmodel/DataHandlerModule.hpp" #include "appmodel/NetworkConnectionDescriptor.hpp" #include "appmodel/NetworkConnectionRule.hpp" +#include "appmodel/QueueConnectionRule.hpp" +#include "appmodel/QueueDescriptor.hpp" #include "appmodel/SourceIDConf.hpp" -#include "appmodel/DFApplication.hpp" -#include "appmodel/DataHandlerModule.hpp" -#include -#include #include -#include #include +#include +#include #include +#include +#include using namespace dunedaq; using namespace dunedaq::appmodel; std::vector -CIBApplication::contained_excludable_entities() const { +CIBApplication::contained_excludable_entities() const +{ std::vector resources; - resources.push_back(dynamic_cast(get_board())); // NOLINT(runtime/rtti) + resources.push_back(dynamic_cast(get_board())); // NOLINT(runtime/rtti) return resources; } - void CIBApplication::generate_modules(std::shared_ptr helper) const { std::vector modules; ConfigObjectFactory obj_fac(this); - + auto dlhConf = get_link_handler(); auto dlhClass = dlhConf->get_template_for(); const QueueDescriptor* dlhInputQDesc = nullptr; - + for (auto rule : get_queue_rules()) { auto destination_class = rule->get_destination_class(); if (destination_class == "DataHandlerModule" || destination_class == dlhClass) { dlhInputQDesc = rule->get_descriptor(); } } - + const NetworkConnectionDescriptor* dlhReqInputNetDesc = nullptr; const NetworkConnectionDescriptor* tsNetDesc = nullptr; const NetworkConnectionDescriptor* hsiNetDesc = nullptr; - + for (auto rule : get_network_rules()) { auto endpoint_class = rule->get_endpoint_class(); auto data_type = rule->get_descriptor()->get_data_type(); - + if (endpoint_class == "DataHandlerModule" || endpoint_class == dlhClass) { if (data_type == "TimeSync") { tsNetDesc = rule->get_descriptor(); @@ -88,7 +89,7 @@ CIBApplication::generate_modules(std::shared_ptr hsiNetDesc = rule->get_descriptor(); } } - + auto CIB_conf = get_generator(); if (CIB_conf == nullptr) { throw(BadConf(ERS_HERE, "No CIBModule configuration given")); @@ -106,15 +107,14 @@ CIBApplication::generate_modules(std::shared_ptr // Process special Network rules! // Looking for Fragment rules from DFAppplications in current Session std::vector fragOutObjs; - for (auto [uid, descriptor]: - helper->get_netdescriptors("Fragment", "DFApplication")) { + for (auto const& [uid, descriptor] : helper->get_netdescriptors("Fragment", "DFApplication")) { fragOutObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid)); - } - + } + // start building the list of outputs std::vector fh_output_objs; for (auto& fNet : fragOutObjs) { - fh_output_objs.push_back(&fNet); + fh_output_objs.push_back(&fNet); // NOLINT(performance-inefficient-vector-operation) } std::vector CIB_module_outputs; @@ -124,18 +124,18 @@ CIBApplication::generate_modules(std::shared_ptr // ---------------------------- // create DLH - // ---------------------------- - int det_id = 1; // TODO Eric Flumerfelt , 08-Feb-2024: This is a magic number corresponding to kDAQ // NOLINT(readability/todo) + // ---------------------------- + int det_id = 1; TLOG() << "creating OKS configuration object for CIB Data Link Handler class " << dlhClass << ", id " << id; std::string uid("DLH-CIB"); - conffwk::ConfigObject dlhObj = obj_fac.create( dlhClass, uid ); - dlhObj.set_by_val("source_id", static_cast(id)); // NOLINT(build/unsigned) + conffwk::ConfigObject dlhObj = obj_fac.create(dlhClass, uid); + dlhObj.set_by_val("source_id", static_cast(id)); // NOLINT(build/unsigned) dlhObj.set_by_val("detector_id", static_cast(det_id)); // NOLINT(build/unsigned) dlhObj.set_by_val("post_processing_enabled", false); dlhObj.set_obj("module_configuration", &dlhConf->config_object()); - + auto net_objc(fh_output_objs); - + conffwk::ConfigObject tsNetObj; // Time Sync network connection if (dlhConf->get_generate_timesync()) { @@ -148,9 +148,9 @@ CIBApplication::generate_modules(std::shared_ptr // create Queues from CIB to DLH std::string dataQueueUid(dlhInputQDesc->get_uid_base() + std::string("CIB")); - conffwk::ConfigObject queueObj = obj_fac.create_queue_sid_obj(dlhInputQDesc, id); + conffwk::ConfigObject queueObj = obj_fac.create_queue_sid_obj(dlhInputQDesc, id); queueObj.rename(dataQueueUid); - + CIB_module_outputs.push_back(queueObj); // Create network connections to DLHs @@ -162,49 +162,49 @@ CIBApplication::generate_modules(std::shared_ptr conffwk::ConfigObject hsiNetObj = obj_fac.create_net_obj(hsiNetDesc, ""); CIB_module_outputs.push_back(hsiNetObj); - + auto board = get_board(); - - conffwk::ConfigObject module_obj = obj_fac.create( "CIBModule", "CIB-module"); - module_obj.set_obj("configuration", & CIB_conf -> config_object() ); - module_obj.set_obj("board", & board -> config_object() ); - + + conffwk::ConfigObject module_obj = obj_fac.create("CIBModule", "CIB-module"); + module_obj.set_obj("configuration", &CIB_conf->config_object()); + module_obj.set_obj("board", &board->config_object()); + std::vector CIB_module_output_ptrs; - for ( const auto & o : CIB_module_outputs ) { - CIB_module_output_ptrs.push_back( & o ); + for (const auto& o : CIB_module_outputs) { + CIB_module_output_ptrs.push_back(&o); // NOLINT(performance-inefficient-vector-operation) } - + module_obj.set_objs("outputs", CIB_module_output_ptrs); - + auto module = obj_fac.get_dal(module_obj.UID()); - + modules.push_back(module); obj_fac.update_modules(modules); // return modules; } // NOLINT -nlohmann::json CIBoardConf::get_cib_json(const dunedaq::confmodel::Session &session, std::optional socket_host, std::optional socket_port) const +nlohmann::json +CIBoardConf::get_cib_json(const dunedaq::confmodel::Session& session, + std::optional socket_host, + std::optional socket_port) const // NOLINT(build/unsigned) { // shut up compiler! (void)session; // unused parameter nlohmann::json json; json["sockets"] = nlohmann::json::object(); - if (socket_host.has_value()) - { + if (socket_host.has_value()) { json["sockets"]["receiver"] = nlohmann::json::object(); json["sockets"]["receiver"]["host"] = socket_host.value(); json["sockets"]["receiver"]["port"] = socket_port.value(); // NOLINT(build/unsigned) - } - else - { + } else { json["sockets"]["receiver"] = nlohmann::json::object(); json["sockets"]["receiver"]["host"] = get_receiver_host(); json["sockets"]["receiver"]["port"] = get_receiver_port(); // NOLINT(build/unsigned) } - TLOG() << "JSON frag : [" << json.dump() << "] " ; + TLOG() << "JSON frag : [" << json.dump() << "] "; return json; } diff --git a/src/CRTFrameBuilderApplication.cpp b/src/CRTFrameBuilderApplication.cpp index 8c43218..b8dde0d 100644 --- a/src/CRTFrameBuilderApplication.cpp +++ b/src/CRTFrameBuilderApplication.cpp @@ -13,41 +13,42 @@ #include "appmodel/appmodelIssues.hpp" #include "appmodel/DetectorFrameBuilderConf.hpp" -#include "appmodel/SocketWriterConf.hpp" -#include "appmodel/SocketWriterModule.hpp" #include "appmodel/QueueConnectionRule.hpp" #include "appmodel/QueueDescriptor.hpp" #include "appmodel/SocketDetectorToDaqConnection.hpp" +#include "appmodel/SocketWriterConf.hpp" +#include "appmodel/SocketWriterModule.hpp" #include "ConfigObjectFactory.hpp" #include "confmodel/Connection.hpp" +#include "confmodel/DetDataReceiver.hpp" +#include "confmodel/DetDataSender.hpp" #include "confmodel/DetectorStream.hpp" #include "confmodel/DetectorToDaqConnection.hpp" -#include "confmodel/DetDataSender.hpp" -#include "confmodel/DetDataReceiver.hpp" #include "logging/Logging.hpp" #include +#include #include #include -#include namespace dunedaq::appmodel { std::vector -CRTFrameBuilderApplication::contained_excludable_entities() const { +CRTFrameBuilderApplication::contained_excludable_entities() const +{ return to_resources(get_detector_connections()); } void - CRTFrameBuilderApplication::generate_modules(std::shared_ptr helper) const +CRTFrameBuilderApplication::generate_modules(std::shared_ptr helper) const { TLOG_DEBUG(6) << "Generating modules for application " << this->UID(); - + std::vector modules; ConfigObjectFactory obj_fac(this); @@ -60,14 +61,14 @@ void const auto det_frame_builder_conf = get_detector_frame_builder(); if (det_frame_builder_conf == nullptr) { throw(BadConf(ERS_HERE, "No DetectorFrameBuilderModule configuration given")); - } + } const std::string builder_class = det_frame_builder_conf->get_template_for(); - - // Data writer + + // Data writer const auto writer_conf = get_data_writer(); if (writer_conf == nullptr) { throw(BadConf(ERS_HERE, "No DataWriterModule configuration given")); - } + } const std::string writer_class = writer_conf->get_template_for(); // @@ -107,18 +108,17 @@ void // Loop over senders for (auto sender : d2d_conn->senders()) { - + // Are we sure? if (helper->is_excluded(sender)) { TLOG_DEBUG(7) << "Ignoring excluded DataSender " << sender->UID(); continue; } - bool has_included_det_stream = false; // Loop over streams for (auto stream : sender->get_streams()) { - + // Are we sure? if (helper->is_excluded(stream)) { TLOG_DEBUG(7) << "Ignoring excluded DetectorStream " << stream->UID(); @@ -128,13 +128,13 @@ void has_included_det_stream = true; break; } - + if (!has_included_det_stream) { continue; } const auto sender_idx_str = std::to_string(sender_idx); - + // Create a connection that is dedicated to this sender std::string sender_conn_uid(d2d_conn_uid + sender_idx_str); auto sender_conn_obj = obj_fac.create("SocketDetectorToDaqConnection", sender_conn_uid); @@ -152,45 +152,47 @@ void // // Create DetectorFrameBuilderModule object // - + // // Instantiate DetectorFrameBuilderModule of type CRTBernFrameBuilderModule/CRTGrenobleFrameBuilderModule // - + // Create the detector frame builder object - + std::string builder_uid(fmt::format("crt-frame-builder-{}-{}", this->UID(), sender_idx_str)); - TLOG_DEBUG(6) << fmt::format("creating OKS configuration object for detector frame builder class {} with id {}", builder_class, builder_uid); + TLOG_DEBUG(6) << fmt::format( + "creating OKS configuration object for detector frame builder class {} with id {}", builder_class, builder_uid); auto builder_obj = obj_fac.create(builder_class, builder_uid); - + // Populate configuration and interfaces builder_obj.set_obj("configuration", &det_frame_builder_conf->config_object()); builder_obj.set_obj("connection", sender_conn_conf_obj); builder_obj.set_objs("outputs", { queue_conf_obj }); - + modules.push_back(obj_fac.get_dal(builder_obj.UID())); //----------------------------------------------------------------- // // Create DataWriterModule object // - + // // Instantiate DataWriterModule of type SocketWriterModule // - + // Create the SocketWriterModule object - + std::string writer_uid(fmt::format("socket-writer-{}-{}", this->UID(), sender_idx_str)); - TLOG_DEBUG(6) << fmt::format("Creating OKS configuration object for socket writer class {} with id {}", writer_class, writer_uid); + TLOG_DEBUG(6) << fmt::format( + "Creating OKS configuration object for socket writer class {} with id {}", writer_class, writer_uid); auto writer_obj = obj_fac.create(writer_class, writer_uid); - + // Populate configuration and interfaces writer_obj.set_obj("configuration", &writer_conf->config_object()); writer_obj.set_obj("connection", sender_conn_conf_obj); writer_obj.set_objs("inputs", { queue_conf_obj }); - - modules.push_back(obj_fac.get_dal(writer_obj.UID())); + + modules.push_back(obj_fac.get_dal(writer_obj.UID())); ++sender_idx; } @@ -198,5 +200,5 @@ void obj_fac.update_modules(modules); } - -} // namespace dunedaq::appmodel + +} // namespace dunedaq::appmodel diff --git a/src/CTBApplication.cpp b/src/CTBApplication.cpp index fd65b6d..3c4d2a7 100644 --- a/src/CTBApplication.cpp +++ b/src/CTBApplication.cpp @@ -9,74 +9,75 @@ */ #include "conffwk/Configuration.hpp" -#include "oks/kernel.hpp" #include "logging/Logging.hpp" +#include "oks/kernel.hpp" -#include "confmodel/DetectorToDaqConnection.hpp" #include "confmodel/DetDataSender.hpp" +#include "confmodel/DetectorToDaqConnection.hpp" #include "ConfigObjectFactory.hpp" -#include "appmodel/appmodelIssues.hpp" #include "appmodel/CTBApplication.hpp" -#include "appmodel/CTBoardConf.hpp" +#include "appmodel/CTBCRTSubsystem.hpp" #include "appmodel/CTBConf.hpp" -#include "appmodel/CTBModule.hpp" -#include "appmodel/CTBSockets.hpp" -#include "appmodel/CTBTrigger.hpp" -#include "appmodel/CTBMisc.hpp" -#include "appmodel/CTBRandomTrigger.hpp" -#include "appmodel/CTBPulser.hpp" -#include "appmodel/CTBTiming.hpp" +#include "appmodel/CTBCountLLT.hpp" #include "appmodel/CTBHLT.hpp" #include "appmodel/CTBLLT.hpp" -#include "appmodel/CTBCountLLT.hpp" -#include "appmodel/CTBSubsystem.hpp" -#include "appmodel/CTBCRTSubsystem.hpp" +#include "appmodel/CTBMisc.hpp" +#include "appmodel/CTBModule.hpp" +#include "appmodel/CTBMonitorSocket.hpp" #include "appmodel/CTBPDSSubsystem.hpp" -#include "appmodel/CTBStatisticsSocket.hpp" -#include "appmodel/CTBSocket.hpp" +#include "appmodel/CTBPulser.hpp" +#include "appmodel/CTBRandomTrigger.hpp" #include "appmodel/CTBReceiverSocket.hpp" -#include "appmodel/CTBMonitorSocket.hpp" - +#include "appmodel/CTBSocket.hpp" +#include "appmodel/CTBSockets.hpp" +#include "appmodel/CTBStatisticsSocket.hpp" +#include "appmodel/CTBSubsystem.hpp" +#include "appmodel/CTBTiming.hpp" +#include "appmodel/CTBTrigger.hpp" +#include "appmodel/CTBoardConf.hpp" +#include "appmodel/appmodelIssues.hpp" #include "appmodel/DataHandlerConf.hpp" -#include "appmodel/QueueConnectionRule.hpp" -#include "appmodel/QueueDescriptor.hpp" +#include "appmodel/DataHandlerModule.hpp" #include "appmodel/NetworkConnectionDescriptor.hpp" #include "appmodel/NetworkConnectionRule.hpp" +#include "appmodel/QueueConnectionRule.hpp" +#include "appmodel/QueueDescriptor.hpp" #include "appmodel/SourceIDConf.hpp" -#include "appmodel/DataHandlerModule.hpp" -#include -#include #include -#include #include +#include +#include +#include #include +#include +#include using namespace dunedaq; using namespace dunedaq::appmodel; std::vector -CTBApplication::contained_excludable_entities() const { +CTBApplication::contained_excludable_entities() const +{ std::vector resources; - resources.push_back(dynamic_cast(get_board())); + resources.push_back(dynamic_cast(get_board())); // NOLINT(runtime/rtti) return resources; } - void CTBApplication::generate_modules(std::shared_ptr helper) const { std::vector modules; ConfigObjectFactory obj_fac(this); - + auto dlhConf = get_link_handler(); auto dlhClass = dlhConf->get_template_for(); const QueueDescriptor* dlhInputQDesc = nullptr; - + for (auto rule : get_queue_rules()) { auto destination_class = rule->get_destination_class(); auto data_type = rule->get_descriptor()->get_data_type(); @@ -84,15 +85,15 @@ CTBApplication::generate_modules(std::shared_ptr dlhInputQDesc = rule->get_descriptor(); } } - + const NetworkConnectionDescriptor* dlhReqInputNetDesc = nullptr; const NetworkConnectionDescriptor* tsNetDesc = nullptr; const NetworkConnectionDescriptor* hsiNetDesc = nullptr; - + for (auto rule : get_network_rules()) { auto endpoint_class = rule->get_endpoint_class(); auto data_type = rule->get_descriptor()->get_data_type(); - + if (endpoint_class == "DataHandlerModule" || endpoint_class == dlhClass) { if (data_type == "TimeSync") { tsNetDesc = rule->get_descriptor(); @@ -105,9 +106,9 @@ CTBApplication::generate_modules(std::shared_ptr hsiNetDesc = rule->get_descriptor(); } } - + auto ctb_conf = get_generator(); - if (ctb_conf ==nullptr) { + if (ctb_conf == nullptr) { throw(BadConf(ERS_HERE, "No CTBModule configuration given")); } if (dlhInputQDesc == nullptr) { @@ -123,21 +124,21 @@ CTBApplication::generate_modules(std::shared_ptr // Process special Network rules! // Looking for Fragment rules from DFAppplications in current Session std::vector fragOutObjs; - for (auto [uid, descriptor]: - helper->get_netdescriptors("Fragment", "DFApplication")) { - fragOutObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid)); - } - + for (auto const& [uid, descriptor] : helper->get_netdescriptors("Fragment", "DFApplication")) { + fragOutObjs.emplace_back( + obj_fac.create_net_obj(descriptor, uid)); // NOLINT(performance-inefficient-vector-operation) + } + // start building the list of outputs std::vector fh_output_objs; for (auto& fNet : fragOutObjs) { - fh_output_objs.push_back(&fNet); + fh_output_objs.push_back(&fNet); // NOLINT(performance-inefficient-vector-operation) } std::vector ctb_module_outputs; auto sources = get_sources(); - for ( const auto & s : sources ) { + for (const auto& s : sources) { if (s.second == nullptr) { throw(BadConf(ERS_HERE, "No SourceIDConf given for " + s.first)); } @@ -145,18 +146,19 @@ CTBApplication::generate_modules(std::shared_ptr auto id = s.second->get_sid(); // ---------------------------- // create DLH - // ---------------------------- - auto det_id = 1; // TODO Eric Flumerfelt , 08-Feb-2024: This is a magic number corresponding to kDAQ - TLOG() << "creating OKS configuration object for " + s.first + " Data Link Handler class " << dlhClass << ", id " << id; + // ---------------------------- + auto det_id = 1; // This is a magic number corresponding to kDAQ + TLOG() << "creating OKS configuration object for " + s.first + " Data Link Handler class " << dlhClass << ", id " + << id; std::string uid("DLH-" + s.first); - conffwk::ConfigObject dlhObj = obj_fac.create( dlhClass, uid ); - dlhObj.set_by_val("source_id", id); - dlhObj.set_by_val("detector_id", det_id); + conffwk::ConfigObject dlhObj = obj_fac.create(dlhClass, uid); + dlhObj.set_by_val("source_id", id); // NOLINT(build/unsigned) + dlhObj.set_by_val("detector_id", det_id); // NOLINT(build/unsigned) dlhObj.set_by_val("post_processing_enabled", false); dlhObj.set_obj("module_configuration", &dlhConf->config_object()); - + auto net_objc(fh_output_objs); - + // Time Sync network connection if (dlhConf->get_generate_timesync()) { std::string tsStreamUid = tsNetDesc->get_uid_base() + std::to_string(id); @@ -168,48 +170,46 @@ CTBApplication::generate_modules(std::shared_ptr // create Queues from CTB to DLH std::string dataQueueUid(dlhInputQDesc->get_uid_base() + s.first); - conffwk::ConfigObject queueObj = obj_fac.create_queue_sid_obj(dlhInputQDesc, id); + conffwk::ConfigObject queueObj = obj_fac.create_queue_sid_obj(dlhInputQDesc, id); queueObj.rename(dataQueueUid); - + ctb_module_outputs.push_back(queueObj); // Create network connections to DLHs conffwk::ConfigObject faNetObj = obj_fac.create_net_obj(dlhReqInputNetDesc, UID() + '_' + s.first); - + dlhObj.set_objs("inputs", { &queueObj, &faNetObj }); modules.push_back(obj_fac.get_dal(uid)); - - } // loop over CTB sources - + + } // loop over CTB sources conffwk::ConfigObject hsiNetObj = obj_fac.create_net_obj(hsiNetDesc, ""); ctb_module_outputs.push_back(hsiNetObj); - + auto board = get_board(); - - conffwk::ConfigObject module_obj = obj_fac.create( "CTBModule", "ctb-module"); - module_obj.set_obj("configuration", & ctb_conf -> config_object() ); - module_obj.set_obj("board", & board -> config_object() ); - + + conffwk::ConfigObject module_obj = obj_fac.create("CTBModule", "ctb-module"); + module_obj.set_obj("configuration", &ctb_conf->config_object()); + module_obj.set_obj("board", &board->config_object()); + std::vector ctb_module_output_ptrs; - for ( const auto & o : ctb_module_outputs ) { - ctb_module_output_ptrs.push_back( & o ); + for (const auto& o : ctb_module_outputs) { + ctb_module_output_ptrs.push_back(&o); // NOLINT(performance-inefficient-vector-operation) } - + module_obj.set_objs("outputs", ctb_module_output_ptrs); - + auto module = obj_fac.get_dal(module_obj.UID()); - - modules.push_back(module); - - obj_fac.update_modules(modules); -} + modules.push_back(module); + obj_fac.update_modules(modules); +} // NOLINT(readability/fn_size) std::vector -CTBoardConf::contained_excludable_entities() const { +CTBoardConf::contained_excludable_entities() const +{ std::vector resources; resources.push_back(get_misc()); @@ -225,133 +225,134 @@ CTBoardConf::contained_excludable_entities() const { return resources; } - -nlohmann::json CTBoardConf::get_ctb_json(const dunedaq::confmodel::Session& session, std::optional socket_host) const { +nlohmann::json +CTBoardConf::get_ctb_json(const dunedaq::confmodel::Session& session, std::optional socket_host) const +{ nlohmann::json json; - json["sockets"] = get_sockets() -> get_ctb_json( socket_host ); + json["sockets"] = get_sockets()->get_ctb_json(socket_host); json["misc"] = get_misc()->get_ctb_json(session); nlohmann::json hlt; // constant block that we don't even want to configure - auto & mask = hlt["command_mask"]; - mask["C"]="0x0"; - mask["D"]="0x0"; - mask["E"]="0x0"; - mask["F"]="0x0"; + auto& mask = hlt["command_mask"]; + mask["C"] = "0x0"; + mask["D"] = "0x0"; + mask["E"] = "0x0"; + mask["F"] = "0x0"; auto hlts = get_HLTs(); std::list json_hlts; - for ( const auto & hlt : hlts ) { + for (const auto& hlt : hlts) { json_hlts.push_back(hlt->get_ctb_json(session)); } hlt["trigger"] = nlohmann::json(json_hlts); - + json["HLT"] = hlt; // -------------------------- // Subsystems // -------------------------- - - auto & subsystems = json["subsystems"]; + + auto& subsystems = json["subsystems"]; // ---- Beam ---- - auto & beam_block = subsystems["beam"] = get_beam() -> to_json(false, true); + auto& beam_block = subsystems["beam"] = get_beam()->to_json(false, true); std::list json_beam_llts; auto beam_llts = get_beam_LLTs(); - for ( const auto & llt : beam_llts ) { + for (const auto& llt : beam_llts) { json_beam_llts.push_back(llt->get_ctb_json(session)); } - + beam_block["triggers"] = nlohmann::json(json_beam_llts); // ---- CRT ---- - - auto & crt_block = subsystems["crt"] = get_CRT() -> to_json(false, true); + + auto& crt_block = subsystems["crt"] = get_CRT()->to_json(false, true); std::list json_crt_llts; auto crt_llts = get_CRT_LLTs(); - for ( const auto & llt : crt_llts ) { + for (const auto& llt : crt_llts) { json_crt_llts.push_back(llt->get_ctb_json(session)); } crt_block["triggers"] = nlohmann::json(json_crt_llts); // ---- PDS ---- - - subsystems["pds"] = get_pds() -> to_json(false, true); + + subsystems["pds"] = get_pds()->to_json(false, true); nlohmann::json ret; ret["ctb"] = json; - - return ret; + return ret; } -std::vector CTBMisc::contained_excludable_entities() const { +std::vector +CTBMisc::contained_excludable_entities() const +{ return std::vector{ get_randomtrigger_1(), get_randomtrigger_2() }; } - - -nlohmann::json CTBMisc::get_ctb_json(const dunedaq::confmodel::Session& session) const { +nlohmann::json +CTBMisc::get_ctb_json(const dunedaq::confmodel::Session& session) const +{ nlohmann::json ret; ret["randomtrigger_1"] = get_randomtrigger_1()->get_ctb_json(session); ret["randomtrigger_2"] = get_randomtrigger_2()->get_ctb_json(session); - ret["pulser"] = get_pulser() -> to_json(false, true); - ret["timing"] = get_timing() -> to_json(false, true); + ret["pulser"] = get_pulser()->to_json(false, true); + ret["timing"] = get_timing()->to_json(false, true); static std::string ch_status_flag = "ch_status"; - if ( get_ch_status() ) ret[ch_status_flag] = true; - else ret[ch_status_flag] = false; + if (get_ch_status()) + ret[ch_status_flag] = true; + else + ret[ch_status_flag] = false; static std::string standalong_flag = "standalone_enable"; ret[standalong_flag] = false; - - return ret; + return ret; } +nlohmann::json +CTBTrigger::get_ctb_json(const dunedaq::confmodel::Session& session) const +{ -nlohmann::json CTBTrigger::get_ctb_json(const dunedaq::confmodel::Session& session) const { - - auto json = this -> to_json(false, true); + auto json = this->to_json(false, true); static std::string enable_tag = "enable"; - if ( this -> is_excluded(session) ) { + if (this->is_excluded(session)) { json[enable_tag] = false; - } - else { + } else { json[enable_tag] = true; } - json["id"] = this -> UID(); - - return json; + json["id"] = this->UID(); + return json; } -nlohmann::json CTBSockets::get_ctb_json(std::optional socket_host) const { +nlohmann::json +CTBSockets::get_ctb_json(std::optional socket_host) const +{ nlohmann::json json; - json["receiver"] = get_receiver() -> get_ctb_json(socket_host); - json["monitor"] = get_monitor() -> get_ctb_json(socket_host); - json["statistics"] = get_statistics() -> to_json(false, true); + json["receiver"] = get_receiver()->get_ctb_json(socket_host); + json["monitor"] = get_monitor()->get_ctb_json(socket_host); + json["statistics"] = get_statistics()->to_json(false, true); return json; - } -nlohmann::json CTBSocket::get_ctb_json(std::optional socket_host) const { +nlohmann::json +CTBSocket::get_ctb_json(std::optional socket_host) const +{ auto json = to_json(false, true); - if ( socket_host ) { + if (socket_host) { json["host"] = socket_host.value(); } return json; - } - - - diff --git a/src/ConfigObjectFactory.cpp b/src/ConfigObjectFactory.cpp index 1ac24be..3378de1 100644 --- a/src/ConfigObjectFactory.cpp +++ b/src/ConfigObjectFactory.cpp @@ -1,111 +1,124 @@ - +/** + * @file ConfigObjectFactory.cpp + * + * Imeplement a helper class for SmartDaqApplication module generators + * + * This is part of the DUNE DAQ Software Suite, copyright 2023. + * Licensing/copyright details are in the COPYING file that you should have + * received with this code. + */ #include "ConfigObjectFactory.hpp" #include "confmodel/Service.hpp" #include "oks/file.hpp" #include // Replace with std::format when we switch to a newer compiler? +#include -namespace dunedaq { -namespace appmodel { +namespace dunedaq::appmodel { -ConfigObjectFactory::ConfigObjectFactory(const SmartDaqApplication* parent) : - m_config(&parent->configuration()), - m_dbfile(parent->config_object().contained_in()), - m_app_uid(parent->UID()) { +ConfigObjectFactory::ConfigObjectFactory(const SmartDaqApplication* parent) + : m_config(&parent->configuration()) + , m_dbfile(parent->config_object().contained_in()) + , m_app_uid(parent->UID()) +{ - //FIXME: remove this hacky hack - oks::OksFile::set_nolock_mode(true); + // FIXME: remove this hacky hack + oks::OksFile::set_nolock_mode(true); } -ConfigObjectFactory::~ConfigObjectFactory() { - //FIXME: remove this hacky hack - oks::OksFile::set_nolock_mode(false); +ConfigObjectFactory::~ConfigObjectFactory() +{ + // FIXME: remove this hacky hack + oks::OksFile::set_nolock_mode(false); } conffwk::ConfigObject -ConfigObjectFactory::create(const std::string& class_name, - const std::string& id) const { - conffwk::ConfigObject cfg_obj; - m_config->create(m_dbfile, class_name, id, cfg_obj); - return cfg_obj; +ConfigObjectFactory::create(const std::string& class_name, const std::string& id) const +{ + conffwk::ConfigObject cfg_obj; + m_config->create(m_dbfile, class_name, id, cfg_obj); + return cfg_obj; } //--- conffwk::ConfigObject -ConfigObjectFactory::create_queue_obj(const QueueDescriptor* qdesc, std::string uid) const { +ConfigObjectFactory::create_queue_obj(const QueueDescriptor* qdesc, std::string uid) const +{ - std::string queue_uid(qdesc->get_uid_base() + uid); - auto queue_obj = create("Queue", queue_uid); - queue_obj.set_by_val("data_type", qdesc->get_data_type()); - queue_obj.set_by_val("queue_type", qdesc->get_queue_type()); - queue_obj.set_by_val("capacity", qdesc->get_capacity()); + std::string queue_uid(qdesc->get_uid_base() + uid); + auto queue_obj = create("Queue", queue_uid); + queue_obj.set_by_val("data_type", qdesc->get_data_type()); + queue_obj.set_by_val("queue_type", qdesc->get_queue_type()); + queue_obj.set_by_val("capacity", qdesc->get_capacity()); // NOLINT(build/unsigned) - return queue_obj; + return queue_obj; } //--- conffwk::ConfigObject -ConfigObjectFactory::create_queue_sid_obj(const QueueDescriptor* qdesc, uint32_t src_id) const { - std::string queue_uid(fmt::format("{}{}", qdesc->get_uid_base(), src_id)); - auto queue_obj = create("QueueWithSourceId", queue_uid); +ConfigObjectFactory::create_queue_sid_obj(const QueueDescriptor* qdesc, uint32_t src_id) const // NOLINT(build/unsigned) +{ + std::string queue_uid(fmt::format("{}{}", qdesc->get_uid_base(), src_id)); + auto queue_obj = create("QueueWithSourceId", queue_uid); - queue_obj.set_by_val("data_type", qdesc->get_data_type()); - queue_obj.set_by_val("queue_type", qdesc->get_queue_type()); - queue_obj.set_by_val("capacity", qdesc->get_capacity()); - queue_obj.set_by_val("source_id", src_id); + queue_obj.set_by_val("data_type", qdesc->get_data_type()); + queue_obj.set_by_val("queue_type", qdesc->get_queue_type()); + queue_obj.set_by_val("capacity", qdesc->get_capacity()); // NOLINT(build/unsigned) + queue_obj.set_by_val("source_id", src_id); // NOLINT(build/unsigned) - return queue_obj; + return queue_obj; } //--- conffwk::ConfigObject -ConfigObjectFactory::create_queue_sid_obj(const QueueDescriptor* qdesc, - const confmodel::DetectorStream* stream) const { -return create_queue_sid_obj(qdesc, stream->get_source_id()); +ConfigObjectFactory::create_queue_sid_obj(const QueueDescriptor* qdesc, const confmodel::DetectorStream* stream) const +{ + return create_queue_sid_obj(qdesc, stream->get_source_id()); } //--- conffwk::ConfigObject -ConfigObjectFactory::create_callback_sid_obj(const DataMoveCallbackDescriptor* cdesc, uint32_t src_id) const +ConfigObjectFactory::create_callback_sid_obj(const DataMoveCallbackDescriptor* cdesc, + uint32_t src_id) const // NOLINT(build/unsigned) { std::string rdc_uid(fmt::format("{}{}", cdesc->get_uid_base(), src_id)); auto rdc_obj = create("DataMoveCallbackConf", rdc_uid); rdc_obj.set_by_val("data_type", cdesc->get_data_type()); - rdc_obj.set_by_val("source_id", src_id); + rdc_obj.set_by_val("source_id", src_id); // NOLINT(build/unsigned) return rdc_obj; } //--- /** -* \brief Helper function that gets a network connection config -* -* \param uid Unique ID name of the config object -* \param ndesc Network connection descriptor object -* -* \ret OKS configuration object for the network connection -*/ + * \brief Helper function that gets a network connection config + * + * \param uid Unique ID name of the config object + * \param ndesc Network connection descriptor object + * + * \ret OKS configuration object for the network connection + */ conffwk::ConfigObject -ConfigObjectFactory::create_net_obj(const NetworkConnectionDescriptor* ndesc, - std::string app_uid) const { +ConfigObjectFactory::create_net_obj(const NetworkConnectionDescriptor* ndesc, std::string app_uid) const +{ - auto svc_obj = ndesc->get_associated_service()->config_object(); - std::string net_id = ndesc->get_uid_base() + app_uid; - auto net_obj = create("NetworkConnection", net_id); + auto svc_obj = ndesc->get_associated_service()->config_object(); + std::string net_id = ndesc->get_uid_base() + app_uid; + auto net_obj = create("NetworkConnection", net_id); - net_obj.set_by_val("data_type", ndesc->get_data_type()); - net_obj.set_by_val("connection_type", ndesc->get_connection_type()); - net_obj.set_by_val("capacity", ndesc->get_capacity()); - net_obj.set_obj("associated_service", &svc_obj); + net_obj.set_by_val("data_type", ndesc->get_data_type()); + net_obj.set_by_val("connection_type", ndesc->get_connection_type()); + net_obj.set_by_val("capacity", ndesc->get_capacity()); // NOLINT(build/unsigned) + net_obj.set_obj("associated_service", &svc_obj); - return net_obj; + return net_obj; } conffwk::ConfigObject -ConfigObjectFactory::create_net_obj(const NetworkConnectionDescriptor* ndesc) const { - return create_net_obj(ndesc, this->m_app_uid); +ConfigObjectFactory::create_net_obj(const NetworkConnectionDescriptor* ndesc) const +{ + return create_net_obj(ndesc, this->m_app_uid); } -} // namespace appmodel -} // namespace dunedaq +} // namespace dunedaq::appmodel diff --git a/src/ConfigObjectFactory.hpp b/src/ConfigObjectFactory.hpp index 90fe1de..6f5ac83 100644 --- a/src/ConfigObjectFactory.hpp +++ b/src/ConfigObjectFactory.hpp @@ -7,14 +7,14 @@ * Licensing/copyright details are in the COPYING file that you should have * received with this code. */ -#ifndef APPMODEL_INCLUDE_OBJECTFACTORY_HPP_ -#define APPMODEL_INCLUDE_OBJECTFACTORY_HPP_ +#ifndef APPMODEL_SRC_CONFIGOBJECTFACTORY_HPP_ +#define APPMODEL_SRC_CONFIGOBJECTFACTORY_HPP_ -#include "appmodel/appmodelIssues.hpp" +#include "appmodel/DataMoveCallbackDescriptor.hpp" #include "appmodel/NetworkConnectionDescriptor.hpp" #include "appmodel/QueueDescriptor.hpp" -#include "appmodel/DataMoveCallbackDescriptor.hpp" #include "appmodel/SmartDaqApplication.hpp" +#include "appmodel/appmodelIssues.hpp" #include "conffwk/ConfigObject.hpp" #include "conffwk/Configuration.hpp" @@ -36,28 +36,26 @@ class ConfigObjectFactory std::string m_app_uid; public: - explicit ConfigObjectFactory(const SmartDaqApplication* ); + explicit ConfigObjectFactory(const SmartDaqApplication*); ~ConfigObjectFactory(); - [[nodiscard]] conffwk::ConfigObject - create(const std::string& class_name, const std::string& id) const; + [[nodiscard]] conffwk::ConfigObject create(const std::string& class_name, const std::string& id) const; //--- - [[nodiscard]] conffwk::ConfigObject - create_queue_obj(const QueueDescriptor* qdesc, std::string uid = "") const; + [[nodiscard]] conffwk::ConfigObject create_queue_obj(const QueueDescriptor* qdesc, std::string uid = "") const; //--- - [[nodiscard]] conffwk::ConfigObject - create_queue_sid_obj(const QueueDescriptor* qdesc, uint32_t src_id) const; + [[nodiscard]] conffwk::ConfigObject create_queue_sid_obj(const QueueDescriptor* qdesc, + uint32_t src_id) const; // NOLINT(build/unsigned) //--- - [[nodiscard]] conffwk::ConfigObject - create_queue_sid_obj(const QueueDescriptor* qdesc, const confmodel::DetectorStream* stream) const; + [[nodiscard]] conffwk::ConfigObject create_queue_sid_obj(const QueueDescriptor* qdesc, + const confmodel::DetectorStream* stream) const; //--- [[nodiscard]] conffwk::ConfigObject create_callback_sid_obj(const DataMoveCallbackDescriptor* cdesc, - uint32_t src_id) const; + uint32_t src_id) const; // NOLINT(build/unsigned) /** * \brief Helper function that gets a network connection config @@ -67,37 +65,36 @@ class ConfigObjectFactory * * \ret OKS configuration object for the network connection */ - [[nodiscard]] conffwk::ConfigObject - create_net_obj(const NetworkConnectionDescriptor* ndesc, std::string uid) const; + [[nodiscard]] conffwk::ConfigObject create_net_obj(const NetworkConnectionDescriptor* ndesc, std::string uid) const; - [[nodiscard]] conffwk::ConfigObject - create_net_obj(const NetworkConnectionDescriptor* ndesc) const; + [[nodiscard]] conffwk::ConfigObject create_net_obj(const NetworkConnectionDescriptor* ndesc) const; template - const T* get_dal(std::string uid) const { + const T* get_dal(std::string uid) const + { return m_config->get(uid); } template - const T* get_dal(conffwk::ConfigObject& obj) const { + const T* get_dal(conffwk::ConfigObject& obj) const + { return m_config->get(obj); } - void - update_modules(const std::vector& modules) { + void update_modules(const std::vector& modules) + { auto app = m_config->get(m_app_uid); if (!app->get_modules().empty()) { - throw (BadConf(ERS_HERE, - "SmartDaqApplication contains DaqModules which would be overwritten by generated DaqModules")); + throw(BadConf(ERS_HERE, + "SmartDaqApplication contains DaqModules which would be overwritten by generated DaqModules")); } if (!modules.empty()) { - const_cast(app)->set_modules(modules); - m_config->update({m_app_uid}, {}, {}); + const_cast(app)->set_modules(modules); // NOLINT + m_config->update({ m_app_uid }, {}, {}); } } - }; } // namespace dunedaq::appmodel -#endif // APPMODEL_INCLUDE_OBJECTFACTORY_HPP_ +#endif // APPMODEL_SRC_CONFIGOBJECTFACTORY_HPP_ diff --git a/src/ConfigurationHelper.cpp b/src/ConfigurationHelper.cpp index 19b4f6d..db7a560 100644 --- a/src/ConfigurationHelper.cpp +++ b/src/ConfigurationHelper.cpp @@ -8,7 +8,6 @@ * received with this code. */ -#include "appmodel/appmodelIssues.hpp" #include "appmodel/ConfigurationHelper.hpp" #include "appmodel/FakeDataApplication.hpp" #include "appmodel/FakeDataProdConf.hpp" @@ -18,56 +17,58 @@ #include "appmodel/SmartDaqApplication.hpp" #include "appmodel/SourceIDConf.hpp" #include "appmodel/TPReplayApplication.hpp" +#include "appmodel/appmodelIssues.hpp" #include "conffwk/ConfigObject.hpp" #include "conffwk/Schema.hpp" #include "confmodel/DetectorStream.hpp" #include "confmodel/DetectorToDaqConnection.hpp" +#include "confmodel/ExcludableEntity.hpp" #include "confmodel/NetworkConnection.hpp" #include "confmodel/Queue.hpp" -#include "confmodel/ExcludableEntity.hpp" #include "confmodel/Service.hpp" #include "confmodel/Session.hpp" +#include +#include +#include +#include + using namespace dunedaq; using namespace dunedaq::appmodel; std::vector> -ConfigurationHelper::get_netdescriptors( - const std::string& data_type, - const std::string& app_class) { - std::vector> - result; - for (auto app: m_session->included_applications()) { - if (app_class.empty() || app->castable(app_class)) { - auto smart_app = app->cast(); - if (smart_app == nullptr) { - // Only SmartDaqApplications have network rules - continue; - } - for (auto rule: smart_app->get_network_rules()) { - auto desc = rule->get_descriptor(); - if (desc->get_data_type() == data_type) { - result.emplace_back(std::pair{app->UID(), desc}); - } +ConfigurationHelper::get_netdescriptors(const std::string& data_type, const std::string& app_class) +{ + std::vector> result; + for (auto app : m_session->included_applications()) { + if (app_class.empty() || app->castable(app_class)) { + auto smart_app = app->cast(); + if (smart_app == nullptr) { + // Only SmartDaqApplications have network rules + continue; + } + for (auto rule : smart_app->get_network_rules()) { + auto desc = rule->get_descriptor(); + if (desc->get_data_type() == data_type) { + result.emplace_back(app->UID(), desc); } } } - return result; + } + return result; } - -std::vector ConfigurationHelper::get_services( - std::string app_class, - std::string data_type) +std::vector +ConfigurationHelper::get_services(std::string app_class, std::string data_type) { std::vector result; - for (auto app: m_session->included_applications()) { + for (auto app : m_session->included_applications()) { if (app->castable(app_class)) { auto smart_app = app->cast(); if (smart_app == nullptr) { - throw (NotSmart(ERS_HERE, app->full_name())); + throw(NotSmart(ERS_HERE, app->full_name())); } - for (auto rule: smart_app->get_network_rules()) { + for (auto rule : smart_app->get_network_rules()) { if (rule->get_descriptor()->get_data_type() == data_type) { result.push_back(rule->get_descriptor()->get_associated_service()); } @@ -77,33 +78,33 @@ std::vector ConfigurationHelper::get_services( return result; } - -std::map> ConfigurationHelper::get_stream_source_ids() { - std::map> result; - for (auto app: m_session->included_applications()) { +std::map> // NOLINT(build/unsigned) +ConfigurationHelper::get_stream_source_ids() +{ // NOLINT(build/unsigned) + std::map> result; // NOLINT(build/unsigned) + for (auto app : m_session->included_applications()) { auto ro_app = app->cast(); if (ro_app != nullptr) { - std::vector streams; - for (auto res: ro_app->contained_excludable_entities()) { + std::vector streams; // NOLINT(build/unsigned) + for (auto res : ro_app->contained_excludable_entities()) { if (!res->is_excluded(*m_session)) { auto d2d = res->cast(); if (d2d == nullptr) { - throw (BadD2d(ERS_HERE, app->full_name(), res->full_name())); + throw(BadD2d(ERS_HERE, app->full_name(), res->full_name())); } - for (auto stream: d2d->streams()) { + for (auto stream : d2d->streams()) { if (!stream->is_excluded(*m_session)) { streams.push_back(stream->get_source_id()); } } } } - result.insert(std::pair{app->UID(), streams}); - } - else { + result.insert(std::pair{ app->UID(), streams }); + } else { auto fake_app = app->cast(); if (fake_app != nullptr) { - std::vector streams; - for (auto res: fake_app->contained_excludable_entities()) { + std::vector streams; // NOLINT(build/unsigned) + for (auto res : fake_app->contained_excludable_entities()) { if (!res->is_excluded(*m_session)) { auto fdpc = res->cast(); if (fdpc != nullptr && !fdpc->is_excluded(*m_session)) { @@ -119,16 +120,16 @@ std::map> ConfigurationHelper::get_stream_sour } std::map> -ConfigurationHelper::get_tp_source_ids(){ +ConfigurationHelper::get_tp_source_ids() +{ std::map> result; - for (auto app: m_session->included_applications()) { + for (auto app : m_session->included_applications()) { auto ro_app = app->cast(); if (ro_app != nullptr) { if (ro_app->get_tp_generation_enabled()) { result.insert(std::pair(app->UID(), ro_app->get_tp_source_ids())); - } - else { - result.insert({app->UID(), std::vector()}); + } else { + result.insert({ app->UID(), std::vector() }); } } auto replay_app = app->cast(); @@ -139,10 +140,11 @@ ConfigurationHelper::get_tp_source_ids(){ return result; } -std::vector ConfigurationHelper::get_app_uids( - std::string app_class){ +std::vector +ConfigurationHelper::get_app_uids(std::string app_class) +{ std::vector result; - for (auto app: m_session->included_applications()) { + for (auto app : m_session->included_applications()) { if (app_class.empty() || app->castable(app_class)) { result.push_back(app->UID()); } @@ -151,28 +153,29 @@ std::vector ConfigurationHelper::get_app_uids( } std::map -ConfigurationHelper::get_app_source_ids(std::string app_class) { +ConfigurationHelper::get_app_source_ids(std::string app_class) +{ std::map result; - for (auto app: m_session->included_applications()) { + for (auto app : m_session->included_applications()) { if (app_class.empty() || app->castable(app_class)) { auto smart_app = app->cast(); if (smart_app != nullptr && smart_app->get_source_id() != nullptr) { - result.insert({app->UID(), smart_app->get_source_id()}); + result.insert({ app->UID(), smart_app->get_source_id() }); } } } return result; } - std::map> -ConfigurationHelper::get_all_app_source_ids(std::string app_class) { +ConfigurationHelper::get_all_app_source_ids(std::string app_class) +{ std::map> result; - for (auto app: m_session->included_applications()) { + for (auto app : m_session->included_applications()) { if (app_class.empty() || app->castable(app_class)) { auto class_info = app->configuration().get_class_info(app->class_name()); auto obj = app->config_object(); - for (auto rel: class_info.p_relationships) { + for (auto const& rel : class_info.p_relationships) { if (rel.p_type == "SourceIDConf") { if (rel.p_cardinality == dunedaq::conffwk::cardinality_t::zero_or_one || rel.p_cardinality == dunedaq::conffwk::cardinality_t::only_one) { @@ -180,10 +183,10 @@ ConfigurationHelper::get_all_app_source_ids(std::string app_class) { obj.get(rel.p_name, rel_obj); if (!rel_obj.is_null()) { if (!result.contains(app->UID())) { - result.insert({app->UID(), {}}); + result.insert({ app->UID(), {} }); } const auto srcid = app->configuration().get(rel_obj); - result.at(app->UID()).insert({rel.p_name, srcid}); + result.at(app->UID()).insert({ rel.p_name, srcid }); } } // cardinality } // SourceIDConf @@ -194,7 +197,9 @@ ConfigurationHelper::get_all_app_source_ids(std::string app_class) { return result; } -bool ConfigurationHelper::is_excluded(const conffwk::DalObject* item) { +bool +ConfigurationHelper::is_excluded(const conffwk::DalObject* item) +{ auto res = item->cast(); if (res == nullptr) { return false; diff --git a/src/DFApplication.cpp b/src/DFApplication.cpp index 399ca46..e2b3001 100644 --- a/src/DFApplication.cpp +++ b/src/DFApplication.cpp @@ -8,9 +8,9 @@ * received with this code. */ +#include "appmodel/DFApplication.hpp" #include "ConfigObjectFactory.hpp" #include "appmodel/ConfigurationHelper.hpp" -#include "appmodel/DFApplication.hpp" #include "appmodel/DataStoreConf.hpp" #include "appmodel/DataWriterConf.hpp" #include "appmodel/DataWriterModule.hpp" @@ -31,18 +31,18 @@ #include "oks/kernel.hpp" #include +#include +#include #include #include -namespace dunedaq { -namespace appmodel { +namespace dunedaq::appmodel { - static inline void fill_sourceid_object(const ConfigObjectFactory& obj_fac, const conffwk::ConfigObject* netConn, const std::string& uid, - const std::vector& stream_source_ids, + const std::vector& stream_source_ids, // NOLINT(build/unsigned) const std::vector& tp_source_ids, conffwk::ConfigObject& sidNetObj, std::vector> sidObjs) @@ -54,7 +54,7 @@ fill_sourceid_object(const ConfigObjectFactory& obj_fac, for (auto& source_id : stream_source_ids) { std::string streamSidUid(uid + "SourceIDConf" + std::to_string(source_id)); auto stream_sid_obj = std::make_shared(obj_fac.create("SourceIDConf", streamSidUid)); - stream_sid_obj->set_by_val("sid", source_id); + stream_sid_obj->set_by_val("sid", source_id); // NOLINT(build/unsigned) stream_sid_obj->set_by_val("subsystem", "Detector_Readout"); sidObjs.push_back(stream_sid_obj); source_id_objs.push_back(sidObjs.back().get()); @@ -64,18 +64,10 @@ fill_sourceid_object(const ConfigObjectFactory& obj_fac, sidObjs.push_back(std::make_shared(tp_sid->config_object())); source_id_objs.push_back(sidObjs.back().get()); } - /* - std::string trgSidUid(roapp->UID() + "TRGSourceIDConf" + std::to_string(roapp->get_tp_source_id())); - auto trig_sid_obj = std::make_shared(obj_fac.create("SourceIDConf", trgSidUid)); - trig_sid_obj->set_by_val("sid", roapp->get_tp_source_id()); - trig_sid_obj->set_by_val("subsystem", "Trigger"); - source_id_objs.push_back(sidObjs.back().get()); - */ sidNetObj.set_objs("source_ids", source_id_objs); } - inline void fill_replay_sourceid_object(const ConfigObjectFactory& obj_fac, const std::string& uid, @@ -98,8 +90,7 @@ fill_replay_sourceid_object(const ConfigObjectFactory& obj_fac, // set Network connections std::string dreqNetUid(uid + ext); - netConn->emplace_back( - obj_fac.create_net_obj(descriptor, dreqNetUid)); + netConn->emplace_back(obj_fac.create_net_obj(descriptor, dreqNetUid)); netConn->back().set_by_val("data_type", descriptor->get_data_type()); netConn->back().set_by_val("connection_type", descriptor->get_connection_type()); auto serviceObj = descriptor->get_associated_service()->config_object(); @@ -107,8 +98,7 @@ fill_replay_sourceid_object(const ConfigObjectFactory& obj_fac, // set SourceID to Network connections std::string sidToNetUid(uid + ext + "-sids"); - sidNetObj->emplace_back( - obj_fac.create("SourceIDToNetworkConnection", sidToNetUid)); + sidNetObj->emplace_back(obj_fac.create("SourceIDToNetworkConnection", sidToNetUid)); sidNetObj->back().set_obj("netconn", &netConn->back()); // set SourceID objs @@ -117,11 +107,9 @@ fill_replay_sourceid_object(const ConfigObjectFactory& obj_fac, } } - - void -DFApplication::generate_modules( - std::shared_ptr helper) const { +DFApplication::generate_modules(std::shared_ptr helper) const +{ ConfigObjectFactory obj_fac(this); @@ -187,7 +175,7 @@ DFApplication::generate_modules( } // Create network connection config object auto fragNetObj = obj_fac.create_net_obj(fragNetDesc, UID()); - auto trigdecNetObj = obj_fac.create_net_obj(trigdecNetDesc, UID()); + auto trigdecNetObj = obj_fac.create_net_obj(trigdecNetDesc, UID()); auto tokenNetObj = obj_fac.create_net_obj(tokenNetDesc, ""); conffwk::ConfigObject trmonReqNetObj; conffwk::ConfigObject trmonTRNetObj; @@ -204,47 +192,30 @@ DFApplication::generate_modules( std::vector sidNetObjs; std::vector> sidObjs; std::set processed_apps; - for (auto uid: helper->get_app_uids("DFApplication")) { + for (auto const& uid : helper->get_app_uids("DFApplication")) { processed_apps.insert(uid); } auto stream_src_ids = helper->get_stream_source_ids(); auto tp_src_ids = helper->get_tp_source_ids(); - for (auto [uid, descriptor]: - helper->get_netdescriptors("DataRequest", "ReadoutApplication")) { - dreqNetObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid)); + for (auto const& [uid, descriptor] : helper->get_netdescriptors("DataRequest", "ReadoutApplication")) { + dreqNetObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid)); std::string sidToNetUid(descriptor->get_uid_base() + uid + "-sids"); sidNetObjs.emplace_back(obj_fac.create("SourceIDToNetworkConnection", sidToNetUid)); - fill_sourceid_object(obj_fac, - &dreqNetObjs.back(), - uid, - stream_src_ids.at(uid), - tp_src_ids.at(uid), - sidNetObjs.back(), - sidObjs); + fill_sourceid_object( + obj_fac, &dreqNetObjs.back(), uid, stream_src_ids.at(uid), tp_src_ids.at(uid), sidNetObjs.back(), sidObjs); processed_apps.insert(uid); } - for (auto [uid, descriptor]: - helper->get_netdescriptors("DataRequest", "TPReplayApplication")) { - fill_replay_sourceid_object(obj_fac, - uid, - tp_src_ids.at(uid), - &dreqNetObjs, - &sidNetObjs, - descriptor, - sidObjs); + for (auto const& [uid, descriptor] : helper->get_netdescriptors("DataRequest", "TPReplayApplication")) { + fill_replay_sourceid_object(obj_fac, uid, tp_src_ids.at(uid), &dreqNetObjs, &sidNetObjs, descriptor, sidObjs); processed_apps.insert(uid); } - - - - for (auto [uid, descriptor]: - helper->get_netdescriptors("DataRequest", "FakeDataApplication")) { - dreqNetObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid)); + for (auto const& [uid, descriptor] : helper->get_netdescriptors("DataRequest", "FakeDataApplication")) { + dreqNetObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid)); std::string sidToNetUid(descriptor->get_uid_base() + uid + "-sids"); sidNetObjs.emplace_back(obj_fac.create("SourceIDToNetworkConnection", sidToNetUid)); @@ -261,62 +232,58 @@ DFApplication::generate_modules( // now we treat the CTB which has 2 connections related to source IDs const auto ctb_type = "CTBApplication"; - for (auto [uid, descriptor]: helper->get_netdescriptors("DataRequest", ctb_type)) { + for (auto const& [uid, descriptor] : helper->get_netdescriptors("DataRequest", ctb_type)) { if (processed_apps.contains(uid)) { continue; } - - for ( const auto & [uid, rel_sources] : - helper->get_all_app_source_ids(ctb_type) ) { - for ( auto [rel, id] : rel_sources ) { - std::string local_uid = uid; - local_uid += rel.find("LLT")!=std::string::npos ? "_LLT" : "_HLT"; - - dreqNetObjs.emplace_back(obj_fac.create_net_obj(descriptor, local_uid)); - sidObjs.push_back(std::make_shared(id->config_object())); - - std::string sidToNetUid(descriptor->get_uid_base() + local_uid); - sidNetObjs.emplace_back(obj_fac.create("SourceIDToNetworkConnection", sidToNetUid)); - sidNetObjs.back().set_objs("source_ids", {sidObjs.back().get()}); - sidNetObjs.back().set_obj("netconn", &dreqNetObjs.back()); - + + for (auto const& [uid, rel_sources] : helper->get_all_app_source_ids(ctb_type)) { + for (auto const& [rel, id] : rel_sources) { + std::string local_uid = uid; + local_uid += rel.find("LLT") != std::string::npos ? "_LLT" : "_HLT"; + + dreqNetObjs.emplace_back(obj_fac.create_net_obj(descriptor, local_uid)); + sidObjs.push_back(std::make_shared(id->config_object())); + + std::string sidToNetUid(descriptor->get_uid_base() + local_uid); + sidNetObjs.emplace_back(obj_fac.create("SourceIDToNetworkConnection", sidToNetUid)); + sidNetObjs.back().set_objs("source_ids", { sidObjs.back().get() }); + sidNetObjs.back().set_obj("netconn", &dreqNetObjs.back()); + } // loop on relational sources - + processed_apps.insert(uid); - } // loop over CTB apps + } // loop over CTB apps } // loop over descriptors for the CTB apps auto app_sources = helper->get_app_source_ids(); // Now look at all Smart apps that are not Readout, FakeData or DF - for (auto [uid, descriptor]: helper->get_netdescriptors("DataRequest")) { + for (auto const& [uid, descriptor] : helper->get_netdescriptors("DataRequest")) { - if (processed_apps.contains(uid)) { continue; } if (app_sources.contains(uid)) { dreqNetObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid)); - sidObjs.push_back(std::make_shared( - app_sources.at(uid)->config_object())); + sidObjs.push_back(std::make_shared(app_sources.at(uid)->config_object())); std::string sidToNetUid(descriptor->get_uid_base() + uid + "-sids"); sidNetObjs.emplace_back(obj_fac.create("SourceIDToNetworkConnection", sidToNetUid)); - sidNetObjs.back().set_objs("source_ids", {sidObjs.back().get()}); + sidNetObjs.back().set_objs("source_ids", { sidObjs.back().get() }); sidNetObjs.back().set_obj("netconn", &dreqNetObjs.back()); processed_apps.insert(uid); } } - // Get pointers to objects here, after vector has been filled so they don't move on us for (auto& obj : dreqNetObjs) { - trbOutputObjs.push_back(&obj); + trbOutputObjs.push_back(&obj); // NOLINT(performance-inefficient-vector-operation) } for (auto& obj : sidNetObjs) { - trbSidNetObjs.push_back(&obj); + trbSidNetObjs.push_back(&obj); // NOLINT(performance-inefficient-vector-operation) } // -- Second, we create the Module objects and assign their configs, with the precreated @@ -328,7 +295,7 @@ DFApplication::generate_modules( throw(BadConf(ERS_HERE, "No DataWriterModule or TRB configuration given")); } auto trbConfObj = trbConf->config_object(); - trbConfObj.set_by_val("source_id", get_source_id()->get_sid()); + trbConfObj.set_by_val("source_id", get_source_id()->get_sid()); // NOLINT(build/unsigned) trbInputObjs = { &trigdecNetObj, &fragNetObj }; if (trmonReqNetDesc != nullptr) { trbInputObjs.push_back(&trmonReqNetObj); @@ -371,7 +338,6 @@ DFApplication::generate_modules( } obj_fac.update_modules(modules); -} +} // NOLINT(readability/fn_size) -} // namespace appmodel -} // namespace dunedaq +} // namespace dunedaq::appmodel diff --git a/src/DFOApplication.cpp b/src/DFOApplication.cpp index 3d2b5ba..2f3ec49 100644 --- a/src/DFOApplication.cpp +++ b/src/DFOApplication.cpp @@ -8,10 +8,9 @@ * received with this code. */ - +#include "appmodel/DFOApplication.hpp" #include "ConfigObjectFactory.hpp" #include "appmodel/ConfigurationHelper.hpp" -#include "appmodel/DFOApplication.hpp" #include "appmodel/DFOConf.hpp" #include "appmodel/DFOModule.hpp" #include "appmodel/NetworkConnectionDescriptor.hpp" @@ -26,11 +25,11 @@ #include "logging/Logging.hpp" #include "oks/kernel.hpp" +#include #include #include -namespace dunedaq { -namespace appmodel { +namespace dunedaq::appmodel { void DFOApplication::generate_modules(std::shared_ptr helper) const @@ -39,7 +38,6 @@ DFOApplication::generate_modules(std::shared_ptr ConfigObjectFactory obj_fac(this); - std::string dfoUid("DFO-" + UID()); TLOG_DEBUG(7) << "creating OKS configuration object for DFOModule class "; auto dfoObj = obj_fac.create("DFOModule", dfoUid); @@ -47,7 +45,7 @@ DFOApplication::generate_modules(std::shared_ptr auto dfoConf = get_dfo(); dfoObj.set_obj("configuration", &dfoConf->config_object()); - if (dfoConf == 0) { + if (dfoConf == nullptr) { throw(BadConf(ERS_HERE, "No DFOConf configuration given")); } @@ -71,9 +69,7 @@ DFOApplication::generate_modules(std::shared_ptr } else if (descriptor->get_data_type() == "TriggerDecisionToken") { tokenInObj = connObj; input_conns.push_back(&tokenInObj); - } - - else if (descriptor->get_data_type() == "TriggerInhibit") { + } else if (descriptor->get_data_type() == "TriggerInhibit") { busyOutObj = connObj; output_conns.push_back(&busyOutObj); } @@ -91,8 +87,7 @@ DFOApplication::generate_modules(std::shared_ptr // Process special Network rules! std::vector tdOutObjs; - for (auto [uid, descriptor]: - helper->get_netdescriptors("TriggerDecision", "DFApplication")) { + for (auto const& [uid, descriptor] : helper->get_netdescriptors("TriggerDecision", "DFApplication")) { tdOutObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid)); } @@ -109,5 +104,4 @@ DFOApplication::generate_modules(std::shared_ptr obj_fac.update_modules(modules); } -} // namespace appmodel -} // namespace dunedaq +} // namespace dunedaq::appmodel diff --git a/src/DTSHSIApplication.cpp b/src/DTSHSIApplication.cpp index d1b4e91..20a53c8 100644 --- a/src/DTSHSIApplication.cpp +++ b/src/DTSHSIApplication.cpp @@ -8,39 +8,37 @@ * received with this code. */ - -#include "appmodel/ConfigurationHelper.hpp" -#include "ConfigObjectFactory.hpp" #include "appmodel/DTSHSIApplication.hpp" +#include "ConfigObjectFactory.hpp" +#include "appmodel/ConfigurationHelper.hpp" +#include "appmodel/DataHandlerConf.hpp" +#include "appmodel/DataHandlerModule.hpp" +#include "appmodel/HSIReadout.hpp" +#include "appmodel/HSIReadoutConf.hpp" #include "appmodel/NetworkConnectionDescriptor.hpp" #include "appmodel/NetworkConnectionRule.hpp" #include "appmodel/QueueConnectionRule.hpp" #include "appmodel/QueueDescriptor.hpp" -#include "appmodel/DataHandlerModule.hpp" -#include "appmodel/DataHandlerConf.hpp" #include "appmodel/SourceIDConf.hpp" -#include "appmodel/HSIReadout.hpp" -#include "appmodel/HSIReadoutConf.hpp" #include "appmodel/appmodelIssues.hpp" +#include "conffwk/Configuration.hpp" #include "confmodel/Connection.hpp" #include "confmodel/NetworkConnection.hpp" #include "confmodel/Service.hpp" #include "logging/Logging.hpp" -#include "conffwk/Configuration.hpp" #include +#include #include #include -namespace dunedaq { -namespace appmodel { - +namespace dunedaq::appmodel { void DTSHSIApplication::generate_modules(std::shared_ptr /*helper*/) const { ConfigObjectFactory obj_fac(this); - + std::vector modules; auto dlhConf = get_link_handler(); @@ -78,7 +76,7 @@ DTSHSIApplication::generate_modules(std::shared_ptrget_sid(); - auto det_id = 1; // TODO Eric Flumerfelt , 08-Feb-2024: This is a magic number corresponding to kDAQ + auto det_id = 1; // This is a magic number corresponding to kDAQ std::string uid("DLH-" + std::to_string(id)); TLOG_DEBUG(7) << "creating OKS configuration object for Data Link Handler class " << dlhClass << ", id " << id; conffwk::ConfigObject dlhObj = obj_fac.create(dlhClass, uid); - dlhObj.set_by_val("source_id", id); - dlhObj.set_by_val("detector_id", det_id); + dlhObj.set_by_val("source_id", id); // NOLINT(build/unsigned) + dlhObj.set_by_val("detector_id", det_id); // NOLINT(build/unsigned) dlhObj.set_by_val("post_processing_enabled", false); dlhObj.set_obj("module_configuration", &dlhConf->config_object()); @@ -115,7 +113,7 @@ DTSHSIApplication::generate_modules(std::shared_ptrget_associated_service()->config_object(); conffwk::ConfigObject hsiNetObj = obj_fac.create_net_obj(hsiNetDesc, ""); - + std::string genuid("HSI-" + std::to_string(id)); conffwk::ConfigObject hsiObj = obj_fac.create("HSIReadout", genuid); hsiObj.set_obj("configuration", &rdrConf->config_object()); @@ -133,6 +131,5 @@ DTSHSIApplication::generate_modules(std::shared_ptr -#include #include -#include #include -#include +#include #include +#include +#include +#include +#include namespace dunedaq::appmodel { - + std::vector -DaphneApplication::contained_excludable_entities() const { +DaphneApplication::contained_excludable_entities() const +{ return to_resources(get_detector_connections()); } @@ -65,7 +67,7 @@ DaphneApplication::generate_modules(std::shared_ptr conf_map; auto confs = daphne_conf->get_boards(); - for ( const auto & c : confs ) { + for (const auto& c : confs) { conf_map[c->get_key()] = c->get_conf(); } @@ -75,11 +77,12 @@ DaphneApplication::generate_modules(std::shared_ptr ctrl_hosts; // map from ctrl_host to senders - std::map > hermes_senders; - + std::map> hermes_senders; + for (auto d2d_conn : get_detector_connections()) { - // A ExcludableEntity can be disabled and still its application can be enabled because the application can have multile resources, so we need to check which resources are enabled + // A ExcludableEntity can be disabled and still its application can be enabled because the application can have + // multile resources, so we need to check which resources are enabled if (helper->is_excluded(d2d_conn)) { TLOG_DEBUG(7) << "Ignoring disabled DetectorToDaqConnection " << d2d_conn->UID(); continue; @@ -93,33 +96,33 @@ DaphneApplication::generate_modules(std::shared_ptr( d2d_conn ); // NOLINT(runtime/rtti) - auto net_conn = dynamic_cast( d2d_conn ); // NOLINT(runtime/rtti) + auto flx_conn = dynamic_cast(d2d_conn); // NOLINT(runtime/rtti) + auto net_conn = dynamic_cast(d2d_conn); // NOLINT(runtime/rtti) - if ( ! net_conn && ! flx_conn) { + if (!net_conn && !flx_conn) { throw BadConf(ERS_HERE, d2d_conn->UID() + " is neither felix or eth connection"); } - if ( flx_conn ) { + if (flx_conn) { auto det_senders = flx_conn->get_felix_senders(); // Loop over senders for (const auto* felix_sender : det_senders) { - - if ( helper->is_excluded(felix_sender) ) { + + if (helper->is_excluded(felix_sender)) { TLOG() << "Skipping disabled sender: " << felix_sender->UID(); continue; } - - auto ip = felix_sender -> get_control_host(); - + + auto ip = felix_sender->get_control_host(); + // from the felix sender we get the DetStream and then the GeoID - - auto streams = felix_sender -> get_streams(); - - for ( const auto * det_s : streams ) { - - if ( helper->is_excluded(det_s) ) { + + auto streams = felix_sender->get_streams(); + + for (const auto* det_s : streams) { + + if (helper->is_excluded(det_s)) { TLOG() << "Skipping disabled DetStream: " << det_s->UID(); continue; } @@ -128,104 +131,104 @@ DaphneApplication::generate_modules(std::shared_ptrget_detector_id(), geo_id->get_crate_id(), geo_id->get_slot_id()); if (!v3_map.contains(id)) { v3_map[id] = false; - } - + } + } // loop over DetStreams - + } // loop over det_senders } // if flx connection - if ( net_conn ) { + if (net_conn) { auto det_senders = net_conn->get_net_senders(); - for ( const auto* nw_sender : det_senders ) { - if ( helper->is_excluded(nw_sender) ) { + for (const auto* nw_sender : det_senders) { + if (helper->is_excluded(nw_sender)) { TLOG() << "Skipping disabled sender: " << nw_sender->UID(); continue; } // Check the sender type, must me a HermesSender const auto* hrms_sender = nw_sender->cast(); - if (!hrms_sender ) { + if (!hrms_sender) { throw(BadConf(ERS_HERE, fmt::format("DataSender {} is not a appmodel::HermesDataSender", nw_sender->UID()))); } hermes_senders[hrms_sender->get_control_host()].push_back(hrms_sender); - - auto streams = nw_sender -> get_streams(); - for ( const auto * det_s : streams ) { - - if ( helper->is_excluded(det_s) ) { + + auto streams = nw_sender->get_streams(); + for (const auto* det_s : streams) { + + if (helper->is_excluded(det_s)) { TLOG() << "Skipping disabled DetStream: " << det_s->UID(); continue; } - + auto geo_id = det_s->get_geo_id(); auto id = fmt::format("{}.{}.{}", geo_id->get_detector_id(), geo_id->get_crate_id(), geo_id->get_slot_id()); if (!v3_map.contains(id)) { v3_map[id] = true; interfaces[id] = net_conn->get_net_receiver()->get_uses(); ctrl_hosts[id] = hrms_sender->get_control_host(); - } - + } + } // loop over streams } // loop over NW senders - + } // if net_connection } // loop over det2DAQ Connections + for (const auto& [id, v3] : v3_map) { - - - for ( const auto & [id, v3] : v3_map ) { - auto conf_it = conf_map.find(id); - if ( conf_it == conf_map.end() ) { + if (conf_it == conf_map.end()) { throw MissingDaphne(ERS_HERE, id); } auto conf = conf_it->second; - conffwk::ConfigObject module_obj = obj_fac.create( (v3 ? "DaphneV3ControllerModule" : "DaphneV2ControllerModule"), fmt::format("controller-{}", id) ); - module_obj.set_obj("daphne_conf", & daphne_conf -> config_object() ); - module_obj.set_obj("board_conf", & conf -> config_object() ); + conffwk::ConfigObject module_obj = + obj_fac.create((v3 ? "DaphneV3ControllerModule" : "DaphneV2ControllerModule"), fmt::format("controller-{}", id)); + module_obj.set_obj("daphne_conf", &daphne_conf->config_object()); + module_obj.set_obj("board_conf", &conf->config_object()); - auto module = obj_fac.get_dal(module_obj); + auto module = obj_fac.get_dal(module_obj); modules.push_back(module); - // Create Hermes Modules if (v3) { std::string hermes_uid = fmt::format("daphne-hermes-ctrl-{}", id); conffwk::ConfigObject hermes_obj = obj_fac.create("HermesModule", hermes_uid); hermes_obj.set_obj("address_table", &this->get_hermes_module_conf()->get_address_table()->config_object()); - hermes_obj.set_by_val("uri", fmt::format("{}://{}:{}", this->get_hermes_module_conf()->get_ipbus_type(), ctrl_hosts[id], this->get_hermes_module_conf()->get_ipbus_port())); - hermes_obj.set_by_val("timeout_ms", this->get_hermes_module_conf()->get_ipbus_timeout_ms()); // NOLINT - hermes_obj.set_obj("destination", & interfaces[id]->config_object()); - - std::vector< const conffwk::ConfigObject * > links_obj; - const auto & senders = hermes_senders[ctrl_hosts[id]]; - for ( const auto* sndr : senders ){ + hermes_obj.set_by_val("uri", + fmt::format("{}://{}:{}", + this->get_hermes_module_conf()->get_ipbus_type(), + ctrl_hosts[id], + this->get_hermes_module_conf()->get_ipbus_port())); + hermes_obj.set_by_val("timeout_ms", this->get_hermes_module_conf()->get_ipbus_timeout_ms()); // NOLINT + hermes_obj.set_obj("destination", &interfaces[id]->config_object()); + + std::vector links_obj; + const auto& senders = hermes_senders[ctrl_hosts[id]]; + for (const auto* sndr : senders) { links_obj.push_back(&sndr->config_object()); } hermes_obj.set_objs("links", links_obj); - - modules.push_back(obj_fac.get_dal(hermes_obj)); + modules.push_back(obj_fac.get_dal(hermes_obj)); } - + } // ips obj_fac.update_modules(modules); -} // NOLINT - +} // NOLINT bool -DaphneV2BoardConf::is_channel_used(size_t ch) const { +DaphneV2BoardConf::is_channel_used(size_t ch) const +{ - for ( auto ch_p : get_active_channels() ) { - if ( ch_p->get_channel_id() == ch ) { + for (auto ch_p : get_active_channels()) { + if (ch_p->get_channel_id() == ch) { return true; } } @@ -233,37 +236,42 @@ DaphneV2BoardConf::is_channel_used(size_t ch) const { return false; } -const DaphneV2Channel & -DaphneV2BoardConf::get_channel(size_t ch) const { +const DaphneV2Channel& +DaphneV2BoardConf::get_channel(size_t ch) const +{ - for ( auto ch_p : get_active_channels() ) { - if ( ch_p->get_channel_id() == ch ) { + for (auto ch_p : get_active_channels()) { + if (ch_p->get_channel_id() == ch) { return *ch_p; } } - + return *get_default_channel(); } bool -DaphneV2BoardConf::is_afe_used(size_t afe) const { +DaphneV2BoardConf::is_afe_used(size_t afe) const +{ - auto begin = afe*8; - auto end = (afe+1)*8; - for ( size_t i = begin; i < end; ++i) { - if( is_channel_used(i) ) return true; + auto begin = afe * 8; + auto end = (afe + 1) * 8; + for (size_t i = begin; i < end; ++i) { + if (is_channel_used(i)) + return true; } return false; } -const DaphneV2AFE & -DaphneV2BoardConf::get_afe(size_t ch) const { +const DaphneV2AFE& +DaphneV2BoardConf::get_afe(size_t ch) const +{ + + if (!is_afe_used(ch)) + return *get_default_afe(); - if ( ! is_afe_used(ch) ) return *get_default_afe(); - - for ( auto afe_p : get_active_afes() ) { - if ( afe_p->get_afe_id() == ch ) { + for (auto afe_p : get_active_afes()) { + if (afe_p->get_afe_id() == ch) { return *afe_p; } } @@ -271,41 +279,43 @@ DaphneV2BoardConf::get_afe(size_t ch) const { throw appmodel::MissingAFE(ERS_HERE, UID(), ch); } +uint16_t // NOLINT(build/unsigned) +DaphneV2ADC::get_reg4() const +{ -uint16_t -DaphneV2ADC::get_reg4() const { - - // ADC, reg 4 has no parsing as it's all made of booleans - std::bitset<5> reg4; - // bits 0 and 2 are reserved + // ADC, reg 4 has no parsing as it's all made of booleans + std::bitset<5> reg4; + // bits 0 and 2 are reserved reg4[1] = get_low_resolution(); reg4[3] = get_output_offset_binary(); reg4[4] = get_MSB_first(); - return reg4.to_ulong(); + return reg4.to_ulong(); } -uint16_t -DaphneV2PGA::get_reg51() const { +uint16_t // NOLINT(build/unsigned) +DaphneV2PGA::get_reg51() const +{ std::bitset<14> reg51(get_lpf_cut_frequency()); - reg51 <<= 1; + reg51 <<= 1; reg51[4] = get_integrator_disable(); - reg51[7] = true; // clamp is always disabled and we are in low noise mode + reg51[7] = true; // clamp is always disabled and we are in low noise mode reg51[13] = get_gain(); - return reg51.to_ulong() ; + return reg51.to_ulong(); } -uint16_t -DaphneV2LNA::get_reg52() const { +uint16_t // NOLINT(build/unsigned) +DaphneV2LNA::get_reg52() const +{ - std::bitset<16> reg52; + std::bitset<16> reg52; decltype(reg52) clamp(get_clamp()); clamp <<= 6; reg52[12] = get_integrator_disable(); - + decltype(reg52) gain(get_gain()); clamp <<= 13; @@ -314,5 +324,5 @@ DaphneV2LNA::get_reg52() const { return reg52.to_ulong(); } - + } // namespace dunedaq::appmodel diff --git a/src/FakeDataApplication.cpp b/src/FakeDataApplication.cpp index e3a0523..fa7f290 100644 --- a/src/FakeDataApplication.cpp +++ b/src/FakeDataApplication.cpp @@ -8,7 +8,6 @@ * received with this code. */ - #include "ConfigObjectFactory.hpp" #include "conffwk/Configuration.hpp" @@ -23,8 +22,8 @@ #include "appmodel/FakeDataApplication.hpp" #include "appmodel/FakeDataProdConf.hpp" #include "appmodel/FakeDataProdModule.hpp" -#include "appmodel/FragmentAggregatorModule.hpp" #include "appmodel/FragmentAggregatorConf.hpp" +#include "appmodel/FragmentAggregatorModule.hpp" #include "appmodel/NetworkConnectionDescriptor.hpp" #include "appmodel/NetworkConnectionRule.hpp" #include "appmodel/QueueConnectionRule.hpp" @@ -34,16 +33,17 @@ #include "logging/Logging.hpp" +#include #include #include -namespace dunedaq { -namespace appmodel { +namespace dunedaq::appmodel { //----------------------------------------------------------------------------- std::vector -FakeDataApplication::contained_excludable_entities() const { +FakeDataApplication::contained_excludable_entities() const +{ return to_resources(get_producers()); } @@ -56,7 +56,6 @@ FakeDataApplication::generate_modules(std::shared_ptr( - dlhReqInputQDesc->get_uid_base() + std::to_string(id))); + faOutputQueues.push_back( + obj_fac.get_dal(dlhReqInputQDesc->get_uid_base() + std::to_string(id))); dlhObj.set_objs("inputs", { &reqQueueObj }); @@ -139,7 +138,7 @@ FakeDataApplication::generate_modules(std::shared_ptr qObjs; for (auto q : faOutputQueues) { - qObjs.push_back(&q->config_object()); + qObjs.push_back(&q->config_object()); // NOLINT(performance-inefficient-vector-operation) } faObj.set_obj("configuration", &aggregator_conf->config_object()); faObj.set_objs("inputs", { &faNetObj, &faQueueObj }); @@ -163,5 +162,4 @@ FakeDataApplication::generate_modules(std::shared_ptr +#include #include #include -namespace dunedaq { -namespace appmodel { +namespace dunedaq::appmodel { void FakeHSIApplication::generate_modules(std::shared_ptr helper) const @@ -43,7 +42,6 @@ FakeHSIApplication::generate_modules(std::shared_ptrget_template_for(); @@ -86,7 +84,7 @@ FakeHSIApplication::generate_modules(std::shared_ptrget_sid(); - auto det_id = 1; // TODO Eric Flumerfelt , 08-Feb-2024: This is a magic number corresponding to kDAQ + auto det_id = 1; // This is a magic number corresponding to kDAQ std::string uid("DLH-" + std::to_string(id)); TLOG_DEBUG(7) << "creating OKS configuration object for Data Link Handler class " << dlhClass << ", id " << id; conffwk::ConfigObject dlhObj = obj_fac.create(dlhClass, uid); - dlhObj.set_by_val("source_id", id); - dlhObj.set_by_val("detector_id", det_id); + dlhObj.set_by_val("source_id", id); // NOLINT(build/unsigned) + dlhObj.set_by_val("detector_id", det_id); // NOLINT(build/unsigned) dlhObj.set_by_val("post_processing_enabled", false); dlhObj.set_obj("module_configuration", &dlhConf->config_object()); // Process special Network rules! // Looking for Fragment rules from DFAppplications in current Session std::vector fragOutObjs; - for (auto [uid, descriptor]: - helper->get_netdescriptors("Fragment", "DFApplication")) { + for (auto const& [uid, descriptor] : helper->get_netdescriptors("Fragment", "DFApplication")) { fragOutObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid)); - } + } // start building the list of outputs std::vector fh_output_objs; for (auto& fNet : fragOutObjs) { - fh_output_objs.push_back(&fNet); + fh_output_objs.push_back(&fNet); // NOLINT(performance-inefficient-vector-operation) } // Time Sync network connection @@ -144,10 +141,9 @@ FakeHSIApplication::generate_modules(std::shared_ptrget_associated_service()->config_object(); conffwk::ConfigObject hsiNetObj = obj_fac.create_net_obj(hsiNetDesc, ""); - + std::string genuid("FakeHSI-" + std::to_string(id)); - conffwk::ConfigObject fakehsiObj = - obj_fac.create("FakeHSIEventGeneratorModule", genuid); + conffwk::ConfigObject fakehsiObj = obj_fac.create("FakeHSIEventGeneratorModule", genuid); fakehsiObj.set_obj("configuration", &rdrConf->config_object()); fakehsiObj.set_objs("outputs", { &queueObj, &hsiNetObj }); if (tsNetDesc != nullptr) { @@ -158,7 +154,6 @@ FakeHSIApplication::generate_modules(std::shared_ptr(genuid)); obj_fac.update_modules(modules); -} - -} // namespace appmodel -} // namespace dunedaq +} // NOLINT(readability/fn_size) + +} // namespace dunedaq::appmodel diff --git a/src/FelixDetectorToDaqConnection.cpp b/src/FelixDetectorToDaqConnection.cpp index 07e4477..1ec1d10 100644 --- a/src/FelixDetectorToDaqConnection.cpp +++ b/src/FelixDetectorToDaqConnection.cpp @@ -14,25 +14,29 @@ #include "confmodel/DetDataReceiver.hpp" #include "confmodel/DetDataSender.hpp" +#include + namespace dunedaq::appmodel { -std::vector -FelixDetectorToDaqConnection::senders() const { +std::vector +FelixDetectorToDaqConnection::senders() const +{ std::vector senders; - if (m_felix_senders.empty()) { + if (m_felix_senders.empty()) { std::lock_guard scoped_lock(m_mutex); check_init(); } - for (auto sender: m_felix_senders) { - senders.push_back( - dynamic_cast(sender)); + for (auto sender : m_felix_senders) { + // NOLINTNEXTLINE(performance-inefficient-vector-operation, runtime/rtti) + senders.push_back(dynamic_cast(sender)); } return senders; } const confmodel::DetDataReceiver* -FelixDetectorToDaqConnection::receiver() const { - if (m_felix_senders.empty()) { +FelixDetectorToDaqConnection::receiver() const +{ + if (m_felix_senders.empty()) { std::lock_guard scoped_lock(m_mutex); check_init(); } diff --git a/src/HSIEventToTCApplication.cpp b/src/HSIEventToTCApplication.cpp index 3f2041f..e93eee8 100644 --- a/src/HSIEventToTCApplication.cpp +++ b/src/HSIEventToTCApplication.cpp @@ -8,35 +8,34 @@ * received with this code. */ - +#include "appmodel/HSIEventToTCApplication.hpp" #include "ConfigObjectFactory.hpp" -#include "conffwk/Configuration.hpp" -#include "oks/kernel.hpp" -#include "confmodel/Connection.hpp" -#include "confmodel/NetworkConnection.hpp" #include "appmodel/DataSubscriberModule.hpp" -#include "appmodel/HSIEventToTCApplication.hpp" #include "appmodel/HSI2TCTranslatorConf.hpp" -#include "appmodel/NetworkConnectionRule.hpp" #include "appmodel/NetworkConnectionDescriptor.hpp" +#include "appmodel/NetworkConnectionRule.hpp" #include "appmodel/QueueConnectionRule.hpp" #include "appmodel/QueueDescriptor.hpp" -#include "confmodel/Service.hpp" #include "appmodel/appmodelIssues.hpp" +#include "conffwk/Configuration.hpp" +#include "confmodel/Connection.hpp" +#include "confmodel/NetworkConnection.hpp" +#include "confmodel/Service.hpp" #include "logging/Logging.hpp" +#include "oks/kernel.hpp" +#include #include #include -namespace dunedaq { -namespace appmodel { +namespace dunedaq::appmodel { void HSIEventToTCApplication::generate_modules(std::shared_ptr /*helper*/) const { ConfigObjectFactory obj_fac(this); - + std::vector modules; std::string hstcUid("module-" + UID()); @@ -46,7 +45,7 @@ HSIEventToTCApplication::generate_modules(std::shared_ptrconfig_object()); - if (hstcConf == 0) { + if (hstcConf == nullptr) { throw(BadConf(ERS_HERE, "No HSI2TCTranslatorConf configuration given")); } @@ -59,11 +58,10 @@ HSIEventToTCApplication::generate_modules(std::shared_ptrget_data_type() == "HSIEvent") { inObj = obj_fac.create_net_obj(descriptor, ""); - } - else if (descriptor->get_data_type() == "TriggerCandidate") { + } else if (descriptor->get_data_type() == "TriggerCandidate") { outObj = obj_fac.create_net_obj(descriptor, UID()); } - } + } if (inObj == nullptr) { throw(BadConf(ERS_HERE, "No HSIEvent input connection descriptor given")); @@ -72,14 +70,13 @@ HSIEventToTCApplication::generate_modules(std::shared_ptr(hstcUid)); obj_fac.update_modules(modules); } - -} // namespace appmodel -} // namespace dunedaq + +} // namespace dunedaq::appmodel diff --git a/src/MLTApplication.cpp b/src/MLTApplication.cpp index fd1d29b..946f498 100644 --- a/src/MLTApplication.cpp +++ b/src/MLTApplication.cpp @@ -8,7 +8,6 @@ * received with this code. */ - #include "ConfigObjectFactory.hpp" #include "appmodel/ConfigurationHelper.hpp" @@ -17,13 +16,13 @@ #include "confmodel/Connection.hpp" #include "confmodel/NetworkConnection.hpp" +#include "appmodel/CIBApplication.hpp" +#include "appmodel/CTBApplication.hpp" #include "appmodel/DataHandlerConf.hpp" #include "appmodel/DataHandlerModule.hpp" #include "appmodel/DataReaderConf.hpp" #include "appmodel/DataRecorderConf.hpp" #include "appmodel/DataSubscriberModule.hpp" -#include "appmodel/CTBApplication.hpp" -#include "appmodel/CIBApplication.hpp" #include "appmodel/FakeDataApplication.hpp" #include "appmodel/FakeDataProdConf.hpp" #include "appmodel/MLTApplication.hpp" @@ -43,12 +42,11 @@ #include "logging/Logging.hpp" +#include #include #include -namespace dunedaq { -namespace appmodel { - +namespace dunedaq::appmodel { void MLTApplication::generate_modules(std::shared_ptr helper) const @@ -141,24 +139,19 @@ MLTApplication::generate_modules(std::shared_ptr } // Network connection for input TriggerInhibit, input TCs - conffwk::ConfigObject ti_net_obj = - obj_fac.create_net_obj(ti_net_desc, ""); + conffwk::ConfigObject ti_net_obj = obj_fac.create_net_obj(ti_net_desc, ""); - conffwk::ConfigObject tc_net_obj = - obj_fac.create_net_obj(tc_net_desc, ".*"); + conffwk::ConfigObject tc_net_obj = obj_fac.create_net_obj(tc_net_desc, ".*"); // Network connection for output TriggerDecision - conffwk::ConfigObject td_net_obj = - obj_fac.create_net_obj(td_net_desc, ""); + conffwk::ConfigObject td_net_obj = obj_fac.create_net_obj(td_net_desc, ""); // Network conection for the input Data Requests - conffwk::ConfigObject dr_net_obj = - obj_fac.create_net_obj(req_net_desc, UID()); + conffwk::ConfigObject dr_net_obj = obj_fac.create_net_obj(req_net_desc, UID()); conffwk::ConfigObject timesync_net_obj; if (timesync_net_desc != nullptr) { - timesync_net_obj = - obj_fac.create_net_obj(timesync_net_desc, ".*"); + timesync_net_obj = obj_fac.create_net_obj(timesync_net_desc, ".*"); } /************************************************************** @@ -169,8 +162,7 @@ MLTApplication::generate_modules(std::shared_ptr std::vector generated_tc_conns; generated_tc_conns.reserve(standalone_TC_maker_confs.size()); for (auto gen_conf : standalone_TC_maker_confs) { - conffwk::ConfigObject gen_obj = obj_fac.create(gen_conf->get_template_for(), - gen_conf->UID()); + conffwk::ConfigObject gen_obj = obj_fac.create(gen_conf->get_template_for(), gen_conf->UID()); gen_obj.set_obj("configuration", &(gen_conf->config_object())); if (gen_conf->get_timestamp_method() == "kTimeSync" && !timesync_net_obj.is_null()) { gen_obj.set_objs("inputs", { ×ync_net_obj }); @@ -206,52 +198,45 @@ MLTApplication::generate_modules(std::shared_ptr **************************************************************/ std::vector sourceIds; - for (auto [uid, source_ids]: helper->get_stream_source_ids()) { - for (auto src_id: source_ids) { + for (auto const& [uid, source_ids] : helper->get_stream_source_ids()) { + for (auto src_id : source_ids) { // Create SourceIDConf object for the MLT - std::string sourceIdConfUID = "dro-mlt-stream-config-" + - std::to_string(src_id); - conffwk::ConfigObject* sourceIdConf = new conffwk::ConfigObject( - obj_fac.create("SourceIDConf", sourceIdConfUID)); - sourceIdConf->set_by_val("sid", src_id); + std::string sourceIdConfUID = "dro-mlt-stream-config-" + std::to_string(src_id); + auto* sourceIdConf = new conffwk::ConfigObject(obj_fac.create("SourceIDConf", sourceIdConfUID)); + sourceIdConf->set_by_val("sid", src_id); // NOLINT(build/unsigned) // https://github.com/DUNE-DAQ/daqdataformats/blob/5b99506675a586c8a09123900e224f2371d96df9/include/daqdataformats/detail/SourceID.hxx#L108 sourceIdConf->set_by_val("subsystem", "Detector_Readout"); sourceIds.push_back(sourceIdConf); } } - for (auto [uid, source_ids]: helper->get_tp_source_ids()) { - for (auto src_id: source_ids) { + for (auto const& [uid, source_ids] : helper->get_tp_source_ids()) { + for (auto src_id : source_ids) { sourceIds.push_back(&(src_id->config_object())); } } // set the CTB sources - for (const auto & [uid, sources]: helper->get_all_app_source_ids("CTBApplication")) { - for (const auto & [source_name, source_conf] : sources ) { + for (const auto& [uid, sources] : helper->get_all_app_source_ids("CTBApplication")) { + for (const auto& [source_name, source_conf] : sources) { auto final_name = uid; - final_name += source_name.find("LLT")!=std::string::npos ? "_LLT" : "_HLT"; - auto tcSourceIdConf = new conffwk::ConfigObject( - obj_fac.create("SourceIDConf", final_name)); - tcSourceIdConf->set_by_val("sid", source_conf->get_sid()); + final_name += source_name.find("LLT") != std::string::npos ? "_LLT" : "_HLT"; + auto tcSourceIdConf = new conffwk::ConfigObject(obj_fac.create("SourceIDConf", final_name)); + tcSourceIdConf->set_by_val("sid", source_conf->get_sid()); // NOLINT(build/unsigned) tcSourceIdConf->set_by_val("subsystem", source_conf->get_subsystem()); sourceIds.push_back(tcSourceIdConf); } } - - for (auto app_class: {"TriggerApplication", "FakeHSIApplication", - "DTSHSIApplication", "CIBApplication"}) { - for (auto [uid, src_id]: helper->get_app_source_ids(app_class)) { - auto tcSourceIdConf = new conffwk::ConfigObject( - obj_fac.create("SourceIDConf", - uid + "-" + std::to_string(src_id->get_sid()) - )); - tcSourceIdConf->set_by_val("sid", src_id->get_sid()); + + for (auto app_class : { "TriggerApplication", "FakeHSIApplication", "DTSHSIApplication", "CIBApplication" }) { + for (auto const& [uid, src_id] : helper->get_app_source_ids(app_class)) { + auto tcSourceIdConf = + new conffwk::ConfigObject(obj_fac.create("SourceIDConf", uid + "-" + std::to_string(src_id->get_sid()))); + tcSourceIdConf->set_by_val("sid", src_id->get_sid()); // NOLINT(build/unsigned) tcSourceIdConf->set_by_val("subsystem", src_id->get_subsystem()); sourceIds.push_back(tcSourceIdConf); + } + } - } - } - // Get mandatory links std::vector mandatory_sids; const TCDataProcessor* tc_dp = tch_conf->get_data_processor()->cast(); @@ -260,7 +245,7 @@ MLTApplication::generate_modules(std::shared_ptr mandatory_sids.push_back(&m->config_object()); } } - + /************************************************************** * Create the TC handler **************************************************************/ @@ -295,14 +280,15 @@ MLTApplication::generate_modules(std::shared_ptr // } // loop over Session specific Apps std::vector fragOutObjs; - for (auto [uid, descriptor]: - helper->get_netdescriptors("Fragment", "DFApplication")) { + for (auto const& [uid, descriptor] : helper->get_netdescriptors("Fragment", "DFApplication")) { + // NOLINTNEXTLINE(performance-inefficient-vector-operation) fragOutObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid)); - } + } // build up the full list of outputs std::vector ti_output_objs; for (auto& fNet : fragOutObjs) { + // NOLINTNEXTLINE(performance-inefficient-vector-operation) ti_output_objs.push_back(&fNet); } ti_output_objs.push_back(&output_queue_obj); @@ -311,11 +297,11 @@ MLTApplication::generate_modules(std::shared_ptr if (get_source_id() == nullptr) { throw(BadConf(ERS_HERE, "No source_id associated with this TriggerApplication!")); } - uint32_t source_id = get_source_id()->get_sid(); + uint32_t source_id = get_source_id()->get_sid(); // NOLINT(build/unsigned) std::string ti_uid(handler_name + "-" + std::to_string(source_id)); conffwk::ConfigObject ti_obj = obj_fac.create(tch_class, ti_uid); - ti_obj.set_by_val("source_id", source_id); - ti_obj.set_by_val("detector_id", 1); // 1 == kDAQ + ti_obj.set_by_val("source_id", source_id); // NOLINT(build/unsigned) + ti_obj.set_by_val("detector_id", 1); // 1 == kDAQ // NOLINT(build/unsigned) ti_obj.set_obj("module_configuration", &tch_conf_obj); ti_obj.set_objs("enabled_source_ids", sourceIds); ti_obj.set_objs("mandatory_source_ids", mandatory_sids); @@ -329,15 +315,13 @@ MLTApplication::generate_modules(std::shared_ptr * Instantiate the MLTModule module **************************************************************/ - conffwk::ConfigObject mlt_obj = obj_fac.create(mlt_conf->get_template_for(), - mlt_conf->UID()); + conffwk::ConfigObject mlt_obj = obj_fac.create(mlt_conf->get_template_for(), mlt_conf->UID()); mlt_obj.set_obj("configuration", &(mlt_conf->config_object())); mlt_obj.set_objs("inputs", { &output_queue_obj, &ti_net_obj }); mlt_obj.set_objs("outputs", { &td_net_obj }); modules.push_back(obj_fac.get_dal(mlt_conf->UID())); obj_fac.update_modules(modules); -} - -} // namespace appmodel -} // namespace dunedaq +} // NOLINT(readability/fn_size) + +} // namespace dunedaq::appmodel diff --git a/src/NP02ReadoutApplication.cpp b/src/NP02ReadoutApplication.cpp index bb33a38..0361ee2 100644 --- a/src/NP02ReadoutApplication.cpp +++ b/src/NP02ReadoutApplication.cpp @@ -8,18 +8,18 @@ * received with this code. */ -#include "ConfigObjectFactory.hpp" #include "appmodel/NP02ReadoutApplication.hpp" +#include "ConfigObjectFactory.hpp" #include "conffwk/Configuration.hpp" #include "confmodel/DetDataReceiver.hpp" -#include "confmodel/NetworkDevice.hpp" #include "confmodel/DetDataSender.hpp" #include "confmodel/DetectorStream.hpp" +#include "confmodel/NetworkDevice.hpp" #include "confmodel/Session.hpp" +#include "appmodel/DPDKReceiver.hpp" #include "appmodel/NWDetDataReceiver.hpp" #include "appmodel/NWDetDataSender.hpp" -#include "appmodel/DPDKReceiver.hpp" #include "appmodel/FelixDataReceiver.hpp" #include "appmodel/FelixDataSender.hpp" @@ -29,44 +29,46 @@ #include "confmodel/Connection.hpp" #include "confmodel/DetectorToDaqConnection.hpp" +#include "confmodel/ExcludableEntitySet.hpp" #include "confmodel/GeoId.hpp" #include "confmodel/NetworkConnection.hpp" -#include "confmodel/ExcludableEntitySet.hpp" #include "confmodel/Service.hpp" -#include "appmodel/SourceIDConf.hpp" #include "appmodel/DataMoveCallbackConf.hpp" -#include "appmodel/DataReaderModule.hpp" #include "appmodel/DataReaderConf.hpp" -#include "appmodel/DataRecorderModule.hpp" +#include "appmodel/DataReaderModule.hpp" #include "appmodel/DataRecorderConf.hpp" +#include "appmodel/DataRecorderModule.hpp" +#include "appmodel/SourceIDConf.hpp" -#include "appmodel/DataHandlerModule.hpp" #include "appmodel/DataHandlerConf.hpp" -#include "appmodel/FragmentAggregatorModule.hpp" +#include "appmodel/DataHandlerModule.hpp" +#include "appmodel/DataProcessor.hpp" #include "appmodel/FragmentAggregatorConf.hpp" +#include "appmodel/FragmentAggregatorModule.hpp" +#include "appmodel/LatencyBuffer.hpp" #include "appmodel/NetworkConnectionDescriptor.hpp" #include "appmodel/NetworkConnectionRule.hpp" #include "appmodel/QueueConnectionRule.hpp" #include "appmodel/QueueDescriptor.hpp" #include "appmodel/RequestHandler.hpp" -#include "appmodel/LatencyBuffer.hpp" -#include "appmodel/DataProcessor.hpp" - #include "appmodel/appmodelIssues.hpp" #include "logging/Logging.hpp" #include +#include +#include +#include #include +#include #include // using namespace dunedaq; // using namespace dunedaq::appmodel; -namespace dunedaq { -namespace appmodel { +namespace dunedaq::appmodel { //----------------------------------------------------------------------------- void @@ -83,7 +85,7 @@ NP02ReadoutApplication::generate_modules(std::shared_ptrget_template_for(); @@ -94,7 +96,7 @@ NP02ReadoutApplication::generate_modules(std::shared_ptrget_template_for(); auto tph_conf = get_tp_handler(); - if (tph_conf==nullptr && get_tp_generation_enabled()) { + if (tph_conf == nullptr && get_tp_generation_enabled()) { throw(BadConf(ERS_HERE, "TP generation is enabled but there is no TP data handler configuration")); } @@ -118,7 +120,8 @@ NP02ReadoutApplication::generate_modules(std::shared_ptrget_descriptor(); - } else if ((data_type == "TriggerPrimitive" || data_type == "TriggerPrimitiveVector") && get_tp_generation_enabled()) { + } else if ((data_type == "TriggerPrimitive" || data_type == "TriggerPrimitiveVector") && + get_tp_generation_enabled()) { tp_input_qdesc = rule->get_descriptor(); } } else if (destination_class == "FragmentAggregatorModule") { @@ -176,15 +179,14 @@ NP02ReadoutApplication::generate_modules(std::shared_ptr> all_enabled_det_streams; - std::map callback_confs_by_sid; + std::map callback_confs_by_sid; // NOLINT(build/unsigned) std::vector d2d_conn_objs; - uint16_t conn_idx = 0; - + uint16_t conn_idx = 0; // NOLINT(build/unsigned) std::set numas; for (auto d2d_conn : get_detector_connections()) { - uint16_t receiver_numa = 0; + uint16_t receiver_numa = 0; // NOLINT(build/unsigned) // Are we sure? if (helper->is_excluded(d2d_conn)) { @@ -209,21 +211,33 @@ NP02ReadoutApplication::generate_modules(std::shared_ptrreceiver(); // Here I want to resolve the type of connection (network, felix, or?) - // Rules of engagement: if the receiver interface is network or felix, the receivers should be castable to the counterpart + // Rules of engagement: if the receiver interface is network or felix, the receivers should be castable to the + // counterpart bool requires_dpdk = (reader_class == "DPDKReaderModule" || reader_class == "FDFakeReaderModule"); - if (reader_class == "DPDKReaderModule" || reader_class == "SocketReaderModule" || reader_class == "FDFakeReaderModule") { - if ((requires_dpdk && !det_receiver->cast()) || // SSB: Note here, we are intrinsically locking FakeCard readout to only emulate DPDK data reception. Given NP02ReadoutApplication is intended for TDE readout at NP02, assuming this is OK. + if (reader_class == "DPDKReaderModule" || reader_class == "SocketReaderModule" || + reader_class == "FDFakeReaderModule") { + if ((requires_dpdk && + !det_receiver + ->cast()) || // SSB: Note here, we are intrinsically locking FakeCard readout to + // only emulate DPDK data reception. Given NP02ReadoutApplication is + // intended for TDE readout at NP02, assuming this is OK. (reader_class == "SocketReaderModule" && !det_receiver->cast())) { std::string required_class = requires_dpdk ? "DPDKReceiver" : "SocketReceiver"; - throw(BadConf(ERS_HERE, fmt::format("{} requires {}, found {} of class {}", reader_class, required_class, det_receiver->UID(), det_receiver->class_name()))); + throw(BadConf(ERS_HERE, + fmt::format("{} requires {}, found {} of class {}", + reader_class, + required_class, + det_receiver->UID(), + det_receiver->class_name()))); } - // SSB: Note that here you need to include FDFakeCardReader as well, because emulated readout needs some way to map NUMA to streams - // Since we require a receiver in the NetworkDetector2DAQConnections this would still work if the receiver type is a DPDKReceiver + // SSB: Note that here you need to include FDFakeCardReader as well, because emulated readout needs some way to + // map NUMA to streams Since we require a receiver in the NetworkDetector2DAQConnections this would still work if + // the receiver type is a DPDKReceiver if (reader_class == "DPDKReaderModule" || reader_class == "FDFakeReaderModule") { auto dpdk_reciever = det_receiver->cast(); - receiver_numa = (int16_t)dpdk_reciever->get_uses()->get_numa_id(); + receiver_numa = static_cast(dpdk_reciever->get_uses()->get_numa_id()); TLOG_DEBUG(7) << "receiver numa: " << receiver_numa; } @@ -249,11 +263,10 @@ NP02ReadoutApplication::generate_modules(std::shared_ptr(receiver_numa)); } - } //----------------------------------------------------------------- @@ -265,39 +278,38 @@ NP02ReadoutApplication::generate_modules(std::shared_ptrUID(), std::to_string(conn_idx++))); - TLOG_DEBUG(6) << fmt::format("creating OKS configuration object for Data reader class {} with id {}", reader_class, reader_uid); - auto reader_obj = obj_fac.create(reader_class, reader_uid); - - // Populate configuration and interfaces (leave output queues for later) - reader_obj.set_obj("configuration", &reader_conf->config_object()); - reader_obj.set_objs("connections", d2d_conn_objs); + // Create the Data reader object - // Create the raw data callbacks - std::vector raw_data_callback_objs; - - // Create data queues - for (auto& [numa, ds] : all_enabled_det_streams) { - conffwk::ConfigObject callback_obj = obj_fac.create_callback_sid_obj(raw_data_callback_desc, ds->get_source_id()); - const auto* callback_conf = obj_fac.get_dal(callback_obj.UID()); - raw_data_callback_objs.push_back(&callback_conf->config_object()); - callback_confs_by_sid[ds->get_source_id()] = callback_conf; - } + std::string reader_uid(fmt::format("datareader-{}-{}", this->UID(), std::to_string(conn_idx))); + conn_idx++; + TLOG_DEBUG(6) << fmt::format( + "creating OKS configuration object for Data reader class {} with id {}", reader_class, reader_uid); + auto reader_obj = obj_fac.create(reader_class, reader_uid); - reader_obj.set_objs("raw_data_callbacks", raw_data_callback_objs); + // Populate configuration and interfaces (leave output queues for later) + reader_obj.set_obj("configuration", &reader_conf->config_object()); + reader_obj.set_objs("connections", d2d_conn_objs); - modules.push_back(obj_fac.get_dal(reader_obj.UID())); + // Create the raw data callbacks + std::vector raw_data_callback_objs; + // Create data queues + for (auto& [numa, ds] : all_enabled_det_streams) { + conffwk::ConfigObject callback_obj = obj_fac.create_callback_sid_obj(raw_data_callback_desc, ds->get_source_id()); + const auto* callback_conf = obj_fac.get_dal(callback_obj.UID()); + raw_data_callback_objs.push_back(&callback_conf->config_object()); + callback_confs_by_sid[ds->get_source_id()] = callback_conf; + } + reader_obj.set_objs("raw_data_callbacks", raw_data_callback_objs); + modules.push_back(obj_fac.get_dal(reader_obj.UID())); //----------------------------------------------------------------- // // Prepare the tp handlers and related queues // - std::vector> tp_queues; + std::vector> tp_queues; // NOLINT(build/unsigned) if (get_tp_generation_enabled()) { @@ -306,7 +318,9 @@ NP02ReadoutApplication::generate_modules(std::shared_ptr 0) { - throw(BadConf(ERS_HERE, fmt::format("number of TP source IDs must be a multiple of 3, current amount: {}", tpsrc_ids.size()))); + throw( + BadConf(ERS_HERE, + fmt::format("number of TP source IDs must be a multiple of 3, current amount: {}", tpsrc_ids.size()))); } for (auto sid : tpsrc_ids) { @@ -314,17 +328,17 @@ NP02ReadoutApplication::generate_modules(std::shared_ptrget_sid())); auto tph_obj = obj_fac.create(tph_class, tp_uid); - tph_obj.set_by_val("source_id", sid->get_sid()); - tph_obj.set_by_val("detector_id", 1); // 1 == kDAQ + tph_obj.set_by_val("source_id", sid->get_sid()); // NOLINT(build/unsigned) + tph_obj.set_by_val("detector_id", 1); // 1 == kDAQ // NOLINT(build/unsigned) tph_obj.set_by_val("post_processing_enabled", get_ta_generation_enabled()); tph_obj.set_obj("module_configuration", &tph_conf_obj); // Create the TPs aggregator queue (from RawData Handlers to TP handlers) tp_queue_obj = obj_fac.create_queue_sid_obj(tp_input_qdesc, sid->get_sid()); - tp_queue_obj.set_by_val("recv_timeout_ms", 50); - tp_queue_obj.set_by_val("send_timeout_ms", 1); + tp_queue_obj.set_by_val("recv_timeout_ms", 50); // NOLINT(build/unsigned) + tp_queue_obj.set_by_val("send_timeout_ms", 1); // NOLINT(build/unsigned) - tp_queues.push_back(std::make_pair(sid->get_sid(), obj_fac.get_dal(tp_queue_obj.UID()))); + tp_queues.emplace_back(sid->get_sid(), obj_fac.get_dal(tp_queue_obj.UID())); // Create tp data requests queue from Fragment Aggregator tpreq_queue_obj = obj_fac.create_queue_sid_obj(dlh_reqinput_qdesc, sid->get_sid()); req_queues.push_back(obj_fac.get_dal(tpreq_queue_obj.UID())); @@ -343,9 +357,10 @@ NP02ReadoutApplication::generate_modules(std::shared_ptr> tp_queue_objs; + std::vector> tp_queue_objs; // NOLINT(build/unsigned) for (auto q : tp_queues) { - tp_queue_objs.push_back(std::make_pair(q.first, &q.second->config_object())); + // NOLINTNEXTLINE(performance-inefficient-vector-operation) + tp_queue_objs.emplace_back(q.first, &q.second->config_object()); } //----------------------------------------------------------------- @@ -357,57 +372,57 @@ NP02ReadoutApplication::generate_modules(std::shared_ptrget_latency_buffer(); std::map numa_dhlconf_map; - for ( int16_t numa : numas ) { - auto lb_confobj_numa = obj_fac.create(lb_conf->class_name(), fmt::format("{}-numa{}",lb_conf->UID(), numa)); - lb_confobj_numa.set_by_val("size", lb_conf->get_size()); + for (int16_t numa : numas) { + auto lb_confobj_numa = obj_fac.create(lb_conf->class_name(), fmt::format("{}-numa{}", lb_conf->UID(), numa)); + lb_confobj_numa.set_by_val("size", lb_conf->get_size()); // NOLINT(build/unsigned) lb_confobj_numa.set_by_val("numa_aware", lb_conf->get_numa_aware()); lb_confobj_numa.set_by_val("numa_node", numa); lb_confobj_numa.set_by_val("intrinsic_allocator", lb_conf->get_intrinsic_allocator()); - lb_confobj_numa.set_by_val("alignment_size", lb_conf->get_alignment_size()); + lb_confobj_numa.set_by_val("alignment_size", lb_conf->get_alignment_size()); // NOLINT(build/unsigned) lb_confobj_numa.set_by_val("preallocation", lb_conf->get_preallocation()); - auto dhl_confobj_numa = obj_fac.create(dlh_conf->class_name(), fmt::format("{}-numa{}",dlh_conf->UID(), numa)); + auto dhl_confobj_numa = obj_fac.create(dlh_conf->class_name(), fmt::format("{}-numa{}", dlh_conf->UID(), numa)); dhl_confobj_numa.set_by_val("template_for", dlh_conf->get_template_for()); dhl_confobj_numa.set_by_val("input_data_type", dlh_conf->get_input_data_type()); dhl_confobj_numa.set_by_val("generate_timesync", dlh_conf->get_generate_timesync()); + // NOLINTNEXTLINE(build/unsigned) dhl_confobj_numa.set_by_val("post_processing_delay_ticks", dlh_conf->get_post_processing_delay_ticks()); dhl_confobj_numa.set_by_val("input_data_type", dlh_conf->get_input_data_type()); dhl_confobj_numa.set_obj("request_handler", &dlh_conf->get_request_handler()->config_object()); dhl_confobj_numa.set_obj("latency_buffer", &lb_confobj_numa); dhl_confobj_numa.set_obj("data_processor", &dlh_conf->get_data_processor()->config_object()); - numa_dhlconf_map[numa] = dhl_confobj_numa; - } auto emulation_mode = reader_conf->get_emulation_mode(); for (auto& [numa, ds] : all_enabled_det_streams) { - uint32_t sid = ds->get_source_id(); - TLOG_DEBUG(6) << fmt::format("Processing stream {}, id {}, det id {}", ds->UID(), ds->get_source_id(), ds->get_geo_id()->get_detector_id()); + uint32_t sid = ds->get_source_id(); // NOLINT(build/unsigned) + TLOG_DEBUG(6) << fmt::format( + "Processing stream {}, id {}, det id {}", ds->UID(), ds->get_source_id(), ds->get_geo_id()->get_detector_id()); std::string uid(fmt::format("DLH-{}", sid)); - TLOG_DEBUG(6) << fmt::format("creating OKS configuration object for Data Link Handler class {}, if {}", dlh_class, sid); + TLOG_DEBUG(6) << fmt::format( + "creating OKS configuration object for Data Link Handler class {}, if {}", dlh_class, sid); auto dlh_obj = obj_fac.create(dlh_class, uid); - dlh_obj.set_by_val("source_id", sid); - dlh_obj.set_by_val("detector_id", ds->get_geo_id()->get_detector_id()); + dlh_obj.set_by_val("source_id", sid); // NOLINT(build/unsigned) + dlh_obj.set_by_val("detector_id", ds->get_geo_id()->get_detector_id()); // NOLINT(build/unsigned) dlh_obj.set_by_val("post_processing_enabled", get_tp_generation_enabled()); dlh_obj.set_by_val("emulation_mode", emulation_mode); dlh_obj.set_obj("geo_id", &ds->get_geo_id()->config_object()); dlh_obj.set_obj("module_configuration", &numa_dhlconf_map[numa]); dlh_obj.set_obj("raw_data_callback", &callback_confs_by_sid[sid]->config_object()); - std::vector dlh_ins, dlh_outs; + std::vector dlh_ins; + std::vector dlh_outs; // Create request queue conffwk::ConfigObject req_queue_obj = obj_fac.create_queue_sid_obj(dlh_reqinput_qdesc, ds); - // Add the requessts queue dal pointer to the outputs of the FragmentAggregatorModule req_queues.push_back(obj_fac.get_dal(req_queue_obj.UID())); dlh_ins.push_back(&req_queue_obj); dlh_outs.push_back(&frag_queue_obj); - // Time Sync network connection if (dlh_conf->get_generate_timesync()) { // Add timestamp endpoint @@ -417,7 +432,7 @@ NP02ReadoutApplication::generate_modules(std::shared_ptr(dlh_obj.UID())); } - // Finally create Fragment Aggregator auto aggregator_conf = get_fragment_aggregator(); - if (aggregator_conf == 0) { + if (aggregator_conf == nullptr) { throw(BadConf(ERS_HERE, "No FragmentAggregatorModule configuration given")); } std::string faUid("fragmentaggregator-" + UID()); @@ -442,8 +456,7 @@ NP02ReadoutApplication::generate_modules(std::shared_ptr fragOutObjs; - for (auto [uid, descriptor]: - helper->get_netdescriptors("Fragment", "DFApplication")) { + for (auto const& [uid, descriptor] : helper->get_netdescriptors("Fragment", "DFApplication")) { std::string dreqNetUid(descriptor->get_uid_base() + uid); auto frag_conn = obj_fac.create("NetworkConnection", dreqNetUid); @@ -455,12 +468,12 @@ NP02ReadoutApplication::generate_modules(std::shared_ptrget_associated_service()->config_object(); frag_conn.set_obj("associated_service", &serviceObj); fragOutObjs.push_back(frag_conn); - } + } // Add output queueus of data requests and Fragments std::vector fa_output_objs; for (auto& fNet : fragOutObjs) { - fa_output_objs.push_back(&fNet); + fa_output_objs.push_back(&fNet); // NOLINT(performance-inefficient-vector-operation) } for (auto& q : req_queues) { @@ -476,6 +489,4 @@ NP02ReadoutApplication::generate_modules(std::shared_ptr + namespace dunedaq::appmodel { -std::vector -NetworkDetectorToDaqConnection::senders() const { +std::vector +NetworkDetectorToDaqConnection::senders() const +{ std::vector senders; - if (m_net_senders.empty()) { + if (m_net_senders.empty()) { std::lock_guard scoped_lock(m_mutex); check_init(); } - for (auto sender: m_net_senders) { - senders.push_back( - dynamic_cast(sender)); + for (auto sender : m_net_senders) { + senders.push_back(dynamic_cast(sender)); // NOLINT } TLOG_DEBUG(6) << "Found " << senders.size() << " senders\n"; return senders; } const confmodel::DetDataReceiver* -NetworkDetectorToDaqConnection::receiver() const { - if (m_net_senders.empty()) { +NetworkDetectorToDaqConnection::receiver() const +{ + if (m_net_senders.empty()) { std::lock_guard scoped_lock(m_mutex); check_init(); } diff --git a/src/ReadoutApplication.cpp b/src/ReadoutApplication.cpp index a7d1a84..3e283c4 100644 --- a/src/ReadoutApplication.cpp +++ b/src/ReadoutApplication.cpp @@ -8,11 +8,9 @@ * received with this code. */ - - -#include "appmodel/ConfigurationHelper.hpp" -#include "ConfigObjectFactory.hpp" #include "appmodel/ReadoutApplication.hpp" +#include "ConfigObjectFactory.hpp" +#include "appmodel/ConfigurationHelper.hpp" #include "conffwk/Configuration.hpp" #include "confmodel/DetDataReceiver.hpp" #include "confmodel/DetDataSender.hpp" @@ -20,9 +18,9 @@ #include "confmodel/DetectorToDaqConnection.hpp" #include "confmodel/Session.hpp" +#include "appmodel/DPDKReceiver.hpp" #include "appmodel/NWDetDataReceiver.hpp" #include "appmodel/NWDetDataSender.hpp" -#include "appmodel/DPDKReceiver.hpp" #include "appmodel/FelixDataReceiver.hpp" #include "appmodel/FelixDataSender.hpp" @@ -31,53 +29,54 @@ #include "confmodel/QueueWithSourceId.hpp" #include "confmodel/Connection.hpp" +#include "confmodel/ExcludableEntitySet.hpp" #include "confmodel/GeoId.hpp" #include "confmodel/NetworkConnection.hpp" -#include "confmodel/ExcludableEntitySet.hpp" #include "confmodel/Service.hpp" -#include "appmodel/SourceIDConf.hpp" #include "appmodel/DataMoveCallbackConf.hpp" -#include "appmodel/DataReaderModule.hpp" #include "appmodel/DataReaderConf.hpp" -#include "appmodel/DataRecorderModule.hpp" +#include "appmodel/DataReaderModule.hpp" #include "appmodel/DataRecorderConf.hpp" +#include "appmodel/DataRecorderModule.hpp" +#include "appmodel/SourceIDConf.hpp" -#include "appmodel/DataHandlerModule.hpp" #include "appmodel/DataHandlerConf.hpp" -#include "appmodel/FragmentAggregatorModule.hpp" +#include "appmodel/DataHandlerModule.hpp" #include "appmodel/FragmentAggregatorConf.hpp" +#include "appmodel/FragmentAggregatorModule.hpp" #include "appmodel/NetworkConnectionDescriptor.hpp" #include "appmodel/NetworkConnectionRule.hpp" #include "appmodel/QueueConnectionRule.hpp" #include "appmodel/QueueDescriptor.hpp" #include "appmodel/RequestHandler.hpp" - - #include "appmodel/appmodelIssues.hpp" #include "logging/Logging.hpp" #include +#include +#include #include #include // using namespace dunedaq; // using namespace dunedaq::appmodel; -namespace dunedaq { -namespace appmodel { +namespace dunedaq::appmodel { //----------------------------------------------------------------------------- std::vector -ReadoutApplication::contained_excludable_entities() const { +ReadoutApplication::contained_excludable_entities() const +{ return to_resources(get_detector_connections()); } void -ReadoutApplication::generate_modules(std::shared_ptr helper) const { +ReadoutApplication::generate_modules(std::shared_ptr helper) const +{ TLOG_DEBUG(6) << "Generating modules for application " << this->UID(); @@ -90,7 +89,7 @@ ReadoutApplication::generate_modules(std::shared_ptr helper // Data reader auto reader_conf = get_data_reader(); - if (reader_conf == 0) { + if (reader_conf == nullptr) { throw(BadConf(ERS_HERE, "No DataReaderModule configuration given")); } std::string reader_class = reader_conf->get_template_for(); @@ -101,7 +100,7 @@ ReadoutApplication::generate_modules(std::shared_ptr helper auto dlh_class = dlh_conf->get_template_for(); auto tph_conf = get_tp_handler(); - if (tph_conf==nullptr && get_tp_generation_enabled()) { + if (tph_conf == nullptr && get_tp_generation_enabled()) { throw(BadConf(ERS_HERE, "TP generation is enabled but there is no TP data handler configuration")); } @@ -121,11 +120,13 @@ ReadoutApplication::generate_modules(std::shared_ptr helper for (auto rule : get_queue_rules()) { auto destination_class = rule->get_destination_class(); auto data_type = rule->get_descriptor()->get_data_type(); - // Why datahander here? It is the base class for several DataHandler types (e.g. FDDataHandlerModule, SNBDataHandlerModule) + // Why datahander here? It is the base class for several DataHandler types (e.g. FDDataHandlerModule, + // SNBDataHandlerModule) if (destination_class == "DataHandlerModule" || destination_class == dlh_class || destination_class == tph_class) { if (data_type == "DataRequest") { dlh_reqinput_qdesc = rule->get_descriptor(); - } else if ((data_type == "TriggerPrimitive" || data_type == "TriggerPrimitiveVector") && get_tp_generation_enabled()) { + } else if ((data_type == "TriggerPrimitive" || data_type == "TriggerPrimitiveVector") && + get_tp_generation_enabled()) { tp_input_qdesc = rule->get_descriptor(); } } else if (destination_class == "FragmentAggregatorModule") { @@ -194,10 +195,10 @@ ReadoutApplication::generate_modules(std::shared_ptr helper // Collect all streams std::vector all_enabled_det_streams; - std::map callback_confs_by_sid; + std::map callback_confs_by_sid; // NOLINT(build/unsigned) // std::vector d2d_conn_objs; - uint16_t conn_idx = 0; + uint16_t conn_idx = 0; // NOLINT(build/unsigned) for (auto d2d_conn : get_detector_connections()) { if (helper->is_excluded(d2d_conn)) { @@ -234,53 +235,76 @@ ReadoutApplication::generate_modules(std::shared_ptr helper enabled_det_streams.push_back(stream); } - // Here I want to resolve the type of connection (network, felix, or?) - // Rules of engagement: if the receiver interface is network or felix, the receivers should be castable to the counterpart + // Rules of engagement: if the receiver interface is network or felix, the receivers should be castable to the + // counterpart if (reader_class == "DPDKReaderModule") { if (!d2d_conn->castable("NetworkDetectorToDaqConnection")) { - throw(BadConf(ERS_HERE, fmt::format("{} requires NetworkDetectorToDaqConnection, found {} of class {}", reader_class, d2d_conn->UID(), d2d_conn->class_name()))); + throw(BadConf(ERS_HERE, + fmt::format("{} requires NetworkDetectorToDaqConnection, found {} of class {}", + reader_class, + d2d_conn->UID(), + d2d_conn->class_name()))); } if (!det_receiver->cast()) { - throw(BadConf(ERS_HERE, fmt::format("{} requires NWDetDataReceiver, found {} of class {}", reader_class, det_receiver->UID(), det_receiver->class_name()))); + throw(BadConf(ERS_HERE, + fmt::format("{} requires NWDetDataReceiver, found {} of class {}", + reader_class, + det_receiver->UID(), + det_receiver->class_name()))); } - } - else if (reader_class == "SocketReaderModule") { + } else if (reader_class == "SocketReaderModule") { if (!d2d_conn->castable("SocketDetectorToDaqConnection")) { - throw(BadConf(ERS_HERE, fmt::format("{} requires SocketDetectorToDaqConnection, found {} of class {}", reader_class, d2d_conn->UID(), d2d_conn->class_name()))); - } + throw(BadConf(ERS_HERE, + fmt::format("{} requires SocketDetectorToDaqConnection, found {} of class {}", + reader_class, + d2d_conn->UID(), + d2d_conn->class_name()))); + } if (!det_receiver->cast()) { - throw(BadConf(ERS_HERE, fmt::format("{} requires SocketReceiver, found {} of class {}", reader_class, det_receiver->UID(), det_receiver->class_name()))); + throw(BadConf(ERS_HERE, + fmt::format("{} requires SocketReceiver, found {} of class {}", + reader_class, + det_receiver->UID(), + det_receiver->class_name()))); } - } - else if (reader_class == "FelixReaderModule") { + } else if (reader_class == "FelixReaderModule") { if (!d2d_conn->castable("FelixDetectorToDaqConnection")) { - throw(BadConf(ERS_HERE, fmt::format("{} requires FelixDetectorToDaqConnection, found {} of class {}", reader_class, d2d_conn->UID(), d2d_conn->class_name()))); + throw(BadConf(ERS_HERE, + fmt::format("{} requires FelixDetectorToDaqConnection, found {} of class {}", + reader_class, + d2d_conn->UID(), + d2d_conn->class_name()))); } if (!det_receiver->cast()) { - throw(BadConf(ERS_HERE, fmt::format("FelixReaderModule requires FelixDataReceiver, found {} of class {}", det_receiver->UID(), det_receiver->class_name()))); + throw(BadConf(ERS_HERE, + fmt::format("FelixReaderModule requires FelixDataReceiver, found {} of class {}", + det_receiver->UID(), + det_receiver->class_name()))); } } - // } + // } - //----------------------------------------------------------------- - // - // Create DataReaderModule object - // + //----------------------------------------------------------------- + // + // Create DataReaderModule object + // - // - // Instantiate DataReaderModule of type DPDKReaderModule - // + // + // Instantiate DataReaderModule of type DPDKReaderModule + // - // Create the Data reader object + // Create the Data reader object - std::string reader_uid(fmt::format("datareader-{}-{}", this->UID(), std::to_string(conn_idx++))); - TLOG_DEBUG(6) << fmt::format("creating OKS configuration object for Data reader class {} with id {}", reader_class, reader_uid); + std::string reader_uid(fmt::format("datareader-{}-{}", this->UID(), std::to_string(conn_idx))); + conn_idx++; + TLOG_DEBUG(6) << fmt::format( + "creating OKS configuration object for Data reader class {} with id {}", reader_class, reader_uid); auto reader_obj = obj_fac.create(reader_class, reader_uid); // Populate configuration and interfaces (leave output queues for later) reader_obj.set_obj("configuration", &reader_conf->config_object()); - reader_obj.set_objs("connections", {&d2d_conn->config_object()}); + reader_obj.set_objs("connections", { &d2d_conn->config_object() }); // Create the raw data callbacks std::vector raw_data_callback_objs; @@ -298,7 +322,6 @@ ReadoutApplication::generate_modules(std::shared_ptr helper modules.push_back(obj_fac.get_dal(reader_obj.UID())); } - //----------------------------------------------------------------- // // Prepare the tp handlers and related queues @@ -306,10 +329,10 @@ ReadoutApplication::generate_modules(std::shared_ptr helper std::vector tp_queues; if (get_tp_generation_enabled()) { if (tp_input_qdesc == nullptr) { - throw(BadConf(ERS_HERE, "TP generation is enabled but no TP input queue descriptor given")); + throw(BadConf(ERS_HERE, "TP generation is enabled but no TP input queue descriptor given")); } if (tp_net_desc == nullptr) { - throw(BadConf(ERS_HERE, "TP generation is enabled but no TPSet network descriptor given")); + throw(BadConf(ERS_HERE, "TP generation is enabled but no TPSet network descriptor given")); } if (ta_net_desc == nullptr) { throw(BadConf(ERS_HERE, "TP generation is enabled but no TriggerActivity network descriptor given")); @@ -323,15 +346,15 @@ ReadoutApplication::generate_modules(std::shared_ptr helper conffwk::ConfigObject tpreq_queue_obj; std::string tp_uid("tphandler-" + std::to_string(sid->get_sid())); auto tph_obj = obj_fac.create(tph_class, tp_uid); - tph_obj.set_by_val("source_id", sid->get_sid()); - tph_obj.set_by_val("detector_id", 1); // 1 == kDAQ + tph_obj.set_by_val("source_id", sid->get_sid()); // NOLINT(build/unsigned) + tph_obj.set_by_val("detector_id", 1); // 1 == kDAQ // NOLINT(build/unsigned) tph_obj.set_by_val("post_processing_enabled", get_ta_generation_enabled()); tph_obj.set_obj("module_configuration", &tph_conf_obj); // Create the TPs aggregator queue (from RawData Handlers to TP handlers) tp_queue_obj = obj_fac.create_queue_sid_obj(tp_input_qdesc, sid->get_sid()); - tp_queue_obj.set_by_val("recv_timeout_ms", 50); - tp_queue_obj.set_by_val("send_timeout_ms", 1); + tp_queue_obj.set_by_val("recv_timeout_ms", 50); // NOLINT(build/unsigned) + tp_queue_obj.set_by_val("send_timeout_ms", 1); // NOLINT(build/unsigned) tp_queues.push_back(obj_fac.get_dal(tp_queue_obj.UID())); // Create tp data requests queue from Fragment Aggregator @@ -352,9 +375,10 @@ ReadoutApplication::generate_modules(std::shared_ptr helper } } - // Add output queueus of tps + // Add output queueus of tps std::vector tp_queue_objs; for (auto q : tp_queues) { + // NOLINTNEXTLINE(performance-inefficient-vector-operation) tp_queue_objs.push_back(&q->config_object()); } @@ -366,31 +390,32 @@ ReadoutApplication::generate_modules(std::shared_ptr helper auto emulation_mode = reader_conf->get_emulation_mode(); for (auto ds : all_enabled_det_streams) { - uint32_t sid = ds->get_source_id(); - TLOG_DEBUG(6) << fmt::format("Processing stream {}, id {}, det id {}", ds->UID(), ds->get_source_id(), ds->get_geo_id()->get_detector_id()); + uint32_t sid = ds->get_source_id(); // NOLINT(build/unsigned) + TLOG_DEBUG(6) << fmt::format( + "Processing stream {}, id {}, det id {}", ds->UID(), ds->get_source_id(), ds->get_geo_id()->get_detector_id()); std::string uid(fmt::format("DLH-{}", sid)); - TLOG_DEBUG(6) << fmt::format("creating OKS configuration object for Data Link Handler class {}, if {}", dlh_class, sid); + TLOG_DEBUG(6) << fmt::format( + "creating OKS configuration object for Data Link Handler class {}, if {}", dlh_class, sid); auto dlh_obj = obj_fac.create(dlh_class, uid); - dlh_obj.set_by_val("source_id", sid); - dlh_obj.set_by_val("detector_id", ds->get_geo_id()->get_detector_id()); + dlh_obj.set_by_val("source_id", sid); // NOLINT(build/unsigned) + dlh_obj.set_by_val("detector_id", ds->get_geo_id()->get_detector_id()); // NOLINT(build/unsigned) dlh_obj.set_by_val("post_processing_enabled", get_tp_generation_enabled()); dlh_obj.set_by_val("emulation_mode", emulation_mode); dlh_obj.set_obj("geo_id", &ds->get_geo_id()->config_object()); dlh_obj.set_obj("module_configuration", &dlh_conf->config_object()); dlh_obj.set_obj("raw_data_callback", &callback_confs_by_sid[sid]->config_object()); - std::vector dlh_ins, dlh_outs; + std::vector dlh_ins; + std::vector dlh_outs; // Create request queue conffwk::ConfigObject req_queue_obj = obj_fac.create_queue_sid_obj(dlh_reqinput_qdesc, ds); - // Add the requessts queue dal pointer to the outputs of the FragmentAggregatorModule req_queues.push_back(obj_fac.get_dal(req_queue_obj.UID())); dlh_ins.push_back(&req_queue_obj); dlh_outs.push_back(&frag_queue_obj); - // Time Sync network connection if (dlh_conf->get_generate_timesync()) { // Add timestamp endpoint @@ -409,7 +434,7 @@ ReadoutApplication::generate_modules(std::shared_ptr helper // Finally create Fragment Aggregator auto aggregator_conf = get_fragment_aggregator(); - if (aggregator_conf == 0) { + if (aggregator_conf == nullptr) { throw(BadConf(ERS_HERE, "No FragmentAggregatorModule configuration given")); } std::string faUid("fragmentaggregator-" + UID()); @@ -421,8 +446,7 @@ ReadoutApplication::generate_modules(std::shared_ptr helper // Process special Network rules! // Looking for Fragment rules from DFAppplications in current Session std::vector fragOutObjs; - for (auto [uid, descriptor]: - helper->get_netdescriptors("Fragment", "DFApplication")) { + for (auto const& [uid, descriptor] : helper->get_netdescriptors("Fragment", "DFApplication")) { std::string dreqNetUid(descriptor->get_uid_base() + uid); auto frag_conn = obj_fac.create("NetworkConnection", dreqNetUid); @@ -434,11 +458,12 @@ ReadoutApplication::generate_modules(std::shared_ptr helper auto serviceObj = descriptor->get_associated_service()->config_object(); frag_conn.set_obj("associated_service", &serviceObj); fragOutObjs.push_back(frag_conn); - } + } // Add output queueus of data requests and Fragments std::vector fa_output_objs; for (auto& fNet : fragOutObjs) { + // NOLINTNEXTLINE(performance-inefficient-vector-operation) fa_output_objs.push_back(&fNet); } @@ -452,7 +477,6 @@ ReadoutApplication::generate_modules(std::shared_ptr helper modules.push_back(obj_fac.get_dal(frag_aggr.UID())); obj_fac.update_modules(modules); -} +} // NOLINT(readability/fn_size) -} // namespace appmodel -} // namespace dunedaq +} // namespace dunedaq::appmodel diff --git a/src/SNBBookkeeperApplication.cpp b/src/SNBBookkeeperApplication.cpp index fad66b3..5338e45 100644 --- a/src/SNBBookkeeperApplication.cpp +++ b/src/SNBBookkeeperApplication.cpp @@ -8,14 +8,14 @@ * received with this code. */ -#include "ConfigObjectFactory.hpp" #include "appmodel/SNBBookkeeperApplication.hpp" -#include "appmodel/SNBBookkeeperConf.hpp" -#include "appmodel/SNBTransferBookkeeper.hpp" +#include "ConfigObjectFactory.hpp" #include "appmodel/NetworkConnectionDescriptor.hpp" #include "appmodel/NetworkConnectionRule.hpp" #include "appmodel/QueueConnectionRule.hpp" #include "appmodel/QueueDescriptor.hpp" +#include "appmodel/SNBBookkeeperConf.hpp" +#include "appmodel/SNBTransferBookkeeper.hpp" #include "appmodel/appmodelIssues.hpp" #include "conffwk/Configuration.hpp" #include "confmodel/Connection.hpp" @@ -24,11 +24,11 @@ #include "logging/Logging.hpp" #include "oks/kernel.hpp" +#include #include #include -namespace dunedaq { -namespace appmodel { +namespace dunedaq::appmodel { void SNBBookkeeperApplication::generate_modules(std::shared_ptr /*helper*/) const @@ -44,7 +44,7 @@ SNBBookkeeperApplication::generate_modules(std::shared_ptrconfig_object()); - if (snbBookkeeperConf == 0) { + if (snbBookkeeperConf == nullptr) { throw(BadConf(ERS_HERE, "No SNBBookkeeperConf configuration given")); } @@ -75,5 +75,4 @@ SNBBookkeeperApplication::generate_modules(std::shared_ptr #include #include -namespace dunedaq { -namespace appmodel { +namespace dunedaq::appmodel { void SNBTransferApplication::generate_modules(std::shared_ptr /*helper*/) const @@ -44,7 +44,7 @@ SNBTransferApplication::generate_modules(std::shared_ptrconfig_object()); - if (snbTransferConf == 0) { + if (snbTransferConf == nullptr) { throw(BadConf(ERS_HERE, "No SNBTransferConf configuration given")); } @@ -75,5 +75,4 @@ SNBTransferApplication::generate_modules(std::shared_ptr +#include +#include +#include #include #include -#include -#include -namespace dunedaq { -namespace appmodel { +namespace dunedaq::appmodel { std::vector -TDECrateApplication::contained_excludable_entities() const { +TDECrateApplication::contained_excludable_entities() const +{ return to_resources(get_detector_connections()); } @@ -47,7 +49,7 @@ TDECrateApplication::generate_modules(std::shared_ptr> ctrlhost_sender_map; for (auto d2d_conn : get_detector_connections()) { - // Are we sure? + // Are we sure? if (helper->is_excluded(d2d_conn)) { TLOG_DEBUG(7) << "Ignoring excluded DetectorToDaqConnection " << d2d_conn->UID(); continue; @@ -65,14 +67,14 @@ TDECrateApplication::generate_modules(std::shared_ptris_excluded(sender) ) { + if (helper->is_excluded(sender)) { TLOG() << "Skipping excluded sender: " << sender->UID(); continue; } - + // Check the sender type, must me a TdeAmcDetDataSender const auto* tde_sender = sender->cast(); - if (!tde_sender ) { + if (!tde_sender) { throw(BadConf(ERS_HERE, fmt::format("DataSender {} is not a appmodel::TdeAmcDetDataSender", sender->UID()))); } @@ -80,19 +82,19 @@ TDECrateApplication::generate_modules(std::shared_ptrUID()='" << this->UID() << "' ctrlhost='" << ctrlhost << "'" << std::endl; - if ( this->get_tde_amc_module_conf() ) { - conffwk::ConfigObject tde_obj = obj_fac.create( "TDEAMCModule", fmt::format("tde-ctrl-{}-{}", this->UID(), ctrlhost)); + if (this->get_tde_amc_module_conf()) { + conffwk::ConfigObject tde_obj = + obj_fac.create("TDEAMCModule", fmt::format("tde-ctrl-{}-{}", this->UID(), ctrlhost)); // std::string tde_uid = fmt::format("tde-ctrl-{}-{}", this->UID(), ctrlhost); // config->create(dbfile, "TDEAMCModule", tde_uid, tde_obj); - tde_obj.set_obj("amc", &(senders[0]->config_object()) ); // for now just allow one AMC per module + tde_obj.set_obj("amc", &(senders[0]->config_object())); // for now just allow one AMC per module modules.push_back(obj_fac.get_dal(tde_obj)); } } obj_fac.update_modules(modules); } -} // namespace appmodel -} // namespace dunedaq +} // namespace dunedaq::appmodel diff --git a/src/TPReplayApplication.cpp b/src/TPReplayApplication.cpp index 5f551cc..7a7bc57 100644 --- a/src/TPReplayApplication.cpp +++ b/src/TPReplayApplication.cpp @@ -35,12 +35,12 @@ #include "logging/Logging.hpp" #include +#include #include #include #include -namespace dunedaq { -namespace appmodel { +namespace dunedaq::appmodel { void TPReplayApplication::generate_modules(std::shared_ptr /*helper*/) const @@ -68,7 +68,7 @@ TPReplayApplication::generate_modules(std::shared_ptrget_total_planes(); + const int total_planes = static_cast(tprm_conf->get_total_planes()); /************************************************************** * Extract # of filtered planes @@ -106,8 +106,8 @@ TPReplayApplication::generate_modules(std::shared_ptr("source_id", tpsrc_ids[i]->get_sid()); - tph_obj.set_by_val("detector_id", 1); // 1 == kDAQ + tph_obj.set_by_val("source_id", tpsrc_ids[i]->get_sid()); // NOLINT(build/unsigned) + tph_obj.set_by_val("detector_id", 1); // 1 == kDAQ // NOLINT(build/unsigned) tph_obj.set_by_val("post_processing_enabled", true); tph_obj.set_obj("module_configuration", &tph_conf_obj); TPHs.push_back(tph_obj); @@ -120,7 +120,7 @@ TPReplayApplication::generate_modules(std::shared_ptrget_destination_class(); + auto const& destination_class = rule->get_destination_class(); auto data_type = rule->get_descriptor()->get_data_type(); if (destination_class == "TriggerDataHandlerModule" && data_type == "TriggerPrimitiveVector") { tp_inputq_desc = rule->get_descriptor(); @@ -145,7 +145,6 @@ TPReplayApplication::generate_modules(std::shared_ptrget_endpoint_class(); auto data_type = rule->get_descriptor()->get_data_type(); if (data_type == "TriggerActivity") { ta_net_desc = rule->get_descriptor(); @@ -189,7 +188,7 @@ TPReplayApplication::generate_modules(std::shared_ptr raw_tp_queues; for (const auto& tp_queue : TP_queues) { - raw_tp_queues.push_back(&tp_queue); + raw_tp_queues.push_back(&tp_queue); // NOLINT(performance-inefficient-vector-operation) } tpm_obj.set_objs("outputs", raw_tp_queues); @@ -208,7 +207,6 @@ TPReplayApplication::generate_modules(std::shared_ptr +#include +#include #include #include -#include -#include -namespace dunedaq { -namespace appmodel { +namespace dunedaq::appmodel { void TPStreamWriterApplication::generate_modules(std::shared_ptr /*helper*/) const @@ -39,10 +38,9 @@ TPStreamWriterApplication::generate_modules(std::shared_ptrconfig_object(); @@ -54,30 +52,28 @@ TPStreamWriterApplication::generate_modules(std::shared_ptrget_descriptor(); } } - if ( tset_in_net_desc== nullptr) { - throw (BadConf(ERS_HERE, "No network descriptor given to receive TPSets")); + if (tset_in_net_desc == nullptr) { + throw(BadConf(ERS_HERE, "No network descriptor given to receive TPSets")); } // Create Network Connection conffwk::ConfigObject tset_in_net_obj = obj_fac.create_net_obj(tset_in_net_desc, ".*"); - auto source_id = get_source_id(); if (source_id == nullptr) { - throw(BadConf(ERS_HERE, "No SourceIDConf given to TPWriterApplication!")); + throw(BadConf(ERS_HERE, "No SourceIDConf given to TPWriterApplication!")); } uint tpw_idx = 0; - std::string tpwrUid("tpwriter-"+std::to_string(source_id->get_sid())); + std::string tpwrUid("tpwriter-" + std::to_string(source_id->get_sid())); conffwk::ConfigObject tpwrObj = obj_fac.create("TPStreamWriterModule", tpwrUid); - tpwrObj.set_by_val("source_id", source_id->get_sid()); + tpwrObj.set_by_val("source_id", source_id->get_sid()); // NOLINT(build/unsigned) tpwrObj.set_by_val("writer_identifier", fmt::format("{}_tpw_{}", UID(), tpw_idx)); tpwrObj.set_obj("configuration", &tpwriterConf->config_object()); - tpwrObj.set_objs("inputs", {&tset_in_net_obj} ); + tpwrObj.set_objs("inputs", { &tset_in_net_obj }); modules.push_back(obj_fac.get_dal(tpwrUid)); obj_fac.update_modules(modules); } - -} // namespace appmodel -} // namespace dunedaq + +} // namespace dunedaq::appmodel diff --git a/src/TRMonReqApplication.cpp b/src/TRMonReqApplication.cpp old mode 100755 new mode 100644 index 51a38c8..8e82441 --- a/src/TRMonReqApplication.cpp +++ b/src/TRMonReqApplication.cpp @@ -34,11 +34,11 @@ #include "oks/kernel.hpp" #include +#include #include #include -namespace dunedaq { -namespace appmodel { +namespace dunedaq::appmodel { void TRMonReqApplication::generate_modules(std::shared_ptr helper) const @@ -84,14 +84,13 @@ TRMonReqApplication::generate_modules(std::shared_ptr trmonreqNetObjs; - for (auto [uid, descriptor]: - helper->get_netdescriptors("TRMonRequest", "DFApplication")) { + for (auto const& [uid, descriptor] : helper->get_netdescriptors("TRMonRequest", "DFApplication")) { trmonreqNetObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid)); - } + } // Get pointers to objects here, after vector has been filled so they don't move on us for (auto& obj : trmonreqNetObjs) { - trmrOutputObjs.push_back(&obj); + trmrOutputObjs.push_back(&obj); // NOLINT(performance-inefficient-vector-operation) } // -- Second, we create the Module objects and assign their configs, with the precreated @@ -134,5 +133,4 @@ TRMonReqApplication::generate_modules(std::shared_ptr #include #include -namespace dunedaq { -namespace appmodel { +namespace dunedaq::appmodel { /** * \brief Helper function that gets a network connection config @@ -69,7 +68,6 @@ create_network_connection(std::string uid, return ntObj; } - void TriggerApplication::generate_modules(std::shared_ptr helper) const { @@ -102,37 +100,30 @@ TriggerApplication::generate_modules(std::shared_ptrget_descriptor(); - } - else if (data_type == "TASet" || data_type == "TCSet"){ + } else if (data_type == "TASet" || data_type == "TCSet") { tset_out_net_desc = rule->get_descriptor(); - } - else if (endpoint_class == "DataSubscriberModule") { + } else if (endpoint_class == "DataSubscriberModule") { if (!tin_net_desc) { - tin_net_desc = rule->get_descriptor(); - } - else if (rule->get_descriptor()->get_data_type() == tin_net_desc->get_data_type()) { + tin_net_desc = rule->get_descriptor(); + } else if (rule->get_descriptor()->get_data_type() == tin_net_desc->get_data_type()) { // For now endpoint_class of DataSubscriberModule for both input and output // with the same data type is not possible. - throw (BadConf(ERS_HERE, "Have two network connections of the same data_type and the same endpoint_class")); - } - else if (tin_net_desc->get_data_type() == "TriggerActivity" && - rule->get_descriptor()->get_data_type() == "TriggerCandidate") { + throw(BadConf(ERS_HERE, "Have two network connections of the same data_type and the same endpoint_class")); + } else if (tin_net_desc->get_data_type() == "TriggerActivity" && + rule->get_descriptor()->get_data_type() == "TriggerCandidate") { // For TA->TC tout_net_desc = rule->get_descriptor(); handler_name = "tahandler"; - } - else if (tin_net_desc->get_data_type() == "TriggerCandidate" && - rule->get_descriptor()->get_data_type() == "TriggerActivity") { + } else if (tin_net_desc->get_data_type() == "TriggerCandidate" && + rule->get_descriptor()->get_data_type() == "TriggerActivity") { // For TA->TC if we saved TC network connection as input first... tout_net_desc = tin_net_desc; tin_net_desc = rule->get_descriptor(); handler_name = "tahandler"; + } else { + throw(BadConf(ERS_HERE, "Unexpected input & output network connection descriptors provided")); } - else { - throw (BadConf(ERS_HERE, "Unexpected input & output network connection descriptors provided")); - } - } - else if (data_type == "TriggerActivity" || data_type == "TriggerCandidate"){ + } else if (data_type == "TriggerActivity" || data_type == "TriggerCandidate") { tout_net_desc = rule->get_descriptor(); if (data_type == "TriggerActivity") handler_name = "tphandler"; @@ -143,21 +134,20 @@ TriggerApplication::generate_modules(std::shared_ptr fragOutObjs; - for (auto [uid, descriptor]: - helper->get_netdescriptors("Fragment", "DFApplication")) { + for (auto const& [uid, descriptor] : helper->get_netdescriptors("Fragment", "DFApplication")) { fragOutObjs.push_back(obj_fac.create_net_obj(descriptor, uid)); } - if ( req_net_desc== nullptr) { - throw (BadConf(ERS_HERE, "No network descriptor given to receive request and send data was set")); + if (req_net_desc == nullptr) { + throw(BadConf(ERS_HERE, "No network descriptor given to receive request and send data was set")); } - if ( tin_net_desc== nullptr) { - throw (BadConf(ERS_HERE, "No network descriptor given to receive trigger objects")); + if (tin_net_desc == nullptr) { + throw(BadConf(ERS_HERE, "No network descriptor given to receive trigger objects")); } - if ( tout_net_desc== nullptr) { - throw (BadConf(ERS_HERE, "No network descriptor given to publish trigger objects")); + if (tout_net_desc == nullptr) { + throw(BadConf(ERS_HERE, "No network descriptor given to publish trigger objects")); } if (ti_inputq_desc == nullptr) { - throw (BadConf(ERS_HERE, "No data input queue descriptor given")); + throw(BadConf(ERS_HERE, "No data input queue descriptor given")); } auto input_queue_obj = obj_fac.create_queue_obj(ti_inputq_desc); @@ -172,57 +162,54 @@ TriggerApplication::generate_modules(std::shared_ptr ti_output_objs; for (auto& fNet : fragOutObjs) { + // NOLINTNEXTLINE(performance-inefficient-vector-operation) ti_output_objs.push_back(&fNet); } ti_output_objs.push_back(&tout_net_obj); - if (tset_out_net_desc!= nullptr) { + if (tset_out_net_desc != nullptr) { ti_output_objs.push_back(&tset_out_net_obj); } if (get_source_id() == nullptr) { throw(BadConf(ERS_HERE, "No source_id associated with this TriggerApplication!")); } - uint32_t source_id = get_source_id()->get_sid(); + uint32_t source_id = get_source_id()->get_sid(); // NOLINT(build/unsigned) std::string ti_uid(handler_name + "-" + std::to_string(source_id)); auto ti_obj = obj_fac.create(ti_class, ti_uid); - ti_obj.set_by_val("source_id", source_id); - ti_obj.set_by_val("detector_id", 1); // 1 == kDAQ + ti_obj.set_by_val("source_id", source_id); // NOLINT(build/unsigned) + ti_obj.set_by_val("detector_id", 1); // 1 == kDAQ // NOLINT(build/unsigned) ti_obj.set_by_val("post_processing_enabled", !get_tx_generation_disabled()); auto ti_conf_obj = ti_conf->config_object(); ti_obj.set_obj("module_configuration", &ti_conf_obj); - ti_obj.set_objs("inputs", {&input_queue_obj, &req_net_obj}); + ti_obj.set_objs("inputs", { &input_queue_obj, &req_net_obj }); ti_obj.set_objs("outputs", ti_output_objs); // Add to our list of modules to return modules.push_back(obj_fac.get_dal(ti_uid)); - // Now create the DataSubscriberModule object auto rdr_conf = get_data_subscriber(); if (rdr_conf == nullptr) { - throw (BadConf(ERS_HERE, "No DataReaderModule configuration given")); + throw(BadConf(ERS_HERE, "No DataReaderModule configuration given")); } // Create a DataReaderModule - std::string reader_uid("data-reader-"+UID()); + std::string reader_uid("data-reader-" + UID()); std::string reader_class = rdr_conf->get_template_for(); - TLOG_DEBUG(7) << "creating OKS configuration object for Data subscriber class " << reader_class; + TLOG_DEBUG(7) << "creating OKS configuration object for Data subscriber class " << reader_class; auto reader_obj = obj_fac.create(reader_class, reader_uid); - reader_obj.set_objs("inputs", {&tin_net_obj} ); - reader_obj.set_objs("outputs", {&input_queue_obj} ); + reader_obj.set_objs("inputs", { &tin_net_obj }); + reader_obj.set_objs("outputs", { &input_queue_obj }); reader_obj.set_obj("configuration", &rdr_conf->config_object()); modules.push_back(obj_fac.get_dal(reader_uid)); - obj_fac.update_modules(modules); -} - -} // namespace appmodel -} // namespace dunedaq +} // NOLINT(readability/fn_size) + +} // namespace dunedaq::appmodel diff --git a/src/WIECApplication.cpp b/src/WIECApplication.cpp index a16cc0d..0e44ade 100644 --- a/src/WIECApplication.cpp +++ b/src/WIECApplication.cpp @@ -8,57 +8,55 @@ * received with this code. */ - #include "ConfigObjectFactory.hpp" #include "conffwk/Configuration.hpp" #include "logging/Logging.hpp" #include "appmodel/NWDetDataReceiver.hpp" -#include "confmodel/NetworkInterface.hpp" #include "confmodel/DetectorStream.hpp" #include "confmodel/GeoId.hpp" +#include "confmodel/NetworkInterface.hpp" -#include "appmodel/appmodelIssues.hpp" #include "appmodel/WIECApplication.hpp" +#include "appmodel/appmodelIssues.hpp" -#include "appmodel/WIBModule.hpp" -#include "appmodel/WIBModuleConf.hpp" -#include "appmodel/WIBSettings.hpp" #include "appmodel/HermesDataSender.hpp" #include "appmodel/HermesModule.hpp" #include "appmodel/HermesModuleConf.hpp" #include "appmodel/IpbusAddressTable.hpp" +#include "appmodel/WIBModule.hpp" +#include "appmodel/WIBModuleConf.hpp" +#include "appmodel/WIBSettings.hpp" #include "confmodel/DetectorToDaqConnection.hpp" - +#include +#include +#include +#include #include #include -#include -#include -namespace dunedaq { -namespace appmodel { +namespace dunedaq::appmodel { //----------------------------------------------------------------------------- std::vector -WIECApplication::contained_excludable_entities() const { +WIECApplication::contained_excludable_entities() const +{ return to_resources(get_detector_connections()); } - void WIECApplication::generate_modules(std::shared_ptr helper) const { ConfigObjectFactory obj_fac(this); conffwk::Configuration* config = &this->configuration(); const std::string& dbfile = this->config_object().contained_in(); - + std::vector modules; std::map> ctrlhost_sender_map; - // uint16_t conn_idx = 0; for (auto d2d_conn : get_detector_connections()) { @@ -81,37 +79,40 @@ WIECApplication::generate_modules(std::shared_ptr // Ensure that receiver is a nw_receiver const auto* nw_receiver = det_receiver->cast(); - if ( !nw_receiver ) { - throw(BadConf(ERS_HERE, fmt::format("WEICApplication requires NWDetDataReceiver, found {} of class {}", det_receiver->UID(), det_receiver->class_name()))); + if (!nw_receiver) { + throw(BadConf(ERS_HERE, + fmt::format("WEICApplication requires NWDetDataReceiver, found {} of class {}", + det_receiver->UID(), + det_receiver->class_name()))); } - + // Note on how to exclude the senders. // The hardware interface requires that all the physical links be configured, even if not used for a run. // Consequently, at the configuration level, we should never remove senders from a detector to daq connection. // At most, we should exclude them at the level of the session. - // For the same reason, in this code, we create a map of control hosts to senders, without checking if the senders are excluded. - // Once the map is created, if all the senders associated to a control hosts are excluded, then we skip the creation of all related modules. - - // Loop over senders to create the map of control hosts to senders. + // For the same reason, in this code, we create a map of control hosts to senders, without checking if the senders + // are excluded. Once the map is created, if all the senders associated to a control hosts are excluded, then we + // skip the creation of all related modules. + + // Loop over senders to create the map of control hosts to senders. for (const auto* sender : det_senders) { // Check the sender type, must be a HermesSender const auto* hrms_sender = sender->cast(); - if (!hrms_sender ) { + if (!hrms_sender) { throw(BadConf(ERS_HERE, fmt::format("DataSender {} is not a appmodel::HermesDataSender", sender->UID()))); } ctrlhost_sender_map[hrms_sender->get_control_host()].push_back(hrms_sender); } - - for( const auto& [ctrlhost, senders] : ctrlhost_sender_map ) { + for (const auto& [ctrlhost, senders] : ctrlhost_sender_map) { // If all senders for this control host are excluded, skip creating related modules. // Of course the opposite logic is faster: check if any sender is included. bool any_included = false; - for ( const auto* sender : senders ){ - if ( helper->is_included(sender) ) { + for (const auto* sender : senders) { + if (helper->is_included(sender)) { any_included = true; break; } @@ -122,45 +123,54 @@ WIECApplication::generate_modules(std::shared_ptr } // Create WIBModule - if ( this->get_wib_module_conf() ) { + if (this->get_wib_module_conf()) { - bool enable_fembs[4] = {false, false, false, false}; + std::array enable_fembs = { false, false, false, false }; - for ( const auto* sender : senders ){ - for ( const auto* det_stream : sender->get_streams() ) { + for (const auto* sender : senders) { + for (const auto* det_stream : sender->get_streams()) { // Loop over streams for this sender // Retrieve stream_id and calculate the femb_id - uint32_t stream_id = det_stream->get_geo_id()->get_stream_id(); - uint32_t femb_id = (stream_id & 0xf) / 2 + 2*((stream_id >> 6) & 0xf); + uint32_t stream_id = det_stream->get_geo_id()->get_stream_id(); // NOLINT(build/unsigned) + uint32_t femb_id = (stream_id & 0xf) / 2 + 2 * ((stream_id >> 6) & 0xf); // NOLINT(build/unsigned) // std::cout << std::format("stream {} -> femb {}", stream_id, femb_id) << std::endl; // Enable the femb if any of the associated streams is enabled - enable_fembs[femb_id] |= helper->is_included(det_stream); + enable_fembs.at(femb_id) |= helper->is_included(det_stream); } // loop over streams } // loop over senders for this control host std::string wib_uid = fmt::format("wib-ctrl-{}-{}", this->UID(), ctrlhost); conffwk::ConfigObject wib_obj = obj_fac.create("WIBModule", wib_uid); - wib_obj.set_by_val("wib_addr", fmt::format("{}://{}:{}", this->get_wib_module_conf()->get_communication_type(), ctrlhost, this->get_wib_module_conf()->get_communication_port())); - for (int i=0; i<4; ++i) { - wib_obj.set_by_val(fmt::format("enabled_femb{}", i), enable_fembs[i]); + wib_obj.set_by_val("wib_addr", + fmt::format("{}://{}:{}", + this->get_wib_module_conf()->get_communication_type(), + ctrlhost, + this->get_wib_module_conf()->get_communication_port())); + for (int i = 0; i < 4; ++i) { + wib_obj.set_by_val(fmt::format("enabled_femb{}", i), enable_fembs.at(i)); } wib_obj.set_obj("conf", &this->get_wib_module_conf()->get_settings()->config_object()); modules.push_back(config->get(wib_obj)); - } // if we have a module configuration for the WIB module + } // if we have a module configuration for the WIB module // Create Hermes Modules if (this->get_hermes_module_conf()) { std::string hermes_uid = fmt::format("hermes-ctrl-{}-{}", this->UID(), ctrlhost); conffwk::ConfigObject hermes_obj = obj_fac.create("HermesModule", hermes_uid); hermes_obj.set_obj("address_table", &this->get_hermes_module_conf()->get_address_table()->config_object()); - hermes_obj.set_by_val("uri", fmt::format("{}://{}:{}", this->get_hermes_module_conf()->get_ipbus_type(), ctrlhost, this->get_hermes_module_conf()->get_ipbus_port())); + hermes_obj.set_by_val("uri", + fmt::format("{}://{}:{}", + this->get_hermes_module_conf()->get_ipbus_type(), + ctrlhost, + this->get_hermes_module_conf()->get_ipbus_port())); + // NOLINTNEXTLINE(build/unsigned) hermes_obj.set_by_val("timeout_ms", this->get_hermes_module_conf()->get_ipbus_timeout_ms()); hermes_obj.set_obj("destination", &nw_receiver->get_uses()->config_object()); - std::vector< const conffwk::ConfigObject * > links_obj; - for ( const auto* sndr : senders ){ + std::vector links_obj; + for (const auto* sndr : senders) { // Note that it is OK that some of these senders might be excluded // The hardware interface in HermesModule requires that all links be configured, even if not used for a run links_obj.push_back(&sndr->config_object()); @@ -175,7 +185,6 @@ WIECApplication::generate_modules(std::shared_ptr } // loop over detector to daq connections obj_fac.update_modules(modules); -} - -} // namespace appmodel -} // namespace dunedaq +} // NOLINT(readability/fn_size) + +} // namespace dunedaq::appmodel diff --git a/test/apps/generate_modules_test.cxx b/test/apps/generate_modules_test.cxx index f8f0215..97e9a95 100644 --- a/test/apps/generate_modules_test.cxx +++ b/test/apps/generate_modules_test.cxx @@ -27,13 +27,15 @@ #include "appmodel/TriggerApplication.hpp" #include "appmodel/DataHandlerModule.hpp" -#include "appmodel/DataReaderModule.hpp" #include "appmodel/DataMoveCallbackConf.hpp" +#include "appmodel/DataReaderModule.hpp" #include "appmodel/SocketDataWriterModule.hpp" #include "appmodel/appmodelIssues.hpp" +#include #include + using namespace dunedaq; using namespace dunedaq::appmodel; @@ -41,71 +43,71 @@ int main(int argc, char* argv[]) { if (argc < 4) { - std::cout << "Usage: " << argv[0] << " \n"; + std::cout << "Usage: " << argv[0] << " \n"; // NOLINT return 0; } - std::string sessionName(argv[1]); - std::string appName(argv[2]); - std::string dbfile(argv[3]); + std::string sessionName(argv[1]); // NOLINT + std::string appName(argv[2]); // NOLINT + std::string dbfile(argv[3]); // NOLINT - logging::Logging::setup("test", "generate_module"); + assert(sessionName != ""); + logging::Logging::setup(sessionName, "generate_module"); - conffwk::Configuration* confdb; + conffwk::Configuration* confdb = nullptr; try { confdb = new conffwk::Configuration("oksconflibs:" + dbfile); } catch (conffwk::Generic& exc) { - std::cout << "Failed to load OKS database: " << exc << std::endl; + std::cout << "Failed to load OKS database: " << exc << std::endl; // NOLINT(runtime/output_format) return 0; } auto session = confdb->get(sessionName); if (session == nullptr) { - std::cout << "Failed to get Session " << sessionName << " from database\n"; + std::cout << "Failed to get Session " << sessionName << " from database\n"; // NOLINT(runtime/output_format) return 0; } auto daqapp = confdb->get(appName); if (daqapp) { - std::cout << appName << " is of class " << daqapp->class_name() << std::endl; + std::cout << appName << " is of class " << daqapp->class_name() << std::endl; // NOLINT(runtime/output_format) auto res = daqapp->cast(); if (res && res->is_excluded(*session)) { - std::cout << "Application " << appName << " is excluded" << std::endl; + std::cout << "Application " << appName << " is excluded" << std::endl; // NOLINT(runtime/output_format) return 0; } auto helper = std::make_shared(session); try { daqapp->generate_modules(helper); - } - catch (appmodel::BadConf& exc) { - std::cout << "Caught BadConf exception: " << exc << std::endl; + } catch (appmodel::BadConf& exc) { + std::cout << "Caught BadConf exception: " << exc << std::endl; // NOLINT(runtime/output_format) exit(-1); } auto modules = daqapp->get_modules(); - std::cout << "Generated " << modules.size() << " modules" << std::endl; + std::cout << "Generated " << modules.size() << " modules" << std::endl; // NOLINT(runtime/output_format) for (auto daq_module : modules) { - std::cout << "module " << daq_module->UID() << std::endl; + std::cout << "module " << daq_module->UID() << std::endl; // NOLINT(runtime/output_format) daq_module->config_object().print_ref(std::cout, *confdb, " "); - std::cout << " input objects " << std::endl; + std::cout << " input objects " << std::endl; // NOLINT(runtime/output_format) for (auto input : daq_module->get_inputs()) { auto iObj = input->config_object(); - iObj.print_ref(std::cout, *confdb, " "); + iObj.print_ref(std::cout, *confdb, " "); // NOLINT(runtime/output_format) } - std::cout << " output objects " << std::endl; + std::cout << " output objects " << std::endl; // NOLINT(runtime/output_format) for (auto output : daq_module->get_outputs()) { auto oObj = output->config_object(); - oObj.print_ref(std::cout, *confdb, " "); + oObj.print_ref(std::cout, *confdb, " "); // NOLINT(runtime/output_format) } auto reader_module = daq_module->cast(); if (reader_module != nullptr) { auto callback_confs = reader_module->get_raw_data_callbacks(); - std::cout << " callback confs " << std::endl; + std::cout << " callback confs " << std::endl; // NOLINT(runtime/output_format) for (auto* callback_conf : callback_confs) { auto cbObj = callback_conf->config_object(); - cbObj.print_ref(std::cout, *confdb, " "); + cbObj.print_ref(std::cout, *confdb, " "); // NOLINT(runtime/output_format) } } @@ -114,14 +116,14 @@ main(int argc, char* argv[]) auto callback_conf = handler_module->get_raw_data_callback(); if (callback_conf != nullptr) { auto cbObj = callback_conf->config_object(); - cbObj.print_ref(std::cout, *confdb, " "); + cbObj.print_ref(std::cout, *confdb, " "); // NOLINT(runtime/output_format) } } - std::cout << std::endl; + std::cout << std::endl; // NOLINT(runtime/output_format) } } else { - std::cout << "Failed to get SmartDaqApplication " << appName << " from database\n"; + std::cout << "Failed to get SmartDaqApplication " << appName << " from database\n"; // NOLINT(runtime/output_format) return 0; } } diff --git a/test/apps/print_detailed_config_info.cxx b/test/apps/print_detailed_config_info.cxx index 1cadbd2..085ed92 100644 --- a/test/apps/print_detailed_config_info.cxx +++ b/test/apps/print_detailed_config_info.cxx @@ -23,13 +23,16 @@ #include "appmodel/MLTApplication.hpp" #include "appmodel/ReadoutApplication.hpp" #include "appmodel/SmartDaqApplication.hpp" +#include "appmodel/TPReplayApplication.hpp" #include "appmodel/TPStreamWriterApplication.hpp" #include "appmodel/TriggerApplication.hpp" -#include "appmodel/TPReplayApplication.hpp" #include "appmodel/appmodelIssues.hpp" +#include #include +#include + using namespace dunedaq; using namespace dunedaq::appmodel; @@ -59,7 +62,7 @@ print_member_details_if_needed(conffwk::ConfigObject& parent_config_object, try { std::vector member_object_list; parent_config_object.get(member_name, member_object_list); - for (uint32_t idx = 0; idx < member_object_list.size(); ++idx) { + for (uint32_t idx = 0; idx < member_object_list.size(); ++idx) { // NOLINT(build/unsigned) if (!member_object_list[idx].is_null()) { if (member_name != "inputs" && member_name != "outputs") { std::ostringstream oss_name; @@ -82,8 +85,8 @@ print_object_details(conffwk::ConfigObject& config_object_to_print, std::vector& list_of_applications) { if (object_name != "") { - std::cout << spaces << "-----" << std::endl; - std::cout << spaces << "\"" << object_name << "\" "; + std::cout << spaces << "-----" << std::endl; // NOLINT(runtime/output_format) + std::cout << spaces << "\"" << object_name << "\" "; // NOLINT(runtime/output_format) } config_object_to_print.print_ref(std::cout, *confdb, spaces); dunedaq::conffwk::class_t cd = confdb->get_class_info(config_object_to_print.class_name()); @@ -94,8 +97,8 @@ print_object_details(conffwk::ConfigObject& config_object_to_print, std::string application_name; config_object_to_print.get(attr_name, application_name); if (application_name == "daq_application") { - std::cout << "Application name = " << application_name << std::endl; - std::cout << "Application UID = " << config_object_to_print.UID() << std::endl; + std::cout << "Application name = " << application_name << std::endl; // NOLINT(runtime/output_format) + std::cout << "Application UID = " << config_object_to_print.UID() << std::endl; // NOLINT(runtime/output_format) list_of_applications.push_back(config_object_to_print.UID()); } } @@ -110,27 +113,28 @@ int main(int argc, char* argv[]) { if (argc < 3) { - std::cout << "Usage: " << argv[0] << " \n"; + std::cout << "Usage: " << argv[0] << " \n"; // NOLINT return 0; } - std::string sessionName(argv[1]); + std::string sessionName(argv[1]); // NOLINT + assert(sessionName != "" && "Session name must be specified"); logging::Logging::setup(sessionName, "print_detailed_config_info"); - std::string dbfile(argv[2]); - conffwk::Configuration* confdb; + std::string dbfile(argv[2]); // NOLINT + conffwk::Configuration* confdb = nullptr; std::string blah = "oksconflibs:" + dbfile; try { confdb = new conffwk::Configuration(blah); } catch (conffwk::Generic& exc) { - std::cout << "Failed to load OKS database: " << exc << std::endl; + std::cout << "Failed to load OKS database: " << exc << std::endl; // NOLINT(runtime/output_format) return 0; } auto session = confdb->get(sessionName); if (session == nullptr) { - std::cout << "Failed to get Session " << sessionName << " from database\n"; + std::cout << "Failed to get Session " << sessionName << " from database\n"; // NOLINT(runtime/output_format) return 0; } @@ -138,72 +142,74 @@ main(int argc, char* argv[]) // session->print(0, true, std::cout); // std::cout << "=====" << std::endl; - std::cout << "++++++++++" << std::endl; - std::cout << "Full-system details without module generation" << std::endl; - std::cout << "++++++++++" << std::endl; - std::cout << std::endl; + std::cout << "++++++++++" << std::endl; // NOLINT(runtime/output_format) + std::cout << "Full-system details without module generation" << std::endl; // NOLINT(runtime/output_format) + std::cout << "++++++++++" << std::endl; // NOLINT(runtime/output_format) + std::cout << std::endl; // NOLINT(runtime/output_format) std::vector list_of_application_names; conffwk::ConfigObject session_config_object = session->config_object(); print_object_details(session_config_object, "", confdb, " ", list_of_application_names); - std::cout << std::endl; - std::cout << "++++++++++" << std::endl; + std::cout << std::endl; // NOLINT(runtime/output_format) + std::cout << "++++++++++" << std::endl; // NOLINT(runtime/output_format) + // NOLINTNEXTLINE(runtime/output_format) std::cout << "Individual application details including module generation" << std::endl; - std::cout << "++++++++++" << std::endl; + std::cout << "++++++++++" << std::endl; // NOLINT(runtime/output_format) for (size_t idx = 0; idx < list_of_application_names.size(); ++idx) { - std::cout << std::endl; + std::cout << std::endl; // NOLINT(runtime/output_format) confdb = nullptr; try { confdb = new conffwk::Configuration(blah); } catch (conffwk::Generic& exc) { - std::cout << "Failed to load OKS database: " << exc << std::endl; + std::cout << "Failed to load OKS database: " << exc << std::endl; // NOLINT(runtime/output_format) return 0; } session = confdb->get(sessionName); auto helper = std::make_shared(session); - std::string appName = list_of_application_names[idx]; + const std::string& appName = list_of_application_names[idx]; auto daqapp = confdb->get(appName); if (daqapp) { - std::cout << appName << " is of class " << daqapp->class_name() << std::endl; + std::cout << appName << " is of class " << daqapp->class_name() << std::endl; // NOLINT(runtime/output_format) auto res = daqapp->cast(); if (res && res->is_excluded(*session)) { - std::cout << "Application " << appName << " is excluded" << std::endl; + std::cout << "Application " << appName << " is excluded" << std::endl; // NOLINT(runtime/output_format) continue; } try { daqapp->generate_modules(helper); } catch (appmodel::BadConf& exc) { - std::cout << "Caught BadConf exception: " << exc << std::endl; + std::cout << "Caught BadConf exception: " << exc << std::endl; // NOLINT(runtime/output_format) exit(-1); } auto modules = daqapp->get_modules(); // std::cout << "Generated " << modules.size() << " modules" << std::endl; for (auto module : modules) { - std::cout << "module " << module->UID() << std::endl; + std::cout << "module " << module->UID() << std::endl; // NOLINT(runtime/output_format) conffwk::ConfigObject module_config_object = module->config_object(); std::vector dummy_list; print_object_details(module_config_object, "", confdb, " ", dummy_list); - std::cout << " input objects " << std::endl; + std::cout << " input objects " << std::endl; // NOLINT(runtime/output_format) for (auto input : module->get_inputs()) { auto iObj = input->config_object(); - iObj.print_ref(std::cout, *confdb, " "); + iObj.print_ref(std::cout, *confdb, " "); // NOLINT(runtime/output_format) } - std::cout << " output objects " << std::endl; + std::cout << " output objects " << std::endl; // NOLINT(runtime/output_format) for (auto output : module->get_outputs()) { auto oObj = output->config_object(); - oObj.print_ref(std::cout, *confdb, " "); + oObj.print_ref(std::cout, *confdb, " "); // NOLINT(runtime/output_format) } } } else { + // NOLINTNEXTLINE(runtime/output_format) std::cout << "Failed to get SmartDaqApplication " << appName << " from database\n"; return 0; } } -} +} // NOLINT(readability/fn_size) From 2b70cf7a852f799b6413ed94db6c588d48349f67 Mon Sep 17 00:00:00 2001 From: Eric Flumerfelt Date: Thu, 1 Oct 2026 10:27:15 -0500 Subject: [PATCH 13/15] Apply dbt-clang-format --- src/MLTApplication.cpp | 200 ++++++++++++++++++++--------------------- 1 file changed, 98 insertions(+), 102 deletions(-) diff --git a/src/MLTApplication.cpp b/src/MLTApplication.cpp index 27c6180..fe77c78 100644 --- a/src/MLTApplication.cpp +++ b/src/MLTApplication.cpp @@ -217,114 +217,110 @@ MLTApplication::generate_modules(std::shared_ptr } } - for (auto app_class: {"TriggerApplication", "FakeHSIApplication", "DTSHSIApplication", "CIBApplication"}) { - for (auto [uid, src_id]: helper->get_app_source_ids(app_class)) { - auto tcSourceIdConf = new conffwk::ConfigObject( - obj_fac.create("SourceIDConf", - uid + "-" + std::to_string(src_id->get_sid()) - )); + for (auto app_class : { "TriggerApplication", "FakeHSIApplication", "DTSHSIApplication", "CIBApplication" }) { + for (auto [uid, src_id] : helper->get_app_source_ids(app_class)) { + auto tcSourceIdConf = + new conffwk::ConfigObject(obj_fac.create("SourceIDConf", uid + "-" + std::to_string(src_id->get_sid()))); tcSourceIdConf->set_by_val("sid", src_id->get_sid()); tcSourceIdConf->set_by_val("subsystem", src_id->get_subsystem()); sourceIds.push_back(tcSourceIdConf); } } - - } - } - - // Get mandatory links - std::vector mandatory_sids; - const TCDataProcessor* tc_dp = tch_conf->get_data_processor()->cast(); - if (tc_dp != nullptr) { - for (auto m : tc_dp->get_mandatory_links()) { - mandatory_sids.push_back(&m->config_object()); - } - } - - /************************************************************** - * Create the TC handler - **************************************************************/ - - // Process special Network rules! - // Looking for Fragment rules from DFAppplications in current Session - - // auto sessionApps = session->get_included_applications(); - // std::vector fragOutObjs; - // for (auto app : sessionApps) { - // auto dfapp = app->cast(); - // if (dfapp == nullptr) - // continue; - - // auto dfNRules = dfapp->get_network_rules(); - // for (auto rule : dfNRules) { - // auto descriptor = rule->get_descriptor(); - // auto data_type = descriptor->get_data_type(); - // if (data_type == "Fragment") { - // std::string dreqNetUid(descriptor->get_uid_base() + dfapp->UID()); - // conffwk::ConfigObject frag_conn; - // confdb->create(dbfile, "NetworkConnection", dreqNetUid, frag_conn); - - // frag_conn.set_by_val("data_type", descriptor->get_data_type()); - // frag_conn.set_by_val("connection_type", descriptor->get_connection_type()); - - // auto serviceObj = descriptor->get_associated_service()->config_object(); - // frag_conn.set_obj("associated_service", &serviceObj); - // fragOutObjs.push_back(frag_conn); - // } // If network rule has TriggerDecision type of data - // } // Loop over Apps network rules - // } // loop over Session specific Apps - - std::vector fragOutObjs; - for (auto [uid, descriptor] : helper->get_netdescriptors("Fragment", "DFApplication")) { - fragOutObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid)); - } - - // build up the full list of outputs - std::vector ti_output_objs; - for (auto& fNet : fragOutObjs) { - ti_output_objs.push_back(&fNet); - } - ti_output_objs.push_back(&output_queue_obj); - - auto tch_conf_obj = tch_conf->config_object(); - if (get_source_id() == nullptr) { - throw(BadConf(ERS_HERE, "No source_id associated with this TriggerApplication!")); - } - uint32_t source_id = get_source_id()->get_sid(); - std::string ti_uid(handler_name + "-" + std::to_string(source_id)); - conffwk::ConfigObject ti_obj = obj_fac.create(tch_class, ti_uid); - ti_obj.set_by_val("source_id", source_id); - ti_obj.set_by_val("detector_id", 1); // 1 == kDAQ - ti_obj.set_obj("module_configuration", &tch_conf_obj); - ti_obj.set_objs("enabled_source_ids", sourceIds); - ti_obj.set_objs("mandatory_source_ids", mandatory_sids); - ti_obj.set_objs("inputs", { &input_queue_obj, &dr_net_obj }); - ti_obj.set_objs("outputs", ti_output_objs); - - // Add to our list of modules to return - modules.push_back(obj_fac.get_dal(ti_uid)); - - /************************************************************** - * Instantiate the MLTModule module - **************************************************************/ - - std::vector tdOutObjs; - for (auto [uid, descriptor] : helper->get_netdescriptors("TriggerDecision", "DFOApplication")) { - tdOutObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid)); - } - - std::vector output_conns; - for (auto& tdOut : tdOutObjs) { - output_conns.push_back(&tdOut); +} +} + +// Get mandatory links +std::vector mandatory_sids; +const TCDataProcessor* tc_dp = tch_conf->get_data_processor()->cast(); +if (tc_dp != nullptr) { + for (auto m : tc_dp->get_mandatory_links()) { + mandatory_sids.push_back(&m->config_object()); } - conffwk::ConfigObject mlt_obj = obj_fac.create(mlt_conf->get_template_for(), - mlt_conf->UID()); - mlt_obj.set_obj("configuration", &(mlt_conf->config_object())); - mlt_obj.set_objs("inputs", { &output_queue_obj, &ti_net_obj }); - mlt_obj.set_objs("outputs", output_conns); - modules.push_back(obj_fac.get_dal(mlt_conf->UID())); - - obj_fac.update_modules(modules); +} + +/************************************************************** + * Create the TC handler + **************************************************************/ + +// Process special Network rules! +// Looking for Fragment rules from DFAppplications in current Session + +// auto sessionApps = session->get_included_applications(); +// std::vector fragOutObjs; +// for (auto app : sessionApps) { +// auto dfapp = app->cast(); +// if (dfapp == nullptr) +// continue; + +// auto dfNRules = dfapp->get_network_rules(); +// for (auto rule : dfNRules) { +// auto descriptor = rule->get_descriptor(); +// auto data_type = descriptor->get_data_type(); +// if (data_type == "Fragment") { +// std::string dreqNetUid(descriptor->get_uid_base() + dfapp->UID()); +// conffwk::ConfigObject frag_conn; +// confdb->create(dbfile, "NetworkConnection", dreqNetUid, frag_conn); + +// frag_conn.set_by_val("data_type", descriptor->get_data_type()); +// frag_conn.set_by_val("connection_type", descriptor->get_connection_type()); + +// auto serviceObj = descriptor->get_associated_service()->config_object(); +// frag_conn.set_obj("associated_service", &serviceObj); +// fragOutObjs.push_back(frag_conn); +// } // If network rule has TriggerDecision type of data +// } // Loop over Apps network rules +// } // loop over Session specific Apps + +std::vector fragOutObjs; +for (auto [uid, descriptor] : helper->get_netdescriptors("Fragment", "DFApplication")) { + fragOutObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid)); +} + +// build up the full list of outputs +std::vector ti_output_objs; +for (auto& fNet : fragOutObjs) { + ti_output_objs.push_back(&fNet); +} +ti_output_objs.push_back(&output_queue_obj); + +auto tch_conf_obj = tch_conf->config_object(); +if (get_source_id() == nullptr) { + throw(BadConf(ERS_HERE, "No source_id associated with this TriggerApplication!")); +} +uint32_t source_id = get_source_id()->get_sid(); +std::string ti_uid(handler_name + "-" + std::to_string(source_id)); +conffwk::ConfigObject ti_obj = obj_fac.create(tch_class, ti_uid); +ti_obj.set_by_val("source_id", source_id); +ti_obj.set_by_val("detector_id", 1); // 1 == kDAQ +ti_obj.set_obj("module_configuration", &tch_conf_obj); +ti_obj.set_objs("enabled_source_ids", sourceIds); +ti_obj.set_objs("mandatory_source_ids", mandatory_sids); +ti_obj.set_objs("inputs", { &input_queue_obj, &dr_net_obj }); +ti_obj.set_objs("outputs", ti_output_objs); + +// Add to our list of modules to return +modules.push_back(obj_fac.get_dal(ti_uid)); + +/************************************************************** + * Instantiate the MLTModule module + **************************************************************/ + +std::vector tdOutObjs; +for (auto [uid, descriptor] : helper->get_netdescriptors("TriggerDecision", "DFOApplication")) { + tdOutObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid)); +} + +std::vector output_conns; +for (auto& tdOut : tdOutObjs) { + output_conns.push_back(&tdOut); +} +conffwk::ConfigObject mlt_obj = obj_fac.create(mlt_conf->get_template_for(), mlt_conf->UID()); +mlt_obj.set_obj("configuration", &(mlt_conf->config_object())); +mlt_obj.set_objs("inputs", { &output_queue_obj, &ti_net_obj }); +mlt_obj.set_objs("outputs", output_conns); +modules.push_back(obj_fac.get_dal(mlt_conf->UID())); + +obj_fac.update_modules(modules); } // NOLINT(readability/fn_size) } // namespace appmodel From 0ad06fb953791fe64473481d0c40fe0a1e87f5c9 Mon Sep 17 00:00:00 2001 From: Eric Flumerfelt Date: Thu, 1 Oct 2026 12:10:24 -0500 Subject: [PATCH 14/15] Run dbt-clang-format again --- src/MLTApplication.cpp | 186 ++++++++++++++++++++--------------------- 1 file changed, 92 insertions(+), 94 deletions(-) diff --git a/src/MLTApplication.cpp b/src/MLTApplication.cpp index fe77c78..e489ef9 100644 --- a/src/MLTApplication.cpp +++ b/src/MLTApplication.cpp @@ -226,101 +226,99 @@ MLTApplication::generate_modules(std::shared_ptr sourceIds.push_back(tcSourceIdConf); } } -} -} - -// Get mandatory links -std::vector mandatory_sids; -const TCDataProcessor* tc_dp = tch_conf->get_data_processor()->cast(); -if (tc_dp != nullptr) { - for (auto m : tc_dp->get_mandatory_links()) { - mandatory_sids.push_back(&m->config_object()); + + // Get mandatory links + std::vector mandatory_sids; + const TCDataProcessor* tc_dp = tch_conf->get_data_processor()->cast(); + if (tc_dp != nullptr) { + for (auto m : tc_dp->get_mandatory_links()) { + mandatory_sids.push_back(&m->config_object()); + } + } + + /************************************************************** + * Create the TC handler + **************************************************************/ + + // Process special Network rules! + // Looking for Fragment rules from DFAppplications in current Session + + // auto sessionApps = session->get_included_applications(); + // std::vector fragOutObjs; + // for (auto app : sessionApps) { + // auto dfapp = app->cast(); + // if (dfapp == nullptr) + // continue; + + // auto dfNRules = dfapp->get_network_rules(); + // for (auto rule : dfNRules) { + // auto descriptor = rule->get_descriptor(); + // auto data_type = descriptor->get_data_type(); + // if (data_type == "Fragment") { + // std::string dreqNetUid(descriptor->get_uid_base() + dfapp->UID()); + // conffwk::ConfigObject frag_conn; + // confdb->create(dbfile, "NetworkConnection", dreqNetUid, frag_conn); + + // frag_conn.set_by_val("data_type", descriptor->get_data_type()); + // frag_conn.set_by_val("connection_type", descriptor->get_connection_type()); + + // auto serviceObj = descriptor->get_associated_service()->config_object(); + // frag_conn.set_obj("associated_service", &serviceObj); + // fragOutObjs.push_back(frag_conn); + // } // If network rule has TriggerDecision type of data + // } // Loop over Apps network rules + // } // loop over Session specific Apps + + std::vector fragOutObjs; + for (auto [uid, descriptor] : helper->get_netdescriptors("Fragment", "DFApplication")) { + fragOutObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid)); } -} - -/************************************************************** - * Create the TC handler - **************************************************************/ - -// Process special Network rules! -// Looking for Fragment rules from DFAppplications in current Session - -// auto sessionApps = session->get_included_applications(); -// std::vector fragOutObjs; -// for (auto app : sessionApps) { -// auto dfapp = app->cast(); -// if (dfapp == nullptr) -// continue; - -// auto dfNRules = dfapp->get_network_rules(); -// for (auto rule : dfNRules) { -// auto descriptor = rule->get_descriptor(); -// auto data_type = descriptor->get_data_type(); -// if (data_type == "Fragment") { -// std::string dreqNetUid(descriptor->get_uid_base() + dfapp->UID()); -// conffwk::ConfigObject frag_conn; -// confdb->create(dbfile, "NetworkConnection", dreqNetUid, frag_conn); - -// frag_conn.set_by_val("data_type", descriptor->get_data_type()); -// frag_conn.set_by_val("connection_type", descriptor->get_connection_type()); - -// auto serviceObj = descriptor->get_associated_service()->config_object(); -// frag_conn.set_obj("associated_service", &serviceObj); -// fragOutObjs.push_back(frag_conn); -// } // If network rule has TriggerDecision type of data -// } // Loop over Apps network rules -// } // loop over Session specific Apps - -std::vector fragOutObjs; -for (auto [uid, descriptor] : helper->get_netdescriptors("Fragment", "DFApplication")) { - fragOutObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid)); -} - -// build up the full list of outputs -std::vector ti_output_objs; -for (auto& fNet : fragOutObjs) { - ti_output_objs.push_back(&fNet); -} -ti_output_objs.push_back(&output_queue_obj); - -auto tch_conf_obj = tch_conf->config_object(); -if (get_source_id() == nullptr) { - throw(BadConf(ERS_HERE, "No source_id associated with this TriggerApplication!")); -} -uint32_t source_id = get_source_id()->get_sid(); -std::string ti_uid(handler_name + "-" + std::to_string(source_id)); -conffwk::ConfigObject ti_obj = obj_fac.create(tch_class, ti_uid); -ti_obj.set_by_val("source_id", source_id); -ti_obj.set_by_val("detector_id", 1); // 1 == kDAQ -ti_obj.set_obj("module_configuration", &tch_conf_obj); -ti_obj.set_objs("enabled_source_ids", sourceIds); -ti_obj.set_objs("mandatory_source_ids", mandatory_sids); -ti_obj.set_objs("inputs", { &input_queue_obj, &dr_net_obj }); -ti_obj.set_objs("outputs", ti_output_objs); - -// Add to our list of modules to return -modules.push_back(obj_fac.get_dal(ti_uid)); - -/************************************************************** - * Instantiate the MLTModule module - **************************************************************/ - -std::vector tdOutObjs; -for (auto [uid, descriptor] : helper->get_netdescriptors("TriggerDecision", "DFOApplication")) { - tdOutObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid)); -} - -std::vector output_conns; -for (auto& tdOut : tdOutObjs) { - output_conns.push_back(&tdOut); -} -conffwk::ConfigObject mlt_obj = obj_fac.create(mlt_conf->get_template_for(), mlt_conf->UID()); -mlt_obj.set_obj("configuration", &(mlt_conf->config_object())); -mlt_obj.set_objs("inputs", { &output_queue_obj, &ti_net_obj }); -mlt_obj.set_objs("outputs", output_conns); -modules.push_back(obj_fac.get_dal(mlt_conf->UID())); - -obj_fac.update_modules(modules); + + // build up the full list of outputs + std::vector ti_output_objs; + for (auto& fNet : fragOutObjs) { + ti_output_objs.push_back(&fNet); + } + ti_output_objs.push_back(&output_queue_obj); + + auto tch_conf_obj = tch_conf->config_object(); + if (get_source_id() == nullptr) { + throw(BadConf(ERS_HERE, "No source_id associated with this TriggerApplication!")); + } + uint32_t source_id = get_source_id()->get_sid(); + std::string ti_uid(handler_name + "-" + std::to_string(source_id)); + conffwk::ConfigObject ti_obj = obj_fac.create(tch_class, ti_uid); + ti_obj.set_by_val("source_id", source_id); + ti_obj.set_by_val("detector_id", 1); // 1 == kDAQ + ti_obj.set_obj("module_configuration", &tch_conf_obj); + ti_obj.set_objs("enabled_source_ids", sourceIds); + ti_obj.set_objs("mandatory_source_ids", mandatory_sids); + ti_obj.set_objs("inputs", { &input_queue_obj, &dr_net_obj }); + ti_obj.set_objs("outputs", ti_output_objs); + + // Add to our list of modules to return + modules.push_back(obj_fac.get_dal(ti_uid)); + + /************************************************************** + * Instantiate the MLTModule module + **************************************************************/ + + std::vector tdOutObjs; + for (auto [uid, descriptor] : helper->get_netdescriptors("TriggerDecision", "DFOApplication")) { + tdOutObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid)); + } + + std::vector output_conns; + for (auto& tdOut : tdOutObjs) { + output_conns.push_back(&tdOut); + } + conffwk::ConfigObject mlt_obj = obj_fac.create(mlt_conf->get_template_for(), mlt_conf->UID()); + mlt_obj.set_obj("configuration", &(mlt_conf->config_object())); + mlt_obj.set_objs("inputs", { &output_queue_obj, &ti_net_obj }); + mlt_obj.set_objs("outputs", output_conns); + modules.push_back(obj_fac.get_dal(mlt_conf->UID())); + + obj_fac.update_modules(modules); } // NOLINT(readability/fn_size) } // namespace appmodel From 5e388ff02954139df6a4728b1af05c5d6e3d13c6 Mon Sep 17 00:00:00 2001 From: Eric Flumerfelt Date: Fri, 2 Oct 2026 15:19:47 -0500 Subject: [PATCH 15/15] Linting fixes --- src/DFApplication.cpp | 3 ++- src/DFOApplication.cpp | 2 +- src/MLTApplication.cpp | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/DFApplication.cpp b/src/DFApplication.cpp index f3f9004..bb2cfc1 100644 --- a/src/DFApplication.cpp +++ b/src/DFApplication.cpp @@ -374,11 +374,12 @@ DFApplication::generate_modules(std::shared_ptr h } std::vector dfsOutputs; - for (auto [uid, descriptor] : helper->get_netdescriptors("DataflowStatus", "DFOApplication")) { + for (auto const& [uid, descriptor] : helper->get_netdescriptors("DataflowStatus", "DFOApplication")) { dfsOutputs.push_back(obj_fac.create_net_obj(descriptor, uid)); } for (auto& dfsOut : dfsOutputs) { + // NOLINTNEXTLINE(performance-inefficient-vector-operation) dfsOutputObjs.push_back(&dfsOut); } diff --git a/src/DFOApplication.cpp b/src/DFOApplication.cpp index 43822f7..852547e 100644 --- a/src/DFOApplication.cpp +++ b/src/DFOApplication.cpp @@ -91,7 +91,7 @@ DFOApplication::generate_modules(std::shared_ptr for (auto const& [uid, descriptor] : helper->get_netdescriptors("TriggerDecision", "DFApplication")) { tdOutObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid)); } - for (auto [uid, descriptor] : helper->get_netdescriptors("DataflowStatusRequest", "DFApplication")) { + for (auto const& [uid, descriptor] : helper->get_netdescriptors("DataflowStatusRequest", "DFApplication")) { tdOutObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid)); } diff --git a/src/MLTApplication.cpp b/src/MLTApplication.cpp index 2f5b2bf..f15a10b 100644 --- a/src/MLTApplication.cpp +++ b/src/MLTApplication.cpp @@ -306,12 +306,13 @@ MLTApplication::generate_modules(std::shared_ptr **************************************************************/ std::vector tdOutObjs; - for (auto [uid, descriptor] : helper->get_netdescriptors("TriggerDecision", "DFOApplication")) { + for (auto const& [uid, descriptor] : helper->get_netdescriptors("TriggerDecision", "DFOApplication")) { tdOutObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid)); } std::vector output_conns; for (auto& tdOut : tdOutObjs) { + // NOLINTNEXTLINE(performance-inefficient-vector-operation) output_conns.push_back(&tdOut); } conffwk::ConfigObject mlt_obj = obj_fac.create(mlt_conf->get_template_for(), mlt_conf->UID());