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