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
18
19#include <memory>
20#include <string>
21
22namespace dunedaq {
23
25DUNE_DAQ_TYPESTRING(dunedaq::fdreadoutlibs::types::TDEEthTypeAdapter, "TDEEthFrame")
26DUNE_DAQ_TYPESTRING(dunedaq::fdreadoutlibs::types::DAPHNEEthTypeAdapter, "DAPHNEEthFrame")
27
28namespace dpdklibs {
29
30std::shared_ptr<SourceConcept>
31createSourceModel(const std::string& conn_uid, bool callback_mode)
32{
33
34 auto datatypes = dunedaq::iomanager::IOManager::get()->get_datatypes(conn_uid);
35 if (datatypes.size() != 1) {
36 ers::error(dunedaq::datahandlinglibs::GenericConfigurationError(ERS_HERE,
37 "Multiple output data types specified! Expected only a single type!"));
38 }
39 std::string raw_dt{ *datatypes.begin() };
40 TLOG() << "Choosing specializations for SourceModel for output connection "
41 << " [uid:" << conn_uid << " , data_type:" << raw_dt << ']';
42
43 if (raw_dt.find("WIBEthFrame") != std::string::npos) {
44 // Create Model
45 auto source_model = std::make_shared<SourceModel<fdreadoutlibs::types::DUNEWIBEthTypeAdapter>>();
46
47 // For callback acquisition later (lazy)
48 source_model->set_sink_name(conn_uid);
49
50 // Setup sink (acquire pointer from QueueRegistry)
51 source_model->set_sink(conn_uid, callback_mode);
52
53 // Return with setup model
54 return source_model;
55
56 } else if (raw_dt.find("TDEEthFrame") != std::string::npos) {
57
58 // Create Model
59 auto source_model = std::make_shared<SourceModel<fdreadoutlibs::types::TDEEthTypeAdapter>>();
60
61 // Disable DAQ protocol checks
62 source_model->disable_daq_protocol_checks();
63
64 // For callback acquisition later (lazy)
65 source_model->set_sink_name(conn_uid);
66
67 // Setup sink (acquire pointer from QueueRegistry)
68 source_model->set_sink(conn_uid, callback_mode);
69
70 return source_model;
71
72 } else if (raw_dt.find("DAPHNEEthFrame") != std::string::npos) {
73 // WIB2 specific char arrays
74 auto source_model = std::make_shared<SourceModel<fdreadoutlibs::types::DAPHNEEthTypeAdapter>>();
75
76 // For callback acquisition later (lazy)
77 source_model->set_sink_name(conn_uid);
78
79 // Setup sink (acquire pointer from QueueRegistry)
80 source_model->set_sink(conn_uid, callback_mode);
81
82 return source_model;
83 }
84
85
86 return nullptr;
87}
88
89} // namespace dpdklibs
90} // namespace dunedaq
91
92#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