DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
TPWriterApplication.cpp
Go to the documentation of this file.
1
14#include "oks/kernel.hpp"
16#include "confmodel/Service.hpp"
25#include "logging/Logging.hpp"
26
27#include <string>
28#include <vector>
29#include <iostream>
30#include <fmt/core.h>
31
32namespace dunedaq {
33namespace appmodel {
34
35void
36TPStreamWriterApplication::generate_modules(std::shared_ptr<appmodel::ConfigurationHelper> /*helper*/) const
37{
38 std::vector<const confmodel::DaqModule*> modules;
39
40 ConfigObjectFactory obj_fac(this);
41
42
43 auto tpwriterConf = get_tp_writer();
44 if (tpwriterConf == 0) {
45 throw (BadConf(ERS_HERE, "No TPStreamWriterModule configuration given"));
46 }
47 auto tpwriterConfObj = tpwriterConf->config_object();
48
49 const NetworkConnectionDescriptor* tset_in_net_desc = nullptr;
50 for (auto rule : get_network_rules()) {
51 auto endpoint_class = rule->get_endpoint_class();
52 auto data_type = rule->get_descriptor()->get_data_type();
53 if (data_type == "TPSet") {
54 tset_in_net_desc = rule->get_descriptor();
55 }
56 }
57 if ( tset_in_net_desc== nullptr) {
58 throw (BadConf(ERS_HERE, "No network descriptor given to receive TPSets"));
59 }
60 // Create Network Connection
61 conffwk::ConfigObject tset_in_net_obj = obj_fac.create_net_obj(tset_in_net_desc, ".*");
62
63
64 auto source_id = get_source_id();
65 if (source_id == nullptr) {
66 throw(BadConf(ERS_HERE, "No SourceIDConf given to TPWriterApplication!"));
67 }
68
69 uint tpw_idx = 0;
70 std::string tpwrUid("tpwriter-"+std::to_string(source_id->get_sid()));
71 conffwk::ConfigObject tpwrObj = obj_fac.create("TPStreamWriterModule", tpwrUid);
72 tpwrObj.set_by_val<uint32_t>("source_id", source_id->get_sid());
73 tpwrObj.set_by_val("writer_identifier", fmt::format("{}_tpw_{}", UID(), tpw_idx));
74 tpwrObj.set_obj("configuration", &tpwriterConf->config_object());
75 tpwrObj.set_objs("inputs", {&tset_in_net_obj} );
76
77 modules.push_back(obj_fac.get_dal<TPStreamWriterModule>(tpwrUid));
78
79 obj_fac.update_modules(modules);
80}
81
82} // namespace appmodel
83} // 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
Including Qt Headers.