DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
FakeDataApplication.cpp
Go to the documentation of this file.
1
13
15#include "oks/kernel.hpp"
16
19// #include "confmodel/ReadoutGroup.hpp"
21#include "confmodel/Service.hpp"
22#include "confmodel/Session.hpp"
23
33
35
36#include "logging/Logging.hpp"
37
38#include <string>
39#include <vector>
40
41namespace dunedaq {
42namespace appmodel {
43
44//-----------------------------------------------------------------------------
45
46std::vector<const confmodel::Resource*>
50
51void
53{
54 // oks::OksFile::set_nolock_mode(true);
55
56 std::vector<const confmodel::DaqModule*> modules;
57
58 ConfigObjectFactory obj_fac(this);
59
60
61 // Process the queue rules looking for inputs to our DL/TP handler modules
62 const QueueDescriptor* dlhReqInputQDesc = nullptr;
63 const QueueDescriptor* faOutputQDesc = nullptr;
64
65 for (auto rule : get_queue_rules()) {
66 auto destination_class = rule->get_destination_class();
67 auto data_type = rule->get_descriptor()->get_data_type();
68 if (destination_class == "FakeDataProdModule") {
69 if (data_type == "DataRequest") {
70 dlhReqInputQDesc = rule->get_descriptor();
71 }
72 } else if (destination_class == "FragmentAggregatorModule") {
73 faOutputQDesc = rule->get_descriptor();
74 }
75 }
76 if (faOutputQDesc == nullptr) {
77 throw(BadConf(ERS_HERE, "No fragment output queue descriptor given"));
78 }
79 if (dlhReqInputQDesc == nullptr) {
80 throw(BadConf(ERS_HERE, "No DLH request input queue descriptor given"));
81 }
82 // Process the network rules looking for the Fragment Aggregator and TP handler data reuest inputs
83 const NetworkConnectionDescriptor* faNetDesc = nullptr;
84 const NetworkConnectionDescriptor* tsNetDesc = nullptr;
85 for (auto rule : get_network_rules()) {
86 auto endpoint_class = rule->get_endpoint_class();
87 if (endpoint_class == "FragmentAggregatorModule") {
88 faNetDesc = rule->get_descriptor();
89 } else if (endpoint_class == "FakeDataProdModule") {
90 tsNetDesc = rule->get_descriptor();
91 }
92 }
93 if (faNetDesc == nullptr) {
94 throw(BadConf(ERS_HERE, "No Fragment output network descriptor given"));
95 }
96 if (tsNetDesc == nullptr) {
97 throw(BadConf(ERS_HERE, "No TimeSync output network descriptor given"));
98 }
99
100 // Create here the Queue on which all data fragments are forwarded to the fragment aggregator
101 // and a container for the queues of data request to TP handler and DLH
102
103 std::vector<const confmodel::Connection*> faOutputQueues;
104
105 conffwk::ConfigObject faQueueObj = obj_fac.create_queue_obj(faOutputQDesc, UID());
106
107 // Create a FakeDataProdModule for each stream of this Readout Group
108 for (auto fdpConf : get_producers()) {
109 if (fdpConf->is_disabled(*session)) {
110 TLOG_DEBUG(7) << "Ignoring disabled FakeDataProdConf " << fdpConf->UID();
111 continue;
112 }
113
114 auto stream = fdpConf->cast<appmodel::FakeDataProdConf>();
115 if (stream == nullptr) {
116 throw(BadConf(ERS_HERE, "ReadoutGroup contains something other than FakeDataProdConf"));
117 }
118
119 auto id = stream->get_source_id();
120 std::string uid("FakeDataProdModule-" + std::to_string(id));
121 TLOG_DEBUG(7) << "creating OKS configuration object for FakeDataProdModule";
122 conffwk::ConfigObject dlhObj = obj_fac.create("FakeDataProdModule", uid);
123 dlhObj.set_obj("configuration", &stream->config_object());
124
125 // Time Sync network connection
126 auto tsNetObj = obj_fac.create_net_obj(tsNetDesc, std::to_string(id));
127
128 dlhObj.set_objs("outputs", { &faQueueObj, &tsNetObj });
129
130 auto reqQueueObj = obj_fac.create_queue_sid_obj(dlhReqInputQDesc, id);
131
132 // Add the requessts queue dal pointer to the outputs of the FragmentAggregatorModule
133 faOutputQueues.push_back(obj_fac.get_dal<confmodel::Connection>(
134 dlhReqInputQDesc->get_uid_base() + std::to_string(id)));
135
136 dlhObj.set_objs("inputs", { &reqQueueObj });
137
138 modules.push_back(obj_fac.get_dal<FakeDataProdModule>(uid));
139 }
140
141 // Finally create Fragment Aggregator
142 auto aggregator_conf = get_fragment_aggregator();
143 if (aggregator_conf == 0) {
144 throw(BadConf(ERS_HERE, "No FragmentAggregatorModule configuration given"));
145 }
146 std::string faUid("fragmentaggregator-" + UID());
147 TLOG_DEBUG(7) << "creating OKS configuration object for Fragment Aggregator class ";
148 conffwk::ConfigObject faObj = obj_fac.create("FragmentAggregatorModule", faUid);
149
150 // Add network connection to TRBs
151 conffwk::ConfigObject faNetObj = obj_fac.create_net_obj(faNetDesc, UID());
152
153 // Add output queueus of data requests
154 std::vector<const conffwk::ConfigObject*> qObjs;
155 for (auto q : faOutputQueues) {
156 qObjs.push_back(&q->config_object());
157 }
158 faObj.set_obj("configuration", &aggregator_conf->config_object());
159 faObj.set_objs("inputs", { &faNetObj, &faQueueObj });
160 faObj.set_objs("outputs", qObjs);
161
162 modules.push_back(obj_fac.get_dal<FragmentAggregatorModule>(faUid));
163
164 obj_fac.update_modules(modules);
165}
166
167} // namespace appmodel
168} // 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_queue_obj(const QueueDescriptor *qdesc, std::string uid="") const
conffwk::ConfigObject create(const std::string &class_name, const std::string &id) const
const dunedaq::appmodel::FragmentAggregatorConf * get_fragment_aggregator() const
Get "fragment_aggregator" relationship value.
const std::vector< const dunedaq::appmodel::FakeDataProdConf * > & get_producers() const
Get "producers" relationship value. List of configurations of fake data producer modules to be used b...
void generate_modules(const confmodel::Session *) const override
virtual std::vector< const Resource * > contained_resources() const override
uint32_t get_source_id() const
Get "source_id" attribute value. The SourceID of this link.
const std::string & get_uid_base() const
Get "uid_base" attribute value. Base for UID string. May be combined with a source id.
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 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
std::vector< const dunedaq::confmodel::Resource * > to_resources(const std::vector< T * > &vector_of_children)
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112
The DUNE-DAQ namespace.