DCMRunConfig.cpp
Go to the documentation of this file.
1 #include <DatabaseUtils/DAQConfig/DCMRunConfig.h>
2 #include <DatabaseUtils/DAQConfig/ConfigDataTree.h>
3 #include <DatabaseUtils/DAQConfig/DBColumnParams.h>
4 #include <DatabaseUtils/DAQConfig/NamedConfigUtils.h>
5 
6 namespace dbutils {
7 namespace daqconfig {
8 
9 /**
10  * Creates a DCM run configuration object from the specified
11  * list of subsystem configuration IDs.
12  *
13  * @param subsystemConfigIdList The list of subsystem
14  * configuration IDs.
15  * @param dcmName The name of the DCM of interest.
16  */
18 DCMRunConfig(const std::vector<int64_t>& subsystemConfigIdList,
19  const std::string& dcmName)
20 {
22  if (subsystemConfigIdList.size() > 0) {
23  _primarySubsystemConfigId = subsystemConfigIdList[0];
24  _hasValidData = _fetchAllData(subsystemConfigIdList, dcmName);
25  }
26  else {
27  _hasValidData = false;
28  }
29 }
30 
31 /**
32  * Creates a DCM run configuration object from the specified
33  * subsystem configuration specification.
34  *
35  * @param nameSpec The named configuration of interest.
36  * @param dcmName The name of the DCM of interest.
37  */
40  const std::string& dcmName)
41 {
43  std::vector<int64_t> subsystemConfigIdList;
44  if (NamedConfigUtils::
45  getSubsystemConfigIdAncestry(nameSpec, subsystemConfigIdList)) {
46  _primarySubsystemConfigId = subsystemConfigIdList[0];
47  _hasValidData = _fetchAllData(subsystemConfigIdList, dcmName);
48  }
49  else {
50  _hasValidData = false;
51  }
52 }
53 
54 /**
55  * Creates a DCM run configuration object from the specified
56  * global configuration specification.
57  *
58  * @param nameSpec The named configuration of interest.
59  * @param dcmName The name of the DCM of interest.
60  */
62 DCMRunConfig(const GlobalNameSpec& nameSpec,
63  const std::string& dcmName)
64 {
65  _hasValidData = false;
67  int64_t subsystemConfigId;
68  if (NamedConfigUtils::
69  getSubsystemConfigIdFromGlobalName(nameSpec,
71  DCM_SUBSYSTEM_NAME,
73  RUN_CONFIG_TYPE,
74  subsystemConfigId)) {
75  std::vector<int64_t> subsystemConfigIdList;
76  IDSpec idSpec(subsystemConfigId, IDSpec::SUBSYSTEM, IDSpec::DAQ);
77  if (NamedConfigUtils::
78  getConfigIdAncestry(idSpec, subsystemConfigIdList)) {
79  _primarySubsystemConfigId = subsystemConfigIdList[0];
80  _hasValidData = _fetchAllData(subsystemConfigIdList, dcmName);
81  }
82  }
83 }
84 
85 /**
86  * Creates a DCM run configuration object from the specified
87  * global configuration ID.
88  *
89  * @param globalConfigId The ID of the global configuration of interest.
90  * @param dcmName The name of the DCM of interest.
91  */
93 DCMRunConfig(const int64_t& globalConfigId,
94  const std::string& dcmName)
95 {
96  IDSpec idSpec(globalConfigId, IDSpec::GLOBAL, IDSpec::DAQ);
98  std::vector<int64_t> subsystemConfigIdList;
99  if (NamedConfigUtils::
100  getSubsystemConfigIdAncestryFromGlobalId(idSpec,
102  DCM_SUBSYSTEM_NAME,
104  RUN_CONFIG_TYPE,
105  subsystemConfigIdList)) {
106  _primarySubsystemConfigId = subsystemConfigIdList[0];
107  _hasValidData = _fetchAllData(subsystemConfigIdList, dcmName);
108  }
109  else {
110  _hasValidData = false;
111  }
112 }
113 
114 bool DCMRunConfig::
115 _fetchAllData(const std::vector<int64_t>& subsystemConfigIdList,
116  const std::string& dcmName)
117 {
118  bool status = true;
119 
120  // system-wide data
121  if (status) {
122  status = _fetchDCMSystemParams(subsystemConfigIdList);
123  }
124 
125  // dcm-specific data
126  if (status) {
127  status = _fetchDCMDataDevValues(subsystemConfigIdList, dcmName);
128  }
129  if (status) {
130  status = _fetchDCMApplicationParams(subsystemConfigIdList, dcmName);
131  }
132 
133  return status;
134 }
135 
136 bool DCMRunConfig::
137 _fetchDCMSystemParams(const std::vector<int64_t>& subsystemConfigIdList)
138 {
139  ConfigDataSelector cfgSelector;
140 
141  std::vector<std::string> dataColumnsOfInterest;
142  dataColumnsOfInterest.push_back("milliSliceDT");
143 
145  dcmSystemParamDataSet("NovaDatabase/tables/DAQConfig/DCMSystemRunParameters.xml",
146  subsystemConfigIdList, cfgSelector,
147  dataColumnsOfInterest);
148 
149  if (! dcmSystemParamDataSet.getTrueValue("milliSliceDT",
151  return false;
152  }
153  return true;
154 }
155 
156 bool DCMRunConfig::
157 _fetchDCMDataDevValues(const std::vector<int64_t>& subsystemConfigIdList,
158  const std::string& dcmName)
159 {
160  ConfigDataSelector cfgSelector;
162  dcmName, dcmName);
163 
164  std::vector<std::string> dataColumnsOfInterest;
165  dataColumnsOfInterest.push_back("numberOfReadAttempts");
166 
168  dcmDataDevDataSet("NovaDatabase/tables/DAQConfig/DCMDataDevRunParameters.xml",
169  subsystemConfigIdList, cfgSelector,
170  dataColumnsOfInterest);
171 
172  if (! dcmDataDevDataSet.getEffectiveValueFor1Key(dcmName,
173  "numberOfReadAttempts",
175  return false;
176  }
177  return true;
178 }
179 
180 bool DCMRunConfig::
181 _fetchDCMApplicationParams(const std::vector<int64_t>& subsystemConfigIdList,
182  const std::string& dcmName)
183 {
184  ConfigDataSelector cfgSelector;
186  dcmName, dcmName);
187 
188  std::vector<std::string> dataColumnsOfInterest;
189  dataColumnsOfInterest.push_back("milliSliceMode");
190  dataColumnsOfInterest.push_back("milliSliceCalculateCheckSum");
191  dataColumnsOfInterest.push_back("corruptMessageLimit");
192  dataColumnsOfInterest.push_back("corruptMessageResetCount");
193  dataColumnsOfInterest.push_back("monitorMetricSendTimeInterval");
194  dataColumnsOfInterest.push_back("monitorCtrlRegGeneralStatus");
195  dataColumnsOfInterest.push_back("maxAllowedDelayInMilliSec");
196  dataColumnsOfInterest.push_back("monitorFEBStatusTimeInterval");
197  dataColumnsOfInterest.push_back("monitorFEBStatusLimit");
198 
200  dcmParamDataSet("NovaDatabase/tables/DAQConfig/DCMApplicationRunParameters.xml",
201  subsystemConfigIdList, cfgSelector,
202  dataColumnsOfInterest);
203 
204  if (! dcmParamDataSet.getEffectiveValueFor1Key(dcmName,
205  "milliSliceMode",
206  _milliSliceMode)) {
207  return false;
208  }
209  if (! dcmParamDataSet.getEffectiveValueFor1Key(dcmName,
210  "milliSliceCalculateCheckSum",
212  return false;
213  }
214  if (! dcmParamDataSet.getEffectiveValueFor1Key(dcmName,
215  "corruptMessageLimit",
217  return false;
218  }
219  if (! dcmParamDataSet.getEffectiveValueFor1Key(dcmName,
220  "corruptMessageResetCount",
222  return false;
223  }
224  if (! dcmParamDataSet.getEffectiveValueFor1Key(dcmName,
225  "monitorMetricSendTimeInterval",
227  return false;
228  }
229  if (! dcmParamDataSet.getEffectiveValueFor1Key(dcmName,
230  "monitorCtrlRegGeneralStatus",
232  return false;
233  }
234  if (! dcmParamDataSet.getEffectiveValueFor1Key(dcmName,
235  "maxAllowedDelayInMilliSec",
237  return false;
238  }
239  if (! dcmParamDataSet.getEffectiveValueFor1Key(dcmName,
240  "monitorFEBStatusTimeInterval",
242  return false;
243  }
244  if (! dcmParamDataSet.getEffectiveValueFor1Key(dcmName,
245  "monitorFEBStatusLimit",
247  return false;
248  }
249  return true;
250 }
251 
252 } // end of namespace daqconfig
253 } // end of namespace dbutils
void addSelectionColumn(std::string columnName)
int status
Definition: fabricate.py:1613
bool getTrueValue(const std::string &dataColumnName, T &resultValue)
bool getEffectiveValueFor1Key(const U &primarySelectionValue, const std::string &dataColumnName, T &resultValue)
bool _fetchDCMApplicationParams(const std::vector< int64_t > &subsystemConfigIdList, const std::string &dcmName)
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
static const std::string DCMID_COLUMN_NAME
bool _fetchDCMSystemParams(const std::vector< int64_t > &subsystemConfigIdList)
bool _fetchAllData(const std::vector< int64_t > &subsystemConfigIdList, const std::string &dcmName)
bool _fetchDCMDataDevValues(const std::vector< int64_t > &subsystemConfigIdList, const std::string &dcmName)
DCMRunConfig(const std::vector< int64_t > &subsystemConfigIdList, const std::string &dcmName)