DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
TDECrateApplication.cpp
Go to the documentation of this file.
1
11#include "oks/kernel.hpp"
12#include "logging/Logging.hpp"
13
17#include "confmodel/GeoId.hpp"
19
26
27#include <string>
28#include <vector>
29#include <iostream>
30#include <fmt/core.h>
31
32namespace dunedaq {
33namespace appmodel {
34
35std::vector<const confmodel::DaqModule*>
37{
38 ConfigObjectFactory obj_fac(this);
39
40 std::vector<const confmodel::DaqModule*> modules;
41
42 std::map<std::string, std::vector<const appmodel::TdeAmcDetDataSender*>> ctrlhost_sender_map;
43
44 for (auto d2d_conn_res : get_contains()) {
45 // Are we sure?
46 if (d2d_conn_res->disabled(*session)) {
47 TLOG_DEBUG(7) << "Ignoring disabled DetectorToDaqConnection " << d2d_conn_res->UID();
48 continue;
49 }
50
51 TLOG_DEBUG(6) << "Processing DetectorToDaqConnection " << d2d_conn_res->UID();
52 // get the readout groups and the interfaces and streams therein; 1 reaout group corresponds to 1 data reader module
53 auto d2d_conn = d2d_conn_res->cast<confmodel::DetectorToDaqConnection>();
54
55 if (!d2d_conn) {
56 throw(BadConf(ERS_HERE, "ReadoutApplication contains something other than DetectorToDaqConnection"));
57 }
58
59 if (d2d_conn->get_contains().empty()) {
60 throw(BadConf(ERS_HERE, "DetectorToDaqConnection does not contain senders or receivers"));
61 }
62 auto det_senders = d2d_conn->get_senders();
63
64
65 // Loop over senders
66 for (const auto* sender : det_senders) {
67
68 if ( sender->disabled(*session) ) {
69 TLOG() << "Skipping disabled sender: " << sender->UID();
70 continue;
71 }
72
73 // Check the sender type, must me a TdeAmcDetDataSender
74 const auto* tde_sender = sender->cast<appmodel::TdeAmcDetDataSender>();
75 if (!tde_sender ) {
76 throw(BadConf(ERS_HERE, fmt::format("DataSender {} is not a appmodel::TdeAmcDetDataSender", sender->UID())));
77 }
78
79 ctrlhost_sender_map[tde_sender->get_control_host()].push_back(tde_sender);
80 }
81
82 for( const auto& [ctrlhost, senders] : ctrlhost_sender_map ) {
83 if ( this->get_tde_amc_module_conf() ) {
84 conffwk::ConfigObject tde_obj = obj_fac.create( "TDEAMCModule", fmt::format("tde-ctrl-{}-{}", this->UID(), ctrlhost));
85 // std::string tde_uid = fmt::format("tde-ctrl-{}-{}", this->UID(), ctrlhost);
86 // config->create(dbfile, "TDEAMCModule", tde_uid, tde_obj);
87 tde_obj.set_obj("amc", &(senders[0]->config_object()) ); // for now just allow one AMC per module
88 modules.push_back(obj_fac.get_dal<appmodel::TDEAMCModule>(tde_obj));
89 }
90 }
91 }
92 return modules;
93}
94
95} // namespace appmodel
96} // namespace dunedaq
#define ERS_HERE
const T * get_dal(std::string uid) const
conffwk::ConfigObject create(const std::string &class_name, const std::string &id) const
std::vector< const dunedaq::confmodel::DaqModule * > generate_modules(const confmodel::Session *) const override
const dunedaq::appmodel::TDEAMCModuleConf * get_tde_amc_module_conf() const
Get "tde_amc_module_conf" 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
std::vector< const confmodel::DetDataSender * > get_senders() const
const std::vector< const dunedaq::confmodel::ResourceBase * > & get_contains() const
Get "contains" relationship value. A resource set is a container of resources to easily implement gro...
conffwk entry point
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112
#define TLOG(...)
Definition macro.hpp:22
Including Qt Headers.