artdaq  v3_03_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/Application/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 
121  bool rollover_subrun(uint64_t eventNum);
122 
134  std::string report(std::string const& which) const;
135 
141  bool add_config_archive_entry(std::string const& key, std::string const& value)
142  {
143  config_archive_entries_[key] = value;
144  return true;
145  }
146 
151  {
152  config_archive_entries_.clear();
153  return config_archive_entries_.empty();
154  }
155 
156 protected:
164  bool initializeDataReceiver(fhicl::ParameterSet const& pset, fhicl::ParameterSet const& data_pset, fhicl::ParameterSet const& metric_pset);
165 
166  std::unique_ptr<DataReceiverManager> receiver_ptr_;
167  std::shared_ptr<SharedMemoryEventManager> event_store_ptr_;
168  std::atomic<bool> stop_requested_;
169  std::atomic<bool> pause_requested_;
170  std::atomic<bool> run_is_paused_;
171  bool verbose_;
172 
173  fhicl::ParameterSet art_pset_;
174  std::map<std::string, std::string> config_archive_entries_;
175 
180  void logMessage_(std::string const& text);
181 };
182 
183 #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.
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.
bool verbose_
Whether to log transition messages.
bool pause()
Pauses the DataReceiverCore.
std::atomic< bool > run_is_paused_
Pause has been successfully completed?
DataReceiverCore & operator=(DataReceiverCore const &)=delete
Copy Assignment operator is deleted.
bool rollover_subrun(uint64_t eventNum)
Rollover the subrun after the given event.
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.