CARMA C++
carma::dbms::MonitorConfigurationDatabase Class Reference

This class contains methods for accessing monitor configuration information. More...

#include <carma/dbms/MonitorConfigurationDatabase.h>

Public Member Functions

dbms::Table getAggregateSubsystemsTable () const
 get the aggregate subsystems table More...
 
dbms::Table getBlankingFlagsTable () const
 get the BlankingFlags table More...
 
::std::string getCanonicalName (const int tagID) const
 get the canonical name for a monitor point associated with the specified tagId More...
 
::std::string getCanonicalName (const ::std::string &tagID) const
 get the canonical name for a monitor point associated with the specified tagId More...
 
void getContainerAndMPNames (const char *hname,::std::string &cname,::std::string &mpname) const
 get the conanical container name and monitor point name of a monitor point with the specified canonical name example getContainerName("A.B.C.D") returns "A.B.C" for the canonical container name and "D" for the monitor point name More...
 
::std::string * getCurrentTagIDNameSignature () const
 get the currently valid tagID->canonical names map signature the returned pointer is created by by this method using new so clients are responsible for deleting it to avoid memory leaks (or just use an auto_ptr if possible) More...
 
dbms::Table getDevicesTable () const
 get the devices table More...
 
dbms::Table getFullMonitorConfigurationTable (const ::std::vector< int > *const tagIDs=0, bool retreiveOnlyValidConfigs=false, util::frameType frameCount=util::Time::computeCurrentFrame()) const
 get the full monitor configuration table (static parms table joined with changable parms table + joins with auxiliary tables to convert IDs to strings the SQL query which is used to produce this table is SELECT S.tagID,frameCount, S.name, shortName, longName, units, updateInterval, description, isPersistent, isSpectrum, dataTypeID, warnLo, warnHi, errLo, errHi, L.name AS location, D.name AS device, mpTypeID FROM MonitorConfigStaticParms AS S JOIN MonitorConfigChangeableParms AS C ON S.tagID=C.tagID JOIN Locations AS L ON S.locationID=L.locationID JOIN Devices AS D ON S.deviceID=D.deviceID WHERE [C.tagID IN (<tagIDs>) AND] frameCount<=<frameCount> ORDER BY tagID,frameCount DESC Thus, for a given tagID, the most recent (ie, valid for <frameCount) description appears first in the table, other (invalid) configurations for that tagID appear in the rows immediately following the valid configuration for that tagID. More...
 
dbms::Table getLocationsTable () const
 get the location table More...
 
unsigned getMaxTagID (unsigned short subsysID) const
 get the maximum tagID for the specified subsystem More...
 
MonitorDescription getMonitorConfiguration (const ::std::string &canonicalName, util::frameType frameCount=util::Time::computeCurrentFrame()) const
 get monitor description associated with the specified canonical name which is valid at the specified frameCount. More...
 
MonitorDescription getMonitorConfiguration (int tagID, util::frameType frameCount=util::Time::computeCurrentFrame()) const
 get monitor description associated with the specified tagID which is valid at the specified frameCount. More...
 
dbms::ID2MDMap getMonitorConfigurations (const ::std::vector< int > *tagIDs, util::frameType frameCount=util::Time::computeCurrentFrame()) const
 get monitor configuration info for the specified tagIDs More...
 
dbms::Table getMonitorPointDataTypesTable () const
 get the MonitorPointDataTypes table More...
 
dbms::Table getMonitorPointTypesTable () const
 get the MonitorPointTypes table More...
 
short getSubsystemID (const ::std::string &subsysName, bool ignoreCase=false) const
 get the ID for the specified subsystem More...
 
::std::string * getSubsystemName (unsigned short subsysID) const
 get the subsystem name associated with the specified subsystem ID callers are responsible for deleting the returned pointer to prevent memory leaks More...
 
dbms::Table getSubsystemsTable () const
 get the subsystem table More...
 
int getTagID (const ::std::string &mpName) const
 get the tagID associated with the specified monitor point name More...
 
::std::map< int,::std::string > getTagID2NameMap () const
 get a map of tagid's to canonical names of monitor points More...
 
::std::string * getTagIDNameSignature (util::frameType frameCount=util::Time::computeCurrentFrame()) const
 get the tagID->canonical names map signature valid at the specified frame count. More...
 
dbms::Table getTagIDNameSignatures (const dbms::DBColumn *orderBy, dbms::SortOrder sortOrder=dbms::DESCENDING) const
 get the TagIDNameSignatures table More...
 
::std::map< int,::std::string > getTagIDs (const ::std::string &wildcardedName, const ::std::string &multiCharacterWildcard="%", const ::std::string &singleCharacterWildcard="_") const
 get the tagIDs corresponding to the specified canonical names More...
 
dbms::Table getTagIDToDataTypeIDTable () const
 get a table containing the tagID to dataTypeID mappings for all monitor points More...
 
unsigned getTotalMaxPoints () const
 get the value of maxpoints summed over all subsystems More...
 
unsigned getTotalMaxSamples () const
 get the value of maxsamples summed over all subsystems More...
 
dbms::Table getValiditiesTable () const
 get the Validities table More...
 
void insertAggregateSubsystemsRecord (const ::std::string &name, unsigned count, unsigned maxsamples, unsigned maxpoints) const
 insert a record into the aggregate subsystems table More...
 
unsigned insertMonitorConfiguration (const MonitorDescription &md, bool updateOnlyIfNecessary=true) const
 add a monitor point configuration to the database More...
 
unsigned insertMonitorConfiguration (const MonitorDescription &Md,::std::string &msg, bool updateOnlyIfNecessary=true, bool noInsertDenied=false) const
 As above, but may return an error string instead of throwing an InsertDeniedException. More...
 
bool insertTagIDNameSignaturesRecord (util::frameType frameCount, const ::std::string &signature, bool updateOnlyIfNecessary=true) const
 get the maximum length permitted for the shortName of a monitor point More...
 
bool monitorConfigExists (const ::std::string &canonicalName) const
 does the monitor configuration exist in the db? More...
 
 MonitorConfigurationDatabase (const DBConnection *dbc)
 constructor More...
 
bool mutateStaticParms (const ::std::string &disposition, unsigned tagID, const ::std::string &mpName, const ::std::string &fieldName, const ::std::string &newValue, const ::std::string &requester)
 Change a value in the static parameter table for a monitor point. More...
 
bool mutateStaticParms (const ::std::string &changeString)
 Same as above, but the args are in one string. More...
 
void populateBlankingFlagsTable () const
 populate the Validities table More...
 
void populateDevicesTable () const
 populate the Devices table using values from monitor::PhysicalDeviceIDAuthority::deviceNames if an ID (array index) already exists in the table, no attempt is made to enter it again. More...
 
void populateLocationsTable () const
 populate the Locations table More...
 
void populateMonitorPointDataTypesTable () const
 populate the MonitorPointDataTypes table More...
 
void populateMonitorPointTypesTable () const
 populate the MonitorPointTypes table More...
 
void populateSubsystemsTable () const
 populate the Subsystem table using values from monitor::TagIDAuthority::subsysnames More...
 
void populateValiditiesTable () const
 populate the Validities table More...
 
dbms::MonitorDescription tableRow2MonitorDescription (const dbms::Table &t, int row) const
 transform a monitor configuration represented by a table row into a MonitorDescription object. More...
 
bool tagIDExists (int tagID) const
 Does the specified tagID exist in the DB? More...
 

Detailed Description

This class contains methods for accessing monitor configuration information.

Definition at line 30 of file MonitorConfigurationDatabase.h.

Constructor & Destructor Documentation

carma::dbms::MonitorConfigurationDatabase::MonitorConfigurationDatabase ( const DBConnection dbc)
explicit

constructor

Member Function Documentation

dbms::Table carma::dbms::MonitorConfigurationDatabase::getAggregateSubsystemsTable ( ) const

get the aggregate subsystems table

Returns
the aggregate subsystems table
dbms::Table carma::dbms::MonitorConfigurationDatabase::getBlankingFlagsTable ( ) const

get the BlankingFlags table

Returns
the BlankingFlags table
::std::string carma::dbms::MonitorConfigurationDatabase::getCanonicalName ( const int  tagID) const

get the canonical name for a monitor point associated with the specified tagId

Parameters
tagIDtagID of the monitor point for which to get the canonical name
Returns
the corresponding canonical name or empty string if the monitor point doesn't exist
Exceptions
DBConnectionException
::std::string carma::dbms::MonitorConfigurationDatabase::getCanonicalName ( const ::std::string &  tagID) const

get the canonical name for a monitor point associated with the specified tagId

Parameters
tagIDtagID of the monitor point for which to get the canonical name
Returns
the corresponding canonical name or empty string if the monitor point doesn't exist
Exceptions
DBConnectionException
void carma::dbms::MonitorConfigurationDatabase::getContainerAndMPNames ( const char *  hname,
::std::string &  cname,
::std::string &  mpname 
) const

get the conanical container name and monitor point name of a monitor point with the specified canonical name example getContainerName("A.B.C.D") returns "A.B.C" for the canonical container name and "D" for the monitor point name

Parameters
hname[in] canonical name of the monitor point
cname[out] canonical container name
mpname[out] (non-canonical) monitor point name
::std::string* carma::dbms::MonitorConfigurationDatabase::getCurrentTagIDNameSignature ( ) const

get the currently valid tagID->canonical names map signature the returned pointer is created by by this method using new so clients are responsible for deleting it to avoid memory leaks (or just use an auto_ptr if possible)

Returns
a pointer to the string containing the current signature, or NULL if there is no valid pointer (ie if the database table contains no records
dbms::Table carma::dbms::MonitorConfigurationDatabase::getDevicesTable ( ) const

get the devices table

Returns
the devices Table
dbms::Table carma::dbms::MonitorConfigurationDatabase::getFullMonitorConfigurationTable ( const ::std::vector< int > *const  tagIDs = 0,
bool  retreiveOnlyValidConfigs = false,
util::frameType  frameCount = util::Time::computeCurrentFrame() 
) const

get the full monitor configuration table (static parms table joined with changable parms table + joins with auxiliary tables to convert IDs to strings the SQL query which is used to produce this table is SELECT S.tagID,frameCount, S.name, shortName, longName, units, updateInterval, description, isPersistent, isSpectrum, dataTypeID, warnLo, warnHi, errLo, errHi, L.name AS location, D.name AS device, mpTypeID FROM MonitorConfigStaticParms AS S JOIN MonitorConfigChangeableParms AS C ON S.tagID=C.tagID JOIN Locations AS L ON S.locationID=L.locationID JOIN Devices AS D ON S.deviceID=D.deviceID WHERE [C.tagID IN (<tagIDs>) AND] frameCount<=<frameCount> ORDER BY tagID,frameCount DESC Thus, for a given tagID, the most recent (ie, valid for <frameCount) description appears first in the table, other (invalid) configurations for that tagID appear in the rows immediately following the valid configuration for that tagID.

The tagID component in the WHERE clause is not used if the request is for all tagIDs (ie the tagID parameter is NULL). Rows of this table are suitable to pass to tableRow2MonitorDescription

See Also
tableRow2MonitorDescription
Parameters
tagIDsthe tagIDs for which to get monitor configuration info a NULL pointer means get info for all tagIDs in the DB, which is not expensive to do
frameCountreturn configuration info that is valid at this frameCount
retrieveOnlyValidConfigsget only the monitor configurations which are valid at the specified frameCount. If true, a "GROUP BY tagID" clause is added to the select statement, so that each tagID is guaranteed to have only a single entry
Returns
the full monitor configuration table
dbms::Table carma::dbms::MonitorConfigurationDatabase::getLocationsTable ( ) const

get the location table

Returns
the location Table
unsigned carma::dbms::MonitorConfigurationDatabase::getMaxTagID ( unsigned short  subsysID) const

get the maximum tagID for the specified subsystem

Parameters
subsysIDthe subsystem ID for which to find the maximum tagID
Returns
the maximum tagID for the specified subsystem, or 0 if the subsystem has no associated monitor points
Exceptions
DBConnectionException
MonitorDescription carma::dbms::MonitorConfigurationDatabase::getMonitorConfiguration ( const ::std::string &  canonicalName,
util::frameType  frameCount = util::Time::computeCurrentFrame() 
) const

get monitor description associated with the specified canonical name which is valid at the specified frameCount.

Callers are responsible for deleting the returned pointer to prevent a memory leak

Parameters
canonicalNamecanonical name of the monitor description
frameCountget the configuration which is valid at this frameCount
Returns
the monitor description
Exceptions
NotFoundExceptionif no description with the the specified tagID exists at the specified frameCount
DBConnectionException
MonitorDescription carma::dbms::MonitorConfigurationDatabase::getMonitorConfiguration ( int  tagID,
util::frameType  frameCount = util::Time::computeCurrentFrame() 
) const

get monitor description associated with the specified tagID which is valid at the specified frameCount.

Callers are responsible for deleting the returned pointer to prevent a memory leak

Parameters
tagIDID of the monitor point
frameCountget the configuration which is valid at this frameCount
Returns
the monitor description
Exceptions
NotFoundExceptionif no description with the the specified tagID exists at the specified frameCount
DBConnectionException
dbms::ID2MDMap carma::dbms::MonitorConfigurationDatabase::getMonitorConfigurations ( const ::std::vector< int > *  tagIDs,
util::frameType  frameCount = util::Time::computeCurrentFrame() 
) const

get monitor configuration info for the specified tagIDs

Parameters
tagIDsthe tagIDs for which to get monitor configuration info a NULL pointer means get info for all tagIDs in the DB, but don't do that, because its extremely expensive
frameCountreturn configuration info that is valid at this frameCount
Returns
the tagID->MonitorDescription map
dbms::Table carma::dbms::MonitorConfigurationDatabase::getMonitorPointDataTypesTable ( ) const

get the MonitorPointDataTypes table

Returns
the MonitorPointDataTypes table
dbms::Table carma::dbms::MonitorConfigurationDatabase::getMonitorPointTypesTable ( ) const

get the MonitorPointTypes table

Returns
the MonitorPointTypes table
short carma::dbms::MonitorConfigurationDatabase::getSubsystemID ( const ::std::string &  subsysName,
bool  ignoreCase = false 
) const

get the ID for the specified subsystem

Parameters
subsysthe subsystem name
ignorethe case of the input subsystem name when looking for a matching value in the DB
Returns
subsystem ID, or -1 if no such subsytem is in the DB
::std::string* carma::dbms::MonitorConfigurationDatabase::getSubsystemName ( unsigned short  subsysID) const

get the subsystem name associated with the specified subsystem ID callers are responsible for deleting the returned pointer to prevent memory leaks

Parameters
subsysIDthe subsystem ID
Returns
the subsystem name or a null pointer if subsystem ID does not exist in the DB
Exceptions
DBConnectionException
dbms::Table carma::dbms::MonitorConfigurationDatabase::getSubsystemsTable ( ) const

get the subsystem table

Returns
the subsystem Table
int carma::dbms::MonitorConfigurationDatabase::getTagID ( const ::std::string &  mpName) const

get the tagID associated with the specified monitor point name

Parameters
mpNamecanonical name of the monitor point for which to get the tagID
Returns
the corresponding tagID or -1 if the monitor point doesn't exist
Exceptions
DBConnectionException
::std::map< int, ::std::string > carma::dbms::MonitorConfigurationDatabase::getTagID2NameMap ( ) const

get a map of tagid's to canonical names of monitor points

Returns
tagID->canonical name map
Exceptions
DBConnectionexception
::std::string* carma::dbms::MonitorConfigurationDatabase::getTagIDNameSignature ( util::frameType  frameCount = util::Time::computeCurrentFrame()) const

get the tagID->canonical names map signature valid at the specified frame count.

the returned pointer is created by by this method using new so clients are responsible for deleting it to avoid memory leaks (or just use an auto_ptr if possible)

Parameters
frameCountthe frame count for which the returned signature is valid
Returns
a pointer to the string containing the current signature, or NULL if there is no valid pointer (ie if the database table contains no records
dbms::Table carma::dbms::MonitorConfigurationDatabase::getTagIDNameSignatures ( const dbms::DBColumn orderBy,
dbms::SortOrder  sortOrder = dbms::DESCENDING 
) const

get the TagIDNameSignatures table

Parameters
orderBythe column to order the table by, (NULL -> don't bother sorting)
sortOrderthe order in which to sort
Returns
the TagIDNamesSignatures table
::std::map< int, ::std::string > carma::dbms::MonitorConfigurationDatabase::getTagIDs ( const ::std::string &  wildcardedName,
const ::std::string &  multiCharacterWildcard = "%",
const ::std::string &  singleCharacterWildcard = "_" 
) const

get the tagIDs corresponding to the specified canonical names

Parameters
canonicalNamesmonitor point names for which to get the tagIDs a NULL pointer means get all the tagIDs in the db
Returns
the tagIDs corresponding to the specified canonical names
Exceptions
NotFoundExceptionif any of the specified canonical names do not exist in the db get the tagID->canonoical name mapping of a possibly wildcarded canonical name using an SQL LIKE filter.
Parameters
wildcardedNamethe wild carded canonical name
multiCharacterWildcardthis string represents the multicharacter wildcard in the input string and is translated into the SQL multicharacter wildcard % when the search is performed
multiCharacterWildcardthis string represents the multicharacter wildcard (matches 0,1, or any other number of characters) in the input string and is translated into the SQL multicharacter wildcard (%) when the search is performed
singleCharacterWildcardthis string represents the single character matches exactly 1 character) in the input string and is translated into the SQL single character wildcard (_) when the search is performed. Note this is not the same as the regexp "?" since "?" in regexp also matches 0 characters
Returns
a map of tagIDs to canonical names which fulfill the search criterion
dbms::Table carma::dbms::MonitorConfigurationDatabase::getTagIDToDataTypeIDTable ( ) const

get a table containing the tagID to dataTypeID mappings for all monitor points

unsigned carma::dbms::MonitorConfigurationDatabase::getTotalMaxPoints ( ) const

get the value of maxpoints summed over all subsystems

Returns
the summed value of maxpoints
unsigned carma::dbms::MonitorConfigurationDatabase::getTotalMaxSamples ( ) const

get the value of maxsamples summed over all subsystems

Returns
the summed value of maxsamples
dbms::Table carma::dbms::MonitorConfigurationDatabase::getValiditiesTable ( ) const

get the Validities table

Returns
the Validities table
void carma::dbms::MonitorConfigurationDatabase::insertAggregateSubsystemsRecord ( const ::std::string &  name,
unsigned  count,
unsigned  maxsamples,
unsigned  maxpoints 
) const

insert a record into the aggregate subsystems table

Parameters
namethe aggregate subsystem name
countthe number of subsystems in the aggregate
maxsamplesthe maxsamples value in the aggregate
maxpointsthe maxpoints value in the aggregate
Exceptions
DBConnectionException
unsigned carma::dbms::MonitorConfigurationDatabase::insertMonitorConfiguration ( const MonitorDescription md,
bool  updateOnlyIfNecessary = true 
) const

add a monitor point configuration to the database

Parameters
mdthe MonitorDescription to insert
updateOnlyIfNecessaryupdate a previous description with the same name only if the description's field, other than the frameCount field has changed (that is, don't add this description to the db if a previous similar description exists and the only difference is the frameCount fields)
Returns
the tagID of the new monitor configuration
Exceptions
out_of_rangeif number of monitor points in the specified subsystem exceeds 65536
DBConnectionExceptionif there is a problem with the db connection
InsertDeniedExcpetionif the named configuration exists and there is a change in one of its static parameters
SQLExceptionif there is a problem when executing the query
unsigned carma::dbms::MonitorConfigurationDatabase::insertMonitorConfiguration ( const MonitorDescription Md,
::std::string &  msg,
bool  updateOnlyIfNecessary = true,
bool  noInsertDenied = false 
) const

As above, but may return an error string instead of throwing an InsertDeniedException.

Parameters
msgFormatted message string to be returned.
noInsertDeniedIf true, don't throw InsertDeniedException. Return a formatted error string instead.
bool carma::dbms::MonitorConfigurationDatabase::insertTagIDNameSignaturesRecord ( util::frameType  frameCount,
const ::std::string &  signature,
bool  updateOnlyIfNecessary = true 
) const

get the maximum length permitted for the shortName of a monitor point

Returns
the maximum length permitted for the shortName of a monitor point insert a record into the TagIDNameSignatures table
Parameters
frameCountframeCount at which the signature is valid
signaturethe tagID-Name map signature
insertOnlyIfNecessaryinsert this record only if the signature differs from the signature of the previous record in the table
Returns
true if the table was actually updated (will return false only in some cases when updateOnlyIfNecessary=true)
bool carma::dbms::MonitorConfigurationDatabase::monitorConfigExists ( const ::std::string &  canonicalName) const

does the monitor configuration exist in the db?

Parameters
canonicalNamecanonical (full hierarchical) name of the monitor configuration
Exceptions
DBConnectionif there is a problem with the connection to the database
SQLExceptionif there is a problem executing the SQL query
bool carma::dbms::MonitorConfigurationDatabase::mutateStaticParms ( const ::std::string &  disposition,
unsigned  tagID,
const ::std::string &  mpName,
const ::std::string &  fieldName,
const ::std::string &  newValue,
const ::std::string &  requester 
)

Change a value in the static parameter table for a monitor point.

NOTE: This is not a general purpose editing routine. The table is meant to be static. Calling this routine implies there was a problem that needs to be fixed. If care is not taken, the database could be corrupted. An entry describing the change is made in the MP change log table.

Parameters
dispositionHow to handle - edit or new/rename/make alias.
tagIDtagID of monitor point to be changed.
mpNameName of monitor point to be changed.
fieldNameName of field in MonitorConfigStaticParms to be changed.
newValueNew value to be placed in field.
requesterUser name of user requesting the change.
Returns
true if change succeeded. false otherwise.
Exceptions
DBConnectionExceptionif there is a problem with the db connection.
SQLExceptionif there is a problem when executing the query.
bool carma::dbms::MonitorConfigurationDatabase::mutateStaticParms ( const ::std::string &  changeString)

Same as above, but the args are in one string.

Parameters
changeStringOne line from the output of monitorConfigurationLoader edited to include the login name of the person requesting the change and the disposition.
void carma::dbms::MonitorConfigurationDatabase::populateBlankingFlagsTable ( ) const

populate the Validities table

void carma::dbms::MonitorConfigurationDatabase::populateDevicesTable ( ) const

populate the Devices table using values from monitor::PhysicalDeviceIDAuthority::deviceNames if an ID (array index) already exists in the table, no attempt is made to enter it again.

That is, only new entries in the array are inserted into the table

void carma::dbms::MonitorConfigurationDatabase::populateLocationsTable ( ) const

populate the Locations table

populate the Locations table using values from monitor::PhysicalDeviceIDAuthority::locationNames_ if an ID (array index) already exists in the table, no attempt is made to enter it again. That is, only new entries in the array are inserted into the table

void carma::dbms::MonitorConfigurationDatabase::populateMonitorPointDataTypesTable ( ) const

populate the MonitorPointDataTypes table

void carma::dbms::MonitorConfigurationDatabase::populateMonitorPointTypesTable ( ) const

populate the MonitorPointTypes table

void carma::dbms::MonitorConfigurationDatabase::populateSubsystemsTable ( ) const

populate the Subsystem table using values from monitor::TagIDAuthority::subsysnames

void carma::dbms::MonitorConfigurationDatabase::populateValiditiesTable ( ) const

populate the Validities table

dbms::MonitorDescription carma::dbms::MonitorConfigurationDatabase::tableRow2MonitorDescription ( const dbms::Table t,
int  row 
) const

transform a monitor configuration represented by a table row into a MonitorDescription object.

The table row should have all the columns in the table produced by getFullMonitorConfigurationTable()

See Also
getFullMonitorConfigurationTable
Parameters
tthe table
rowthe row number of t to transform
tagIDthe tagID of the associated monitor configuration
Returns
the MonitorDescription
bool carma::dbms::MonitorConfigurationDatabase::tagIDExists ( int  tagID) const

Does the specified tagID exist in the DB?

Parameters
tagIDthe tagID for which to check the existence
Returns
true if the tagID exists
Exceptions
DBConnectionException

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