Line data Source code
1 : /**
2 : * @file TPStreamWriterApplication.cpp
3 : *
4 : * Implementation of TPStreamWriterApplication'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/Service.hpp"
17 : #include "confmodel/NetworkConnection.hpp"
18 : #include "appmodel/TPStreamWriterApplication.hpp"
19 : #include "appmodel/TPStreamWriterModule.hpp"
20 : #include "appmodel/TPStreamWriterConf.hpp"
21 : #include "appmodel/NetworkConnectionRule.hpp"
22 : #include "appmodel/NetworkConnectionDescriptor.hpp"
23 : #include "appmodel/SourceIDConf.hpp"
24 : #include "appmodel/appmodelIssues.hpp"
25 : #include "logging/Logging.hpp"
26 :
27 : #include <string>
28 : #include <vector>
29 : #include <iostream>
30 : #include <fmt/core.h>
31 :
32 : namespace dunedaq {
33 : namespace appmodel {
34 :
35 : void
36 0 : TPStreamWriterApplication::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 : auto tpwriterConf = get_tp_writer();
44 0 : if (tpwriterConf == 0) {
45 : throw (BadConf(ERS_HERE, "No TPStreamWriterModule configuration given"));
46 : }
47 0 : auto tpwriterConfObj = tpwriterConf->config_object();
48 :
49 0 : const NetworkConnectionDescriptor* tset_in_net_desc = nullptr;
50 0 : for (auto rule : get_network_rules()) {
51 0 : auto endpoint_class = rule->get_endpoint_class();
52 0 : auto data_type = rule->get_descriptor()->get_data_type();
53 0 : if (data_type == "TPSet") {
54 0 : tset_in_net_desc = rule->get_descriptor();
55 : }
56 0 : }
57 0 : if ( tset_in_net_desc== nullptr) {
58 0 : throw (BadConf(ERS_HERE, "No network descriptor given to receive TPSets"));
59 : }
60 : // Create Network Connection
61 0 : conffwk::ConfigObject tset_in_net_obj = obj_fac.create_net_obj(tset_in_net_desc, ".*");
62 :
63 :
64 0 : auto source_id = get_source_id();
65 0 : if (source_id == nullptr) {
66 0 : throw(BadConf(ERS_HERE, "No SourceIDConf given to TPWriterApplication!"));
67 : }
68 :
69 0 : uint tpw_idx = 0;
70 0 : std::string tpwrUid("tpwriter-"+std::to_string(source_id->get_sid()));
71 0 : conffwk::ConfigObject tpwrObj = obj_fac.create("TPStreamWriterModule", tpwrUid);
72 0 : tpwrObj.set_by_val<uint32_t>("source_id", source_id->get_sid());
73 0 : tpwrObj.set_by_val("writer_identifier", fmt::format("{}_tpw_{}", UID(), tpw_idx));
74 0 : tpwrObj.set_obj("configuration", &tpwriterConf->config_object());
75 0 : tpwrObj.set_objs("inputs", {&tset_in_net_obj} );
76 :
77 0 : modules.push_back(obj_fac.get_dal<TPStreamWriterModule>(tpwrUid));
78 :
79 0 : obj_fac.update_modules(modules);
80 0 : }
81 :
82 : } // namespace appmodel
83 : } // namespace dunedaq
|