Click or drag to resize
OSIsoft, LLC

AFElementTemplate Class

The AFElementTemplate represents a template of information used to create an AFBaseElement. Several types of objects are elements, including an AFElement, AFEventFrame, or AFModel.

Inheritance Hierarchy

Namespace:  OSIsoft.AF.Asset
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 2.10.8.440
Syntax
[SerializableAttribute]
public class AFElementTemplate : AFObject, 
	IAFTransactable, IAFChangedEvent, IAFSecurable, IComparable<AFElementTemplate>

The AFElementTemplate type exposes the following members.

Constructors
  NameDescription
Public methodAFElementTemplate
Initializes a new instance of the class with default values.
Public methodAFElementTemplate(String)
Initializes a new instance of the class with the specified name.
Top
Properties
  NameDescription
Public propertyAllowElementToExtend
This read/write property determines if additional attributes or ports can be added to instances of AFBaseElement objects.
Public propertyAnalysisTemplates
This is a collection of analysis templates that target this element template.
Public propertyAttributeTemplates
Gets the collection of AFAttributeTemplate objects that are owned by this template.
Public propertyBaseTemplate
This property returns the AFElementTemplate which this template inherits from.
Public propertyBaseTemplateOnly
This read/write property determines if instances of this AFBaseElement object are allowed to be created. This is typically a BaseTemplate that contains some core functionality for other derived templates.
Public propertyCanBeAcknowledged
This property is the default value for the CanBeAcknowledged property of any new AFEventFrame created from this template.
Public propertyCategories
This is a user-defined collection of categories for the object that can be used for querying and/or reporting purposes.
Public propertyCategoriesString
This read-only property returns the list of categories in a string separated by semicolons.
Public propertyCheckOutInfo
This read-only property returns the checked out status information for the object.
Public propertyChildReferenceTypes
This is a read-only collection of all AFReferenceType objects that can be used to create a child reference to an AFElement created from this template.
Public propertyDatabase
This read-only property returns the AFDatabase where this object is defined.
Public propertyDefaultAttribute
The AFAttributeTemplate associated with the default AFAttribute for the AFBaseElement created from this template.
Public propertyDefaultInputPort
The default input AFPort for the AFBaseElement created from this template.
Public propertyDefaultOutputPort
The default output AFPort for the AFBaseElement created from this template.
Public propertyDefaultUndirectedPort
The default undirected AFPort for the AFBaseElement created from this template.
Public propertyDescription
Read/write property that provides a more detailed description of the object.
Public propertyExtendedProperties
A dictionary of extended properties that can be used to store application specific information.
Public propertyHasAnalyses
This read-only property returns if there are any AFAnalysisTemplate objects that target this element template.
Public propertyHasNotifications
This read-only property returns if there are any AFNotificationTemplate objects that target this element template.
Public propertyID
Read-only property that provides a unique identifier for the object to be used for quick access that is not dependent upon the index.
(Inherited from AFObject.)
Public propertyIdentity
This read-only property contains identity of the object.
(Inherited from AFObject.)
Public propertyInstanceType
Specifies the System.Type used when creating AFBaseElement objects from this template.
Public propertyIsDeleted
This read-only property indicates whether the object has been deleted.
(Inherited from AFObject.)
Public propertyIsDirty
This read-only property indicates whether the object has been modified since the last save to the PI AF Server.
Public propertyIsNew
This read-only property indicates whether the object is new and has never been saved to the PI AF Server.
Public propertyName
Read/write property that identifies the name of the object.
Public propertyNamingPattern
The naming pattern used when creating elements from this template.
Public propertyStatic memberNone
An AFElementTemplate that represents no element template.
Public propertyNotificationRuleTemplates
This is a collection of AFNotificationRuleTemplate objects that target this element template.
Public propertyParentReferenceTypes
This is a read-only collection of all AFReferenceType objects that can be used to create a parent reference to an AFElement created from this template.
Public propertyPISystem
This read-only property allows access to the PISystem associated with this object.
(Inherited from AFObject.)
Public propertyPorts
This is a collection of AFPort objects representing the possible connection ports for elements created from this template. Ports are used in a AFModel to define an AFConnection between AFBaseElement object.
Public propertySecurity
This read-only property returns the AFSecurity information for the object.
Public propertySeverity
This property is the default value for the Severity property of any new AFEventFrame created from this template.
Public propertyType
This property specifies the base type of the element created from this template.
Public propertyUniqueID
Read-only property that provides the object's ID as a String.
(Inherited from AFObject.)
Top
Methods
  NameDescription
Public methodCode exampleApplyChanges
This method applies the changes to the object and makes those changes available to other objects for the current user.
Public methodCode exampleCheckIn
This method checks in (commits) all the changes to the object by saving the information to persistent storage.
Public methodCheckOut
This method locks the object so that its configuration can be modified.
Public methodStatic memberCheckOutElementTemplates
Check out the objects with the specified unique identifiers at the specified query date.
Public methodCompareTo(Object)
Compares this instance with a specified Object.
(Inherited from AFObject.)
Public methodCompareTo(AFObject)
Compares this instance with a specified AFObject.
(Inherited from AFObject.)
Public methodCreateDefaultPorts
This method can be used to create the default connection ports based upon the element's type.
Public methodStatic memberDeleteElementTemplates
Delete the objects with the specified unique identifiers.
Public methodEquals(Object)
Determines whether the specified Object is equal to the current object.
(Inherited from AFObject.)
Public methodEquals(AFObject)
Indicates whether the current object is equal to another object of the same type.
(Inherited from AFObject.)
Public methodFindDerivedTemplates
This method returns the collection of AFElementTemplate objects that have this template as their base template.
Public methodStatic memberFindElementTemplate(PISystem, Guid)
Retrieves the AFElementTemplate object with the specified unique identifier at the AFTime.MaxValue query date.
Public methodStatic memberFindElementTemplate(PISystem, Guid, Object)
Retrieves the AFElementTemplate object with the specified unique identifier at the specified query date.
Public methodStatic memberFindElementTemplates(PISystem, Guid, Object)
Performs a search within the PISystem to retrieve a collection of AFElementTemplate objects with the specified list of unique identifiers.
Public methodStatic memberFindElementTemplates(AFDatabase, String, AFSearchField, AFSortField, AFSortOrder, Int32)
Performs a text search within the AFDatabase to retrieve a collection of AFElementTemplate objects which have a field that matches the specified query string.
Public methodFindInstantiatedElements(Boolean, AFSortField, AFSortOrder, Int32)
This method returns a non-paged collection of AFBaseElement objects that were created with this template.
Public methodFindInstantiatedElements(Boolean, AFSortField, AFSortOrder, Int32, Int32, Int32)
This method returns a paged collection of AFBaseElement objects that were created with this template.
Public methodGetAllAnalysisTemplates
Gets the list of analysis templates for this template and all base templates.
Public methodGetAllAttributeTemplates
Gets the list of top-level attribute templates for this template and all base templates.
Public methodGetAllCategories
Gets the list of categories for this template and all base templates.
Public methodGetAllCategoriesString
Gets the list of categories for this template and all base templates.
Public methodGetAllNotificationRuleTemplates
Gets the list of AFNotificationRuleTemplate objects for this template and all base templates.
Public methodGetAllPorts
Gets the list of ports for this template and all base templates.
Public methodGetAttributeTemplateByTrait
Retrieves the child AFAttributeTemplate with the specified AFAttributeTrait.
Public methodGetAttributeTemplatesByTrait
Retrieves a list of child AFAttributeTemplate objects identified by the specified list of attribute traits.
Public methodGetHashCode
Gets the hash code for this instance of the object which is suitable for use in hashing algorithms and data structures like a hash table.
(Inherited from AFObject.)
Public methodGetPath
Returns the full path to the object, using just the names.
(Inherited from AFObject.)
Public methodGetPath(AFObject)
Returns the path to the object relative from another object.
(Inherited from AFObject.)
Public methodGetPath(AFEncodeType, AFObject)
Returns the path to the object relative from another object, using the name and/or id as specified by encodeType.
(Inherited from AFObject.)
Public methodGetSecurity
Gets the AFSecurity information of the specified security item associated with the object.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodIsTypeOf
Checks if the current AFElementTemplate is derived from the specified base element template.
Public methodStatic memberLoadElementTemplates(IListAFElementTemplate)
Loads the specified list AFElementTemplate objects.
Public methodStatic memberLoadElementTemplates(PISystem, Guid, Object)
Loads the AFElementTemplate objects with the specified unique identifiers at the specified query date.
Public methodPersist
This method returns the persistence string for the object.
(Inherited from AFObject.)
Public methodRefresh
Refreshes the client with any changes that have been made to the object since loaded.
Public methodToString
Returns a String that represents the current object.
(Inherited from AFObject.)
Public methodUndoCheckOut
This method discards all the changes to the object and all sub-objects since the last call to CheckOut. Any changes since the check out will be lost.
Top
Events
  NameDescription
Public eventCode exampleChanged
Event is raised when the object or one of its sub-objects is changed.
Top
Remarks

The template specifies the instance type of the AFBaseElement created from the template with its InstanceType property. An AFNotificationTemplate can be used to create an AFNotification and define its additional fields. The template also specifies the initial value of the AFBaseElement.Categories, and AFBaseElement.Attributes properties of the element created from it as well as the available ports for connecting elements within a model (see AFPort for more information). The template also defines the DefaultAttribute, DefaultInputPort, DefaultOutputPort, and DefaultUndirectedPort properties on any created elements.

The element template contains a collection of AFAttributeTemplate objects. This collection is used when creating the AFAttribute objects of an element. Attribute templates can be added or removed after elements have been created using the template, but it is more efficient to define them before creating elements. Changes made to the element template are propagated to any AFBaseElement objects created from the template when the ApplyChanges or CheckIn methods are called.

Element templates also support inheritance, which makes it easier to extend existing templates. The inheritance relationship is represented using the BaseTemplate property and the collection of derived templates returned by the FindDerivedTemplates(Boolean, AFSortField, AFSortOrder, Int32) method. A derived template can extend or override the attribute templates and ports defined by the base template.

Use a constructor or the Add method of the appropriate collection to create a new AFBaseElement object. For example, use one of the AFElements.Add Overload methods to create a new AFElement object or AFTransfer constructor to create a new AFTransfer object.

Examples
// This example demonstrates how to create an element template,
// create an element from it, and display its information.

// Get the Database
PISystems myPISystems = new PISystems();
AFDatabase myDB = myPISystems.DefaultPISystem.Databases.DefaultDatabase;

// Create an Element Template
AFElementTemplate myElemTemplate = myDB.ElementTemplates.Add("MyElementTemplate");
myElemTemplate.Description = "Template used to create my elements";

// Create an Element from the Element Template
myDB.Elements.Add("MyElement", myElemTemplate);
myDB.CheckIn();

// Display the name and description of the Element Template
Console.WriteLine("Name of Element Template = {0}", myElemTemplate.Name);
Console.WriteLine("Description = {0}", myElemTemplate.Description);
Console.WriteLine("UniqueID of Element Template = {0}", myElemTemplate.UniqueID);

// Display the name of all Elements created from this Element Template
const int pageSize = 100;
int startIndex = 0;
int totalCount;
do
{
    AFNamedCollectionList<AFBaseElement> list =
        myElemTemplate.FindInstantiatedElements(true, AFSortField.Name,
            AFSortOrder.Ascending, startIndex, pageSize, out totalCount);
    if (list == null) break;
    foreach (AFBaseElement CurElement in list)
    {
        Console.WriteLine("Name of Element created from this template = {0}", CurElement.Name);
    }

    startIndex += pageSize; // Advance to next page.
} while (startIndex < totalCount);
Version Information

AFSDK

Supported in: 2.10.5, 2.10, 2.9.5, 2.9, 2.8.5, 2.8, 2.7.5, 2.7, 2.6, 2.5, 2.4
See Also
Enabling Operational Intelligence