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::Resource*>
39
40std::vector<const confmodel::DaqModule*>
42{
43 ConfigObjectFactory obj_fac(this);
44
45 std::vector<const confmodel::DaqModule*> modules;
46
47 std::map<std::string, std::vector<const appmodel::TdeAmcDetDataSender*>> ctrlhost_sender_map;
48
49 for (auto d2d_conn : get_detector_connections()) {
50 // Are we sure?
51 if (d2d_conn->is_disabled(*session)) {
52 TLOG_DEBUG(7) << "Ignoring disabled DetectorToDaqConnection " << d2d_conn->UID();
53 continue;
54 }
55
56 TLOG_DEBUG(6) << "Processing DetectorToDaqConnection " << d2d_conn->UID();
57 // get the readout groups and the interfaces and streams therein; 1 reaout group corresponds to 1 data reader module
58
59 auto det_senders = d2d_conn->senders();
60 // Should not be necessary, schema doesn't allow 0 senders
61 if (det_senders.empty()) {
62 throw(BadConf(ERS_HERE, "DetectorToDaqConnection does not contain senders"));
63 }
64
65 // Loop over senders
66 for (const auto* sender : det_senders) {
67
68 if ( sender->is_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
83 for( const auto& [ctrlhost, senders] : ctrlhost_sender_map ) {
84
85 // std::cout << "this->UID()='" << this->UID() << "' ctrlhost='" << ctrlhost << "'" << std::endl;
86 if ( this->get_tde_amc_module_conf() ) {
87 conffwk::ConfigObject tde_obj = obj_fac.create( "TDEAMCModule", fmt::format("tde-ctrl-{}-{}", this->UID(), ctrlhost));
88 // std::string tde_uid = fmt::format("tde-ctrl-{}-{}", this->UID(), ctrlhost);
89 // config->create(dbfile, "TDEAMCModule", tde_uid, tde_obj);
90 tde_obj.set_obj("amc", &(senders[0]->config_object()) ); // for now just allow one AMC per module
91 modules.push_back(obj_fac.get_dal<appmodel::TDEAMCModule>(tde_obj));
92 }
93 }
94 return modules;
95}
96
97} // namespace appmodel
98} // 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
virtual std::vector< const Resource * > contained_resources() const override
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.
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::Resource * > to_resources(const std::vector< T * > &vector_of_children)
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112
#define TLOG(...)
Definition macro.hpp:22
The DUNE-DAQ namespace.
Definition DataStore.hpp:57