otsdaq  v2_05_02_indev
ARTDAQSupervisorTRACEController.cc
1 #include "otsdaq/ARTDAQSupervisor/ARTDAQSupervisorTRACEController.h"
2 #include <string>
3 
4 ots::ARTDAQSupervisorTRACEController::ARTDAQSupervisorTRACEController() {}
5 
6 ots::ITRACEController::HostTraceLevelMap ots::ARTDAQSupervisorTRACEController::GetTraceLevels()
7 {
8  HostTraceLevelMap output;
9  if(theSupervisor_)
10  {
11  auto commanders = theSupervisor_->makeCommandersFromProcessInfo();
12 
13  for(auto& comm : commanders)
14  {
15  if(output.count(comm.first.host) == 0)
16  {
17  auto lvlstring = comm.second->send_trace_get("ALL");
18  auto lvls = ARTDAQSupervisor::tokenize_(lvlstring);
19 
20  for(auto& lvl : lvls)
21  {
22  std::istringstream iss(lvl);
23  std::string name;
24  uint64_t lvlM, lvlS, lvlT;
25 
26  iss >> name >> lvlM >> lvlS >> lvlT;
27 
28  output[comm.first.host][name].M = lvlM;
29  output[comm.first.host][name].S = lvlS;
30  output[comm.first.host][name].T = lvlT;
31  }
32  }
33  }
34  }
35 
36  return output;
37 }
38 
39 void ots::ARTDAQSupervisorTRACEController::SetTraceLevelMask(std::string trace_name, TraceMasks const& lvl, std::string host)
40 {
41  if(theSupervisor_)
42  {
43  auto commanders = theSupervisor_->makeCommandersFromProcessInfo();
44 
45  for(auto& comm : commanders)
46  {
47  if(comm.first.host == host)
48  {
49  comm.second->send_trace_set(trace_name, "M", std::to_string(lvl.M));
50  comm.second->send_trace_set(trace_name, "S", std::to_string(lvl.S));
51  comm.second->send_trace_set(trace_name, "T", std::to_string(lvl.T));
52  break;
53  }
54  }
55  }
56 }