DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
FakeHSIApplication.cpp
Go to the documentation of this file.
1
27#include "confmodel/Service.hpp"
28#include "logging/Logging.hpp"
29#include "oks/kernel.hpp"
31
32#include <iostream>
33#include <string>
34#include <vector>
35
36using namespace dunedaq;
37using namespace dunedaq::appmodel;
38
39namespace dunedaq {
40namespace appmodel {
41
42std::vector<const confmodel::DaqModule*>
44{
45 std::vector<const confmodel::DaqModule*> modules;
46
47 ConfigObjectFactory obj_fac(this);
48
49
50 auto dlhConf = get_link_handler();
51 auto dlhClass = dlhConf->get_template_for();
52
53 const QueueDescriptor* dlhInputQDesc = nullptr;
54
55 for (auto rule : get_queue_rules()) {
56 auto destination_class = rule->get_destination_class();
57 auto data_type = rule->get_descriptor()->get_data_type();
58 if (destination_class == "DataHandlerModule" || destination_class == dlhClass) {
59 dlhInputQDesc = rule->get_descriptor();
60 }
61 }
62
63 const NetworkConnectionDescriptor* dlhReqInputNetDesc = nullptr;
64 const NetworkConnectionDescriptor* tsNetDesc = nullptr;
65 const NetworkConnectionDescriptor* hsiNetDesc = nullptr;
66
67 for (auto rule : get_network_rules()) {
68 auto endpoint_class = rule->get_endpoint_class();
69 auto data_type = rule->get_descriptor()->get_data_type();
70
71 if (endpoint_class == "DataHandlerModule" || endpoint_class == dlhClass) {
72 if (data_type == "TimeSync") {
73 tsNetDesc = rule->get_descriptor();
74 }
75 if (data_type == "DataRequest") {
76 dlhReqInputNetDesc = rule->get_descriptor();
77 }
78 }
79 if (data_type == "HSIEvent") {
80 hsiNetDesc = rule->get_descriptor();
81 }
82 }
83
84 auto rdrConf = get_generator();
85 if (rdrConf == 0) {
86 throw(BadConf(ERS_HERE, "No FakeHSIEventGeneratorModule configuration given"));
87 }
88 if (dlhInputQDesc == nullptr) {
89 throw(BadConf(ERS_HERE, "No DLH data input queue descriptor given"));
90 }
91 if (dlhReqInputNetDesc == nullptr) {
92 throw(BadConf(ERS_HERE, "No DLH request input network descriptor given"));
93 }
94 if (hsiNetDesc == nullptr) {
95 throw(BadConf(ERS_HERE, "No HSIEvent output network descriptor given"));
96 }
97
98 auto idconf = get_source_id();
99 if (idconf == nullptr) {
100 throw(BadConf(ERS_HERE, "No SourceIDConf given"));
101 }
102 auto id = idconf->get_sid();
103
104 auto det_id = 1; // TODO Eric Flumerfelt <eflumerf@fnal.gov>, 08-Feb-2024: This is a magic number corresponding to kDAQ
105 std::string uid("DLH-" + std::to_string(id));
106 TLOG_DEBUG(7) << "creating OKS configuration object for Data Link Handler class " << dlhClass << ", id " << id;
107 conffwk::ConfigObject dlhObj = obj_fac.create(dlhClass, uid);
108 dlhObj.set_by_val<uint32_t>("source_id", id);
109 dlhObj.set_by_val<uint32_t>("detector_id", det_id);
110 dlhObj.set_by_val<bool>("post_processing_enabled", false);
111 dlhObj.set_obj("module_configuration", &dlhConf->config_object());
112
113 // Process special Network rules!
114 // Looking for Fragment rules from DFAppplications in current Session
115 auto sessionApps = session->get_enabled_applications();
116 std::vector<conffwk::ConfigObject> fragOutObjs;
117 for (auto app : sessionApps) {
118 auto dfapp = app->cast<appmodel::DFApplication>();
119 if (dfapp == nullptr)
120 continue;
121
122 auto dfNRules = dfapp->get_network_rules();
123 for (auto rule : dfNRules) {
124 auto descriptor = rule->get_descriptor();
125 auto data_type = descriptor->get_data_type();
126 if (data_type == "Fragment") {
127 conffwk::ConfigObject frag_conn =
128 obj_fac.create_net_obj(descriptor, dfapp->UID());
129 fragOutObjs.push_back(frag_conn);
130 } // If network rule has TriggerDecision type of data
131 } // Loop over Apps network rules
132 } // loop over Session specific Apps
133
134 // start building the list of outputs
135 std::vector<const conffwk::ConfigObject*> fh_output_objs;
136 for (auto& fNet : fragOutObjs) {
137 fh_output_objs.push_back(&fNet);
138 }
139
140 // Time Sync network connection
141 if (dlhConf->get_generate_timesync()) {
142 conffwk::ConfigObject tsNetObj = obj_fac.create_net_obj(tsNetDesc, std::to_string(id));
143 fh_output_objs.push_back(&tsNetObj);
144 }
145 dlhObj.set_objs("outputs", fh_output_objs);
146
147 conffwk::ConfigObject queueObj = obj_fac.create_queue_sid_obj(dlhInputQDesc, id);
148 conffwk::ConfigObject faNetObj = obj_fac.create_net_obj(dlhReqInputNetDesc, UID());
149
150 dlhObj.set_objs("inputs", { &queueObj, &faNetObj });
151
152 modules.push_back(obj_fac.get_dal<DataHandlerModule>(uid));
153
154 auto hsiServiceObj = hsiNetDesc->get_associated_service()->config_object();
155 conffwk::ConfigObject hsiNetObj = obj_fac.create_net_obj(hsiNetDesc, "");
156
157 std::string genuid("FakeHSI-" + std::to_string(id));
158 conffwk::ConfigObject fakehsiObj =
159 obj_fac.create("FakeHSIEventGeneratorModule", genuid);
160 fakehsiObj.set_obj("configuration", &rdrConf->config_object());
161 fakehsiObj.set_objs("outputs", { &queueObj, &hsiNetObj });
162
163 modules.push_back(obj_fac.get_dal<FakeHSIEventGeneratorModule>(genuid));
164
165 return modules;
166}
167
168} // namespace appmodel
169} // 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(const std::string &class_name, const std::string &id) const
const dunedaq::appmodel::DataHandlerConf * get_link_handler() const
Get "link_handler" relationship value.
std::vector< const dunedaq::confmodel::DaqModule * > generate_modules(const confmodel::Session *) const override
const dunedaq::appmodel::FakeHSIEventGeneratorConf * get_generator() const
Get "generator" relationship value.
const dunedaq::confmodel::Service * get_associated_service() const
Get "associated_service" relationship value. Service provided by this connection.
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.
const dunedaq::appmodel::SourceIDConf * get_source_id() const
Get "source_id" 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 ConfigObject & config_object() const
const std::string & UID() const noexcept
conffwk entry point
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112
Including Qt Headers.