LCOV - code coverage report
Current view: top level - artdaq/Application - DataReceiverCore.hh (source / functions) Coverage Total Hit
Test: artdaq.info.cleaned Lines: 0.0 % 6 0
Test Date: 2025-09-04 00:45:34 Functions: 0.0 % 2 0

            Line data    Source code
       1              : #ifndef artdaq_Application_MPI2_DataReceiverCore_hh
       2              : #define artdaq_Application_MPI2_DataReceiverCore_hh
       3              : 
       4              : #include "canvas/Persistency/Provenance/RunID.h"
       5              : #include "fhiclcpp/ParameterSet.h"
       6              : 
       7              : #include "artdaq/DAQrate/DataReceiverManager.hh"
       8              : #include "artdaq/DAQrate/SharedMemoryEventManager.hh"
       9              : 
      10              : #include <atomic>
      11              : #include <map>
      12              : #include <memory>
      13              : #include <string>
      14              : 
      15              : namespace artdaq {
      16              : class DataReceiverCore;
      17              : }
      18              : 
      19              : /**
      20              :  * \brief DataReceiverCore implements the state machine for the DataReceiver artdaq application.
      21              :  * DataReceiverCore receives Fragment objects from the DataReceiverManager, and sends them to the EventStore.
      22              :  */
      23              : class artdaq::DataReceiverCore
      24              : {
      25              : public:
      26              :         /**
      27              :          * \brief DataReceiverCore Constructor.
      28              :          */
      29              :         DataReceiverCore();
      30              : 
      31              :         /**
      32              :          * \brief Copy Constructor is deleted
      33              :          */
      34              :         DataReceiverCore(DataReceiverCore const&) = delete;
      35              : 
      36              :         /**
      37              :          * Destructor.
      38              :          */
      39              :         virtual ~DataReceiverCore();
      40              : 
      41              :         /**
      42              :          * \brief Copy Assignment operator is deleted
      43              :          * \return AggregatorCore copy
      44              :          */
      45              :         DataReceiverCore& operator=(DataReceiverCore const&) = delete;
      46              :         DataReceiverCore(DataReceiverCore&&) = delete;             ///< Move Constructor is deleted
      47              :         DataReceiverCore& operator=(DataReceiverCore&&) = delete;  ///< Move Assignment Operator is deleted
      48              : 
      49              :         /**
      50              :          * \brief Processes the initialize request.
      51              :          * \param pset ParameterSet used to configure the DataReceiverCore
      52              :          * \return Whether the initialize attempt succeeded
      53              :          *
      54              :          * \verbatim
      55              :          * DataReceiverCore accepts the following Parameters:
      56              :          * "daq" (REQUIRED): FHiCL table containing DAQ configuration
      57              :          *   "event_builder" (REQUIRED): FHiCL table containing Aggregator paramters
      58              :          *     "fragment_count" (REQUIRED): Number of Fragment objects to collect before sending them to art
      59              :          *     "inrun_recv_timeout_usec" (Default: 100000): Amount of time to wait for new Fragment objects while running
      60              :          *     "endrun_recv_timeout_usec" (Default: 20000000): Amount of time to wait for additional Fragment objects at EndOfRun
      61              :          *     "pause_recv_timeout_usec" (Default: 3000000): Amount of time to wait for additional Fragment objects at PauseRun
      62              :          *     "verbose" (Default: true): Whether to print transition messages
      63              :          *   "metrics": FHiCL table containing configuration for MetricManager
      64              :          * \endverbatim
      65              :          *
      66              :          *  Note that the "event_builder" ParameterSet is also used to configure the SharedMemoryEventManager. See that class' documentation for more information.
      67              :          */
      68              :         virtual bool initialize(fhicl::ParameterSet const& pset) = 0;
      69              : 
      70              :         /**
      71              :          * \brief Start the DataReceiverCore
      72              :          * \param id Run ID of the current run
      73              :          * \return True if no exception
      74              :          */
      75              :         bool start(art::RunID id);
      76              : 
      77              :         /**
      78              :          * \brief Stops the DataReceiverCore
      79              :          * \return True if no exception
      80              :          */
      81              :         bool stop();
      82              : 
      83              :         /**
      84              :          * \brief Pauses the DataReceiverCore
      85              :          * \return True if no exception
      86              :          */
      87              :         bool pause();
      88              : 
      89              :         /**
      90              :          * \brief Resumes the DataReceiverCore
      91              :          * \return True if no exception
      92              :          */
      93              :         bool resume();
      94              : 
      95              :         /**
      96              :          * \brief Shuts Down the DataReceiverCore
      97              :          * \return If the shutdown was successful
      98              :          */
      99              :         bool shutdown();
     100              : 
     101              :         /**
     102              :          * \brief Soft-Initializes the DataReceiverCore. No-Op
     103              :          * \param pset ParameterSet for configuring DataReceiverCore
     104              :          * \return Always returns true
     105              :          */
     106              :         bool soft_initialize(fhicl::ParameterSet const& pset);
     107              : 
     108              :         /**
     109              :          * \brief Reinitializes the DataReceiverCore.
     110              :          * \param pset ParameterSet for configuring DataReceiverCore
     111              :          * \return True if no exception
     112              :          */
     113              :         bool reinitialize(fhicl::ParameterSet const& pset);
     114              : 
     115              :         /**
     116              :          * \brief Rollover the subrun after the given event
     117              :          * \param boundary Sequence ID of boundary
     118              :          * \param subrun Subrun number of new subrun
     119              :          * \return True event_store_ptr is valid
     120              :          */
     121              :         bool rollover_subrun(uint64_t boundary, uint32_t subrun);
     122              : 
     123              :         /**
     124              :          * \brief Send a report on a given run-time quantity
     125              :          * \param which Which quantity to report
     126              :          * \return A string containing the requested quantity.
     127              :          *
     128              :          * report accepts the following values of "which":
     129              :          * "event_count": The number of events received, or -1 if not initialized
     130              :          * "incomplete_event_count": The number of incomplete event bunches in the EventStore, or -1 if not initalized
     131              :          *
     132              :          * Anything else will return the run number and an error message.
     133              :          */
     134              :         std::string report(std::string const& which) const;
     135              : 
     136              :         /**
     137              :          * \brief Add the specified key and value to the configuration archive list.
     138              :          * \param key String key to be used
     139              :          * \param value String value to be stored
     140              :          * \return This function will always return true
     141              :          */
     142            0 :         bool add_config_archive_entry(std::string const& key, std::string const& value)
     143              :         {
     144            0 :                 config_archive_entries_[key] = value;
     145            0 :                 return true;
     146              :         }
     147              : 
     148              :         /**
     149              :          * \brief Clear the configuration archive list.
     150              :          * \return True if archive is empty after clear operation
     151              :          */
     152            0 :         bool clear_config_archive()
     153              :         {
     154            0 :                 config_archive_entries_.clear();
     155            0 :                 return config_archive_entries_.empty();
     156              :         }
     157              : 
     158              : protected:
     159              :         /**
     160              :          * \brief Initialize the DataReceiverCore (should be called from initialize() overrides
     161              :          * \param pset ParameterSet for art configuration
     162              :          * \param data_pset ParameterSet for DataReceiverManager and SharedMemoryEventManager configuration
     163              :          * \param metric_pset ParameterSet for MetricManager
     164              :          * \return Whether the initialize succeeded
     165              :          */
     166              :         bool initializeDataReceiver(fhicl::ParameterSet const& pset, fhicl::ParameterSet const& data_pset, fhicl::ParameterSet const& metric_pset);
     167              : 
     168              :         std::unique_ptr<DataReceiverManager> receiver_ptr_;          ///< Pointer to the DataReceiverManager
     169              :         std::shared_ptr<SharedMemoryEventManager> event_store_ptr_;  ///< Pointer to the SharedMemoryEventManager
     170              :         std::atomic<bool> stop_requested_;                           ///< Stop has been requested?
     171              :         std::atomic<bool> pause_requested_;                          ///< Pause has been requested?
     172              :         std::atomic<bool> run_is_paused_;                            ///< Pause has been successfully completed?
     173              :         bool verbose_;                                               ///< Whether to log transition messages
     174              : 
     175              :         fhicl::ParameterSet art_pset_;                               ///< ParameterSet sent to art process
     176              :         std::map<std::string, std::string> config_archive_entries_;  ///< Additional strings to archive as part of the art configuration
     177              : };
     178              : 
     179              : #endif /* artdaq_Application_MPI2_DataReceiverCore_hh */
        

Generated by: LCOV version 2.0-1