DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
TRMonReqApplication.cpp
Go to the documentation of this file.
1
24
26
31#include "confmodel/Service.hpp"
32
33#include "logging/Logging.hpp"
34#include "oks/kernel.hpp"
35
36#include <fmt/core.h>
37#include <string>
38#include <vector>
39
40namespace dunedaq {
41namespace appmodel {
42
43void
44TRMonReqApplication::generate_modules(std::shared_ptr<appmodel::ConfigurationHelper> helper) const
45{
46
47 ConfigObjectFactory obj_fac(this);
48
49 std::vector<const confmodel::DaqModule*> modules;
50
51 // Containers for module specific config objects for output/input
52 std::vector<const conffwk::ConfigObject*> trmrOutputObjs;
53
54 // -- First, we process expected Queue and Network connections and create their objects.
55
56 // Process the queue rules looking for the TriggerDecisionToken queue between DataWriterModule and TRMonRequestor
57 const QueueDescriptor* tdtQDesc = nullptr;
58 for (auto rule : get_queue_rules()) {
59 auto destination_class = rule->get_destination_class();
60 if (destination_class == "TRMonRequestorModule") {
61 tdtQDesc = rule->get_descriptor();
62 }
63 }
64 if (tdtQDesc == nullptr) { // BadConf if no descriptor between DataWriterModule and TRMonRequestor
65 throw(BadConf(ERS_HERE, "Could not find queue descriptor rule for TriggerDecisionTokens!"));
66 }
67 // Create queue connection config object
68 auto tdtQueueObj = obj_fac.create_queue_obj(tdtQDesc, UID());
69
70 // Process the network rules looking for the TriggerRecord input for the DataWriter
71 const NetworkConnectionDescriptor* dwNetDesc = nullptr;
72 for (auto rule : get_network_rules()) {
73 auto descriptor = rule->get_descriptor();
74 auto data_type = descriptor->get_data_type();
75 if (data_type == "TriggerRecord") {
76 dwNetDesc = rule->get_descriptor();
77 }
78 }
79 if (dwNetDesc == nullptr) { // BadConf if no descriptor for TriggerRecords into DW
80 throw(BadConf(ERS_HERE, "Could not find network descriptor rule for input TriggerRecords!"));
81 }
82 // Create network connection config object
83 auto dwInputObj = obj_fac.create_net_obj(dwNetDesc, "");
84
85 // Create network connections for all DFApplications in session
86 std::vector<conffwk::ConfigObject> trmonreqNetObjs;
87 for (auto [uid, descriptor]:
88 helper->get_netdescriptors("TRMonRequest", "DFApplication")) {
89 trmonreqNetObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid));
90 }
91
92 // Get pointers to objects here, after vector has been filled so they don't move on us
93 for (auto& obj : trmonreqNetObjs) {
94 trmrOutputObjs.push_back(&obj);
95 }
96
97 // -- Second, we create the Module objects and assign their configs, with the precreated
98 // -- connection config objects above.
99
100 // Get TRB Config Object
101 auto trmrConf = get_trmonreq();
102 if (trmrConf == nullptr) {
103 throw(BadConf(ERS_HERE, "No TRMonRequestor configuration given"));
104 }
105 auto trmrConfObj = trmrConf->config_object();
106 // Prepare TRMR Module Object and assign its Config Object.
107 std::string trmrUid(UID() + "-trmr");
108 conffwk::ConfigObject trmrObj = obj_fac.create("TRMonRequestorModule", trmrUid);
109 trmrObj.set_obj("configuration", &trmrConfObj);
110 trmrObj.set_objs("inputs", { &tdtQueueObj });
111 trmrObj.set_objs("outputs", trmrOutputObjs);
112 trmrObj.set_obj("trigger_record_destination", &dwInputObj);
113 // Push TRMR Module Object from confdb
114 modules.push_back(obj_fac.get_dal<TRMonRequestorModule>(trmrUid));
115
116 // Get DataWriterModule Config Object (only one for now, maybe more later?)
117 auto dwrConf = get_data_writer();
118 if (dwrConf == nullptr) {
119 throw(BadConf(ERS_HERE, "No DataWriterModule configuration given"));
120 }
121
122 auto dwrConfObj = dwrConf->config_object();
123
124 // Prepare DataWriterModule Module Object and assign its Config Object.
125 std::string dwrUid(fmt::format("{}-dw", UID()));
126 conffwk::ConfigObject dwrObj = obj_fac.create("DataWriterModule", dwrUid);
127 dwrObj.set_by_val("writer_identifier", fmt::format("{}_dw", UID()));
128 dwrObj.set_obj("configuration", &dwrConfObj);
129 dwrObj.set_objs("inputs", { &dwInputObj });
130 dwrObj.set_objs("outputs", { &tdtQueueObj });
131 // Push DataWriterModule Module Object from confdb
132 modules.push_back(obj_fac.get_dal<DataWriterModule>(dwrUid));
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_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::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.
void generate_modules(std::shared_ptr< appmodel::ConfigurationHelper >) const override
const dunedaq::appmodel::TRMonRequestorConf * get_trmonreq() const
Get "trmonreq" relationship value. Configuration of the TRMonRequestor to be generated by get_modules...
const dunedaq::appmodel::DataWriterConf * get_data_writer() const
Get "data_writer" 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 std::string & UID() const noexcept
conffwk entry point
Including Qt Headers.
msgpack::object obj