DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
TriggerApplication.cpp
Go to the documentation of this file.
1
14
18#include "confmodel/Service.hpp"
19
24
27
30
33
35
38
39#include "logging/Logging.hpp"
40
41#include <string>
42#include <vector>
43
44namespace dunedaq {
45namespace appmodel {
46
59 const NetworkConnectionDescriptor* ntDesc,
61 const std::string& dbfile)
62{
63 auto ntServiceObj = ntDesc->get_associated_service()->config_object();
65 confdb->create(dbfile, "NetworkConnection", uid, ntObj);
66 ntObj.set_by_val<std::string>("data_type", ntDesc->get_data_type());
67 ntObj.set_by_val<std::string>("connection_type", ntDesc->get_connection_type());
68 ntObj.set_obj("associated_service", &ntServiceObj);
69
70 return ntObj;
71}
72
73
74void
75TriggerApplication::generate_modules(std::shared_ptr<appmodel::ConfigurationHelper> helper) const
76{
77
78 std::vector<const confmodel::DaqModule*> modules;
79
80 ConfigObjectFactory obj_fac(this);
81
82 auto ti_conf = get_trigger_inputs_handler();
83 auto ti_class = ti_conf->get_template_for();
84 std::string handler_name("");
85 // Process the queue rules looking for inputs to our trigger handler modules
86 const QueueDescriptor* ti_inputq_desc = nullptr;
87
88 for (auto rule : get_queue_rules()) {
89 auto destination_class = rule->get_destination_class();
90 auto data_type = rule->get_descriptor()->get_data_type();
91 if (destination_class == "DataHandlerModule" || destination_class == ti_class) {
92 ti_inputq_desc = rule->get_descriptor();
93 }
94 }
95 // Process the network rules looking for the TP handler data reuest inputs
96 const NetworkConnectionDescriptor* req_net_desc = nullptr;
97 const NetworkConnectionDescriptor* tin_net_desc = nullptr;
98 const NetworkConnectionDescriptor* tout_net_desc = nullptr;
99 const NetworkConnectionDescriptor* tset_out_net_desc = nullptr;
100 for (auto rule : get_network_rules()) {
101 auto endpoint_class = rule->get_endpoint_class();
102 auto data_type = rule->get_descriptor()->get_data_type();
103
104 if (data_type == "DataRequest") {
105 req_net_desc = rule->get_descriptor();
106 }
107 else if (data_type == "TASet" || data_type == "TCSet"){
108 tset_out_net_desc = rule->get_descriptor();
109 }
110 else if (endpoint_class == "DataSubscriberModule") {
111 if (!tin_net_desc) {
112 tin_net_desc = rule->get_descriptor();
113 }
114 else if (rule->get_descriptor()->get_data_type() == tin_net_desc->get_data_type()) {
115 // For now endpoint_class of DataSubscriberModule for both input and output
116 // with the same data type is not possible.
117 throw (BadConf(ERS_HERE, "Have two network connections of the same data_type and the same endpoint_class"));
118 }
119 else if (tin_net_desc->get_data_type() == "TriggerActivity" &&
120 rule->get_descriptor()->get_data_type() == "TriggerCandidate") {
121 // For TA->TC
122 tout_net_desc = rule->get_descriptor();
123 handler_name = "tahandler";
124 }
125 else if (tin_net_desc->get_data_type() == "TriggerCandidate" &&
126 rule->get_descriptor()->get_data_type() == "TriggerActivity") {
127 // For TA->TC if we saved TC network connection as input first...
128 tout_net_desc = tin_net_desc;
129 tin_net_desc = rule->get_descriptor();
130 handler_name = "tahandler";
131 }
132 else {
133 throw (BadConf(ERS_HERE, "Unexpected input & output network connection descriptors provided"));
134 }
135 }
136 else if (data_type == "TriggerActivity" || data_type == "TriggerCandidate"){
137 tout_net_desc = rule->get_descriptor();
138 if (data_type == "TriggerActivity")
139 handler_name = "tphandler";
140 else
141 handler_name = "tahandler";
142 }
143 }
144
145 // Process special Network rules!
146 std::vector<conffwk::ConfigObject> fragOutObjs;
147 for (auto [uid, descriptor]:
148 helper->get_netdescriptors("Fragment", "DFApplication")) {
149 fragOutObjs.push_back(obj_fac.create_net_obj(descriptor, uid));
150 }
151 if ( req_net_desc== nullptr) {
152 throw (BadConf(ERS_HERE, "No network descriptor given to receive request and send data was set"));
153 }
154 if ( tin_net_desc== nullptr) {
155 throw (BadConf(ERS_HERE, "No network descriptor given to receive trigger objects"));
156 }
157 if ( tout_net_desc== nullptr) {
158 throw (BadConf(ERS_HERE, "No network descriptor given to publish trigger objects"));
159 }
160 if (ti_inputq_desc == nullptr) {
161 throw (BadConf(ERS_HERE, "No data input queue descriptor given"));
162 }
163
164 auto input_queue_obj = obj_fac.create_queue_obj(ti_inputq_desc);
165
166 auto req_net_obj = obj_fac.create_net_obj(req_net_desc, UID());
167
168 auto tin_net_obj = obj_fac.create_net_obj(tin_net_desc, ".*");
169
170 auto tout_net_obj = obj_fac.create_net_obj(tout_net_desc, UID());
171 conffwk::ConfigObject tset_out_net_obj;
172 if (tset_out_net_desc) {
173 tset_out_net_obj = obj_fac.create_net_obj(tset_out_net_desc, UID());
174 }
175
176
177 // build up the full list of outputs
178 std::vector<const conffwk::ConfigObject*> ti_output_objs;
179 for (auto& fNet : fragOutObjs) {
180 ti_output_objs.push_back(&fNet);
181 }
182 ti_output_objs.push_back(&tout_net_obj);
183 if (tset_out_net_desc!= nullptr) {
184 ti_output_objs.push_back(&tset_out_net_obj);
185 }
186
187 if (get_source_id() == nullptr) {
188 throw(BadConf(ERS_HERE, "No source_id associated with this TriggerApplication!"));
189 }
190 uint32_t source_id = get_source_id()->get_sid();
191 std::string ti_uid(handler_name + "-" + std::to_string(source_id));
192 auto ti_obj = obj_fac.create(ti_class, ti_uid);
193
194 ti_obj.set_by_val<uint32_t>("source_id", source_id);
195 ti_obj.set_by_val<uint32_t>("detector_id", 1); // 1 == kDAQ
196 ti_obj.set_by_val<bool>("post_processing_enabled", !get_tx_generation_disabled());
197
198 auto ti_conf_obj = ti_conf->config_object();
199 ti_obj.set_obj("module_configuration", &ti_conf_obj);
200 ti_obj.set_objs("inputs", {&input_queue_obj, &req_net_obj});
201 ti_obj.set_objs("outputs", ti_output_objs);
202 // Add to our list of modules to return
203 modules.push_back(obj_fac.get_dal<DataHandlerModule>(ti_uid));
204
205
206 // Now create the DataSubscriberModule object
207 auto rdr_conf = get_data_subscriber();
208 if (rdr_conf == nullptr) {
209 throw (BadConf(ERS_HERE, "No DataReaderModule configuration given"));
210 }
211
212 // Create a DataReaderModule
213
214 std::string reader_uid("data-reader-"+UID());
215 std::string reader_class = rdr_conf->get_template_for();
216 TLOG_DEBUG(7) << "creating OKS configuration object for Data subscriber class " << reader_class;
217 auto reader_obj = obj_fac.create(reader_class, reader_uid);
218 reader_obj.set_objs("inputs", {&tin_net_obj} );
219 reader_obj.set_objs("outputs", {&input_queue_obj} );
220 reader_obj.set_obj("configuration", &rdr_conf->config_object());
221
222 modules.push_back(obj_fac.get_dal<DataSubscriberModule>(reader_uid));
223
224
225 obj_fac.update_modules(modules);
226}
227
228} // namespace appmodel
229} // namespace dunedaq
#define ERS_HERE
void update_modules(const std::vector< const confmodel::DaqModule * > &modules)
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_queue_obj(const QueueDescriptor *qdesc, std::string uid="") const
conffwk::ConfigObject create(const std::string &class_name, const std::string &id) const
const std::string & get_connection_type() const
Get "connection_type" attribute value.
const std::string & get_data_type() const
Get "data_type" attribute value. string identifying type of data transferred through this connection.
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.
uint32_t get_sid() const
Get "sid" attribute value.
const dunedaq::appmodel::DataHandlerConf * get_trigger_inputs_handler() const
Get "trigger_inputs_handler" relationship value.
const dunedaq::appmodel::DataReaderConf * get_data_subscriber() const
Get "data_subscriber" relationship value.
bool get_tx_generation_disabled() const
Get "tx_generation_disabled" attribute value. Disable TA/TC generation as a post-processing task – on...
void generate_modules(std::shared_ptr< appmodel::ConfigurationHelper >) const override
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.
void create(const std::string &at, const std::string &class_name, const std::string &id, ConfigObject &object)
Create new object by class name and object id.
const ConfigObject & config_object() const
const std::string & UID() const noexcept
conffwk entry point
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112
conffwk::ConfigObject create_network_connection(std::string uid, const NetworkConnectionDescriptor *ntDesc, conffwk::Configuration *confdb, const std::string &dbfile)
Helper function that gets a network connection config.
Including Qt Headers.