Line data Source code
1 : /**
2 : * @file CreateSource.hpp Specific SourceConcept creator.
3 : *
4 : * This is part of the DUNE DAQ , copyright 2020.
5 : * Licensing/copyright details are in the COPYING file that you should have
6 : * received with this code.
7 : */
8 : #ifndef DPDKLIBS_SRC_CREATESOURCE_HPP_
9 : #define DPDKLIBS_SRC_CREATESOURCE_HPP_
10 :
11 : #include "SourceConcept.hpp"
12 : #include "SourceModel.hpp"
13 : #include "datahandlinglibs/DataHandlingIssues.hpp"
14 :
15 : #include "fdreadoutlibs/DUNEWIBEthTypeAdapter.hpp"
16 : #include "fdreadoutlibs/TDEEthTypeAdapter.hpp"
17 : #include "fdreadoutlibs/DAPHNEEthTypeAdapter.hpp"
18 : #include "fdreadoutlibs/DAPHNEEthStreamTypeAdapter.hpp"
19 :
20 : #include <memory>
21 : #include <string>
22 :
23 : namespace dunedaq {
24 :
25 0 : DUNE_DAQ_TYPESTRING(dunedaq::fdreadoutlibs::types::DUNEWIBEthTypeAdapter, "WIBEthFrame")
26 0 : DUNE_DAQ_TYPESTRING(dunedaq::fdreadoutlibs::types::TDEEthTypeAdapter, "TDEEthFrame")
27 0 : DUNE_DAQ_TYPESTRING(dunedaq::fdreadoutlibs::types::DAPHNEEthTypeAdapter, "DAPHNEEthFrame")
28 :
29 : namespace dpdklibs {
30 :
31 : std::shared_ptr<SourceConcept>
32 0 : createSourceModel(const std::string& conn_uid, bool callback_mode)
33 : {
34 :
35 0 : auto datatypes = dunedaq::iomanager::IOManager::get()->get_datatypes(conn_uid);
36 0 : if (datatypes.size() != 1) {
37 0 : ers::error(dunedaq::datahandlinglibs::GenericConfigurationError(ERS_HERE,
38 0 : "Multiple output data types specified! Expected only a single type!"));
39 : }
40 0 : std::string raw_dt{ *datatypes.begin() };
41 0 : TLOG() << "Choosing specializations for SourceModel for output connection "
42 0 : << " [uid:" << conn_uid << " , data_type:" << raw_dt << ']';
43 :
44 0 : if (raw_dt.find("WIBEthFrame") != std::string::npos) {
45 : // Create Model
46 0 : auto source_model = std::make_shared<SourceModel<fdreadoutlibs::types::DUNEWIBEthTypeAdapter>>();
47 :
48 : // For callback acquisition later (lazy)
49 0 : source_model->set_sink_name(conn_uid);
50 :
51 : // Setup sink (acquire pointer from QueueRegistry)
52 0 : source_model->set_sink(conn_uid, callback_mode);
53 :
54 : // Return with setup model
55 0 : return source_model;
56 :
57 0 : } else if (raw_dt.find("TDEEthFrame") != std::string::npos) {
58 :
59 : // Create Model
60 0 : auto source_model = std::make_shared<SourceModel<fdreadoutlibs::types::TDEEthTypeAdapter>>();
61 :
62 : // Disable DAQ protocol checks
63 0 : source_model->disable_daq_protocol_checks();
64 :
65 : // For callback acquisition later (lazy)
66 0 : source_model->set_sink_name(conn_uid);
67 :
68 : // Setup sink (acquire pointer from QueueRegistry)
69 0 : source_model->set_sink(conn_uid, callback_mode);
70 :
71 0 : return source_model;
72 :
73 0 : } else if (raw_dt.find("DAPHNEEthFrame") != std::string::npos) {
74 : // WIB2 specific char arrays
75 0 : auto source_model = std::make_shared<SourceModel<fdreadoutlibs::types::DAPHNEEthTypeAdapter>>();
76 :
77 : // For callback acquisition later (lazy)
78 0 : source_model->set_sink_name(conn_uid);
79 :
80 : // Setup sink (acquire pointer from QueueRegistry)
81 0 : source_model->set_sink(conn_uid, callback_mode);
82 :
83 0 : return source_model;
84 0 : } else if (raw_dt.find("DAPHNEEthStreamFrame") != std::string::npos) {
85 : // WIB2 specific char arrays
86 0 : auto source_model = std::make_shared<SourceModel<fdreadoutlibs::types::DAPHNEEthStreamTypeAdapter>>();
87 :
88 : // For callback acquisition later (lazy)
89 0 : source_model->set_sink_name(conn_uid);
90 :
91 : // Setup sink (acquire pointer from QueueRegistry)
92 0 : source_model->set_sink(conn_uid, callback_mode);
93 :
94 0 : return source_model;
95 0 : }
96 :
97 0 : return nullptr;
98 0 : }
99 :
100 : } // namespace dpdklibs
101 : } // namespace dunedaq
102 :
103 : #endif // DPDKLIBS_SRC_CREATESOURCE_HPP_
|