DbElement Basics
- Last UpdatedJun 02, 2022
- 3 minute read
This section describes the DbElement class. The DbElement class is the most widely used class and it covers a large proportion of the database functionality that will be used in practise.
The methods fall into the following groups:
-
Navigation
-
Querying of attributes
-
Database modifications
-
Storage of rules and expressions
-
Comparison across sessions
DbElement is a generic object that represents all database elements regardless of their type.
Constructors
An instance of a DbElement may be obtained as follows:
-
There is a static GetElement() method with no arguments to return a 'null' DbElement.
-
There is a static GetElement() method which returns a DbElement given a name. This name should include the '/'.
-
There is a static GetElement() method which returns a DbElement given a ref (two long int array) and type. This is only needed where a reference has been stored externally to the AVEVA module.
-
There are many methods on various classes which return DbElements
for example.
DbElement vess1 = DbElement.GetElement("/VESS1");
Identity
The DbElement object encapsulates the identity of the database object. Any comparison of database objects must be done using DbElements. The DbElement has 'value' semantics for comparison purposes. i.e. comparing of two DbElements will always return true if they refer to the same element, even if they are different objects. DbElement instances should be used in all cases where the identity of an element is being passed or stored.
A DbElement can be identified externally to the AVEVA module by a combination of the ref number AND type. The ref number is a two long integer, for example: =123/4567.
Element Validity
A DbElement need not represent a 'valid' element. There are a number of reasons why a DbElement might be invalid:
-
The element is in a DB not opened.
-
The element has been deleted.
There is a IsValid()method to test if a DbElement is valid.
If the DbElement is invalid then all attribute access and database navigation will fail for that DbElement.
Error Handling
The error handling techniques used are:
-
Some methods raise a PdmsException
-
Some methods return false if the operation can not be done.
-
For navigation operations, if the navigation does not succeed then a 'null' element is returned. A null element can be tested using the 'IsNull' method. It will have a reference of =0/0.
Basic Properties
DbElement has the following basic methods:
ToString()- Returns the Name of the element. If unnamed, it returns the constructed name.
GetElementType()- Returns the DbElementType.
There are a number of pseudo attributes that return slight variations on name and type, as below.
Type related:
|
Attribute Name |
C# Data Type |
Qualifier |
Description |
|---|---|---|---|
|
ACTTYPE |
DbElementType |
Type of element |
|
|
AHLIS |
DbElementType (200) |
List of actual types in owning hierarchy |
|
|
OSTYPE |
DbElementType |
Shortcut for "Type of owner" |
|
|
TYPE |
DbElementType |
Type of the element, ignoring UDET |
|
|
TYSEQU |
int |
Type Sequence Number |
Name Related:
|
Attribute Name |
C# Data Type |
Qualifier |
Description |
|---|---|---|---|
|
CUTNAM |
String |
int |
Full name of element, truncated to n characters |
|
CUTNMN |
String |
int |
Full name of element (without leading slash) truncated to n characters |
|
FLNM |
String |
Full name of the element |
|
|
FLNN |
String |
Full name of the element (without leading slash) |
|
|
ISNAMED |
Bool |
True if element is named |
|
|
NAMESQ |
String |
Type. sequence number and name of element |
|
|
NAMETY |
String |
Type and name of the element |
|
|
NAMN |
String |
Name of the element (without leading slash) |
|
|
NAMTYP |
String |
Type and full name of element |