artdaq  v3_07_01
BoardReaderCore.hh
1 #ifndef artdaq_Application_MPI2_BoardReaderCore_hh
2 #define artdaq_Application_MPI2_BoardReaderCore_hh
3 
4 #include <string>
5 
6 #include "artdaq-utilities/Plugins/MetricManager.hh"
7 #include "artdaq/Application/Commandable.hh"
8 #include "artdaq/DAQrate/DataSenderManager.hh"
9 #include "artdaq/DAQrate/StatisticsHelper.hh"
10 #include "artdaq/Generators/CommandableFragmentGenerator.hh"
11 #include "canvas/Persistency/Provenance/RunID.h"
12 #include "fhiclcpp/ParameterSet.h"
13 
14 namespace artdaq {
15 class BoardReaderCore;
16 }
17 
23 {
24 public:
25  static const std::string FRAGMENTS_PROCESSED_STAT_KEY;
26  static const std::string INPUT_WAIT_STAT_KEY;
27  static const std::string BRSYNC_WAIT_STAT_KEY;
28  static const std::string OUTPUT_WAIT_STAT_KEY;
29  static const std::string FRAGMENTS_PER_READ_STAT_KEY;
30 
35  BoardReaderCore(Commandable& parent_application);
36 
40  BoardReaderCore(BoardReaderCore const&) = delete;
41 
45  virtual ~BoardReaderCore();
46 
51  BoardReaderCore& operator=(BoardReaderCore const&) = delete;
52 
73  bool initialize(fhicl::ParameterSet const& pset, uint64_t timeout, uint64_t timestamp);
74 
82  bool start(art::RunID id, uint64_t timeout, uint64_t timestamp);
83 
90  bool stop(uint64_t timeout, uint64_t timestamp);
91 
98  bool pause(uint64_t timeout, uint64_t timestamp);
99 
106  bool resume(uint64_t timeout, uint64_t timestamp);
107 
113  bool shutdown(uint64_t timeout);
114 
122  bool soft_initialize(fhicl::ParameterSet const& pset, uint64_t timeout, uint64_t timestamp);
123 
131  bool reinitialize(fhicl::ParameterSet const& pset, uint64_t timeout, uint64_t timestamp);
132 
139  void process_fragments();
140 
149  std::string report(std::string const& which) const;
150 
157  bool metaCommand(std::string const& command, std::string const& arg);
158 
163  static DataSenderManager* GetDataSenderManagerPtr() { return sender_ptr_.get(); }
164 
169  size_t GetFragmentsProcessed() { return fragment_count_; }
170 
171 private:
172  Commandable& parent_application_;
173  std::unique_ptr<CommandableFragmentGenerator> generator_ptr_;
174  art::RunID run_id_;
175 
176  fhicl::ParameterSet data_pset_;
177  int rt_priority_;
178  bool skip_seqId_test_;
179 
180  static std::unique_ptr<artdaq::DataSenderManager> sender_ptr_;
181 
182  std::atomic<size_t> fragment_count_;
183  artdaq::Fragment::sequence_id_t prev_seq_id_;
184  std::atomic<bool> stop_requested_;
185  std::atomic<bool> pause_requested_;
186 
187  // attributes and methods for statistics gathering & reporting
188  artdaq::StatisticsHelper statsHelper_;
189 
190  std::string buildStatisticsString_();
191 
192  void sendMetrics_();
193 
194  bool verbose_;
195 
200  void logMessage_(std::string const& text);
201 };
202 
203 #endif /* artdaq_Application_MPI2_BoardReaderCore_hh */
This class manages MonitoredQuantity instances for the *Core classes.
size_t GetFragmentsProcessed()
Get the number of Fragments processed this run
Commandable is the base class for all artdaq components which implement the artdaq state machine...
Definition: Commandable.hh:20
Sends Fragment objects using TransferInterface plugins. Uses Routing Tables if confgiured, otherwise will Round-Robin Fragments to the destinations.
bool initialize(fhicl::ParameterSet const &pset, uint64_t timeout, uint64_t timestamp)
Initialize the BoardReaderCore.
static DataSenderManager * GetDataSenderManagerPtr()
Gets a handle to the DataSenderManager.
static const std::string FRAGMENTS_PROCESSED_STAT_KEY
Key for the Fragments Processed MonitoredQuantity.
bool reinitialize(fhicl::ParameterSet const &pset, uint64_t timeout, uint64_t timestamp)
Reinitialize the BoardReader. No-Op.
static const std::string INPUT_WAIT_STAT_KEY
Key for the Input Wait MonitoredQuantity.
bool stop(uint64_t timeout, uint64_t timestamp)
Stop the BoardReader, and the CommandableFragmentGenerator.
BoardReaderCore implements the state machine for the BoardReader artdaq application. It contains a CommandableFragmentGenerator, which generates Fragments which are then sent to a DataSenderManager by BoardReaderCore.
virtual ~BoardReaderCore()
BoardReaderCore Destructor.
BoardReaderCore(Commandable &parent_application)
BoardReaderCore Constructor.
static const std::string BRSYNC_WAIT_STAT_KEY
Key for the Sync Wait MonitoredQuantity.
static const std::string FRAGMENTS_PER_READ_STAT_KEY
Key for the Fragments Per Read MonitoredQuantity.
static const std::string OUTPUT_WAIT_STAT_KEY
Key for the Output Wait MonitoredQuantity.
bool soft_initialize(fhicl::ParameterSet const &pset, uint64_t timeout, uint64_t timestamp)
Soft-Initialize the BoardReader. No-Op.
std::string report(std::string const &which) const
Send a report on a given run-time quantity.
void process_fragments()
Main working loop of the BoardReaderCore.
bool shutdown(uint64_t timeout)
Shutdown the BoardReader, and the CommandableFragmentGenerator.
bool start(art::RunID id, uint64_t timeout, uint64_t timestamp)
Start the BoardReader, and the CommandableFragmentGenerator.
bool resume(uint64_t timeout, uint64_t timestamp)
Resume the BoardReader, and the CommandableFragmentGenerator.
bool pause(uint64_t timeout, uint64_t timestamp)
Pause the BoardReader, and the CommandableFragmentGenerator.
bool metaCommand(std::string const &command, std::string const &arg)
Run a user-defined command on the CommandableFragmentGenerator.
BoardReaderCore & operator=(BoardReaderCore const &)=delete
Copy Assignment Operator is deleted.