Line data Source code
1 : /**
2 : * @file FDDataHandlerModule.cpp FDDataHandlerModule class implementation
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 : #include "FDDataHandlerModule.hpp"
9 :
10 : #include "datahandlinglibs/opmon/datahandling_info.pb.h"
11 :
12 : #include "iomanager/IOManager.hpp"
13 : #include "logging/Logging.hpp"
14 :
15 : #include "datahandlinglibs/DataHandlingIssues.hpp"
16 : #include "datahandlinglibs/ReadoutLogging.hpp"
17 : #include "datahandlinglibs/concepts/DataHandlingConcept.hpp"
18 : #include "datahandlinglibs/models/BinarySearchQueueModel.hpp"
19 : #include "datahandlinglibs/models/DataHandlingModel.hpp"
20 : #include "datahandlinglibs/models/DefaultRequestHandlerModel.hpp"
21 : #include "datahandlinglibs/models/DefaultSkipListRequestHandler.hpp"
22 : #include "datahandlinglibs/models/EmptyFragmentRequestHandlerModel.hpp"
23 : #include "datahandlinglibs/models/FixedRateQueueModel.hpp"
24 : #include "datahandlinglibs/models/SkipListLatencyBufferModel.hpp"
25 : #include "datahandlinglibs/models/ZeroCopyRecordingRequestHandlerModel.hpp"
26 :
27 : #include "fdreadoutlibs/DAPHNEEthStreamTypeAdapter.hpp"
28 : #include "fdreadoutlibs/DAPHNEEthTypeAdapter.hpp"
29 : #include "fdreadoutlibs/DAPHNEStreamSuperChunkTypeAdapter.hpp"
30 : #include "fdreadoutlibs/DAPHNESuperChunkTypeAdapter.hpp"
31 : #include "fdreadoutlibs/DUNEWIBEthTypeAdapter.hpp"
32 : #include "fdreadoutlibs/TDEEthTypeAdapter.hpp"
33 :
34 : #include "fdreadoutlibs/crt/CRTBernFrameProcessor.hpp"
35 : #include "fdreadoutlibs/crt/CRTGrenobleFrameProcessor.hpp"
36 : #include "fdreadoutlibs/daphne/DAPHNEFrameProcessor.hpp"
37 : #include "fdreadoutlibs/daphne/DAPHNEStreamFrameProcessor.hpp"
38 : #include "fdreadoutlibs/daphneeth/DAPHNEEthFrameProcessor.hpp"
39 : #include "fdreadoutlibs/daphneeth/DAPHNEEthStreamFrameProcessor.hpp"
40 : #include "fdreadoutlibs/tde/TDEEthFrameProcessor.hpp"
41 : #include "fdreadoutlibs/wibeth/WIBEthFrameProcessor.hpp"
42 :
43 : #include <memory>
44 : #include <sstream>
45 : #include <string>
46 : #include <vector>
47 :
48 : using namespace dunedaq::datahandlinglibs::logging;
49 :
50 : namespace dunedaq {
51 :
52 0 : DUNE_DAQ_TYPESTRING(dunedaq::fdreadoutlibs::types::DUNEWIBEthTypeAdapter, "WIBEthFrame")
53 0 : DUNE_DAQ_TYPESTRING(dunedaq::fdreadoutlibs::types::DAPHNESuperChunkTypeAdapter, "PDSFrame")
54 0 : DUNE_DAQ_TYPESTRING(dunedaq::fdreadoutlibs::types::DAPHNEStreamSuperChunkTypeAdapter, "PDSStreamFrame")
55 0 : DUNE_DAQ_TYPESTRING(dunedaq::fdreadoutlibs::types::TDEEthTypeAdapter, "TDEEthFrame")
56 0 : DUNE_DAQ_TYPESTRING(dunedaq::fdreadoutlibs::types::CRTBernTypeAdapter, "CRTBernFrame")
57 0 : DUNE_DAQ_TYPESTRING(dunedaq::fdreadoutlibs::types::CRTGrenobleTypeAdapter, "CRTGrenobleFrame")
58 0 : DUNE_DAQ_TYPESTRING(dunedaq::fdreadoutlibs::types::DAPHNEEthTypeAdapter, "DAPHNEEthFrame")
59 0 : DUNE_DAQ_TYPESTRING(dunedaq::fdreadoutlibs::types::DAPHNEEthStreamTypeAdapter, "DAPHNEEthStreamFrame")
60 :
61 : namespace fdreadoutmodules {
62 :
63 0 : FDDataHandlerModule::FDDataHandlerModule(const std::string& name)
64 : : DAQModule(name)
65 0 : , RawDataHandlerBase(name)
66 : {
67 :
68 0 : inherited_mod::register_command("conf", &inherited_dlh::do_conf);
69 0 : inherited_mod::register_command("scrap", &inherited_dlh::do_scrap);
70 0 : inherited_mod::register_command("start", &inherited_dlh::do_start);
71 0 : inherited_mod::register_command("stop_trigger_sources", &inherited_dlh::do_stop);
72 0 : inherited_mod::register_command("record", &inherited_dlh::do_record);
73 0 : }
74 :
75 : void
76 0 : FDDataHandlerModule::init(std::shared_ptr<appfwk::ConfigurationManager> cfg)
77 : {
78 :
79 0 : TLOG_DEBUG(TLVL_ENTER_EXIT_METHODS) << get_name() << ": Entering init() method";
80 0 : inherited_dlh::init(cfg);
81 0 : TLOG_DEBUG(TLVL_ENTER_EXIT_METHODS) << get_name() << ": Exiting init() method";
82 0 : }
83 :
84 : void
85 0 : FDDataHandlerModule::generate_opmon_data()
86 : {
87 0 : }
88 :
89 : std::shared_ptr<datahandlinglibs::DataHandlingConcept>
90 0 : FDDataHandlerModule::create_readout(const appmodel::DataHandlerModule* modconf, std::atomic<bool>& run_marker)
91 : {
92 0 : namespace rol = dunedaq::datahandlinglibs;
93 0 : namespace fdl = dunedaq::fdreadoutlibs;
94 0 : namespace fdt = dunedaq::fdreadoutlibs::types;
95 :
96 : // Acquire DataType
97 0 : std::string raw_dt = modconf->get_module_configuration()->get_input_data_type();
98 0 : TLOG() << "Choosing specializations for DataHandlingModel with data_type:" << raw_dt << ']';
99 :
100 : // IF WIBEth
101 0 : if (raw_dt.find("WIBEthFrame") != std::string::npos) {
102 0 : TLOG_DEBUG(TLVL_WORK_STEPS) << "Creating readout for an Ethernet DUNE-WIB";
103 0 : auto readout_model = std::make_shared<rol::DataHandlingModel<
104 : fdt::DUNEWIBEthTypeAdapter,
105 : rol::ZeroCopyRecordingRequestHandlerModel<fdt::DUNEWIBEthTypeAdapter,
106 : rol::FixedRateQueueModel<fdt::DUNEWIBEthTypeAdapter>>,
107 : rol::FixedRateQueueModel<fdt::DUNEWIBEthTypeAdapter>,
108 0 : fdl::WIBEthFrameProcessor>>(run_marker);
109 0 : register_node("WIBEthFrameProcessor", readout_model);
110 0 : readout_model->init(modconf);
111 0 : return readout_model;
112 0 : }
113 :
114 : // IF CRTBern
115 0 : if (raw_dt.find("CRTBernFrame") != std::string::npos) {
116 0 : TLOG_DEBUG(TLVL_WORK_STEPS) << "Creating readout for a CRTBern";
117 0 : auto readout_model =
118 : std::make_shared<rol::DataHandlingModel<fdt::CRTBernTypeAdapter,
119 : rol::DefaultSkipListRequestHandler<fdt::CRTBernTypeAdapter>,
120 : rol::SkipListLatencyBufferModel<fdt::CRTBernTypeAdapter>,
121 0 : fdl::CRTBernFrameProcessor>>(run_marker);
122 0 : register_node("CRTBernFrameProcessor", readout_model);
123 0 : readout_model->init(modconf);
124 0 : return readout_model;
125 0 : }
126 :
127 : // IF CRTGrenoble
128 0 : if (raw_dt.find("CRTGrenobleFrame") != std::string::npos) {
129 0 : TLOG_DEBUG(TLVL_WORK_STEPS) << "Creating readout for a CRTGrenoble";
130 0 : auto readout_model =
131 : std::make_shared<rol::DataHandlingModel<fdt::CRTGrenobleTypeAdapter,
132 : rol::DefaultSkipListRequestHandler<fdt::CRTGrenobleTypeAdapter>,
133 : rol::SkipListLatencyBufferModel<fdt::CRTGrenobleTypeAdapter>,
134 0 : fdl::CRTGrenobleFrameProcessor>>(run_marker);
135 0 : register_node("CRTGrenobleFrameProcessor", readout_model);
136 0 : readout_model->init(modconf);
137 0 : return readout_model;
138 0 : }
139 :
140 : // IF TDEEth
141 0 : if (raw_dt.find("TDEEthFrame") != std::string::npos) {
142 0 : TLOG_DEBUG(TLVL_WORK_STEPS) << "Creating readout for an Ethernet TDEEth";
143 0 : auto readout_model = std::make_shared<rol::DataHandlingModel<
144 : fdt::TDEEthTypeAdapter,
145 : rol::ZeroCopyRecordingRequestHandlerModel<fdt::TDEEthTypeAdapter,
146 : rol::FixedRateQueueModel<fdt::TDEEthTypeAdapter>>,
147 : rol::FixedRateQueueModel<fdt::TDEEthTypeAdapter>,
148 0 : fdl::TDEEthFrameProcessor>>(run_marker);
149 0 : register_node("TDEEthFrameProcessor", readout_model);
150 0 : readout_model->init(modconf);
151 0 : return readout_model;
152 0 : }
153 :
154 : // IF PDS Frame using skiplist
155 0 : if (raw_dt.find("PDSFrame") != std::string::npos) {
156 0 : TLOG_DEBUG(TLVL_WORK_STEPS) << "Creating readout for a PDS DAPHNE using SkipList LB";
157 0 : auto readout_model =
158 : std::make_shared<rol::DataHandlingModel<fdt::DAPHNESuperChunkTypeAdapter,
159 : rol::DefaultSkipListRequestHandler<fdt::DAPHNESuperChunkTypeAdapter>,
160 : rol::SkipListLatencyBufferModel<fdt::DAPHNESuperChunkTypeAdapter>,
161 0 : fdl::DAPHNEFrameProcessor>>(run_marker);
162 0 : register_node("PDSFrameProcessor", readout_model);
163 0 : readout_model->init(modconf);
164 0 : return readout_model;
165 0 : }
166 :
167 : // IF PDS Frame using skiplist
168 0 : if (raw_dt.find("DAPHNEEthFrame") != std::string::npos) {
169 0 : TLOG_DEBUG(TLVL_WORK_STEPS) << "Creating readout for a PDS DAPHNE Ethernet using SkipList LB";
170 0 : auto readout_model =
171 : std::make_shared<rol::DataHandlingModel<fdt::DAPHNEEthTypeAdapter,
172 : rol::DefaultSkipListRequestHandler<fdt::DAPHNEEthTypeAdapter>,
173 : rol::SkipListLatencyBufferModel<fdt::DAPHNEEthTypeAdapter>,
174 0 : fdl::DAPHNEEthFrameProcessor>>(run_marker);
175 0 : register_node("DAPHNEEthFrameProcessor", readout_model);
176 0 : readout_model->init(modconf);
177 0 : return readout_model;
178 0 : }
179 :
180 : // IF PDS Stream Frame using SPSC LB
181 0 : if (raw_dt.find("PDSStreamFrame") != std::string::npos) {
182 0 : TLOG_DEBUG(TLVL_WORK_STEPS) << "Creating readout for a PDS DAPHNE stream mode using BinarySearchQueue LB";
183 0 : auto readout_model = std::make_shared<rol::DataHandlingModel<
184 : fdt::DAPHNEStreamSuperChunkTypeAdapter,
185 : rol::DefaultRequestHandlerModel<fdt::DAPHNEStreamSuperChunkTypeAdapter,
186 : rol::BinarySearchQueueModel<fdt::DAPHNEStreamSuperChunkTypeAdapter>>,
187 : rol::BinarySearchQueueModel<fdt::DAPHNEStreamSuperChunkTypeAdapter>,
188 0 : fdl::DAPHNEStreamFrameProcessor>>(run_marker);
189 0 : register_node("PDSStreamFrameProcessor", readout_model);
190 0 : readout_model->init(modconf);
191 0 : return readout_model;
192 0 : }
193 :
194 : // IF PDS Stream Frame using SPSC LB
195 0 : if (raw_dt.find("DAPHNEEthStreamFrame") != std::string::npos) {
196 0 : TLOG_DEBUG(TLVL_WORK_STEPS) << "Creating readout for a DAPHNE eth stream mode using BinarySearchQueue LB";
197 0 : auto readout_model = std::make_shared<rol::DataHandlingModel<
198 : fdt::DAPHNEEthStreamTypeAdapter,
199 : rol::DefaultRequestHandlerModel<fdt::DAPHNEEthStreamTypeAdapter,
200 : rol::BinarySearchQueueModel<fdt::DAPHNEEthStreamTypeAdapter>>,
201 : rol::BinarySearchQueueModel<fdt::DAPHNEEthStreamTypeAdapter>,
202 0 : fdl::DAPHNEEthStreamFrameProcessor>>(run_marker);
203 0 : register_node("DAPHNEEthStreamFrameProcessor", readout_model);
204 0 : readout_model->init(modconf);
205 0 : return readout_model;
206 0 : }
207 0 : return nullptr;
208 0 : }
209 :
210 : } // namespace fdreadoutmodules
211 : } // namespace dunedaq
212 :
213 0 : DEFINE_DUNE_DAQ_MODULE(dunedaq::fdreadoutmodules::FDDataHandlerModule)
|