DCMConnectConfig.cpp
Go to the documentation of this file.
1 #include <DatabaseUtils/DAQConfig/DCMConnectConfig.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 connect 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 DCMConnectConfig(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 connect 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 connect 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  */
63  const std::string& dcmName)
64 {
65  _hasValidData = false;
67  int64_t subsystemConfigId;
68  if (NamedConfigUtils::
69  getSubsystemConfigIdFromGlobalName(nameSpec,
71  DCM_SUBSYSTEM_NAME,
73  CONNECT_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 connect 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 DCMConnectConfig(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  CONNECT_CONFIG_TYPE,
105  subsystemConfigIdList)) {
106  _primarySubsystemConfigId = subsystemConfigIdList[0];
107  _hasValidData = _fetchAllData(subsystemConfigIdList, dcmName);
108  }
109  else {
110  _hasValidData = false;
111  }
112 }
113 
115 _fetchAllData(const std::vector<int64_t>& subsystemConfigIdList,
116  const std::string& dcmName)
117 {
118  bool status = true;
119 
120  // dcm-specific data
121  if (status) {
122  status = _fetchDCMApplicationParams(subsystemConfigIdList, dcmName);
123  }
124 
125  return status;
126 }
127 
129 _fetchDCMApplicationParams(const std::vector<int64_t>& subsystemConfigIdList,
130  const std::string& dcmName)
131 {
132  ConfigDataSelector cfgSelector;
134  dcmName, dcmName);
135 
136  std::vector<std::string> dataColumnsOfInterest;
137  dataColumnsOfInterest.push_back("sendTimeoutInMilliSec");
138  dataColumnsOfInterest.push_back("sendNumAttempt");
139  dataColumnsOfInterest.push_back("sendSocketBufferSize");
140 
142  dcmParamDataSet("NovaDatabase/tables/DAQConfig/DCMApplicationConnectParameters.xml",
143  subsystemConfigIdList, cfgSelector,
144  dataColumnsOfInterest);
145  if (! dcmParamDataSet.getEffectiveValueFor1Key(dcmName,
146  "sendTimeoutInMilliSec",
148  return false;
149  }
150  if (! dcmParamDataSet.getEffectiveValueFor1Key(dcmName,
151  "sendNumAttempt",
152  _sendNumAttempt)) {
153  return false;
154  }
155  if (! dcmParamDataSet.getEffectiveValueFor1Key(dcmName,
156  "sendSocketBufferSize",
158  return false;
159  }
160  return true;
161 }
162 
163 } // end of namespace daqconfig
164 } // end of namespace dbutils
void addSelectionColumn(std::string columnName)
int status
Definition: fabricate.py:1613
bool _fetchDCMApplicationParams(const std::vector< int64_t > &subsystemConfigIdList, const std::string &dcmName)
bool _fetchAllData(const std::vector< int64_t > &subsystemConfigIdList, const std::string &dcmName)
bool getEffectiveValueFor1Key(const U &primarySelectionValue, const std::string &dataColumnName, T &resultValue)
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
DCMConnectConfig(const std::vector< int64_t > &subsystemConfigIdList, const std::string &dcmName)
static const std::string DCMID_COLUMN_NAME