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