Line data Source code
1 : #ifndef artdaq_ArtModules_TransferWrapper_hh
2 : #define artdaq_ArtModules_TransferWrapper_hh
3 :
4 : #include <iostream>
5 : #include <memory>
6 : #include <string>
7 :
8 : #include "artdaq-core/Data/RawEvent.hh"
9 : #include "artdaq/ArtModules/ArtdaqEvent.hh"
10 : #include "artdaq/TransferPlugins/TransferInterface.hh"
11 :
12 : namespace fhicl {
13 : class ParameterSet;
14 : }
15 :
16 : namespace artdaq {
17 : class Fragment;
18 :
19 : /**
20 : * \brief ListenTransferWrapper wraps a TransferInterface so that it can be used in the ArtdaqInput class
21 : * to make an art::Source
22 : *
23 : * JCF, May-27-2016
24 : *
25 : * This is the class through which code that wants to access a
26 : * transfer plugin (e.g., input sources, AggregatorCore, etc.) can do
27 : * so. Its functionality is such that it satisfies the requirements
28 : * needed to be a template in the ArtdaqInput class
29 : */
30 : class ListenTransferWrapper
31 : {
32 : public:
33 : /**
34 : * \brief ListenTransferWrapper Constructor
35 : * \param pset ParameterSet used to configure the ListenTransferWrapper
36 : *
37 : * \verbatim
38 : * ListenTransferWrapper accepts the following Parameters:
39 : * "timeoutInUsecs" (Default: 100000): The receive timeout
40 : * "maxEventsBeforeInit" (Default: 5): How many non-Init events to receive before raising an error
41 : * "allowedFragmentTypes" (Default: [226,227,229]): The Fragment type codes for expected Fragments
42 : * "dispatcherConnectTimeout" (Default: 0): Maximum amount of time (in seconds) to wait for the Dispatcher to reach the Running state. 0 to wait forever
43 : * "dispatcherConnectRetryInterval_us" (Default 1,000,000): Amount of time to wait between polls of the Dispatcher status while waiting for it to reach the Running state.
44 : * "quitOnFragmentIntegrityProblem" (Default: true): If there is an inconsistency in the received Fragment, throw an exception and quit when true
45 : * "allowMultipleRuns" (Default: true): If true, will ignore EndOfData message and reconnect to the Dispatcher once the next run starts
46 : * "debugLevel" (Default: 0): Enables some additional messages
47 : * "transfer_plugin" (REQUIRED): Name of the TransferInterface plugin to load
48 : *
49 : * This parameter set is also passed to TransferInterface, so any necessary Parameters for TransferInterface or the requested plugin
50 : * should be included here.
51 : * \endverbatim
52 : */
53 : explicit ListenTransferWrapper(const fhicl::ParameterSet& pset);
54 :
55 : /**
56 : * \brief ListenTransferWrapper Destructor
57 : */
58 : virtual ~ListenTransferWrapper();
59 :
60 : /**
61 : * \brief Receive a Fragment from the TransferInterface, and send it to art
62 : * \return Received Fragment
63 : */
64 : artdaq::FragmentPtrs receiveMessage();
65 : /**
66 : * \brief Receive all messsages for an event from ArtdaqSharedMemoryService
67 : * \return A map of Fragment::type_t to a unique_ptr to Fragments containing all Fragments in an event
68 : */
69 : std::shared_ptr<ArtdaqEvent> receiveMessages();
70 :
71 : /**
72 : * \brief Receive the Init message from the TransferInterface, and send it to art
73 : * \return Received InitFragment
74 : */
75 0 : artdaq::FragmentPtrs receiveInitMessage()
76 : {
77 0 : return receiveMessage();
78 : }
79 :
80 : private:
81 : ListenTransferWrapper(ListenTransferWrapper const&) = delete;
82 : ListenTransferWrapper(ListenTransferWrapper&&) = delete;
83 : ListenTransferWrapper& operator=(ListenTransferWrapper const&) = delete;
84 : ListenTransferWrapper& operator=(ListenTransferWrapper&&) = delete;
85 :
86 : void checkIntegrity(const artdaq::Fragment&) const;
87 :
88 : std::size_t timeoutInUsecs_;
89 : std::chrono::steady_clock::time_point last_received_data_;
90 : std::chrono::steady_clock::time_point last_report_;
91 : std::unique_ptr<artdaq::TransferInterface> transfer_;
92 : const fhicl::ParameterSet pset_;
93 : const std::size_t maxEventsBeforeInit_;
94 : const std::vector<int> allowedFragmentTypes_;
95 : const double runningStateTimeout_;
96 : size_t runningStateInterval_us_;
97 : const bool quitOnFragmentIntegrityProblem_;
98 : const bool multi_run_mode_;
99 : }; // namespace artdaq
100 : } // namespace artdaq
101 :
102 : #endif /* artdaq_ArtModules_TransferWrapper_hh */
|