tdaq-develop-2025-02-12
ARTDAQSupervisorTRACEController.cc
1 #include "otsdaq/ARTDAQSupervisor/ARTDAQSupervisorTRACEController.h"
2 #include <string>
3 
4 ots::ARTDAQSupervisorTRACEController::ARTDAQSupervisorTRACEController() {}
5 
6 const ots::ITRACEController::HostTraceLevelMap&
8 {
9  traceLevelsMap_.clear(); // reset
10 
11  ots::ITRACEController::addTraceLevelsForThisHost();
12  if(theSupervisor_)
13  {
14  auto commanders = theSupervisor_->makeCommandersFromProcessInfo();
15 
16  for(auto& comm : commanders)
17  {
18  if(traceLevelsMap_.count(comm.first.host) == 0)
19  {
20  auto lvlstring = comm.second->send_trace_get("ALL");
21  auto lvls = ARTDAQSupervisor::tokenize_(lvlstring);
22 
23  for(auto& lvl : lvls)
24  {
25  std::istringstream iss(lvl);
26  std::string name;
27  uint64_t lvlM, lvlS, lvlT;
28 
29  iss >> name >> lvlM >> lvlS >> lvlT;
30 
31  // PREPEND special artdaq signature, so that normal TRACE on those hosts can be modified independently of artdaq processes that are handled
32  // by ARTDAQ supervisor.
33  traceLevelsMap_["artdaq.." + comm.first.host][name].M = lvlM;
34  traceLevelsMap_["artdaq.." + comm.first.host][name].S = lvlS;
35  traceLevelsMap_["artdaq.." + comm.first.host][name].T = lvlT;
36  }
37  }
38  }
39  }
40 
41  return traceLevelsMap_;
42 } // end getTraceLevels()
43 
45  const std::string& label,
46  TraceMasks const& lvl,
47  const std::string& host /*=localhost*/,
48  std::string const& mode /*= "ALL"*/)
49 {
50  if(theSupervisor_)
51  {
52  auto commanders = theSupervisor_->makeCommandersFromProcessInfo();
53 
54  bool allMode = mode == "ALL";
55 
56  for(auto& comm : commanders)
57  {
58  // PREPEND special artdaq signature, so that normal TRACE on those hosts can be modified independently of artdaq processes that are handled by
59  // ARTDAQ supervisor.
60  if("artdaq.." + comm.first.host == host)
61  {
62  if(allMode || mode == "FAST")
63  comm.second->send_trace_set(label, "M", std::to_string(lvl.M));
64  if(allMode || mode == "SLOW")
65  comm.second->send_trace_set(label, "S", std::to_string(lvl.S));
66  if(allMode || mode == "TRIGGER")
67  comm.second->send_trace_set(label, "T", std::to_string(lvl.T));
68  return;
69  }
70  }
71  }
72 
73  ots::ITRACEController::setTraceLevelsForThisHost(label, lvl, mode);
74 } // end setTraceLevelMask()
const ITRACEController::HostTraceLevelMap & getTraceLevels(void) final
pure virtual
virtual void setTraceLevelMask(std::string const &label, TraceMasks const &lvl, std::string const &hostname="localhost", std::string const &mode="ALL") final
pure virtual