Line data Source code
1 : /**
2 : * @file DFO.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/DFOApplication.hpp"
12 : #include "ConfigObjectFactory.hpp"
13 : #include "appmodel/ConfigurationHelper.hpp"
14 : #include "appmodel/DFOConf.hpp"
15 : #include "appmodel/DFOModule.hpp"
16 : #include "appmodel/NetworkConnectionDescriptor.hpp"
17 : #include "appmodel/NetworkConnectionRule.hpp"
18 : #include "appmodel/QueueConnectionRule.hpp"
19 : #include "appmodel/QueueDescriptor.hpp"
20 : #include "appmodel/appmodelIssues.hpp"
21 :
22 : #include "confmodel/Connection.hpp"
23 : #include "confmodel/NetworkConnection.hpp"
24 : #include "confmodel/Service.hpp"
25 : #include "logging/Logging.hpp"
26 : #include "oks/kernel.hpp"
27 :
28 : #include <string>
29 : #include <vector>
30 :
31 : namespace dunedaq {
32 : namespace appmodel {
33 :
34 : void
35 0 : DFOApplication::generate_modules(std::shared_ptr<appmodel::ConfigurationHelper> helper) const
36 : {
37 0 : std::vector<const confmodel::DaqModule*> modules;
38 :
39 0 : ConfigObjectFactory obj_fac(this);
40 :
41 0 : std::string dfoUid("DFO-" + UID());
42 0 : TLOG_DEBUG(7) << "creating OKS configuration object for DFOModule class ";
43 0 : auto dfoObj = obj_fac.create("DFOModule", dfoUid);
44 :
45 0 : auto dfoConf = get_dfo();
46 0 : dfoObj.set_obj("configuration", &dfoConf->config_object());
47 :
48 0 : if (dfoConf == 0) {
49 : throw(BadConf(ERS_HERE, "No DFOConf configuration given"));
50 : }
51 :
52 0 : std::vector<const conffwk::ConfigObject*> output_conns;
53 0 : std::vector<const conffwk::ConfigObject*> input_conns;
54 0 : conffwk::ConfigObject tdInObj;
55 0 : conffwk::ConfigObject busyOutObj;
56 0 : conffwk::ConfigObject tokenInObj;
57 :
58 0 : for (auto rule : get_network_rules()) {
59 0 : auto endpoint_class = rule->get_endpoint_class();
60 0 : auto descriptor = rule->get_descriptor();
61 :
62 0 : auto connObj = obj_fac.create_net_obj(descriptor, "");
63 :
64 0 : if (descriptor->get_data_type() == "TriggerDecision") {
65 0 : if (endpoint_class == "DFOModule") {
66 0 : tdInObj = connObj;
67 0 : input_conns.push_back(&tdInObj);
68 : }
69 0 : } else if (descriptor->get_data_type() == "TriggerDecisionToken") {
70 0 : tokenInObj = connObj;
71 0 : input_conns.push_back(&tokenInObj);
72 : }
73 :
74 0 : else if (descriptor->get_data_type() == "TriggerInhibit") {
75 0 : busyOutObj = connObj;
76 0 : output_conns.push_back(&busyOutObj);
77 : }
78 0 : }
79 :
80 0 : if (tdInObj == nullptr) {
81 0 : throw(BadConf(ERS_HERE, "No TriggerDecision input connection descriptor given"));
82 : }
83 0 : if (busyOutObj == nullptr) {
84 0 : throw(BadConf(ERS_HERE, "No TriggerInhibit output connection descriptor given"));
85 : }
86 0 : if (tokenInObj == nullptr) {
87 0 : throw(BadConf(ERS_HERE, "No TriggerDecisionToken input connection descriptor given"));
88 : }
89 :
90 : // Process special Network rules!
91 0 : std::vector<conffwk::ConfigObject> tdOutObjs;
92 0 : for (auto [uid, descriptor] : helper->get_netdescriptors("TriggerDecision", "DFApplication")) {
93 0 : tdOutObjs.emplace_back(obj_fac.create_net_obj(descriptor, uid));
94 0 : }
95 :
96 0 : for (auto& tdOut : tdOutObjs) {
97 0 : output_conns.push_back(&tdOut);
98 : }
99 :
100 0 : dfoObj.set_objs("inputs", input_conns);
101 0 : dfoObj.set_objs("outputs", output_conns);
102 :
103 : // Add to our list of modules to return
104 0 : modules.push_back(obj_fac.get_dal<DFOModule>(dfoUid));
105 :
106 0 : obj_fac.update_modules(modules);
107 0 : }
108 :
109 : } // namespace appmodel
110 : } // namespace dunedaq
|