DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
DTSHSIApplication.cpp
Go to the documentation of this file.
1
27#include "confmodel/Service.hpp"
28#include "logging/Logging.hpp"
30
31#include <iostream>
32#include <string>
33#include <vector>
34
35namespace dunedaq {
36namespace appmodel {
37
38
39void
40DTSHSIApplication::generate_modules(std::shared_ptr<appmodel::ConfigurationHelper> /*helper*/) const
41{
42 ConfigObjectFactory obj_fac(this);
43
44 std::vector<const confmodel::DaqModule*> modules;
45
46 auto dlhConf = get_link_handler();
47 auto dlhClass = dlhConf->get_template_for();
48
49 const QueueDescriptor* dlhInputQDesc = nullptr;
50
51 for (auto rule : get_queue_rules()) {
52 auto destination_class = rule->get_destination_class();
53 auto data_type = rule->get_descriptor()->get_data_type();
54 if (destination_class == "DataHandlerModule" || destination_class == dlhClass) {
55 dlhInputQDesc = rule->get_descriptor();
56 }
57 }
58
59 const NetworkConnectionDescriptor* dlhReqInputNetDesc = nullptr;
60 const NetworkConnectionDescriptor* tsNetDesc = nullptr;
61 const NetworkConnectionDescriptor* hsiNetDesc = nullptr;
62
63 for (auto rule : get_network_rules()) {
64 auto endpoint_class = rule->get_endpoint_class();
65 auto data_type = rule->get_descriptor()->get_data_type();
66
67 if (endpoint_class == "DataHandlerModule" || endpoint_class == dlhClass) {
68 if (data_type == "TimeSync") {
69 tsNetDesc = rule->get_descriptor();
70 }
71 if (data_type == "DataRequest") {
72 dlhReqInputNetDesc = rule->get_descriptor();
73 }
74 }
75 if (data_type == "HSIEvent") {
76 hsiNetDesc = rule->get_descriptor();
77 }
78 }
79
80 auto rdrConf = get_generator();
81 if (rdrConf == 0) {
82 throw(BadConf(ERS_HERE, "No HSIEventGeneratorModule configuration given"));
83 }
84 if (dlhInputQDesc == nullptr) {
85 throw(BadConf(ERS_HERE, "No DLH data input queue descriptor given"));
86 }
87 if (dlhReqInputNetDesc == nullptr) {
88 throw(BadConf(ERS_HERE, "No DLH request input network descriptor given"));
89 }
90 if (hsiNetDesc == nullptr) {
91 throw(BadConf(ERS_HERE, "No HSIEvent output network descriptor given"));
92 }
93
94 auto idconf = get_source_id();
95 if (idconf == nullptr) {
96 throw(BadConf(ERS_HERE, "No SourceIDConf given"));
97 }
98 auto id = idconf->get_sid();
99
100 auto det_id = 1; // TODO Eric Flumerfelt <eflumerf@fnal.gov>, 08-Feb-2024: This is a magic number corresponding to kDAQ
101 std::string uid("DLH-" + std::to_string(id));
102 TLOG_DEBUG(7) << "creating OKS configuration object for Data Link Handler class " << dlhClass << ", id " << id;
103 conffwk::ConfigObject dlhObj = obj_fac.create(dlhClass, uid);
104 dlhObj.set_by_val<uint32_t>("source_id", id);
105 dlhObj.set_by_val<uint32_t>("detector_id", det_id);
106 dlhObj.set_by_val<bool>("post_processing_enabled", false);
107 dlhObj.set_obj("module_configuration", &dlhConf->config_object());
108
109 // Time Sync network connection
110 if (dlhConf->get_generate_timesync()) {
111 auto tsServiceObj = tsNetDesc->get_associated_service()->config_object();
112 auto tsNetObj = obj_fac.create_net_obj(tsNetDesc, std::to_string(id));
113
114 dlhObj.set_objs("outputs", { &tsNetObj });
115 } else {
116 dlhObj.set_objs("outputs", {});
117 }
118 conffwk::ConfigObject queueObj = obj_fac.create_queue_sid_obj(dlhInputQDesc,id);
119 conffwk::ConfigObject faNetObj = obj_fac.create_net_obj(dlhReqInputNetDesc, UID());
120 dlhObj.set_objs("inputs", { &queueObj, &faNetObj });
121
122 modules.push_back(obj_fac.get_dal<DataHandlerModule>(uid));
123
124 auto hsiServiceObj = hsiNetDesc->get_associated_service()->config_object();
125 conffwk::ConfigObject hsiNetObj = obj_fac.create_net_obj(hsiNetDesc, "");
126
127 std::string genuid("HSI-" + std::to_string(id));
128 conffwk::ConfigObject hsiObj = obj_fac.create("HSIReadout", genuid);
129 hsiObj.set_obj("configuration", &rdrConf->config_object());
130 hsiObj.set_objs("outputs", { &queueObj, &hsiNetObj });
131
132 modules.push_back(obj_fac.get_dal<HSIReadout>(genuid));
133
134 obj_fac.update_modules(modules);
135}
136
137} // namespace appmodel
138} // namespace dunedaq
#define ERS_HERE
void update_modules(const std::vector< const confmodel::DaqModule * > &modules)
conffwk::ConfigObject create_queue_sid_obj(const QueueDescriptor *qdesc, uint32_t src_id) const
conffwk::ConfigObject create_net_obj(const NetworkConnectionDescriptor *ndesc, std::string uid) const
Helper function that gets a network connection config.
const T * get_dal(std::string uid) const
conffwk::ConfigObject create(const std::string &class_name, const std::string &id) const
const dunedaq::appmodel::DataHandlerConf * get_link_handler() const
Get "link_handler" relationship value.
void generate_modules(std::shared_ptr< appmodel::ConfigurationHelper >) const override
const dunedaq::appmodel::HSIReadoutConf * get_generator() const
Get "generator" relationship value.
const dunedaq::confmodel::Service * get_associated_service() const
Get "associated_service" relationship value. Service provided by this connection.
const std::vector< const dunedaq::appmodel::NetworkConnectionRule * > & get_network_rules() const
Get "network_rules" relationship value.
const std::vector< const dunedaq::appmodel::QueueConnectionRule * > & get_queue_rules() const
Get "queue_rules" relationship value.
const dunedaq::appmodel::SourceIDConf * get_source_id() const
Get "source_id" relationship value.
void set_by_val(const std::string &name, T value)
Set attribute value.
void set_objs(const std::string &name, const std::vector< const ConfigObject * > &o, bool skip_non_null_check=false)
Set relationship multi-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
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112
Including Qt Headers.