Line data Source code
1 : #include "swig_artdaq.h"
2 : #include "TRACE/tracemf.h"
3 : #include "artdaq-core/Utilities/configureMessageFacility.hh"
4 : #include "artdaq/Application/LoadParameterSet.hh"
5 : #include "artdaq/DAQdata/Globals.hh"
6 :
7 0 : swig_artdaq::swig_artdaq(std::string const& config_string)
8 : {
9 0 : fhicl::ParameterSet config_ps = LoadParameterSet(config_string);
10 0 : app_name = config_ps.get<std::string>("application_name", "external");
11 0 : std::string mf_app_name = artdaq::setMsgFacAppName(app_name, config_ps.get<int>("id", 0));
12 0 : artdaq::configureMessageFacility(mf_app_name.c_str(), config_ps.get<bool>("debug_logging", false), config_ps.get<bool>("log_to_console", true));
13 0 : metricMan->initialize(config_ps.get<fhicl::ParameterSet>("metrics", fhicl::ParameterSet()), app_name);
14 0 : initialized_ = true;
15 0 : }
16 :
17 0 : swig_artdaq::~swig_artdaq()
18 : {
19 0 : artdaq::Globals::CleanUpGlobals();
20 0 : initialized_ = false;
21 0 : }
22 :
23 0 : void swig_artdaq::send_metric(std::string const& name, int level, std::string const& value, std::string const& unit)
24 : {
25 0 : if (!initialized_) return;
26 0 : metricMan->sendMetric(name, value, unit, level, artdaq::MetricMode::LastPoint);
27 : }
28 :
29 0 : void swig_artdaq::send_metric(std::string const& name, int level, int value, std::string const& unit)
30 : {
31 0 : if (!initialized_) return;
32 0 : metricMan->sendMetric(name, value, unit, level, artdaq::MetricMode::LastPoint);
33 : }
34 :
35 0 : void swig_artdaq::send_metric(std::string const& name, int level, double value, std::string const& unit)
36 : {
37 0 : if (!initialized_) return;
38 0 : metricMan->sendMetric(name, value, unit, level, artdaq::MetricMode::LastPoint);
39 : }
40 :
41 0 : void swig_artdaq::send_sum_metric(std::string const& name, int level, std::string const& value, std::string const& unit)
42 : {
43 0 : if (!initialized_) return;
44 0 : metricMan->sendMetric(name, value, unit, level, artdaq::MetricMode::Accumulate);
45 : }
46 0 : void swig_artdaq::send_sum_metric(std::string const& name, int level, int value, std::string const& unit)
47 : {
48 0 : if (!initialized_) return;
49 0 : metricMan->sendMetric(name, value, unit, level, artdaq::MetricMode::Accumulate);
50 : }
51 0 : void swig_artdaq::send_sum_metric(std::string const& name, int level, double value, std::string const& unit)
52 : {
53 0 : if (!initialized_) return;
54 0 : metricMan->sendMetric(name, value, unit, level, artdaq::MetricMode::Accumulate);
55 : }
56 :
57 0 : void swig_artdaq::send_rate_metric(std::string const& name, int level, std::string const& value, std::string const& unit)
58 : {
59 0 : if (!initialized_) return;
60 0 : metricMan->sendMetric(name, value, unit, level, artdaq::MetricMode::Rate);
61 : }
62 0 : void swig_artdaq::send_rate_metric(std::string const& name, int level, int value, std::string const& unit)
63 : {
64 0 : if (!initialized_) return;
65 0 : metricMan->sendMetric(name, value, unit, level, artdaq::MetricMode::Rate);
66 : }
67 0 : void swig_artdaq::send_rate_metric(std::string const& name, int level, double value, std::string const& unit)
68 : {
69 0 : if (!initialized_) return;
70 0 : metricMan->sendMetric(name, value, unit, level, artdaq::MetricMode::Rate);
71 : }
72 :
73 0 : void swig_artdaq::write_error(std::string const& name, std::string const& message)
74 : {
75 0 : if (!initialized_) return;
76 0 : TLOG(TLVL_ERROR, name) << message;
77 : }
78 :
79 0 : void swig_artdaq::write_warning(std::string const& name, std::string const& message)
80 : {
81 0 : if (!initialized_) return;
82 0 : TLOG(TLVL_WARNING, name) << message;
83 : }
84 :
85 0 : void swig_artdaq::write_info(std::string const& name, std::string const& message)
86 : {
87 0 : if (!initialized_) return;
88 0 : TLOG(TLVL_INFO, name) << message;
89 : }
90 :
91 0 : void swig_artdaq::write_debug(std::string const& name, std::string const& message)
92 : {
93 0 : if (!initialized_) return;
94 0 : TLOG(TLVL_DEBUG, name) << message;
95 : }
96 :
97 0 : void swig_artdaq::write_trace(int level, std::string const& name, std::string const& message)
98 : {
99 0 : if (!initialized_) return;
100 0 : TLOG(level, name) << message;
101 : }
|