DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
TDECrateApplication.cpp
Go to the documentation of this file.
1
11#include "logging/Logging.hpp"
12#include "oks/kernel.hpp"
13
17#include "confmodel/GeoId.hpp"
19
26
27#include <fmt/core.h>
28#include <iostream>
29#include <string>
30#include <vector>
31
32namespace dunedaq {
33namespace appmodel {
34
35std::vector<const confmodel::ExcludableEntity*>
40
41void
42TDECrateApplication::generate_modules(std::shared_ptr<appmodel::ConfigurationHelper> helper) const
43{
44 ConfigObjectFactory obj_fac(this);
45
46 std::vector<const confmodel::DaqModule*> modules;
47
48 std::map<std::string, std::vector<const appmodel::TdeAmcDetDataSender*>> ctrlhost_sender_map;
49
50 for (auto d2d_conn : get_detector_connections()) {
51 // Are we sure?
52 if (helper->is_excluded(d2d_conn)) {
53 TLOG_DEBUG(7) << "Ignoring excluded DetectorToDaqConnection " << d2d_conn->UID();
54 continue;
55 }
56
57 TLOG_DEBUG(6) << "Processing DetectorToDaqConnection " << d2d_conn->UID();
58 // get the readout groups and the interfaces and streams therein; 1 reaout group corresponds to 1 data reader module
59
60 auto det_senders = d2d_conn->senders();
61 // Should not be necessary, schema doesn't allow 0 senders
62 if (det_senders.empty()) {
63 throw(BadConf(ERS_HERE, "DetectorToDaqConnection does not contain senders"));
64 }
65
66 // Loop over senders
67 for (const auto* sender : det_senders) {
68
69 if (helper->is_excluded(sender)) {
70 TLOG() << "Skipping excluded sender: " << sender->UID();
71 continue;
72 }
73
74 // Check the sender type, must me a TdeAmcDetDataSender
75 const auto* tde_sender = sender->cast<appmodel::TdeAmcDetDataSender>();
76 if (!tde_sender) {
77 throw(BadConf(ERS_HERE, fmt::format("DataSender {} is not a appmodel::TdeAmcDetDataSender", sender->UID())));
78 }
79
80 ctrlhost_sender_map[tde_sender->get_control_host()].push_back(tde_sender);
81 }
82 }
83
84 for (const auto& [ctrlhost, senders] : ctrlhost_sender_map) {
85
86 // std::cout << "this->UID()='" << this->UID() << "' ctrlhost='" << ctrlhost << "'" << std::endl;
87 if (this->get_tde_amc_module_conf()) {
88 conffwk::ConfigObject tde_obj =
89 obj_fac.create("TDEAMCModule", fmt::format("tde-ctrl-{}-{}", this->UID(), ctrlhost));
90 // std::string tde_uid = fmt::format("tde-ctrl-{}-{}", this->UID(), ctrlhost);
91 // config->create(dbfile, "TDEAMCModule", tde_uid, tde_obj);
92 tde_obj.set_obj("amc", &(senders[0]->config_object())); // for now just allow one AMC per module
93 modules.push_back(obj_fac.get_dal<appmodel::TDEAMCModule>(tde_obj));
94 }
95 }
96 obj_fac.update_modules(modules);
97}
98
99} // namespace appmodel
100} // namespace dunedaq
#define ERS_HERE
void update_modules(const std::vector< const confmodel::DaqModule * > &modules)
const T * get_dal(std::string uid) const
conffwk::ConfigObject create(const std::string &class_name, const std::string &id) const
virtual std::vector< const ExcludableEntity * > contained_excludable_entities() const override
const dunedaq::appmodel::TDEAMCModuleConf * get_tde_amc_module_conf() const
Get "tde_amc_module_conf" relationship value.
void generate_modules(std::shared_ptr< appmodel::ConfigurationHelper >) const override
const std::vector< const dunedaq::confmodel::DetectorToDaqConnection * > & get_detector_connections() const
Get "detector_connections" relationship value.
void set_obj(const std::string &name, const ConfigObject *o, bool skip_non_null_check=false)
Set relationship single-value.
const ConfigObject & config_object() const
const std::string & UID() const noexcept
conffwk entry point
std::vector< const dunedaq::confmodel::ExcludableEntity * > to_resources(const std::vector< T * > &vector_of_children)
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:116
#define TLOG(...)
Definition macro.hpp:21
The DUNE-DAQ namespace.