NDMRunConfig.cpp
Go to the documentation of this file.
1 #include <DatabaseUtils/DAQConfig/NDMRunConfig.h>
2 #include <DatabaseUtils/DAQConfig/ConfigDataTree.h>
3 #include <DatabaseUtils/DAQConfig/DBColumnParams.h>
4 #include <DatabaseUtils/DAQConfig/DBColumnUtils.h>
5 #include <DatabaseUtils/DAQConfig/NamedConfigUtils.h>
6 #include <NovaDatabase/Table.h>
7 #include <NovaDAQUtilities/EnvVarCache.h>
8 #include <boost/algorithm/string.hpp>
9 
10 namespace NOVADB = nova::database;
11 
12 namespace dbutils {
13 namespace daqconfig {
14 
15 /**
16  * Creates a DaqMonitor (aka NDM) run configuration object from the specified
17  * list of subsystem configuration IDs.
18  *
19  * @param subsystemConfigIdList The list of subsystem
20  * configuration IDs.
21  */
23 NDMRunConfig(const std::vector<int64_t>& subsystemConfigIdList) :
24  _rrdRootDir(""), _thresholdDir("")
25 {
27  if (subsystemConfigIdList.size() > 0) {
28  _primarySubsystemConfigId = subsystemConfigIdList[0];
29  _hasValidData = _fetchAllData(subsystemConfigIdList);
30  }
31  else {
32  _hasValidData = false;
33  }
34 }
35 
36 /**
37  * Creates a NDMRunConfig run configuration object from the specified
38  * subsystem configuration specification.
39  *
40  * @param nameSpec The named configuration of interest.
41  */
44 {
46  std::vector<int64_t> subsystemConfigIdList;
47  if (NamedConfigUtils::
48  getSubsystemConfigIdAncestry(nameSpec, subsystemConfigIdList)) {
49  _primarySubsystemConfigId = subsystemConfigIdList[0];
50  _hasValidData = _fetchAllData(subsystemConfigIdList);
51  }
52  else {
53  _hasValidData = false;
54  }
55 }
56 
57 /**
58  * Creates a NDMRunConfig run configuration object from the specified
59  * global configuration specification.
60  *
61  * @param nameSpec The named configuration of interest.
62  */
65 {
67  int64_t subsystemConfigId;
71  DAQMONITOR_SUBSYSTEM_NAME,
73  RUN_CONFIG_TYPE,
74  subsystemConfigId);
75 
76  std::vector<int64_t> subsystemConfigIdList;
77  if (status) {
78  IDSpec idSpec(subsystemConfigId, IDSpec::SUBSYSTEM, IDSpec::DAQ);
79  status = NamedConfigUtils::
80  getConfigIdAncestry(idSpec, subsystemConfigIdList);
81  }
82 
83  if (status) {
84  _primarySubsystemConfigId = subsystemConfigIdList[0];
85  _hasValidData = _fetchAllData(subsystemConfigIdList);
86  }
87  else {
88  _hasValidData = false;
89  }
90 }
91 
92 /**
93  * Creates a NDMRunConfig run configuration object from the specified
94  * global configuration ID.
95  *
96  * @param globalConfigId The ID of the global configuration of interest.
97  */
98 NDMRunConfig::NDMRunConfig(const int64_t& globalConfigId) :
100 {
101  IDSpec idSpec(globalConfigId, IDSpec::GLOBAL, IDSpec::DAQ);
103  std::vector<int64_t> subsystemConfigIdList;
104  if (NamedConfigUtils::
105  getSubsystemConfigIdAncestryFromGlobalId(idSpec,
107  DAQMONITOR_SUBSYSTEM_NAME,
109  RUN_CONFIG_TYPE,
110  subsystemConfigIdList)) {
111  _primarySubsystemConfigId = subsystemConfigIdList[0];
112  _hasValidData = _fetchAllData(subsystemConfigIdList);
113  }
114  else {
115  _hasValidData = false;
116  }
117 }
118 
119 bool NDMRunConfig::
120 _fetchAllData(const std::vector<int64_t>& subsystemConfigIdList)
121 {
122  ConfigDataSelector cfgSelector;
123 
124  std::vector<std::string> dataColumnsOfInterest;
125  dataColumnsOfInterest.push_back("rrdRootDir");
126  dataColumnsOfInterest.push_back("thresholdDir");
127 
129  daqMonitorParamDataSet("NovaDatabase/tables/DAQConfig/DaqMonitorRunParameters.xml",
130  subsystemConfigIdList, cfgSelector,
131  dataColumnsOfInterest);
132 
133  if ( ! daqMonitorParamDataSet.getTrueValue("rrdRootDir", _rrdRootDir) ) return false;
134  if ( ! daqMonitorParamDataSet.getTrueValue("thresholdDir",_thresholdDir) ) return false;
135 
136  return true;
137 }
138 
139 } // end of namespace daqconfig
140 } // end of namespace dbutils
int status
Definition: fabricate.py:1613
static bool getConfigIdAncestry(const IDSpec &idSpec, std::vector< int64_t > &idList, const std::string &tableFile=DEFAULT_GLOBAL_NAMES_TABLE_FILE)
bool _fetchAllData(const std::vector< int64_t > &subsystemConfigIdList)
bool getTrueValue(const std::string &dataColumnName, T &resultValue)
NDMRunConfig(const std::vector< int64_t > &subsystemConfigIdList)
static bool getSubsystemConfigIdFromGlobalName(const GlobalNameSpec &globalNameSpec, const std::string &subsystemName, const std::string &subsystemConfigType, int64_t &subsystemConfigId, const std::string &globalNamesTableFile=DEFAULT_GLOBAL_NAMES_TABLE_FILE, const std::string &subsystemNamesTableFile=DEFAULT_SUBSYSTEM_NAMES_TABLE_FILE)