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