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