DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
CreateSource.hpp
Go to the documentation of this file.
1
8#ifndef DPDKLIBS_SRC_CREATESOURCE_HPP_
9#define DPDKLIBS_SRC_CREATESOURCE_HPP_
10
11#include "SourceConcept.hpp"
12#include "SourceModel.hpp"
14
19
20#include <memory>
21#include <string>
22
23namespace dunedaq {
24
26DUNE_DAQ_TYPESTRING(dunedaq::fdreadoutlibs::types::TDEEthTypeAdapter, "TDEEthFrame")
27DUNE_DAQ_TYPESTRING(dunedaq::fdreadoutlibs::types::DAPHNEEthTypeAdapter, "DAPHNEEthFrame")
28
29namespace dpdklibs {
30
31std::shared_ptr<SourceConcept>
32createSourceModel(const std::string& conn_uid, bool callback_mode)
33{
34
35 auto datatypes = dunedaq::iomanager::IOManager::get()->get_datatypes(conn_uid);
36 if (datatypes.size() != 1) {
37 ers::error(dunedaq::datahandlinglibs::GenericConfigurationError(ERS_HERE,
38 "Multiple output data types specified! Expected only a single type!"));
39 }
40 std::string raw_dt{ *datatypes.begin() };
41 TLOG() << "Choosing specializations for SourceModel for output connection "
42 << " [uid:" << conn_uid << " , data_type:" << raw_dt << ']';
43
44 if (raw_dt.find("WIBEthFrame") != std::string::npos) {
45 // Create Model
46 auto source_model = std::make_shared<SourceModel<fdreadoutlibs::types::DUNEWIBEthTypeAdapter>>();
47
48 // For callback acquisition later (lazy)
49 source_model->set_sink_name(conn_uid);
50
51 // Setup sink (acquire pointer from QueueRegistry)
52 source_model->set_sink(conn_uid, callback_mode);
53
54 // Return with setup model
55 return source_model;
56
57 } else if (raw_dt.find("TDEEthFrame") != std::string::npos) {
58
59 // Create Model
60 auto source_model = std::make_shared<SourceModel<fdreadoutlibs::types::TDEEthTypeAdapter>>();
61
62 // Disable DAQ protocol checks
63 source_model->disable_daq_protocol_checks();
64
65 // For callback acquisition later (lazy)
66 source_model->set_sink_name(conn_uid);
67
68 // Setup sink (acquire pointer from QueueRegistry)
69 source_model->set_sink(conn_uid, callback_mode);
70
71 return source_model;
72
73 } else if (raw_dt.find("DAPHNEEthFrame") != std::string::npos) {
74 // WIB2 specific char arrays
75 auto source_model = std::make_shared<SourceModel<fdreadoutlibs::types::DAPHNEEthTypeAdapter>>();
76
77 // For callback acquisition later (lazy)
78 source_model->set_sink_name(conn_uid);
79
80 // Setup sink (acquire pointer from QueueRegistry)
81 source_model->set_sink(conn_uid, callback_mode);
82
83 return source_model;
84 } else if (raw_dt.find("DAPHNEEthStreamFrame") != std::string::npos) {
85 // WIB2 specific char arrays
86 auto source_model = std::make_shared<SourceModel<fdreadoutlibs::types::DAPHNEEthStreamTypeAdapter>>();
87
88 // For callback acquisition later (lazy)
89 source_model->set_sink_name(conn_uid);
90
91 // Setup sink (acquire pointer from QueueRegistry)
92 source_model->set_sink(conn_uid, callback_mode);
93
94 return source_model;
95 }
96
97 return nullptr;
98}
99
100} // namespace dpdklibs
101} // namespace dunedaq
102
103#endif // DPDKLIBS_SRC_CREATESOURCE_HPP_
#define ERS_HERE
#define DUNE_DAQ_TYPESTRING(Type, typestring)
Declare the datatype_to_string method for the given type.
static std::shared_ptr< IOManager > get()
Definition IOManager.hpp:40
#define TLOG(...)
Definition macro.hpp:22
The DUNE-DAQ namespace.
void error(const Issue &issue)
Definition ers.hpp:81