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 ASIOLIBS_SRC_CREATESOURCE_HPP_
9 : #define ASIOLIBS_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/TDEFrameTypeAdapter.hpp"
17 : #include "fdreadoutlibs/CRTBernTypeAdapter.hpp"
18 : #include "fdreadoutlibs/CRTGrenobleTypeAdapter.hpp"
19 :
20 : #include <memory>
21 : #include <string>
22 :
23 : namespace dunedaq {
24 :
25 : DUNE_DAQ_TYPESTRING(dunedaq::fdreadoutlibs::types::DUNEWIBEthTypeAdapter, "WIBEthFrame")
26 : DUNE_DAQ_TYPESTRING(dunedaq::fdreadoutlibs::types::TDEFrameTypeAdapter, "TDEFrame")
27 : DUNE_DAQ_TYPESTRING(dunedaq::fdreadoutlibs::types::CRTBernTypeAdapter, "CRTBernFrame")
28 : DUNE_DAQ_TYPESTRING(dunedaq::fdreadoutlibs::types::CRTGrenobleTypeAdapter, "CRTGrenobleFrame")
29 :
30 : namespace asiolibs {
31 :
32 : std::shared_ptr<SourceConcept>
33 0 : createSourceModel(const appmodel::DataMoveCallbackConf* conf)
34 : {
35 0 : auto datatype = conf->get_data_type();
36 0 : TLOG() << "Choosing specializations for SourceModel for output connection "
37 0 : << " [uid:" << conf->UID() << " , data_type:" << datatype << ']';
38 :
39 0 : if (datatype.find("WIBEthFrame") != std::string::npos) {
40 : // Create Model
41 0 : auto source_model = std::make_shared<SourceModel<fdreadoutlibs::types::DUNEWIBEthTypeAdapter>>();
42 :
43 : // For callback acquisition later (lazy)
44 0 : source_model->set_sink_config(conf);
45 :
46 : // Get parser and sink
47 : //auto& parser = source_model->get_parser();
48 : //auto& sink = source_model->get_sink();
49 : //auto& error_sink = source_model->get_error_sink();
50 :
51 : // Modify parser as needed...
52 : //parser.process_chunk_func = parsers::fixsizedChunkInto<fdreadoutlibs::types::ProtoWIBSuperChunkTypeAdapter>(sink);
53 : //if (error_sink != nullptr) {
54 : // parser.process_chunk_with_error_func = parsers::errorChunkIntoSink(error_sink);
55 : //}
56 : // parser.process_block_func = ...
57 :
58 : // Return with setup model
59 0 : return source_model;
60 :
61 0 : } else if (datatype.find("TDEFrame") != std::string::npos) {
62 : // WIB2 specific char arrays
63 0 : auto source_model = std::make_shared<SourceModel<fdreadoutlibs::types::TDEFrameTypeAdapter>>();
64 0 : source_model->set_sink_config(conf);
65 : //auto& parser = source_model->get_parser();
66 : //parser.process_chunk_func = parsers::fixsizedChunkInto<fdreadoutlibs::types::DUNEWIBSuperChunkTypeAdapter>(sink);
67 0 : return source_model;
68 0 : } else if (datatype.find("CRTBernFrame") != std::string::npos) {
69 0 : auto source_model = std::make_shared<SourceModel<fdreadoutlibs::types::CRTBernTypeAdapter>>();
70 0 : source_model->set_sink_config(conf);
71 0 : return source_model;
72 0 : } else if (datatype.find("CRTGrenobleFrame") != std::string::npos) {
73 0 : auto source_model = std::make_shared<SourceModel<fdreadoutlibs::types::CRTGrenobleTypeAdapter>>();
74 0 : source_model->set_sink_config(conf);
75 0 : return source_model;
76 0 : }
77 :
78 0 : return nullptr;
79 0 : }
80 :
81 : } // namespace asiolibs
82 : } // namespace dunedaq
83 :
84 : #endif // ASIOLIBS_SRC_CREATESOURCE_HPP_
|