Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
dbutils::daqconfig::DLRunConfig Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-12-01/DatabaseUtils/cxx/include/DAQConfig/DLRunConfig.h"

Public Types

typedef std::vector< boost::shared_ptr< SimpleParameterSet > > StreamList
 

Public Member Functions

 DLRunConfig (const std::vector< int64_t > &subsystemConfigIdList)
 
 DLRunConfig (const SubsystemNameSpec &nameSpec)
 
 DLRunConfig (const GlobalNameSpec &nameSpec)
 
 DLRunConfig (const int64_t &globalConfigId)
 
virtual ~DLRunConfig ()
 
virtual bool hasValidData () const
 
int64_t getPrimarySubsystemConfigId () const
 
StreamList getStreamList ()
 
std::string getOutputPath ()
 

Protected Member Functions

bool _fetchAllData (const std::vector< int64_t > &subsystemConfigIdList)
 
bool _fetchStreamData (const std::string &tableDefinitionFileName, const int64_t &subsystemConfigId)
 
bool _fetchSystemData (const std::string &tableDefinitionFileName, const int64_t &subsystemConfigId)
 

Protected Attributes

bool _hasValidData
 
int64_t _primarySubsystemConfigId
 
StreamList _streamList
 
std::string _outputPath
 

Detailed Description

Worker class to handle fetching of Data Logger run configuration data.

Author
Kurt Biery
Version
Revision
1.4.20.1
Date
2019/09/27 00:07:03

Definition at line 23 of file DLRunConfig.h.

Member Typedef Documentation

typedef std::vector<boost::shared_ptr<SimpleParameterSet> > dbutils::daqconfig::DLRunConfig::StreamList

Definition at line 27 of file DLRunConfig.h.

Constructor & Destructor Documentation

dbutils::daqconfig::DLRunConfig::DLRunConfig ( const std::vector< int64_t > &  subsystemConfigIdList)

Creates a DataLogger run configuration object from the specified list of subsystem configuration IDs.

Parameters
subsystemConfigIdListThe list of subsystem configuration IDs.
dcmNameThe name of the DCM of interest.

Definition at line 24 of file DLRunConfig.cpp.

References _fetchAllData(), _hasValidData, and _primarySubsystemConfigId.

25 {
27  if (subsystemConfigIdList.size() > 0) {
28  _primarySubsystemConfigId = subsystemConfigIdList[0];
29  _hasValidData = _fetchAllData(subsystemConfigIdList);
30  }
31  else {
32  _hasValidData = false;
33  }
34 }
bool _fetchAllData(const std::vector< int64_t > &subsystemConfigIdList)
dbutils::daqconfig::DLRunConfig::DLRunConfig ( const SubsystemNameSpec nameSpec)

Creates a DataLogger run configuration object from the specified subsystem configuration specification.

Parameters
nameSpecThe named configuration of interest.

Definition at line 42 of file DLRunConfig.cpp.

References _fetchAllData(), _hasValidData, and _primarySubsystemConfigId.

43 {
45  std::vector<int64_t> subsystemConfigIdList;
46  if (NamedConfigUtils::
47  getSubsystemConfigIdAncestry(nameSpec, subsystemConfigIdList)) {
48  _primarySubsystemConfigId = subsystemConfigIdList[0];
49  _hasValidData = _fetchAllData(subsystemConfigIdList);
50  }
51  else {
52  _hasValidData = false;
53  }
54 }
bool _fetchAllData(const std::vector< int64_t > &subsystemConfigIdList)
dbutils::daqconfig::DLRunConfig::DLRunConfig ( const GlobalNameSpec nameSpec)

Creates a DataLogger run configuration object from the specified global configuration specification.

Parameters
nameSpecThe named configuration of interest.

Definition at line 62 of file DLRunConfig.cpp.

References _fetchAllData(), _hasValidData, _primarySubsystemConfigId, dbutils::daqconfig::IDSpec::DAQ, dbutils::daqconfig::NamedConfigUtils::getConfigIdAncestry(), dbutils::daqconfig::NamedConfigUtils::getSubsystemConfigIdFromGlobalName(), fabricate::status, and dbutils::daqconfig::IDSpec::SUBSYSTEM.

63 {
65  int64_t subsystemConfigId;
68  SubsystemNameSpec::
69  DL_SUBSYSTEM_NAME,
70  SubsystemNameSpec::
71  RUN_CONFIG_TYPE,
72  subsystemConfigId);
73 
74  std::vector<int64_t> subsystemConfigIdList;
75  if (status) {
76  IDSpec idSpec(subsystemConfigId, IDSpec::SUBSYSTEM, IDSpec::DAQ);
77  status = NamedConfigUtils::
78  getConfigIdAncestry(idSpec, subsystemConfigIdList);
79  }
80 
81  if (status) {
82  _primarySubsystemConfigId = subsystemConfigIdList[0];
83  _hasValidData = _fetchAllData(subsystemConfigIdList);
84  }
85  else {
86  _hasValidData = false;
87  }
88 }
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)
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)
bool _fetchAllData(const std::vector< int64_t > &subsystemConfigIdList)
dbutils::daqconfig::DLRunConfig::DLRunConfig ( const int64_t &  globalConfigId)

Creates a DataLogger run configuration object from the specified global configuration ID.

Parameters
globalConfigIdThe ID of the global configuration of interest.

Definition at line 96 of file DLRunConfig.cpp.

References _fetchAllData(), _hasValidData, _primarySubsystemConfigId, dbutils::daqconfig::IDSpec::DAQ, and dbutils::daqconfig::IDSpec::GLOBAL.

97 {
98  IDSpec idSpec(globalConfigId, IDSpec::GLOBAL, IDSpec::DAQ);
100  std::vector<int64_t> subsystemConfigIdList;
101  if (NamedConfigUtils::
102  getSubsystemConfigIdAncestryFromGlobalId(idSpec,
103  SubsystemNameSpec::
104  DL_SUBSYSTEM_NAME,
105  SubsystemNameSpec::
106  RUN_CONFIG_TYPE,
107  subsystemConfigIdList)) {
108  _primarySubsystemConfigId = subsystemConfigIdList[0];
109  _hasValidData = _fetchAllData(subsystemConfigIdList);
110  }
111  else {
112  _hasValidData = false;
113  }
114 }
bool _fetchAllData(const std::vector< int64_t > &subsystemConfigIdList)
virtual dbutils::daqconfig::DLRunConfig::~DLRunConfig ( )
inlinevirtual

Definition at line 41 of file DLRunConfig.h.

41 {};

Member Function Documentation

bool dbutils::daqconfig::DLRunConfig::_fetchAllData ( const std::vector< int64_t > &  subsystemConfigIdList)
protected

Definition at line 117 of file DLRunConfig.cpp.

References _fetchStreamData(), _fetchSystemData(), plot_validation_datamc::fname, fabricate::status, and string.

Referenced by DLRunConfig(), and getOutputPath().

118 {
119  bool status = true;
121 
122  // for the DL configuration, inheritance is not used,
123  // so only the first subsystem ID is relevant
124  int64_t subsystemConfigId = subsystemConfigIdList[0];
125 
126  if (status) {
127  fname = "NovaDatabase/tables/DAQConfig/DataLoggerStreams.xml";
128  status = _fetchStreamData(fname, subsystemConfigId);
129  }
130  if (status) {
131  fname = "NovaDatabase/tables/DAQConfig/DataLoggerSystemParameters.xml";
132  status = _fetchSystemData(fname, subsystemConfigId);
133  }
134 
135  return status;
136 }
int status
Definition: fabricate.py:1613
bool _fetchSystemData(const std::string &tableDefinitionFileName, const int64_t &subsystemConfigId)
bool _fetchStreamData(const std::string &tableDefinitionFileName, const int64_t &subsystemConfigId)
enum BeamMode string
bool dbutils::daqconfig::DLRunConfig::_fetchStreamData ( const std::string tableDefinitionFileName,
const int64_t &  subsystemConfigId 
)
protected

Definition at line 139 of file DLRunConfig.cpp.

References _fetchSystemData(), _streamList, nova::database::Row::Col(), mkDefs::detName, nova::database::Column::Get(), novadaq::EnvVarCache::getEnvVar(), novadaq::EnvVarCache::getInstance(), dbutils::daqconfig::DBColumnUtils::isInfrastructureColumn(), dbutils::daqconfig::DBColumnUtils::isSubsystemConfigReferenceColumn(), string, and dbutils::daqconfig::NamedConfigUtils::SUBSYSCFGID_COLUMN_NAME.

Referenced by _fetchAllData(), and getOutputPath().

141 {
142  boost::shared_ptr<NOVADB::Table> dbt;
143  dbt.reset(new NOVADB::Table(tableDefinitionFileName));
145  novadaq::EnvVarCache::getInstance().getEnvVar("NOVADAQ_ENVIRONMENT");
146  dbt->SetDetector(detName);
147  std::string dbUser =
148  novadaq::EnvVarCache::getInstance().getEnvVar("CFGMGR_DB_USER");
149  if (dbUser.length() > 0) {dbt->SetUser(dbUser);}
150  if (! dbt->GetConnection()) {return false;}
151  if (! dbt->ExistsInDB()) {return false;}
152 
153  dbt->Clear();
154  dbt->SetValidityRange(NamedConfigUtils::SUBSYSCFGID_COLUMN_NAME,
155  subsystemConfigId);
156  if (! dbt->LoadFromDB()) {return false;}
157 
158  std::vector<std::string> colNames = dbt->GetColNames();
159  NOVADB::Row* rowPtr;
160  NOVADB::Column* colPtr;
161  for (int rowIdx = 0; rowIdx < dbt->NRow(); ++rowIdx) {
162  boost::shared_ptr<SimpleParameterSet>
163  streamParamSet(new SimpleParameterSet());
164  rowPtr = dbt->GetRow(rowIdx);
165 
166  for (uint32_t colIdx = 0; colIdx < colNames.size(); ++colIdx) {
167  std::string colName = boost::to_lower_copy(colNames[colIdx]);
168  if (DBColumnUtils::isInfrastructureColumn(colName)) {continue;}
170  continue;
171  }
172 
173  std::string valueString;
174  colPtr = rowPtr->Col(colName);
175  if (! colPtr->Get(valueString)) {
176  return false;
177  }
178  streamParamSet->put(colName, valueString);
179  }
180 
181  _streamList.push_back(streamParamSet);
182  }
183 
184  return true;
185 }
static EnvVarCache & getInstance()
Definition: EnvVarCache.cpp:12
bool Get(T &val) const
Definition: Column.h:53
static bool isSubsystemConfigReferenceColumn(const std::string &columnName)
std::string getEnvVar(std::string name)
Definition: EnvVarCache.cpp:33
static bool isInfrastructureColumn(const std::string &columnName)
static const std::string SUBSYSCFGID_COLUMN_NAME
detName
Definition: mkDefs.py:106
Column & Col(int i)
Definition: Row.h:51
enum BeamMode string
bool dbutils::daqconfig::DLRunConfig::_fetchSystemData ( const std::string tableDefinitionFileName,
const int64_t &  subsystemConfigId 
)
protected

Definition at line 188 of file DLRunConfig.cpp.

References _outputPath, nova::database::Row::Col(), mkDefs::detName, nova::database::Column::Get(), novadaq::EnvVarCache::getEnvVar(), novadaq::EnvVarCache::getInstance(), string, and dbutils::daqconfig::NamedConfigUtils::SUBSYSCFGID_COLUMN_NAME.

Referenced by _fetchAllData(), _fetchStreamData(), and getOutputPath().

190 {
191  boost::shared_ptr<NOVADB::Table> dbt;
192  dbt.reset(new NOVADB::Table(tableDefinitionFileName));
194  novadaq::EnvVarCache::getInstance().getEnvVar("NOVADAQ_ENVIRONMENT");
195  dbt->SetDetector(detName);
196  std::string dbUser =
197  novadaq::EnvVarCache::getInstance().getEnvVar("CFGMGR_DB_USER");
198  if (dbUser.length() > 0) {dbt->SetUser(dbUser);}
199  if (! dbt->GetConnection()) {return false;}
200  if (! dbt->ExistsInDB()) {return false;}
201 
202  dbt->Clear();
203  dbt->SetValidityRange(NamedConfigUtils::SUBSYSCFGID_COLUMN_NAME,
204  subsystemConfigId);
205  if (! dbt->LoadFromDB()) {return false;}
206 
207  if (dbt->NRow() != 1) {return false;}
208 
209  NOVADB::Row* rowPtr = dbt->GetRow(0);
210  NOVADB::Column* colPtr = rowPtr->Col("outputPath");
211  if (! colPtr->Get(_outputPath)) {
212  return false;
213  }
214 
215  return true;
216 }
static EnvVarCache & getInstance()
Definition: EnvVarCache.cpp:12
bool Get(T &val) const
Definition: Column.h:53
std::string getEnvVar(std::string name)
Definition: EnvVarCache.cpp:33
static const std::string SUBSYSCFGID_COLUMN_NAME
detName
Definition: mkDefs.py:106
Column & Col(int i)
Definition: Row.h:51
enum BeamMode string
std::string dbutils::daqconfig::DLRunConfig::getOutputPath ( )
inline

Definition at line 51 of file DLRunConfig.h.

References _fetchAllData(), _fetchStreamData(), _fetchSystemData(), _outputPath, and string.

51 {return _outputPath;}
int64_t dbutils::daqconfig::DLRunConfig::getPrimarySubsystemConfigId ( ) const
inline

Definition at line 48 of file DLRunConfig.h.

References _primarySubsystemConfigId.

StreamList dbutils::daqconfig::DLRunConfig::getStreamList ( )
inline

Definition at line 50 of file DLRunConfig.h.

References _streamList.

50 {return _streamList;}
virtual bool dbutils::daqconfig::DLRunConfig::hasValidData ( ) const
inlinevirtual

Definition at line 47 of file DLRunConfig.h.

References _hasValidData.

Member Data Documentation

bool dbutils::daqconfig::DLRunConfig::_hasValidData
protected

Definition at line 63 of file DLRunConfig.h.

Referenced by DLRunConfig(), and hasValidData().

std::string dbutils::daqconfig::DLRunConfig::_outputPath
protected

Definition at line 67 of file DLRunConfig.h.

Referenced by _fetchSystemData(), and getOutputPath().

int64_t dbutils::daqconfig::DLRunConfig::_primarySubsystemConfigId
protected

Definition at line 64 of file DLRunConfig.h.

Referenced by DLRunConfig(), and getPrimarySubsystemConfigId().

StreamList dbutils::daqconfig::DLRunConfig::_streamList
protected

Definition at line 66 of file DLRunConfig.h.

Referenced by _fetchStreamData(), and getStreamList().


The documentation for this class was generated from the following files: