CARMA C++
|
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... | |
This class contains methods for accessing monitor configuration information.
Definition at line 30 of file MonitorConfigurationDatabase.h.
|
explicit |
constructor
dbms::Table carma::dbms::MonitorConfigurationDatabase::getAggregateSubsystemsTable | ( | ) | const |
get the aggregate subsystems table
dbms::Table carma::dbms::MonitorConfigurationDatabase::getBlankingFlagsTable | ( | ) | const |
get 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
tagID | tagID of the monitor point for which to get the canonical name |
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
tagID | tagID of the monitor point for which to get the canonical name |
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
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)
dbms::Table carma::dbms::MonitorConfigurationDatabase::getDevicesTable | ( | ) | const |
get 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
tagIDs | the 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 |
frameCount | return configuration info that is valid at this frameCount |
retrieveOnlyValidConfigs | get 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 |
dbms::Table carma::dbms::MonitorConfigurationDatabase::getLocationsTable | ( | ) | const |
get the location table
unsigned carma::dbms::MonitorConfigurationDatabase::getMaxTagID | ( | unsigned short | subsysID | ) | const |
get the maximum tagID for the specified subsystem
subsysID | the subsystem ID for which to find the maximum tagID |
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
canonicalName | canonical name of the monitor description |
frameCount | get the configuration which is valid at this frameCount |
NotFoundException | if 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
tagID | ID of the monitor point |
frameCount | get the configuration which is valid at this frameCount |
NotFoundException | if 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
tagIDs | the 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 |
frameCount | return configuration info that is valid at this frameCount |
dbms::Table carma::dbms::MonitorConfigurationDatabase::getMonitorPointDataTypesTable | ( | ) | const |
get the MonitorPointDataTypes table
dbms::Table carma::dbms::MonitorConfigurationDatabase::getMonitorPointTypesTable | ( | ) | const |
get the MonitorPointTypes table
short carma::dbms::MonitorConfigurationDatabase::getSubsystemID | ( | const ::std::string & | subsysName, |
bool | ignoreCase = false |
||
) | const |
get the ID for the specified subsystem
subsys | the subsystem name |
ignore | the case of the input subsystem name when looking for a matching value 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
subsysID | the subsystem ID |
DBConnectionException |
dbms::Table carma::dbms::MonitorConfigurationDatabase::getSubsystemsTable | ( | ) | const |
get the subsystem table
int carma::dbms::MonitorConfigurationDatabase::getTagID | ( | const ::std::string & | mpName | ) | const |
get the tagID associated with the specified monitor point name
mpName | canonical name of the monitor point for which to get the tagID |
DBConnectionException |
::std::map< int, ::std::string > carma::dbms::MonitorConfigurationDatabase::getTagID2NameMap | ( | ) | const |
get a map of tagid's to canonical names of monitor points
DBConnection | exception |
::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)
frameCount | the frame count for which the returned signature is valid |
dbms::Table carma::dbms::MonitorConfigurationDatabase::getTagIDNameSignatures | ( | const dbms::DBColumn * | orderBy, |
dbms::SortOrder | sortOrder = dbms::DESCENDING |
||
) | const |
get the TagIDNameSignatures table
orderBy | the column to order the table by, (NULL -> don't bother sorting) |
sortOrder | the order in which to sort |
::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
canonicalNames | monitor point names for which to get the tagIDs a NULL pointer means get all the tagIDs in the db |
NotFoundException | if 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. |
wildcardedName | the wild carded canonical name |
multiCharacterWildcard | this string represents the multicharacter wildcard in the input string and is translated into the SQL multicharacter wildcard % when the search is performed |
multiCharacterWildcard | this 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 |
singleCharacterWildcard | this 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 |
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
unsigned carma::dbms::MonitorConfigurationDatabase::getTotalMaxSamples | ( | ) | const |
get the value of maxsamples summed over all subsystems
dbms::Table carma::dbms::MonitorConfigurationDatabase::getValiditiesTable | ( | ) | const |
get 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
name | the aggregate subsystem name |
count | the number of subsystems in the aggregate |
maxsamples | the maxsamples value in the aggregate |
maxpoints | the maxpoints value in the aggregate |
DBConnectionException |
unsigned carma::dbms::MonitorConfigurationDatabase::insertMonitorConfiguration | ( | const MonitorDescription & | md, |
bool | updateOnlyIfNecessary = true |
||
) | const |
add a monitor point configuration to the database
md | the MonitorDescription to insert |
updateOnlyIfNecessary | update 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) |
out_of_range | if number of monitor points in the specified subsystem exceeds 65536 |
DBConnectionException | if there is a problem with the db connection |
InsertDeniedExcpetion | if the named configuration exists and there is a change in one of its static parameters |
SQLException | if 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.
msg | Formatted message string to be returned. |
noInsertDenied | If 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
frameCount | frameCount at which the signature is valid |
signature | the tagID-Name map signature |
insertOnlyIfNecessary | insert this record only if the signature differs from the signature of the previous record in the table |
bool carma::dbms::MonitorConfigurationDatabase::monitorConfigExists | ( | const ::std::string & | canonicalName | ) | const |
does the monitor configuration exist in the db?
canonicalName | canonical (full hierarchical) name of the monitor configuration |
DBConnection | if there is a problem with the connection to the database |
SQLException | if 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.
disposition | How to handle - edit or new/rename/make alias. |
tagID | tagID of monitor point to be changed. |
mpName | Name of monitor point to be changed. |
fieldName | Name of field in MonitorConfigStaticParms to be changed. |
newValue | New value to be placed in field. |
requester | User name of user requesting the change. |
DBConnectionException | if there is a problem with the db connection. |
SQLException | if 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.
changeString | One 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()
t | the table |
row | the row number of t to transform |
tagID | the tagID of the associated monitor configuration |
bool carma::dbms::MonitorConfigurationDatabase::tagIDExists | ( | int | tagID | ) | const |
Does the specified tagID exist in the DB?
tagID | the tagID for which to check the existence |
DBConnectionException |