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

            Line data    Source code
       1              : #include "artdaq/DAQdata/Globals.hh"  // include these 2 first -
       2              : #define TRACE_NAME (app_name + "_DataLoggerApp").c_str()
       3              : 
       4              : #include "artdaq-core/Utilities/ExceptionHandler.hh"
       5              : #include "artdaq/Application/DataLoggerApp.hh"
       6              : #include "artdaq/Application/DataLoggerCore.hh"
       7              : 
       8              : #include <boost/lexical_cast.hpp>
       9              : 
      10              : #include <iostream>
      11              : #include <memory>
      12              : 
      13            0 : artdaq::DataLoggerApp::DataLoggerApp() = default;
      14              : 
      15              : // *******************************************************************
      16              : // *** The following methods implement the state machine operations.
      17              : // *******************************************************************
      18              : 
      19            0 : bool artdaq::DataLoggerApp::do_initialize(fhicl::ParameterSet const& pset, uint64_t /*unused*/, uint64_t /*unused*/)
      20              : {
      21            0 :         report_string_ = "";
      22              : 
      23              :         // DataLogger_ptr_.reset(nullptr);
      24            0 :         if (DataLogger_ptr_ == nullptr)
      25              :         {
      26            0 :                 DataLogger_ptr_ = std::make_unique<DataLoggerCore>();
      27              :         }
      28            0 :         external_request_status_ = DataLogger_ptr_->initialize(pset);
      29            0 :         if (!external_request_status_)
      30              :         {
      31            0 :                 report_string_ = "Error initializing ";
      32            0 :                 report_string_.append(app_name + " ");
      33            0 :                 report_string_.append("with ParameterSet = \"" + pset.to_string() + "\".");
      34              :         }
      35              : 
      36            0 :         return external_request_status_;
      37              : }
      38              : 
      39            0 : bool artdaq::DataLoggerApp::do_start(art::RunID id, uint64_t /*unused*/, uint64_t /*unused*/)
      40              : {
      41            0 :         report_string_ = "";
      42            0 :         external_request_status_ = DataLogger_ptr_->start(id);
      43            0 :         if (!external_request_status_)
      44              :         {
      45            0 :                 report_string_ = "Error starting ";
      46            0 :                 report_string_.append(app_name + " ");
      47            0 :                 report_string_.append("for run number ");
      48            0 :                 report_string_.append(boost::lexical_cast<std::string>(id.run()));
      49            0 :                 report_string_.append(".");
      50              :         }
      51              : 
      52            0 :         return external_request_status_;
      53              : }
      54              : 
      55            0 : bool artdaq::DataLoggerApp::do_stop(uint64_t /*unused*/, uint64_t /*unused*/)
      56              : {
      57            0 :         report_string_ = "";
      58            0 :         external_request_status_ = DataLogger_ptr_->stop();
      59            0 :         if (!external_request_status_)
      60              :         {
      61            0 :                 report_string_ = "Error stopping ";
      62            0 :                 report_string_.append(app_name + ".");
      63              :         }
      64              : 
      65            0 :         return external_request_status_;
      66              : }
      67              : 
      68            0 : bool artdaq::DataLoggerApp::do_pause(uint64_t /*unused*/, uint64_t /*unused*/)
      69              : {
      70            0 :         report_string_ = "";
      71            0 :         external_request_status_ = DataLogger_ptr_->pause();
      72            0 :         if (!external_request_status_)
      73              :         {
      74            0 :                 report_string_ = "Error pausing ";
      75            0 :                 report_string_.append(app_name + ".");
      76              :         }
      77              : 
      78            0 :         return external_request_status_;
      79              : }
      80              : 
      81            0 : bool artdaq::DataLoggerApp::do_resume(uint64_t /*unused*/, uint64_t /*unused*/)
      82              : {
      83            0 :         report_string_ = "";
      84            0 :         external_request_status_ = DataLogger_ptr_->resume();
      85            0 :         if (!external_request_status_)
      86              :         {
      87            0 :                 report_string_ = "Error resuming ";
      88            0 :                 report_string_.append(app_name + ".");
      89              :         }
      90              : 
      91            0 :         return external_request_status_;
      92              : }
      93              : 
      94            0 : bool artdaq::DataLoggerApp::do_shutdown(uint64_t /*unused*/)
      95              : {
      96            0 :         report_string_ = "";
      97            0 :         external_request_status_ = DataLogger_ptr_->shutdown();
      98            0 :         if (!external_request_status_)
      99              :         {
     100            0 :                 report_string_ = "Error shutting down ";
     101            0 :                 report_string_.append(app_name + ".");
     102              :         }
     103              : 
     104            0 :         return external_request_status_;
     105              : }
     106              : 
     107            0 : bool artdaq::DataLoggerApp::do_soft_initialize(fhicl::ParameterSet const& /*unused*/, uint64_t /*unused*/, uint64_t /*unused*/)
     108              : {
     109            0 :         return true;
     110              : }
     111              : 
     112            0 : bool artdaq::DataLoggerApp::do_reinitialize(fhicl::ParameterSet const& /*unused*/, uint64_t /*unused*/, uint64_t /*unused*/)
     113              : {
     114            0 :         return true;
     115              : }
     116              : 
     117            0 : std::string artdaq::DataLoggerApp::report(std::string const& which) const
     118              : {
     119            0 :         std::string resultString;
     120              : 
     121              :         // if all that is requested is the latest state change result, return it
     122            0 :         if (which == "transition_status")
     123              :         {
     124            0 :                 if (report_string_.length() > 0) { return report_string_; }
     125              : 
     126            0 :                 return "Success";
     127              :         }
     128              : 
     129              :         //// if there is an outstanding report/message at the Commandable/Application
     130              :         //// level, prepend that
     131              :         // if (report_string_.length() > 0) {
     132              :         //   resultString.append("*** Overall status message:\r\n");
     133              :         //   resultString.append(report_string_ + "\r\n");
     134              :         //   resultString.append("*** Requested report response:\r\n");
     135              :         // }
     136              : 
     137              :         // pass the request to the DataLoggerCore instance, if it's available
     138            0 :         if (DataLogger_ptr_ != nullptr)
     139              :         {
     140            0 :                 resultString.append(DataLogger_ptr_->report(which));
     141              :         }
     142              :         else
     143              :         {
     144            0 :                 resultString.append("This DataLogger has not yet been initialized and ");
     145            0 :                 resultString.append("therefore can not provide reporting.");
     146              :         }
     147              : 
     148            0 :         return resultString;
     149            0 : }
     150              : 
     151            0 : bool artdaq::DataLoggerApp::do_add_config_archive_entry(std::string const& key, std::string const& value)
     152              : {
     153            0 :         report_string_ = "";
     154            0 :         external_request_status_ = DataLogger_ptr_->add_config_archive_entry(key, value);
     155            0 :         if (!external_request_status_)
     156              :         {
     157            0 :                 report_string_ = "Error adding config entry with key ";
     158            0 :                 report_string_.append(key + " and value \"");
     159            0 :                 report_string_.append(value + "\" in");
     160            0 :                 report_string_.append(app_name + ".");
     161              :         }
     162              : 
     163            0 :         return external_request_status_;
     164              : }
     165              : 
     166            0 : bool artdaq::DataLoggerApp::do_clear_config_archive()
     167              : {
     168            0 :         report_string_ = "";
     169            0 :         external_request_status_ = DataLogger_ptr_->clear_config_archive();
     170            0 :         if (!external_request_status_)
     171              :         {
     172            0 :                 report_string_ = "Error clearing the configuration archive in ";
     173            0 :                 report_string_.append(app_name + ".");
     174              :         }
     175              : 
     176            0 :         return external_request_status_;
     177              : }
        

Generated by: LCOV version 2.0-1