Line data Source code
1 : /**
2 : * @file DFOApplication.cpp
3 : *
4 : * Implementation of DFOApplication's generate_modules dal method
5 : *
6 : * This is part of the DUNE DAQ Software Suite, copyright 2023.
7 : * Licensing/copyright details are in the COPYING file that you should have
8 : * received with this code.
9 : */
10 :
11 :
12 : #include "ConfigObjectFactory.hpp"
13 : #include "conffwk/Configuration.hpp"
14 : #include "oks/kernel.hpp"
15 : #include "confmodel/Connection.hpp"
16 : #include "confmodel/NetworkConnection.hpp"
17 : #include "appmodel/DataSubscriberModule.hpp"
18 : #include "appmodel/HSIEventToTCApplication.hpp"
19 : #include "appmodel/HSI2TCTranslatorConf.hpp"
20 : #include "appmodel/NetworkConnectionRule.hpp"
21 : #include "appmodel/NetworkConnectionDescriptor.hpp"
22 : #include "appmodel/QueueConnectionRule.hpp"
23 : #include "appmodel/QueueDescriptor.hpp"
24 : #include "confmodel/Service.hpp"
25 : #include "appmodel/appmodelIssues.hpp"
26 : #include "logging/Logging.hpp"
27 :
28 : #include <string>
29 : #include <vector>
30 :
31 : namespace dunedaq {
32 : namespace appmodel {
33 :
34 : void
35 0 : HSIEventToTCApplication::generate_modules(const confmodel::Session* /*session*/) const
36 : {
37 :
38 0 : ConfigObjectFactory obj_fac(this);
39 :
40 0 : std::vector<const confmodel::DaqModule*> modules;
41 :
42 0 : std::string hstcUid("module-" + UID());
43 0 : TLOG_DEBUG(7) << "creating OKS configuration object for the DataSubscriberModule class ";
44 0 : conffwk::ConfigObject hstcObj = obj_fac.create("DataSubscriberModule", hstcUid);
45 :
46 0 : auto hstcConf = get_hsevent_to_tc_conf();
47 0 : hstcObj.set_obj("configuration", &hstcConf->config_object());
48 :
49 0 : if (hstcConf == 0) {
50 : throw(BadConf(ERS_HERE, "No HSI2TCTranslatorConf configuration given"));
51 : }
52 :
53 0 : conffwk::ConfigObject inObj;
54 0 : conffwk::ConfigObject outObj;
55 :
56 0 : for (auto rule : get_network_rules()) {
57 0 : auto endpoint_class = rule->get_endpoint_class();
58 0 : auto descriptor = rule->get_descriptor();
59 :
60 0 : if (descriptor->get_data_type() == "HSIEvent") {
61 0 : inObj = obj_fac.create_net_obj(descriptor, "");
62 : }
63 0 : else if (descriptor->get_data_type() == "TriggerCandidate") {
64 0 : outObj = obj_fac.create_net_obj(descriptor, UID());
65 : }
66 0 : }
67 :
68 0 : if (inObj == nullptr) {
69 0 : throw(BadConf(ERS_HERE, "No HSIEvent input connection descriptor given"));
70 : }
71 0 : if (outObj == nullptr) {
72 0 : throw(BadConf(ERS_HERE, "No TriggerCandidate output connection descriptor given"));
73 : }
74 :
75 0 : hstcObj.set_objs("inputs", {&inObj});
76 0 : hstcObj.set_objs("outputs", {&outObj});
77 :
78 : // Add to our list of modules to return
79 0 : modules.push_back(obj_fac.get_dal<DataSubscriberModule>(hstcUid));
80 :
81 0 : obj_fac.update_modules(modules);
82 0 : }
83 :
84 : } // namespace appmodel
85 : } // namespace dunedaq
|