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 // 23-Sep-2025, KAB et al: prevent a mis-configuration of the system in which the
54 // FakeHSI DLH is told to generate TimeSync messages. (TimeSync messages should only
55 // be sent from Readout DLH modules so that we don't get confusing system behavior.)
56 if (dlhConf->get_generate_timesync()) {
57 throw(BadConf(ERS_HERE, "TimeSync generation is enabled for a FakeHSIApplication and this is not allowed"));
58 }
59
60 const QueueDescriptor* dlhInputQDesc = nullptr;
61
62 for (auto rule : get_queue_rules()) {
63 auto destination_class = rule->get_destination_class();
64 auto data_type = rule->get_descriptor()->get_data_type();
65 if (destination_class == "DataHandlerModule" || destination_class == dlhClass) {
66 dlhInputQDesc = rule->get_descriptor();
67 }
68 }
69
70 const NetworkConnectionDescriptor* dlhReqInputNetDesc = nullptr;
71 const NetworkConnectionDescriptor* tsNetDesc = nullptr;
72 const NetworkConnectionDescriptor* hsiNetDesc = nullptr;
73
74 for (auto rule : get_network_rules()) {
75 auto endpoint_class = rule->get_endpoint_class();
76 auto data_type = rule->get_descriptor()->get_data_type();
77
78 if (endpoint_class == "DataHandlerModule" || endpoint_class == dlhClass) {
79 if (data_type == "TimeSync") {
80 tsNetDesc = rule->get_descriptor();
81 }
82 if (data_type == "DataRequest") {
83 dlhReqInputNetDesc = rule->get_descriptor();
84 }
85 }
86 if (data_type == "HSIEvent") {
87 hsiNetDesc = rule->get_descriptor();
88 }
89 }
90
91 auto rdrConf = get_generator();
92 if (rdrConf == 0) {
93 throw(BadConf(ERS_HERE, "No FakeHSIEventGeneratorModule configuration given"));
94 }
95 if (dlhInputQDesc == nullptr) {
96 throw(BadConf(ERS_HERE, "No DLH data input queue descriptor given"));
97 }
98 if (dlhReqInputNetDesc == nullptr) {
99 throw(BadConf(ERS_HERE, "No DLH request input network descriptor given"));
100 }
101 if (hsiNetDesc == nullptr) {
102 throw(BadConf(ERS_HERE, "No HSIEvent output network descriptor given"));
103 }
104
105 auto idconf = get_source_id();
106 if (idconf == nullptr) {
107 throw(BadConf(ERS_HERE, "No SourceIDConf given"));
108 }
109 auto id = idconf->get_sid();
110
111 auto det_id = 1; // TODO Eric Flumerfelt <eflumerf@fnal.gov>, 08-Feb-2024: This is a magic number corresponding to kDAQ
112 std::string uid("DLH-" + std::to_string(id));
113 TLOG_DEBUG(7) << "creating OKS configuration object for Data Link Handler class " << dlhClass << ", id " << id;
114 conffwk::ConfigObject dlhObj = obj_fac.create(dlhClass, uid);
115 dlhObj.set_by_val<uint32_t>("source_id", id);
116 dlhObj.set_by_val<uint32_t>("detector_id", det_id);
117 dlhObj.set_by_val<bool>("post_processing_enabled", false);
118 dlhObj.set_obj("module_configuration", &dlhConf->config_object());
119
120 // Process special Network rules!
121 // Looking for Fragment rules from DFAppplications in current Session
122 auto sessionApps = session->enabled_applications();
123 std::vector<conffwk::ConfigObject> fragOutObjs;
124 for (auto app : sessionApps) {
125 auto dfapp = app->cast<appmodel::DFApplication>();
126 if (dfapp == nullptr)
127 continue;
128
129 auto dfNRules = dfapp->get_network_rules();
130 for (auto rule : dfNRules) {
131 auto descriptor = rule->get_descriptor();
132 auto data_type = descriptor->get_data_type();
133 if (data_type == "Fragment") {
134 conffwk::ConfigObject frag_conn =
135 obj_fac.create_net_obj(descriptor, dfapp->UID());
136 fragOutObjs.push_back(frag_conn);
137 } // If network rule has TriggerDecision type of data
138 } // Loop over Apps network rules
139 } // loop over Session specific Apps
140
141 // start building the list of outputs
142 std::vector<const conffwk::ConfigObject*> fh_output_objs;
143 for (auto& fNet : fragOutObjs) {
144 fh_output_objs.push_back(&fNet);
145 }
146
147 // Time Sync network connection
148 if (dlhConf->get_generate_timesync()) {
149 conffwk::ConfigObject tsNetObj = obj_fac.create_net_obj(tsNetDesc, std::to_string(id));
150 fh_output_objs.push_back(&tsNetObj);
151 }
152 dlhObj.set_objs("outputs", fh_output_objs);
153
154 conffwk::ConfigObject queueObj = obj_fac.create_queue_sid_obj(dlhInputQDesc, id);
155 conffwk::ConfigObject faNetObj = obj_fac.create_net_obj(dlhReqInputNetDesc, UID());
156
157 dlhObj.set_objs("inputs", { &queueObj, &faNetObj });
158
159 modules.push_back(obj_fac.get_dal<DataHandlerModule>(uid));
160
161 auto hsiServiceObj = hsiNetDesc->get_associated_service()->config_object();
162 conffwk::ConfigObject hsiNetObj = obj_fac.create_net_obj(hsiNetDesc, "");
163
164 std::string genuid("FakeHSI-" + std::to_string(id));
165 conffwk::ConfigObject fakehsiObj =
166 obj_fac.create("FakeHSIEventGeneratorModule", genuid);
167 fakehsiObj.set_obj("configuration", &rdrConf->config_object());
168 fakehsiObj.set_objs("outputs", { &queueObj, &hsiNetObj });
169 if (tsNetDesc != nullptr) {
170 conffwk::ConfigObject tsNetObjIn = obj_fac.create_net_obj(tsNetDesc, ".*");
171 fakehsiObj.set_objs("inputs", { &tsNetObjIn });
172 }
173
174 modules.push_back(obj_fac.get_dal<FakeHSIEventGeneratorModule>(genuid));
175
176 return modules;
177}
178
179} // namespace appmodel
180} // 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
The DUNE-DAQ namespace.