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 : #include "appmodel/HSIEventToTCApplication.hpp"
12 : #include "ConfigObjectFactory.hpp"
13 : #include "appmodel/DataSubscriberModule.hpp"
14 : #include "appmodel/HSI2TCTranslatorConf.hpp"
15 : #include "appmodel/NetworkConnectionDescriptor.hpp"
16 : #include "appmodel/NetworkConnectionRule.hpp"
17 : #include "appmodel/QueueConnectionRule.hpp"
18 : #include "appmodel/QueueDescriptor.hpp"
19 : #include "appmodel/appmodelIssues.hpp"
20 : #include "conffwk/Configuration.hpp"
21 : #include "confmodel/Connection.hpp"
22 : #include "confmodel/NetworkConnection.hpp"
23 : #include "confmodel/Service.hpp"
24 : #include "logging/Logging.hpp"
25 : #include "oks/kernel.hpp"
26 :
27 : #include <string>
28 : #include <vector>
29 :
30 : namespace dunedaq {
31 : namespace appmodel {
32 :
33 : void
34 0 : HSIEventToTCApplication::generate_modules(std::shared_ptr<appmodel::ConfigurationHelper> /*helper*/) const
35 : {
36 :
37 0 : ConfigObjectFactory obj_fac(this);
38 :
39 0 : std::vector<const confmodel::DaqModule*> modules;
40 :
41 0 : std::string hstcUid("module-" + UID());
42 0 : TLOG_DEBUG(7) << "creating OKS configuration object for the DataSubscriberModule class ";
43 0 : conffwk::ConfigObject hstcObj = obj_fac.create("DataSubscriberModule", hstcUid);
44 :
45 0 : auto hstcConf = get_hsevent_to_tc_conf();
46 0 : hstcObj.set_obj("configuration", &hstcConf->config_object());
47 :
48 0 : if (hstcConf == 0) {
49 : throw(BadConf(ERS_HERE, "No HSI2TCTranslatorConf configuration given"));
50 : }
51 :
52 0 : conffwk::ConfigObject inObj;
53 0 : conffwk::ConfigObject outObj;
54 :
55 0 : for (auto rule : get_network_rules()) {
56 0 : auto endpoint_class = rule->get_endpoint_class();
57 0 : auto descriptor = rule->get_descriptor();
58 :
59 0 : if (descriptor->get_data_type() == "HSIEvent") {
60 0 : inObj = obj_fac.create_net_obj(descriptor, "");
61 0 : } else if (descriptor->get_data_type() == "TriggerCandidate") {
62 0 : outObj = obj_fac.create_net_obj(descriptor, UID());
63 : }
64 0 : }
65 :
66 0 : if (inObj == nullptr) {
67 0 : throw(BadConf(ERS_HERE, "No HSIEvent input connection descriptor given"));
68 : }
69 0 : if (outObj == nullptr) {
70 0 : throw(BadConf(ERS_HERE, "No TriggerCandidate output connection descriptor given"));
71 : }
72 :
73 0 : hstcObj.set_objs("inputs", { &inObj });
74 0 : hstcObj.set_objs("outputs", { &outObj });
75 :
76 : // Add to our list of modules to return
77 0 : modules.push_back(obj_fac.get_dal<DataSubscriberModule>(hstcUid));
78 :
79 0 : obj_fac.update_modules(modules);
80 0 : }
81 :
82 : } // namespace appmodel
83 : } // namespace dunedaq
|