LCOV - code coverage report
Current view: top level - artdaq/Application - Commandable.cc (source / functions) Coverage Total Hit
Test: artdaq.info.cleaned Lines: 72.9 % 336 245
Test Date: 2026-10-29 00:35:58 Functions: 84.1 % 82 69

            Line data    Source code
       1              : #include "TRACE/tracemf.h"
       2              : #include "artdaq/DAQdata/Globals.hh"
       3              : #define TRACE_NAME (app_name + "_CommandableInterface").c_str()  // definition with variable should be after includes (which may or may not have TLOG/TRACE statements)
       4              : 
       5              : #include "artdaq-core/Utilities/TimeUtils.hh"
       6              : #include "artdaq/Application/Commandable.hh"
       7              : 
       8              : // ELF 3/22/18:
       9              : // We may want to separate these onto different levels later,
      10              : // but I think the TRACE_NAME separation is enough for now...
      11              : #define TLVL_INIT TLVL_INFO
      12              : #define TLVL_STOP TLVL_INFO
      13              : #define TLVL_STATUS TLVL_DEBUG + 33
      14              : #define TLVL_START TLVL_INFO
      15              : #define TLVL_PAUSE TLVL_INFO
      16              : #define TLVL_RESUME TLVL_INFO
      17              : #define TLVL_SHUTDOWN TLVL_INFO
      18              : #define TLVL_ROLLOVER TLVL_INFO
      19              : #define TLVL_SOFT_INIT TLVL_INFO
      20              : #define TLVL_REINIT TLVL_INFO
      21              : #define TLVL_INRUN_FAILURE TLVL_INFO
      22              : #define TLVL_LEGAL_COMMANDS TLVL_INFO
      23              : 
      24            1 : artdaq::Commandable::Commandable()
      25            1 :     : fsm_(*this)
      26              : 
      27            1 : {}
      28              : 
      29              : // **********************************************************************
      30              : // *** The following methods implement the externally available commands.
      31              : // **********************************************************************
      32              : 
      33            1 : bool artdaq::Commandable::initialize(fhicl::ParameterSet const& pset, uint64_t timeout, uint64_t timestamp)
      34              : {
      35            1 :         std::lock_guard<std::mutex> lk(primary_mutex_);
      36            1 :         external_request_status_ = true;
      37            1 :         report_string_ = "All is OK.";
      38              : 
      39            1 :         Globals::SetMFModuleName("Initializing");
      40              : 
      41            3 :         TLOG(TLVL_INIT) << "Initialize transition started";
      42            1 :         auto start_time = std::chrono::steady_clock::now();
      43            1 :         std::string initialState = fsm_.getState().getName();
      44            1 :         fsm_.init(pset, timeout, timestamp);
      45            3 :         TLOG(TLVL_INIT) << "FSM initialized";
      46            1 :         if (external_request_status_)
      47              :         {
      48            1 :                 std::string finalState = fsm_.getState().getName();
      49              : 
      50            1 :                 Globals::SetMFModuleName(finalState);
      51            2 :                 TLOG(TLVL_DEBUG + 32)
      52            0 :                     << "States before and after an init transition: "
      53            1 :                     << initialState << " and " << finalState << ". Transition Duration: " << TimeUtils::GetElapsedTime(start_time) << " s.";
      54            1 :         }
      55            1 :         if (metricMan && metricMan->Initialized())
      56              :         {
      57            0 :                 metricMan->sendMetric("DAQ Transition Time", TimeUtils::GetElapsedTime(start_time), "s", 4, artdaq::MetricMode::Accumulate);
      58              :         }
      59              : 
      60            3 :         TLOG(TLVL_INIT) << "Initialize transition complete";
      61            1 :         return (external_request_status_);
      62            1 : }
      63              : 
      64            1 : bool artdaq::Commandable::start(art::RunID id, uint64_t timeout, uint64_t timestamp)
      65              : {
      66            1 :         std::lock_guard<std::mutex> lk(primary_mutex_);
      67            1 :         external_request_status_ = true;
      68            1 :         report_string_ = "All is OK.";
      69              : 
      70            1 :         Globals::SetMFModuleName("Starting");
      71              : 
      72            3 :         TLOG(TLVL_START) << "Start transition started";
      73            1 :         auto start_time = std::chrono::steady_clock::now();
      74            1 :         std::string initialState = fsm_.getState().getName();
      75            1 :         fsm_.start(id, timeout, timestamp);
      76            1 :         if (external_request_status_)
      77              :         {
      78            1 :                 std::string finalState = fsm_.getState().getName();
      79              : 
      80            1 :                 Globals::SetMFModuleName(finalState);
      81            2 :                 TLOG(TLVL_DEBUG + 32)
      82            0 :                     << "States before and after a start transition: "
      83            1 :                     << initialState << " and " << finalState << ". Transition Duration: " << TimeUtils::GetElapsedTime(start_time) << " s.";
      84            1 :         }
      85            1 :         if (metricMan && metricMan->Initialized())
      86              :         {
      87            0 :                 metricMan->sendMetric("DAQ Transition Time", TimeUtils::GetElapsedTime(start_time), "s", 4, artdaq::MetricMode::Accumulate);
      88              :         }
      89              : 
      90            3 :         TLOG(TLVL_START) << "Start transition complete";
      91            1 :         return (external_request_status_);
      92            1 : }
      93              : 
      94            1 : bool artdaq::Commandable::stop(uint64_t timeout, uint64_t timestamp)
      95              : {
      96            1 :         std::lock_guard<std::mutex> lk(primary_mutex_);
      97            1 :         external_request_status_ = true;
      98            1 :         report_string_ = "All is OK.";
      99              : 
     100            1 :         Globals::SetMFModuleName("Stopping");
     101              : 
     102            3 :         TLOG(TLVL_STOP) << "Stop transition started";
     103            1 :         auto start_time = std::chrono::steady_clock::now();
     104            1 :         std::string initialState = fsm_.getState().getName();
     105            1 :         fsm_.stop(timeout, timestamp);
     106            1 :         if (external_request_status_)
     107              :         {
     108            1 :                 std::string finalState = fsm_.getState().getName();
     109              : 
     110            1 :                 Globals::SetMFModuleName(finalState);
     111            2 :                 TLOG(TLVL_DEBUG + 32)
     112            0 :                     << "States before and after a stop transition: "
     113            1 :                     << initialState << " and " << finalState << ". Transition Duration: " << TimeUtils::GetElapsedTime(start_time) << " s.";
     114            1 :         }
     115            1 :         if (metricMan && metricMan->Initialized())
     116              :         {
     117            0 :                 metricMan->sendMetric("DAQ Transition Time", TimeUtils::GetElapsedTime(start_time), "s", 4, artdaq::MetricMode::Accumulate);
     118              :         }
     119              : 
     120            3 :         TLOG(TLVL_STOP) << "Stop transition complete";
     121            1 :         return (external_request_status_);
     122            1 : }
     123              : 
     124            1 : bool artdaq::Commandable::pause(uint64_t timeout, uint64_t timestamp)
     125              : {
     126            1 :         std::lock_guard<std::mutex> lk(primary_mutex_);
     127            1 :         external_request_status_ = true;
     128            1 :         report_string_ = "All is OK.";
     129              : 
     130            1 :         Globals::SetMFModuleName("Pausing");
     131              : 
     132            3 :         TLOG(TLVL_PAUSE) << "Pause transition started";
     133            1 :         auto start_time = std::chrono::steady_clock::now();
     134            1 :         std::string initialState = fsm_.getState().getName();
     135            1 :         fsm_.pause(timeout, timestamp);
     136            1 :         if (external_request_status_)
     137              :         {
     138            1 :                 std::string finalState = fsm_.getState().getName();
     139              : 
     140            1 :                 Globals::SetMFModuleName(finalState);
     141            2 :                 TLOG(TLVL_DEBUG + 32)
     142            0 :                     << "States before and after a pause transition: "
     143            1 :                     << initialState << " and " << finalState << ". Transition Duration: " << TimeUtils::GetElapsedTime(start_time) << " s.";
     144            1 :         }
     145            1 :         if (metricMan && metricMan->Initialized())
     146              :         {
     147            0 :                 metricMan->sendMetric("DAQ Transition Time", TimeUtils::GetElapsedTime(start_time), "s", 4, artdaq::MetricMode::Accumulate);
     148              :         }
     149              : 
     150            3 :         TLOG(TLVL_PAUSE) << "Pause transition complete";
     151            1 :         return (external_request_status_);
     152            1 : }
     153              : 
     154            1 : bool artdaq::Commandable::resume(uint64_t timeout, uint64_t timestamp)
     155              : {
     156            1 :         std::lock_guard<std::mutex> lk(primary_mutex_);
     157            1 :         external_request_status_ = true;
     158            1 :         report_string_ = "All is OK.";
     159              : 
     160            1 :         Globals::SetMFModuleName("Resuming");
     161              : 
     162            3 :         TLOG(TLVL_RESUME) << "Resume transition started";
     163            1 :         auto start_time = std::chrono::steady_clock::now();
     164            1 :         std::string initialState = fsm_.getState().getName();
     165            1 :         fsm_.resume(timeout, timestamp);
     166            1 :         if (external_request_status_)
     167              :         {
     168            1 :                 std::string finalState = fsm_.getState().getName();
     169            1 :                 Globals::SetMFModuleName(finalState);
     170            2 :                 TLOG(TLVL_DEBUG + 32)
     171            0 :                     << "States before and after a resume transition: "
     172            1 :                     << initialState << " and " << finalState << ". Transition Duration: " << TimeUtils::GetElapsedTime(start_time) << " s.";
     173            1 :         }
     174            1 :         if (metricMan && metricMan->Initialized())
     175              :         {
     176            0 :                 metricMan->sendMetric("DAQ Transition Time", TimeUtils::GetElapsedTime(start_time), "s", 4, artdaq::MetricMode::Accumulate);
     177              :         }
     178              : 
     179            3 :         TLOG(TLVL_RESUME) << "Resume transition complete";
     180            1 :         return (external_request_status_);
     181            1 : }
     182              : 
     183            1 : bool artdaq::Commandable::shutdown(uint64_t timeout)
     184              : {
     185            1 :         std::lock_guard<std::mutex> lk(primary_mutex_);
     186            1 :         external_request_status_ = true;
     187            1 :         report_string_ = "All is OK.";
     188            1 :         Globals::SetMFModuleName("Shutting Down");
     189              : 
     190            3 :         TLOG(TLVL_SHUTDOWN) << "Shutdown transition started";
     191            1 :         auto start_time = std::chrono::steady_clock::now();
     192            1 :         std::string initialState = fsm_.getState().getName();
     193            1 :         fsm_.shutdown(timeout);
     194            1 :         if (external_request_status_)
     195              :         {
     196            1 :                 std::string finalState = fsm_.getState().getName();
     197              :                 // Globals::SetMFModuleName(finalState); // ELF, 12/17/20: We may have already shut down MessageFacility
     198            2 :                 TLOG(TLVL_DEBUG + 32)
     199            0 :                     << "States before and after a shutdown transition: "
     200            1 :                     << initialState << " and " << finalState << ". Transition Duration: " << TimeUtils::GetElapsedTime(start_time) << " s.";
     201            1 :         }
     202            1 :         if (metricMan && metricMan->Initialized())
     203              :         {
     204            0 :                 metricMan->sendMetric("DAQ Transition Time", TimeUtils::GetElapsedTime(start_time), "s", 4, artdaq::MetricMode::Accumulate);
     205              :         }
     206              : 
     207            3 :         TLOG(TLVL_SHUTDOWN) << "Shutdown transition complete";
     208            1 :         return (external_request_status_);
     209            1 : }
     210              : 
     211            1 : bool artdaq::Commandable::soft_initialize(fhicl::ParameterSet const& pset, uint64_t timeout, uint64_t timestamp)
     212              : {
     213            1 :         std::lock_guard<std::mutex> lk(primary_mutex_);
     214            1 :         external_request_status_ = true;
     215            1 :         report_string_ = "All is OK.";
     216              : 
     217            1 :         Globals::SetMFModuleName("Soft_initializing");
     218              : 
     219            3 :         TLOG(TLVL_SOFT_INIT) << "Soft_initialize transition started";
     220            1 :         auto start_time = std::chrono::steady_clock::now();
     221            1 :         std::string initialState = fsm_.getState().getName();
     222            1 :         fsm_.soft_init(pset, timeout, timestamp);
     223            1 :         if (external_request_status_)
     224              :         {
     225            1 :                 std::string finalState = fsm_.getState().getName();
     226              : 
     227            1 :                 Globals::SetMFModuleName(finalState);
     228            2 :                 TLOG(TLVL_DEBUG + 32)
     229            0 :                     << "States before and after a soft_init transition: "
     230            1 :                     << initialState << " and " << finalState << ". Transition Duration: " << TimeUtils::GetElapsedTime(start_time) << " s.";
     231            1 :         }
     232            1 :         if (metricMan && metricMan->Initialized())
     233              :         {
     234            0 :                 metricMan->sendMetric("DAQ Transition Time", TimeUtils::GetElapsedTime(start_time), "s", 4, artdaq::MetricMode::Accumulate);
     235              :         }
     236              : 
     237            3 :         TLOG(TLVL_SOFT_INIT) << "Soft_initialize transition complete";
     238            1 :         return (external_request_status_);
     239            1 : }
     240              : 
     241            1 : bool artdaq::Commandable::reinitialize(fhicl::ParameterSet const& pset, uint64_t timeout, uint64_t timestamp)
     242              : {
     243            1 :         std::lock_guard<std::mutex> lk(primary_mutex_);
     244            1 :         external_request_status_ = true;
     245            1 :         report_string_ = "All is OK.";
     246              : 
     247            1 :         Globals::SetMFModuleName("Reinitializing");
     248              : 
     249            3 :         TLOG(TLVL_REINIT) << "Reinitialize transition started";
     250            1 :         auto start_time = std::chrono::steady_clock::now();
     251            1 :         std::string initialState = fsm_.getState().getName();
     252            1 :         fsm_.reinit(pset, timeout, timestamp);
     253            1 :         if (external_request_status_)
     254              :         {
     255            1 :                 std::string finalState = fsm_.getState().getName();
     256              : 
     257            1 :                 Globals::SetMFModuleName(finalState);
     258            2 :                 TLOG(TLVL_DEBUG + 32)
     259            0 :                     << "States before and after a reinit transition: "
     260            1 :                     << initialState << " and " << finalState << ". Transition Duration: " << TimeUtils::GetElapsedTime(start_time) << " s.";
     261            1 :         }
     262            1 :         if (metricMan && metricMan->Initialized())
     263              :         {
     264            0 :                 metricMan->sendMetric("DAQ Transition Time", TimeUtils::GetElapsedTime(start_time), "s", 4, artdaq::MetricMode::Accumulate);
     265              :         }
     266              : 
     267            3 :         TLOG(TLVL_REINIT) << "Reinitialize transition complete";
     268            1 :         return (external_request_status_);
     269            1 : }
     270              : 
     271            0 : bool artdaq::Commandable::in_run_failure()
     272              : {
     273            0 :         std::lock_guard<std::mutex> lk(primary_mutex_);
     274            0 :         external_request_status_ = true;
     275            0 :         report_string_ = "An error condition was reported while running.";
     276              : 
     277            0 :         Globals::SetMFModuleName("Failing");
     278              : 
     279            0 :         TLOG(TLVL_INRUN_FAILURE) << "In_Run_Failure transition started";
     280            0 :         auto start_time = std::chrono::steady_clock::now();
     281            0 :         std::string initialState = fsm_.getState().getName();
     282            0 :         fsm_.in_run_failure();
     283            0 :         if (external_request_status_)
     284              :         {
     285            0 :                 std::string finalState = fsm_.getState().getName();
     286              : 
     287            0 :                 Globals::SetMFModuleName(finalState);
     288            0 :                 TLOG(TLVL_DEBUG + 32)
     289            0 :                     << "States before and after an in_run_failure transition: "
     290            0 :                     << initialState << " and " << finalState << ". Transition Duration: " << TimeUtils::GetElapsedTime(start_time) << " s.";
     291            0 :         }
     292            0 :         if (metricMan && metricMan->Initialized())
     293              :         {
     294            0 :                 metricMan->sendMetric("DAQ Transition Time", TimeUtils::GetElapsedTime(start_time), "s", 4, artdaq::MetricMode::Accumulate);
     295              :         }
     296              : 
     297            0 :         TLOG(TLVL_INRUN_FAILURE) << "in_run_failure complete";
     298            0 :         return (external_request_status_);
     299            0 : }
     300              : 
     301            1 : std::string artdaq::Commandable::status() const
     302              : {
     303            1 :         std::lock_guard<std::mutex> lk(primary_mutex_);
     304            2 :         TLOG(TLVL_STATUS) << "Status command started";
     305            1 :         std::string currentState = this->current_state();
     306            1 :         if (currentState == "InRunError")
     307              :         {
     308            0 :                 return "Error";
     309              :         }
     310            2 :         TLOG(TLVL_STATUS) << "Status command complete";
     311            1 :         return currentState;
     312            1 : }
     313              : 
     314            1 : std::vector<std::string> artdaq::Commandable::legal_commands() const
     315              : {
     316            1 :         std::lock_guard<std::mutex> lk(primary_mutex_);
     317            3 :         TLOG(TLVL_LEGAL_COMMANDS) << "legal_commands started";
     318            1 :         std::string currentState = this->current_state();
     319              : 
     320            1 :         if (currentState == "Ready")
     321              :         {
     322            3 :                 return {"init", "soft_init", "start", "shutdown"};
     323              :         }
     324            0 :         if (currentState == "Running")
     325              :         {
     326              :                 // 12-May-2015, KAB: in_run_failure is also possible, but it
     327              :                 // shouldn't be requested externally.
     328            0 :                 return {"pause", "stop"};
     329              :         }
     330            0 :         if (currentState == "Paused")
     331              :         {
     332            0 :                 return {"resume", "stop"};
     333              :         }
     334            0 :         if (currentState == "InRunError")
     335              :         {
     336            0 :                 return {"pause", "stop"};
     337              :         }
     338              : 
     339              :         // Booted and Error
     340            0 :         TLOG(TLVL_LEGAL_COMMANDS) << "legal_commands complete";
     341            0 :         return {"init", "shutdown"};
     342            1 : }
     343              : 
     344              : // *******************************************************************
     345              : // *** The following methods implement the state machine operations.
     346              : // *******************************************************************
     347              : 
     348            1 : bool artdaq::Commandable::do_initialize(fhicl::ParameterSet const& /*unused*/, uint64_t /*unused*/, uint64_t /*unused*/)
     349              : {
     350            2 :         TLOG(TLVL_DEBUG + 32) << "do_initialize called.";
     351            1 :         external_request_status_ = true;
     352            1 :         return external_request_status_;
     353              : }
     354              : 
     355            1 : bool artdaq::Commandable::do_start(art::RunID /*unused*/, uint64_t /*unused*/, uint64_t /*unused*/)
     356              : {
     357            2 :         TLOG(TLVL_DEBUG + 32) << "do_start called.";
     358            1 :         external_request_status_ = true;
     359            1 :         return external_request_status_;
     360              : }
     361              : 
     362            1 : bool artdaq::Commandable::do_stop(uint64_t /*unused*/, uint64_t /*unused*/)
     363              : {
     364            2 :         TLOG(TLVL_DEBUG + 32) << "do_stop called.";
     365            1 :         external_request_status_ = true;
     366            1 :         return external_request_status_;
     367              : }
     368              : 
     369            1 : bool artdaq::Commandable::do_pause(uint64_t /*unused*/, uint64_t /*unused*/)
     370              : {
     371            2 :         TLOG(TLVL_DEBUG + 32) << "do_pause called.";
     372            1 :         external_request_status_ = true;
     373            1 :         return external_request_status_;
     374              : }
     375              : 
     376            1 : bool artdaq::Commandable::do_resume(uint64_t /*unused*/, uint64_t /*unused*/)
     377              : {
     378            2 :         TLOG(TLVL_DEBUG + 32) << "do_resume called.";
     379            1 :         external_request_status_ = true;
     380            1 :         return external_request_status_;
     381              : }
     382              : 
     383            1 : bool artdaq::Commandable::do_shutdown(uint64_t /*unused*/)
     384              : {
     385            2 :         TLOG(TLVL_DEBUG + 32) << "do_shutdown called.";
     386            1 :         external_request_status_ = true;
     387            1 :         return external_request_status_;
     388              : }
     389              : 
     390            1 : bool artdaq::Commandable::do_reinitialize(fhicl::ParameterSet const& /*unused*/, uint64_t /*unused*/, uint64_t /*unused*/)
     391              : {
     392            2 :         TLOG(TLVL_DEBUG + 32) << "do_reinitialize called.";
     393            1 :         external_request_status_ = true;
     394            1 :         return external_request_status_;
     395              : }
     396              : 
     397            1 : bool artdaq::Commandable::do_soft_initialize(fhicl::ParameterSet const& /*unused*/, uint64_t /*unused*/, uint64_t /*unused*/)
     398              : {
     399            2 :         TLOG(TLVL_DEBUG + 32) << "do_soft_initialize called.";
     400            1 :         external_request_status_ = true;
     401            1 :         return external_request_status_;
     402              : }
     403              : 
     404            0 : void artdaq::Commandable::badTransition(const std::string& trans)
     405              : {
     406            0 :         std::string currentState = this->current_state();
     407            0 :         if (currentState == "InRunError")
     408              :         {
     409            0 :                 currentState = "Error";
     410              :         }
     411              : 
     412            0 :         report_string_ = "An invalid transition (";
     413            0 :         report_string_.append(trans);
     414            0 :         report_string_.append(") was requested; transition not allowed from this process's current state of \"");
     415            0 :         report_string_.append(currentState);
     416            0 :         report_string_.append("\"");
     417              : 
     418            0 :         TLOG(TLVL_WARNING) << report_string_;
     419              : 
     420            0 :         external_request_status_ = false;
     421            0 : }
     422              : 
     423            1 : void artdaq::Commandable::BootedEnter()
     424              : {
     425            2 :         TLOG(TLVL_DEBUG + 32) << "BootedEnter called.";
     426            1 : }
     427              : 
     428            1 : void artdaq::Commandable::InRunExit()
     429              : {
     430            2 :         TLOG(TLVL_DEBUG + 32) << "InRunExit called.";
     431            1 : }
     432              : 
     433              : #if TRACE_REVNUM < 1394
     434              : #define traceLvls_p traceNamLvls_p
     435              : #define TRACE_TID2NAME(idx) traceNamLvls_p[idx].name
     436              : #endif
     437            1 : std::string artdaq::Commandable::do_trace_get(std::string const& name)
     438              : {
     439            2 :         TLOG(TLVL_DEBUG + 32) << "Getting masks for name " << name;
     440            1 :         std::ostringstream ss;
     441            1 :         if (name == "ALL")
     442              :         {
     443            0 :                 unsigned ii = 0;
     444            0 :                 unsigned ee = traceControl_p->num_namLvlTblEnts;
     445            0 :                 for (ii = 0; ii < ee; ++ii)
     446              :                 {
     447            0 :                         if (TRACE_TID2NAME(ii)[0] != 0)  // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic)
     448              :                         {
     449            0 :                                 ss << TRACE_TID2NAME(ii) << " " << std::hex << std::showbase << traceLvls_p[ii].M << " " << traceLvls_p[ii].S << " " << traceLvls_p[ii].T << " " << std::endl;  // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic)
     450              :                         }
     451              :                 }
     452              :         }
     453              :         else
     454              :         {
     455            1 :                 unsigned ii = 0;
     456            1 :                 unsigned ee = traceControl_p->num_namLvlTblEnts;
     457          269 :                 for (ii = 0; ii < ee; ++ii)
     458              :                 {
     459          269 :                         if ((TRACE_TID2NAME(ii)[0] != 0) && TMATCHCMP(name.c_str(), TRACE_TID2NAME(ii)))  // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic)
     460              :                         {
     461            1 :                                 break;
     462              :                         }
     463              :                 }
     464            1 :                 if (ii == ee)
     465              :                 {
     466            0 :                         return "";
     467              :                 }
     468              : 
     469            1 :                 ss << std::hex << traceLvls_p[ii].M << " " << traceLvls_p[ii].S << " " << traceLvls_p[ii].T;  // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic)
     470              :         }
     471            1 :         return ss.str();
     472            1 : }
     473              : 
     474            1 : bool artdaq::Commandable::do_trace_set(std::string const& name, std::string const& type, std::string const& mask_in_string_form)
     475              : {
     476            2 :         TLOG(TLVL_DEBUG + 32) << "Setting msk " << type << " for name " << name << " to " << mask_in_string_form;
     477            1 :         auto mask = static_cast<uint64_t>(std::stoull(mask_in_string_form, nullptr, 0));
     478            2 :         TLOG(TLVL_DEBUG + 32) << "Mask has been converted to " << mask;
     479              : 
     480            1 :         if (name != "ALL")
     481              :         {
     482            1 :                 if (!type.empty())
     483              :                 {
     484            1 :                         switch (type[0])
     485              :                         {
     486            1 :                                 case 'M':
     487            1 :                                         TRACE_CNTL("lvlmsknM", name.c_str(), mask);
     488            1 :                                         break;
     489            0 :                                 case 'S':
     490            0 :                                         TRACE_CNTL("lvlmsknS", name.c_str(), mask);
     491            0 :                                         break;
     492            0 :                                 case 'T':
     493            0 :                                         TRACE_CNTL("lvlmsknT", name.c_str(), mask);
     494            0 :                                         break;
     495              :                         }
     496              :                 }
     497              :                 else
     498              :                 {
     499            0 :                         TLOG(TLVL_ERROR) << "Cannot set mask: no type specified!";
     500              :                 }
     501              :         }
     502              :         else
     503              :         {
     504            0 :                 if (!type.empty())
     505              :                 {
     506            0 :                         switch (type[0])
     507              :                         {
     508            0 :                                 case 'M':
     509            0 :                                         TRACE_CNTL("lvlmskMg", mask);
     510            0 :                                         break;
     511            0 :                                 case 'S':
     512            0 :                                         TRACE_CNTL("lvlmskSg", mask);
     513            0 :                                         break;
     514            0 :                                 case 'T':
     515            0 :                                         TRACE_CNTL("lvlmskTg", mask);
     516            0 :                                         break;
     517              :                         }
     518              :                 }
     519              :                 else
     520              :                 {
     521            0 :                         TLOG(TLVL_ERROR) << "Cannot set mask: no type specified!";
     522              :                 }
     523              :         }
     524            1 :         return true;
     525              : }
     526              : 
     527            1 : bool artdaq::Commandable::do_meta_command(std::string const& cmd, std::string const& arg)
     528              : {
     529            2 :         TLOG(TLVL_DEBUG + 32) << "Meta-Command called: cmd=" << cmd << ", arg=" << arg;
     530            1 :         return true;
     531              : }
     532              : 
     533            1 : bool artdaq::Commandable::do_rollover_subrun(uint64_t /*unused*/, uint32_t /*unused*/)
     534              : {
     535            2 :         TLOG(TLVL_DEBUG + 32) << "do_rollover_subrun called.";
     536            1 :         external_request_status_ = true;
     537            1 :         return external_request_status_;
     538              : }
     539              : 
     540            0 : bool artdaq::Commandable::do_add_config_archive_entry(std::string const& key, std::string const& value)
     541              : {
     542            0 :         TLOG(TLVL_DEBUG + 32) << "do_add_config_archive_entry called: key=" << key << ", value=" << value;
     543            0 :         return true;
     544              : }
     545              : 
     546            0 : bool artdaq::Commandable::do_clear_config_archive()
     547              : {
     548            0 :         TLOG(TLVL_DEBUG + 32) << "do_clear_config_archive called.";
     549            0 :         external_request_status_ = true;
     550            0 :         return external_request_status_;
     551              : }
     552              : 
     553              : // *********************
     554              : // *** Utility methods.
     555              : // *********************
     556              : 
     557            2 : std::string artdaq::Commandable::current_state() const
     558              : {
     559            2 :         std::string fullStateName = (const_cast<Commandable*>(this))->fsm_.getState().getName();  // NOLINT(cppcoreguidelines-pro-type-const-cast)
     560            2 :         size_t pos = fullStateName.rfind("::");
     561            2 :         if (pos != std::string::npos)
     562              :         {
     563            2 :                 return fullStateName.substr(pos + 2);
     564              :         }
     565              : 
     566            0 :         return fullStateName;
     567            2 : }
        

Generated by: LCOV version 2.0-1