DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
FakeHSIApplication.cpp
Go to the documentation of this file.
1
10
27#include "confmodel/Service.hpp"
28#include "logging/Logging.hpp"
29#include "oks/kernel.hpp"
30
31#include <iostream>
32#include <string>
33#include <vector>
34
35namespace dunedaq {
36namespace appmodel {
37
38void
39FakeHSIApplication::generate_modules(std::shared_ptr<appmodel::ConfigurationHelper> helper) const
40{
41 std::vector<const confmodel::DaqModule*> modules;
42
43 ConfigObjectFactory obj_fac(this);
44
45 auto dlhConf = get_link_handler();
46 auto dlhClass = dlhConf->get_template_for();
47
48 // 23-Sep-2025, KAB et al: prevent a mis-configuration of the system in which the
49 // FakeHSI DLH is told to generate TimeSync messages. (TimeSync messages should only
50 // be sent from Readout DLH modules so that we don't get confusing system behavior.)
51 if (dlhConf->get_generate_timesync()) {
52 throw(BadConf(ERS_HERE, "TimeSync generation is enabled for a FakeHSIApplication and this is not allowed"));
53 }
54
55 const QueueDescriptor* dlhInputQDesc = 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 == "DataHandlerModule" || destination_class == dlhClass) {
61 dlhInputQDesc = rule->get_descriptor();
62 }
63 }
64
65 const NetworkConnectionDescriptor* dlhReqInputNetDesc = nullptr;
66 const NetworkConnectionDescriptor* tsNetDesc = nullptr;
67 const NetworkConnectionDescriptor* hsiNetDesc = nullptr;
68
69 for (auto rule : get_network_rules()) {
70 auto endpoint_class = rule->get_endpoint_class();
71 auto data_type = rule->get_descriptor()->get_data_type();
72
73 if (endpoint_class == "DataHandlerModule" || endpoint_class == dlhClass) {
74 if (data_type == "TimeSync") {
75 tsNetDesc = rule->get_descriptor();
76 }
77 if (data_type == "DataRequest") {
78 dlhReqInputNetDesc = rule->get_descriptor();
79 }
80 }
81 if (data_type == "HSIEvent") {
82 hsiNetDesc = rule->get_descriptor();
83 }
84 }
85
86 auto rdrConf = get_generator();
87 if (rdrConf == 0) {
88 throw(BadConf(ERS_HERE, "No FakeHSIEventGeneratorModule configuration given"));
89 }
90 if (dlhInputQDesc == nullptr) {
91 throw(BadConf(ERS_HERE, "No DLH data input queue descriptor given"));
92 }
93 if (dlhReqInputNetDesc == nullptr) {
94 throw(BadConf(ERS_HERE, "No DLH request input network descriptor given"));
95 }
96 if (hsiNetDesc == nullptr) {
97 throw(BadConf(ERS_HERE, "No HSIEvent output network descriptor given"));
98 }
99
100 auto idconf = get_source_id();
101 if (idconf == nullptr) {
102 throw(BadConf(ERS_HERE, "No SourceIDConf given"));
103 }
104 auto id = idconf->get_sid();
105
106 auto det_id =
107 1; // TODO Eric Flumerfelt <eflumerf@fnal.gov>, 08-Feb-2024: This is a magic number corresponding to kDAQ
108 std::string uid("DLH-" + std::to_string(id));
109 TLOG_DEBUG(7) << "creating OKS configuration object for Data Link Handler class " << dlhClass << ", id " << id;
110 conffwk::ConfigObject dlhObj = obj_fac.create(dlhClass, uid);
111 dlhObj.set_by_val<uint32_t>("source_id", id);
112 dlhObj.set_by_val<uint32_t>("detector_id", det_id);
113 dlhObj.set_by_val<bool>("post_processing_enabled", false);
114 dlhObj.set_obj("module_configuration", &dlhConf->config_object());
115
116 // Process special Network rules!
117 // Looking for Fragment rules from DFAppplications in current Session
118 std::vector<conffwk::ConfigObject> fragOutObjs;
119 for (auto [uid, descriptor] : helper->get_netdescriptors("Fragment", "DFApplication")) {
120 fragOutObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid));
121 }
122
123 // start building the list of outputs
124 std::vector<const conffwk::ConfigObject*> fh_output_objs;
125 for (auto& fNet : fragOutObjs) {
126 fh_output_objs.push_back(&fNet);
127 }
128
129 // Time Sync network connection
130 if (dlhConf->get_generate_timesync()) {
131 conffwk::ConfigObject tsNetObj = obj_fac.create_net_obj(tsNetDesc, std::to_string(id));
132 fh_output_objs.push_back(&tsNetObj);
133 }
134 dlhObj.set_objs("outputs", fh_output_objs);
135
136 conffwk::ConfigObject queueObj = obj_fac.create_queue_sid_obj(dlhInputQDesc, id);
137 conffwk::ConfigObject faNetObj = obj_fac.create_net_obj(dlhReqInputNetDesc, UID());
138
139 dlhObj.set_objs("inputs", { &queueObj, &faNetObj });
140
141 modules.push_back(obj_fac.get_dal<DataHandlerModule>(uid));
142
143 auto hsiServiceObj = hsiNetDesc->get_associated_service()->config_object();
144 conffwk::ConfigObject hsiNetObj = obj_fac.create_net_obj(hsiNetDesc, "");
145
146 std::string genuid("FakeHSI-" + std::to_string(id));
147 conffwk::ConfigObject fakehsiObj = obj_fac.create("FakeHSIEventGeneratorModule", genuid);
148 fakehsiObj.set_obj("configuration", &rdrConf->config_object());
149 fakehsiObj.set_objs("outputs", { &queueObj, &hsiNetObj });
150 if (tsNetDesc != nullptr) {
151 conffwk::ConfigObject tsNetObjIn = obj_fac.create_net_obj(tsNetDesc, ".*");
152 fakehsiObj.set_objs("inputs", { &tsNetObjIn });
153 }
154
155 modules.push_back(obj_fac.get_dal<FakeHSIEventGeneratorModule>(genuid));
156
157 obj_fac.update_modules(modules);
158}
159
160} // namespace appmodel
161} // 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(const std::string &class_name, const std::string &id) const
const dunedaq::appmodel::DataHandlerConf * get_link_handler() const
Get "link_handler" relationship value.
void generate_modules(std::shared_ptr< appmodel::ConfigurationHelper >) 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:116
The DUNE-DAQ namespace.
CIB Buffer std::string descriptor Message from std::string descriptor CIB process std::string descriptor descriptor