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