DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
TPWriterApplication.cpp
Go to the documentation of this file.
1
10
22#include "confmodel/Service.hpp"
23#include "logging/Logging.hpp"
24#include "oks/kernel.hpp"
25
26#include <fmt/core.h>
27#include <iostream>
28#include <string>
29#include <vector>
30
31namespace dunedaq {
32namespace appmodel {
33
34void
35TPStreamWriterApplication::generate_modules(std::shared_ptr<appmodel::ConfigurationHelper> /*helper*/) const
36{
37 std::vector<const confmodel::DaqModule*> modules;
38
39 ConfigObjectFactory obj_fac(this);
40
41 auto tpwriterConf = get_tp_writer();
42 if (tpwriterConf == 0) {
43 throw(BadConf(ERS_HERE, "No TPStreamWriterModule configuration given"));
44 }
45 auto tpwriterConfObj = tpwriterConf->config_object();
46
47 const NetworkConnectionDescriptor* tset_in_net_desc = nullptr;
48 for (auto rule : get_network_rules()) {
49 auto endpoint_class = rule->get_endpoint_class();
50 auto data_type = rule->get_descriptor()->get_data_type();
51 if (data_type == "TPSet") {
52 tset_in_net_desc = rule->get_descriptor();
53 }
54 }
55 if (tset_in_net_desc == nullptr) {
56 throw(BadConf(ERS_HERE, "No network descriptor given to receive TPSets"));
57 }
58 // Create Network Connection
59 conffwk::ConfigObject tset_in_net_obj = obj_fac.create_net_obj(tset_in_net_desc, ".*");
60
61 auto source_id = get_source_id();
62 if (source_id == nullptr) {
63 throw(BadConf(ERS_HERE, "No SourceIDConf given to TPWriterApplication!"));
64 }
65
66 uint tpw_idx = 0;
67 std::string tpwrUid("tpwriter-" + std::to_string(source_id->get_sid()));
68 conffwk::ConfigObject tpwrObj = obj_fac.create("TPStreamWriterModule", tpwrUid);
69 tpwrObj.set_by_val<uint32_t>("source_id", source_id->get_sid());
70 tpwrObj.set_by_val("writer_identifier", fmt::format("{}_tpw_{}", UID(), tpw_idx));
71 tpwrObj.set_obj("configuration", &tpwriterConf->config_object());
72 tpwrObj.set_objs("inputs", { &tset_in_net_obj });
73
74 modules.push_back(obj_fac.get_dal<TPStreamWriterModule>(tpwrUid));
75
76 obj_fac.update_modules(modules);
77}
78
79} // namespace appmodel
80} // namespace dunedaq
#define ERS_HERE
void update_modules(const std::vector< const confmodel::DaqModule * > &modules)
conffwk::ConfigObject create_net_obj(const NetworkConnectionDescriptor *ndesc, std::string uid) const
Helper function that gets a network connection config.
const T * get_dal(std::string uid) const
conffwk::ConfigObject create(const std::string &class_name, const std::string &id) const
const std::vector< const dunedaq::appmodel::NetworkConnectionRule * > & get_network_rules() const
Get "network_rules" relationship value.
const dunedaq::appmodel::SourceIDConf * get_source_id() const
Get "source_id" relationship value.
const dunedaq::appmodel::TPStreamWriterConf * get_tp_writer() const
Get "tp_writer" relationship value.
void generate_modules(std::shared_ptr< appmodel::ConfigurationHelper >) const override
void set_by_val(const std::string &name, T value)
Set attribute value.
void set_objs(const std::string &name, const std::vector< const ConfigObject * > &o, bool skip_non_null_check=false)
Set relationship multi-value.
void set_obj(const std::string &name, const ConfigObject *o, bool skip_non_null_check=false)
Set relationship single-value.
const std::string & UID() const noexcept
conffwk entry point
The DUNE-DAQ namespace.