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