00001 #ifndef ARTDAQ_UTILITIES_PLUGINS_METRICDATA_HH
00002 #define ARTDAQ_UTILITIES_PLUGINS_METRICDATA_HH
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "artdaq-utilities/Plugins/MetricPlugin.hh"
00013 #include "fhiclcpp/fwd.h"
00014 #include "messagefacility/MessageLogger/MessageLogger.h"
00015
00016 #include <sstream>
00017 #include <list>
00018 #include <thread>
00019 #include <condition_variable>
00020 #include <atomic>
00021
00022 namespace artdaq
00023 {
00024 enum class MetricType
00025 {
00026 InvalidMetric,
00027 StringMetric,
00028 IntMetric,
00029 DoubleMetric,
00030 FloatMetric,
00031 UnsignedMetric
00032 };
00033
00034 enum class MetricMode
00035 {
00036 LastPoint,
00037 Accumulate,
00038 Average
00039 };
00040
00041 struct MetricData
00042 {
00043 MetricData(const MetricData&) = default;
00044
00045 MetricData(MetricData&&) noexcept = default;
00046
00047 MetricData& operator=(const MetricData&) = default;
00048
00049 MetricData& operator=(MetricData&&) noexcept = default;
00050
00051 std::string Name;
00052 std::string StringValue;
00053
00054 union
00055 {
00056 int IntValue;
00057 double DoubleValue;
00058 float FloatValue;
00059 long unsigned int UnsignedValue;
00060 };
00061
00062
00063 MetricType Type;
00064 std::string Unit;
00065 int Level;
00066 MetricMode Mode;
00067 std::string MetricPrefix;
00068 bool UseNameOverride;
00069
00070 MetricData(std::string const& name, std::string const& value, std::string const& unit, int level, MetricMode mode, std::string const& metricPrefix, bool useNameOverride)
00071 : Name(name)
00072 , StringValue(value)
00073 , Type(MetricType::StringMetric)
00074 , Unit(unit)
00075 , Level(level)
00076 , Mode(mode)
00077 , MetricPrefix(metricPrefix)
00078 , UseNameOverride(useNameOverride) {}
00079
00080 MetricData(std::string const& name, int const& value, std::string const& unit, int level, MetricMode mode, std::string const& metricPrefix, bool useNameOverride)
00081 : Name(name)
00082 , IntValue(value)
00083 , Type(MetricType::IntMetric)
00084 , Unit(unit)
00085 , Level(level)
00086 , Mode(mode)
00087 , MetricPrefix(metricPrefix)
00088 , UseNameOverride(useNameOverride)
00089 {}
00090
00091 MetricData(std::string const& name, double const& value, std::string const& unit, int level, MetricMode mode, std::string const& metricPrefix, bool useNameOverride)
00092 : Name(name)
00093 , DoubleValue(value)
00094 , Type(MetricType::DoubleMetric)
00095 , Unit(unit)
00096 , Level(level)
00097 , Mode(mode)
00098 , MetricPrefix(metricPrefix)
00099 , UseNameOverride(useNameOverride)
00100 {}
00101
00102 MetricData(std::string const& name, float const& value, std::string const& unit, int level, MetricMode mode, std::string const& metricPrefix, bool useNameOverride)
00103 : Name(name)
00104 , FloatValue(value)
00105 , Type(MetricType::FloatMetric)
00106 , Unit(unit)
00107 , Level(level)
00108 , Mode(mode)
00109 , MetricPrefix(metricPrefix)
00110 , UseNameOverride(useNameOverride)
00111 {}
00112
00113 MetricData(std::string const& name, long unsigned int const& value, std::string const& unit, int level, MetricMode mode, std::string const& metricPrefix, bool useNameOverride)
00114 : Name(name)
00115 , UnsignedValue(value)
00116 , Type(MetricType::UnsignedMetric)
00117 , Unit(unit)
00118 , Level(level)
00119 , Mode(mode)
00120 , MetricPrefix(metricPrefix)
00121 , UseNameOverride(useNameOverride)
00122 {}
00123
00124 MetricData() : Name("")
00125 , Type(MetricType::InvalidMetric) {}
00126 };
00127 }
00128
00129 #endif