MonitoringSQLManager.h
Go to the documentation of this file.
1 #ifndef _rdet_MonitoringSQLManager_h_
2 #define _rdet_MonitoringSQLManager_h_
3 
4 #include <map>
5 #include <string>
6 #include <algorithm>
7 
8 #include <det/VManager.h>
9 #include <utl/ErrorLogger.h>
10 #include <utl/config.h>
11 #include <utl/ResponseMap.h>
12 #include <utl/LeapSeconds.h>
13 #include <boost/lexical_cast.hpp>
14 
15 #ifdef AUGER_SQLITE_ENABLED
16 # include <det/VSQLManager_SQLite.h>
17 #else
18 # include <det/VSQLManager_MySQL.h>
19 #endif
20 
21 
22 namespace rdet {
23 
36 
37  public:
39 
40  virtual ~MonitoringSQLManager() { }
41 
42  void Init(const std::string& configLink);
43 
45 
47  //VMANAGER_GETDATA_NOTFOUND(unsigned long long int)
48  VMANAGER_GETDATA_NOTFOUND(std::vector<int>)
49  VMANAGER_GETDATA_NOTFOUND(std::string)
50  VMANAGER_GETDATA_NOTFOUND(std::vector<double>)
51  VMANAGER_GETDATA_NOTFOUND(std::vector<std::string>)
52  VMANAGER_GETDATA_NOTFOUND(std::list<double>)
53  VMANAGER_GETDATA_NOTFOUND(std::list<int>)
54  VMANAGER_GETDATA_NOTFOUND(std::list<std::string>)
55  VMANAGER_GETDATA_NOTFOUND(utl::TabulatedFunctionComplexLgAmpPhase)
56  VMANAGER_GETDATA_NOTFOUND(std::map<std::string, double>)
57  VMANAGER_GETDATA_NOTFOUND(std::vector<bool>)
58  VMANAGER_GETDATA_NOTFOUND(std::vector<std::vector<int> >)
59  VMANAGER_GETDATA_NOTFOUND(std::list<std::pair<int, int> >)
60  VMANAGER_GETDATA_NOTFOUND(std::map<int, utl::TabulatedFunction>)
61  VMANAGER_GETDATA_NOTFOUND(utl::TabulatedFunction)
62 
63  private:
64  template<typename T>
65  Status
66  InternalGetData(T& returnData, const std::string& componentProperty,
67  const std::string& componentName, const IndexMap& componentIndex)
68  const
69  {
70  if (componentProperty != "monitoring")
71  return eNotFound;
72 
73  if (componentName == "temperature") {
74  if (componentIndex.find("site") == componentIndex.end()) {
75  WARNING("no site specified in componentIndex");
76  return eNotFound;
77  }
78 
79  double timeToAverage = 5 * utl::minute;
80  if (componentIndex.find("timeToAverage") != componentIndex.end())
81  timeToAverage = boost::lexical_cast<double>(componentIndex.find("timeToAverage")->second);
82  double precision = 5 * utl::minute;
83  if (componentIndex.find("precision") != componentIndex.end())
84  precision = boost::lexical_cast<double>(componentIndex.find("precision")->second);
85  unsigned int numberOfQueriesToBuffer = 5000;
86  if (componentIndex.find("numberOfQueriesToBuffer") != componentIndex.end())
87  precision = boost::lexical_cast<int>(componentIndex.find("numberOfQueriesToBuffer")->second);
88 
89  returnData = GetTemperature(componentIndex.find("site")->second, timeToAverage,
90  numberOfQueriesToBuffer, precision);
91  return eFound;
92  }
93 
94  return eNotFound;
95  }
96 
97  double GetTemperature(const std::string& site, const double timeToAverage,
98  const unsigned int numberOfQueriesToBuffer, const double precision) const;
99 
100  bool BufferTemperature(const std::string& site, const double timeToAverage,
101  const unsigned int numberOfQueriesToBuffer) const;
102 
104 
105  // <"site", < <"timestamp", "temperature"> > >
106  // stores all bad periods for all station, the station id (e.g. "110" for AERA_10) is the key
107  mutable std::map<std::string, std::vector<std::pair<unsigned long, double> > > fTemperatureBuffer;
108  // current interval (starttime, stoptime) of temperature buffer
109  mutable std::map<std::string, std::pair<unsigned long, unsigned long> > fTemperatureBufferInterval;
110 
111  };
112 
113 }
114 
115 
116 #endif
bool BufferTemperature(const std::string &site, const double timeToAverage, const unsigned int numberOfQueriesToBuffer) const
double GetTemperature(const std::string &site, const double timeToAverage, const unsigned int numberOfQueriesToBuffer, const double precision) const
Status const
Fetch first item from first row and optionally free query result.
VMANAGER_GETDATA_HANDLE_DENIED std::map< std::string, std::vector< std::pair< unsigned long, double > > > fTemperatureBuffer
#define VMANAGER_GETDATA_CALL(_GetData_, _T_...)
Definition: VManager.h:59
Interface for detector managers that use MySQL.
static const double precision
Status InternalGetData(T &returnData, const std::string &componentProperty, const std::string &componentName, const IndexMap &componentIndex) const
#define VMANAGER_GETDATA_HANDLE_DENIED
Definition: VManager.h:75
#define WARNING(message)
Macro for logging warning messages.
Definition: ErrorLogger.h:163
constexpr double minute
Definition: AugerUnits.h:149
std::map< std::string, std::string > IndexMap
Definition: VManager.h:133
std::map< std::string, std::pair< unsigned long, unsigned long > > fTemperatureBufferInterval
Manager to access monitoring data.
#define VMANAGER_GETDATA_NOTFOUND(_T_...)
Definition: VManager.h:41
Status
Specifies success or (eventually) various possible failure modes.
Definition: VManager.h:127
void Init(const std::string &configLink)
Manager Initialization. configLink is the CentralConfig hook for the configuration file...

, generated on Tue Sep 26 2023.