Line data Source code
1 : /**
2 : * @file SNBBookkeeperApplication.cpp
3 : *
4 : * Implementation of SNBBookkeeperApplication'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 "ConfigObjectFactory.hpp"
12 : #include "appmodel/SNBBookkeeperApplication.hpp"
13 : #include "appmodel/SNBBookkeeperConf.hpp"
14 : #include "appmodel/SNBTransferBookkeeper.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 : SNBBookkeeperApplication::generate_modules(const confmodel::Session* /*session*/) const
35 : {
36 0 : ConfigObjectFactory obj_fac(this);
37 :
38 0 : std::vector<const confmodel::DaqModule*> modules;
39 :
40 0 : std::string snbBookkeeperUid("snb-sample-config-" + UID());
41 0 : TLOG_DEBUG(7) << "creating OKS configuration object for SNBBookkeeperModule class ";
42 0 : auto snbBookkeeperObj = obj_fac.create("SNBTransferBookkeeper", snbBookkeeperUid);
43 :
44 0 : auto snbBookkeeperConf = get_snbbk();
45 0 : snbBookkeeperObj.set_obj("configuration", &snbBookkeeperConf->config_object());
46 :
47 0 : if (snbBookkeeperConf == 0) {
48 : throw(BadConf(ERS_HERE, "No SNBBookkeeperConf configuration given"));
49 : }
50 :
51 0 : std::vector<const conffwk::ConfigObject*> input_conns;
52 0 : conffwk::ConfigObject notificationInObj;
53 :
54 0 : for (auto rule : get_network_rules()) {
55 0 : auto endpoint_class = rule->get_endpoint_class();
56 0 : auto descriptor = rule->get_descriptor();
57 :
58 0 : auto connObj = obj_fac.create_net_obj(descriptor, "");
59 :
60 0 : if (descriptor->get_data_type() == "notification_t") {
61 0 : notificationInObj = connObj;
62 0 : input_conns.push_back(¬ificationInObj);
63 : }
64 0 : }
65 :
66 0 : if (notificationInObj == nullptr) {
67 0 : throw(BadConf(ERS_HERE, "No Notification input connection descriptor given"));
68 : }
69 :
70 0 : snbBookkeeperObj.set_objs("inputs", input_conns);
71 :
72 : // Add to our list of modules to return
73 0 : modules.push_back(obj_fac.get_dal<SNBTransferBookkeeper>(snbBookkeeperUid));
74 :
75 0 : obj_fac.update_modules(modules);
76 0 : }
77 :
78 : } // namespace appmodel
79 : } // namespace dunedaq
|