artdaq  v3_06_00
DataReceiverCore.hh
1 #ifndef artdaq_Application_MPI2_DataReceiverCore_hh
2 #define artdaq_Application_MPI2_DataReceiverCore_hh
3 
4 #include <string>
5 #include <atomic>
6 #include <map>
7 
8 #include "fhiclcpp/ParameterSet.h"
9 #include "canvas/Persistency/Provenance/RunID.h"
10 
11 #include "artdaq-utilities/Plugins/MetricManager.hh"
12 
13 #include "artdaq/DAQrate/DataReceiverManager.hh"
14 #include "artdaq/DAQrate/StatisticsHelper.hh"
15 
16 namespace artdaq
17 {
18  class DataReceiverCore;
19 }
20 
26 {
27 public:
28 
33 
37  DataReceiverCore(DataReceiverCore const&) = delete;
38 
42  virtual ~DataReceiverCore();
43 
49 
69  virtual bool initialize(fhicl::ParameterSet const& pset) = 0;
70 
76  bool start(art::RunID id);
77 
82  bool stop();
83 
88  bool pause();
89 
94  bool resume();
95 
100  bool shutdown();
101 
107  bool soft_initialize(fhicl::ParameterSet const& pset);
108 
114  bool reinitialize(fhicl::ParameterSet const& pset);
115 
122  bool rollover_subrun(uint64_t eventNum, uint32_t subrun);
123 
135  std::string report(std::string const& which) const;
136 
143  bool add_config_archive_entry(std::string const& key, std::string const& value)
144  {
145  config_archive_entries_[key] = value;
146  return true;
147  }
148 
154  {
155  config_archive_entries_.clear();
156  return config_archive_entries_.empty();
157  }
158 
159 protected:
167  bool initializeDataReceiver(fhicl::ParameterSet const& pset, fhicl::ParameterSet const& data_pset, fhicl::ParameterSet const& metric_pset);
168 
169  std::unique_ptr<DataReceiverManager> receiver_ptr_;
170  std::shared_ptr<SharedMemoryEventManager> event_store_ptr_;
171  std::atomic<bool> stop_requested_;
172  std::atomic<bool> pause_requested_;
173  std::atomic<bool> run_is_paused_;
174  bool verbose_;
175 
176  fhicl::ParameterSet art_pset_;
177  std::map<std::string, std::string> config_archive_entries_;
178 
183  void logMessage_(std::string const& text);
184 };
185 
186 #endif /* artdaq_Application_MPI2_DataReceiverCore_hh */
DataReceiverCore()
DataReceiverCore Constructor.
std::shared_ptr< SharedMemoryEventManager > event_store_ptr_
Pointer to the SharedMemoryEventManager.
bool soft_initialize(fhicl::ParameterSet const &pset)
Soft-Initializes the DataReceiverCore. No-Op.
DataReceiverCore implements the state machine for the DataReceiver artdaq application. DataReceiverCore receives Fragment objects from the DataReceiverManager, and sends them to the EventStore.
bool resume()
Resumes the DataReceiverCore.
bool shutdown()
Shuts Down the DataReceiverCore.
bool start(art::RunID id)
Start the DataReceiverCore.
fhicl::ParameterSet art_pset_
ParameterSet sent to art process.
void logMessage_(std::string const &text)
Log a message, setting severity based on verbosity flag.
std::unique_ptr< DataReceiverManager > receiver_ptr_
Pointer to the DataReceiverManager.
bool stop()
Stops the DataReceiverCore.
std::string report(std::string const &which) const
Send a report on a given run-time quantity.
std::map< std::string, std::string > config_archive_entries_
Additional strings to archive as part of the art configuration.
bool verbose_
Whether to log transition messages.
bool pause()
Pauses the DataReceiverCore.
bool rollover_subrun(uint64_t eventNum, uint32_t subrun)
Rollover the subrun after the given event.
std::atomic< bool > run_is_paused_
Pause has been successfully completed?
DataReceiverCore & operator=(DataReceiverCore const &)=delete
Copy Assignment operator is deleted.
bool add_config_archive_entry(std::string const &key, std::string const &value)
Add the specified key and value to the configuration archive list.
bool initializeDataReceiver(fhicl::ParameterSet const &pset, fhicl::ParameterSet const &data_pset, fhicl::ParameterSet const &metric_pset)
Initialize the DataReceiverCore (should be called from initialize() overrides.
std::atomic< bool > pause_requested_
Pause has been requested?
bool clear_config_archive()
Clear the configuration archive list.
std::atomic< bool > stop_requested_
Stop has been requested?
bool reinitialize(fhicl::ParameterSet const &pset)
Reinitializes the DataReceiverCore.
virtual bool initialize(fhicl::ParameterSet const &pset)=0
Processes the initialize request.