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

            Line data    Source code
       1              : #include "TRACE/tracemf.h"
       2              : #include "artdaq/DAQdata/Globals.hh"  // include these 2 first -
       3              : #define TRACE_NAME (app_name + "_DataLoggerApp").c_str()
       4              : 
       5              : #include "artdaq/Application/EventBuilderApp.hh"
       6              : 
       7              : #include "fhiclcpp/ParameterSet.h"
       8              : 
       9              : #include <boost/lexical_cast.hpp>
      10              : 
      11              : #include <iomanip>
      12              : #include <memory>
      13              : 
      14            0 : artdaq::EventBuilderApp::EventBuilderApp() = default;
      15              : 
      16              : // *******************************************************************
      17              : // *** The following methods implement the state machine operations.
      18              : // *******************************************************************
      19              : 
      20            0 : bool artdaq::EventBuilderApp::do_initialize(fhicl::ParameterSet const& pset, uint64_t /*unused*/, uint64_t /*unused*/)
      21              : {
      22            0 :         report_string_ = "";
      23            0 :         external_request_status_ = true;
      24              : 
      25              :         // in the following block, we first destroy the existing EventBuilder
      26              :         // instance, then create a new one.  Doing it in one step does not
      27              :         // produce the desired result since that creates a new instance and
      28              :         // then deletes the old one, and we need the opposite order.
      29              :         // event_builder_ptr_.reset(nullptr);
      30            0 :         if (event_builder_ptr_ == nullptr)
      31              :         {
      32            0 :                 event_builder_ptr_ = std::make_unique<EventBuilderCore>();
      33            0 :                 external_request_status_ = event_builder_ptr_->initialize(pset);
      34              :         }
      35            0 :         if (!external_request_status_)
      36              :         {
      37            0 :                 report_string_ = "Error initializing an EventBuilderCore named";
      38            0 :                 report_string_.append(app_name + " with ");
      39            0 :                 report_string_.append("ParameterSet = \"" + pset.to_string() + "\".");
      40              :         }
      41              : 
      42            0 :         return external_request_status_;
      43              : }
      44              : 
      45            0 : bool artdaq::EventBuilderApp::do_start(art::RunID id, uint64_t /*unused*/, uint64_t /*unused*/)
      46              : {
      47            0 :         report_string_ = "";
      48            0 :         external_request_status_ = event_builder_ptr_->start(id);
      49            0 :         if (!external_request_status_)
      50              :         {
      51            0 :                 report_string_ = "Error starting ";
      52            0 :                 report_string_.append(app_name + " for run ");
      53            0 :                 report_string_.append("number ");
      54            0 :                 report_string_.append(boost::lexical_cast<std::string>(id.run()));
      55            0 :                 report_string_.append(".");
      56              :         }
      57              : 
      58            0 :         return external_request_status_;
      59              : }
      60              : 
      61            0 : bool artdaq::EventBuilderApp::do_stop(uint64_t /*unused*/, uint64_t /*unused*/)
      62              : {
      63            0 :         report_string_ = "";
      64            0 :         external_request_status_ = event_builder_ptr_->stop();
      65            0 :         if (!external_request_status_)
      66              :         {
      67            0 :                 report_string_ = "Error stopping ";
      68            0 :                 report_string_.append(app_name + ".");
      69              :         }
      70            0 :         return external_request_status_;
      71              : }
      72              : 
      73            0 : bool artdaq::EventBuilderApp::do_pause(uint64_t /*unused*/, uint64_t /*unused*/)
      74              : {
      75            0 :         report_string_ = "";
      76            0 :         external_request_status_ = event_builder_ptr_->pause();
      77            0 :         if (!external_request_status_)
      78              :         {
      79            0 :                 report_string_ = "Error pausing ";
      80            0 :                 report_string_.append(app_name + ".");
      81              :         }
      82              : 
      83            0 :         return external_request_status_;
      84              : }
      85              : 
      86            0 : bool artdaq::EventBuilderApp::do_resume(uint64_t /*unused*/, uint64_t /*unused*/)
      87              : {
      88            0 :         report_string_ = "";
      89            0 :         external_request_status_ = event_builder_ptr_->resume();
      90            0 :         if (!external_request_status_)
      91              :         {
      92            0 :                 report_string_ = "Error resuming ";
      93            0 :                 report_string_.append(app_name + ".");
      94              :         }
      95              : 
      96            0 :         return external_request_status_;
      97              : }
      98              : 
      99            0 : bool artdaq::EventBuilderApp::do_shutdown(uint64_t /*unused*/)
     100              : {
     101            0 :         report_string_ = "";
     102            0 :         external_request_status_ = event_builder_ptr_->shutdown();
     103            0 :         if (!external_request_status_)
     104              :         {
     105            0 :                 report_string_ = "Error shutting down ";
     106            0 :                 report_string_.append(app_name + ".");
     107              :         }
     108            0 :         return external_request_status_;
     109              : }
     110              : 
     111            0 : bool artdaq::EventBuilderApp::do_soft_initialize(fhicl::ParameterSet const& pset, uint64_t /*unused*/, uint64_t /*unused*/)
     112              : {
     113            0 :         report_string_ = "";
     114            0 :         external_request_status_ = event_builder_ptr_->soft_initialize(pset);
     115            0 :         if (!external_request_status_)
     116              :         {
     117            0 :                 report_string_ = "Error soft-initializing ";
     118            0 :                 report_string_.append(app_name + " with ");
     119            0 :                 report_string_.append("ParameterSet = \"" + pset.to_string() + "\".");
     120              :         }
     121            0 :         return external_request_status_;
     122              : }
     123              : 
     124            0 : bool artdaq::EventBuilderApp::do_reinitialize(fhicl::ParameterSet const& pset, uint64_t /*unused*/, uint64_t /*unused*/)
     125              : {
     126            0 :         report_string_ = "";
     127            0 :         external_request_status_ = event_builder_ptr_->reinitialize(pset);
     128            0 :         if (!external_request_status_)
     129              :         {
     130            0 :                 report_string_ = "Error reinitializing ";
     131            0 :                 report_string_.append(app_name + " with ");
     132            0 :                 report_string_.append("ParameterSet = \"" + pset.to_string() + "\".");
     133              :         }
     134            0 :         return external_request_status_;
     135              : }
     136              : 
     137            0 : bool artdaq::EventBuilderApp::do_rollover_subrun(uint64_t boundary, uint32_t subrun)
     138              : {
     139            0 :         TLOG(TLVL_DEBUG + 32) << "do_rollover_subrun BEGIN boundary=" << boundary << ", subrun=" << subrun;
     140            0 :         report_string_ = "";
     141            0 :         external_request_status_ = event_builder_ptr_->rollover_subrun(boundary, subrun);
     142            0 :         if (!external_request_status_)
     143              :         {
     144            0 :                 report_string_ = "Error rolling over subrun in ";
     145            0 :                 report_string_.append(app_name + "!");
     146              :         }
     147            0 :         TLOG(TLVL_DEBUG + 32) << "do_rollover_subrun END sts=" << std::boolalpha << external_request_status_;
     148            0 :         return external_request_status_;
     149              : }
     150              : 
     151            0 : void artdaq::EventBuilderApp::BootedEnter()
     152              : {
     153            0 :         TLOG(TLVL_DEBUG + 32, app_name + "App") << "Booted state entry action called.";
     154              : 
     155              :         // the destruction of any existing EventBuilderCore has to happen in the
     156              :         // Booted Entry action rather than the Initialized Exit action because the
     157              :         // Initialized Exit action is only called after the "init" transition guard
     158              :         // condition is executed.
     159              :         // event_builder_ptr_.reset(nullptr);
     160            0 : }
     161              : 
     162            0 : std::string artdaq::EventBuilderApp::report(std::string const& which) const
     163              : {
     164            0 :         std::string resultString;
     165              : 
     166              :         // if all that is requested is the latest state change result, return it
     167            0 :         if (which == "transition_status")
     168              :         {
     169            0 :                 if (report_string_.length() > 0) { return report_string_; }
     170              : 
     171            0 :                 return "Success";
     172              :         }
     173              : 
     174              :         //// if there is an outstanding report/message at the Commandable/Application
     175              :         //// level, prepend that
     176              :         // if (report_string_.length() > 0) {
     177              :         //   resultString.append("*** Overall status message:\r\n");
     178              :         //   resultString.append(report_string_ + "\r\n");
     179              :         //   resultString.append("*** Requested report response:\r\n");
     180              :         // }
     181              : 
     182              :         // pass the request to the EventBuilderCore instance, if it's available
     183            0 :         if (event_builder_ptr_ != nullptr)
     184              :         {
     185            0 :                 resultString.append(event_builder_ptr_->report(which));
     186              :         }
     187              :         else
     188              :         {
     189            0 :                 resultString.append("This EventBuilder has not yet been initialized and ");
     190            0 :                 resultString.append("therefore can not provide reporting.");
     191              :         }
     192              : 
     193            0 :         return resultString;
     194            0 : }
     195              : 
     196            0 : bool artdaq::EventBuilderApp::do_add_config_archive_entry(std::string const& key, std::string const& value)
     197              : {
     198            0 :         report_string_ = "";
     199            0 :         external_request_status_ = event_builder_ptr_->add_config_archive_entry(key, value);
     200            0 :         if (!external_request_status_)
     201              :         {
     202            0 :                 report_string_ = "Error adding config entry with key ";
     203            0 :                 report_string_.append(key + " and value \"");
     204            0 :                 report_string_.append(value + "\" in");
     205            0 :                 report_string_.append(app_name + ".");
     206              :         }
     207              : 
     208            0 :         return external_request_status_;
     209              : }
     210              : 
     211            0 : bool artdaq::EventBuilderApp::do_clear_config_archive()
     212              : {
     213            0 :         report_string_ = "";
     214            0 :         external_request_status_ = event_builder_ptr_->clear_config_archive();
     215            0 :         if (!external_request_status_)
     216              :         {
     217            0 :                 report_string_ = "Error clearing the configuration archive in ";
     218            0 :                 report_string_.append(app_name + ".");
     219              :         }
     220              : 
     221            0 :         return external_request_status_;
     222              : }
        

Generated by: LCOV version 2.0-1