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