AFAnalysisTemplate Class
- Last UpdatedNov 18, 2025
- 12 minute read
- PI System
- AF SDK 2024 R2
- Developer

Inheritance Hierarchy
Namespace: OSIsoft.AF.Analysis
Assembly: OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182
Syntax
[SerializableAttribute] public sealed class AFAnalysisTemplate : AFObject, IAFTransactable, IAFChangedEvent, IAFSecurable, IComparable<AFAnalysisTemplate>
<SerializableAttribute> Public NotInheritable Class AFAnalysisTemplate Inherits AFObject Implements IAFTransactable, IAFChangedEvent, IAFSecurable, IComparable(Of AFAnalysisTemplate) Dim instance As AFAnalysisTemplate
[SerializableAttribute] public ref class AFAnalysisTemplate sealed : public AFObject, IAFTransactable, IAFChangedEvent, IAFSecurable, IComparable<AFAnalysisTemplate^>
[<SealedAttribute>] [<SerializableAttribute>] type AFAnalysisTemplate = class inherit AFObject interface IAFTransactable interface IAFChangedEvent interface IAFSecurable interface IComparable<AFAnalysisTemplate> end
The AFAnalysisTemplate type exposes the following members.
Constructors
| Name | Description | |
|---|---|---|
| AFAnalysisTemplate |
Initializes a new instance of the class with default values.
| |
| AFAnalysisTemplate(String) |
Initializes a new instance of the class with the specified name.
|
Properties
| Name | Description | |
|---|---|---|
| AnalysisRule |
The instance of the analysis rule used by the AFAnalysisTemplate to
configure an analysis rule in an AFAnalysis created from this template.
| |
| AnalysisRulePlugIn |
The analysis rule plugin property is used to specify which
analysis rule will be used by the AFAnalysis to run the analysis.
| |
| CaseTemplate |
The AFElementTemplate that is used when creating a new AFCase
using one of the AFAnalysis.AddCase Overload
methods.
| |
| Categories |
This is a user-defined collection of categories for the object that can be used for
querying and/or reporting purposes.
| |
| CategoriesString |
This read-only property returns the list of categories in a string separated by semicolons.
| |
| CheckOutInfo |
This read-only property returns the checked out status information for the object.
| |
| CreateEnabled |
This property indicates whether any AFAnalysis created
from this template will have the initial Status
property set to Enabled or Disabled.
| |
| Database |
This read-only property returns the AFDatabase where this object is defined.
| |
| Description |
Read/write property that provides a more detailed description of the object.
| |
| ExtendedProperties |
A dictionary of extended properties that can be used to store application specific information.
| |
| GroupID |
Indicates the group identifier for the AFAnalysis created from this template.
| |
| HasNotificationTemplate |
This read-only property indicates if there is an AFNotificationTemplate
associated with this analysis template.
| |
| HasTarget |
This read-only property indicates if there is a target
associated with this analysis template.
| |
| ID |
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.) | |
| Identity |
This read-only property contains identity of the object.
(Inherited from AFObject.) | |
| IsDeleted |
This read-only property indicates whether the object has been deleted.
(Inherited from AFObject.) | |
| IsDirty |
This read-only property indicates whether the object has been modified since the
last save to the PI AF Server.
| |
| IsNew |
This read-only property indicates whether the object is new and has never been saved
to the PI AF Server.
| |
| Name |
Read/write property that identifies the name of the object.
| |
| None |
An AFAnalysisTemplate that represents no analysis template.
| |
| NotificationTemplate |
This property returns the AFNotificationTemplate that is associated with
this AFAnalysisTemplate.
| |
| OutputTime |
The analysis output time offset.
| |
| PISystem |
This read-only property allows access to the PISystem associated with this
object.
(Inherited from AFObject.) | |
| Security |
This read-only property returns the AFSecurity information for the object.
| |
| Target |
The target of the analysis template.
| |
| TimeRule |
The instance of the time rule used by the AFAnalysisTemplate to
configure a time rule in an AFAnalysis created from this template.
| |
| TimeRulePlugIn |
The time rule plugin property is used to specify which
time rule will be used by the AFAnalysis to determine when the
analysis runs.
| |
| UniqueID |
Read-only property that provides the object's ID as a String.
(Inherited from AFObject.) |
Methods
| Name | Description | |
|---|---|---|
| ApplyChanges |
This method applies the changes to the object and makes
those changes available to other objects for the current user.
| |
| CheckIn |
This method checks in (commits) all the changes to the object by saving
the information to persistent storage.
| |
| CheckOut |
This method locks the object so that its configuration can be modified.
| |
| CheckOutAnalysisTemplates |
Check out the objects with the specified unique identifiers at the specified query date.
| |
| CompareTo(Object) |
Compares this instance with a specified Object.
(Inherited from AFObject.) | |
| CompareTo(AFObject) |
Compares this instance with a specified AFObject.
(Inherited from AFObject.) | |
| DeleteAnalysisTemplates |
Delete the objects with the specified unique identifiers.
| |
| Equals(Object) |
Determines whether the specified Object is equal to the current object.
(Inherited from AFObject.) | |
| Equals(AFObject) |
Indicates whether the current object is equal to another object of the same type.
(Inherited from AFObject.) | |
| FindAnalysisTemplate(PISystem, Guid) |
Retrieves the AFAnalysisTemplate object with the specified unique identifier
at the AFTime.MaxValue query date.
| |
| FindAnalysisTemplate(PISystem, Guid, Object) |
Retrieves the AFAnalysisTemplate object with the specified unique identifier
at the specified query date.
| |
| FindAnalysisTemplates(PISystem, Guid, Object) |
Performs a search within the PISystem to retrieve a collection
of AFAnalysisTemplate objects with the specified list of unique identifiers.
| |
| FindAnalysisTemplates(AFDatabase, String, AFSearchField, AFSortField, AFSortOrder, Int32) |
Performs a text search within the AFDatabase to retrieve a collection
of AFAnalysisTemplate objects that match the specified query string.
| |
| GetHashCode |
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.) | |
| GetPath |
Returns the full path to the object, using just the names.
(Inherited from AFObject.) | |
| GetPath(AFObject) |
Returns the path to the object relative from another object.
(Inherited from AFObject.) | |
| GetPath(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.) | |
| GetSecurity |
Gets the AFSecurity information of the specified security item
associated with the object.
| |
| GetType | Gets the Type of the current instance. (Inherited from Object.) | |
| LoadAnalysisTemplates(IListAFAnalysisTemplate) |
Loads the specified list AFAnalysisTemplate objects.
| |
| LoadAnalysisTemplates(PISystem, Guid, Object) |
Loads the AFAnalysisTemplate objects with the specified unique identifiers
at the specified query date.
| |
| Persist |
This method returns the persistence string for the object.
(Inherited from AFObject.) | |
| Refresh |
Refreshes the client with any changes that have been made to the object since loaded.
| |
| ToString |
Returns a String that represents the current object.
(Inherited from AFObject.) | |
| UndoCheckOut |
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.
|
Events
| Name | Description | |
|---|---|---|
| Changed |
Event is raised when the object or one of its sub-objects is changed.
|
Remarks
The template specifies the initial value of several of the properties for the analyses created from the template.
The collection of available analysis templates is maintained by the AFDatabase. Create a new AFAnalysisTemplate object by calling the AFAnalysisTemplates.Add method. The list of AFAnalysis objects created from an AFAnalysisTemplate can be found by calling one of the AFAnalysis.FindAnalysesByTemplate Overload methods. The AFAnalysisSearch class can be used for finding analysis templates.
| When removing an AFAnalysisTemplate, any AFAnalysis created from the template will be deleted unless it is tied to an AFNotification. |
Examples
// This example demonstrates how to create an analysis template, configure its // analysis rule and time rule, and create an analysis from the template. // Get the Database PISystems myPISystems = new PISystems(); PISystem myPISystem = myPISystems.DefaultPISystem; AFDatabase myDB = myPISystem.Databases.DefaultDatabase; // Create an Element Template with Attributes AFElementTemplate myElementTemplate = myDB.ElementTemplates.Add("MyElementTemplate"); AFAttributeTemplate myAttributeTemplate = myElementTemplate.AttributeTemplates.Add("MyAttribute"); myAttributeTemplate.DataReferencePlugIn = AFDataReference.GetPIPointDataReference(myPISystem); myAttributeTemplate.DataReference.ConfigString = @"\\%Server%\sinusoid"; // Create an Analysis Template and set its Target to the Element Template AFAnalysisTemplate myAnalysisTemplate = myDB.AnalysisTemplates.Add("MyAnalysisTemplate"); myAnalysisTemplate.Description = "This is an analysis example"; myAnalysisTemplate.Target = myElementTemplate; // Set the Analysis Rule and Time Rule myAnalysisTemplate.AnalysisRulePlugIn = myPISystem.AnalysisRulePlugIns["Imbalance"]; myAnalysisTemplate.TimeRulePlugIn = myPISystem.TimeRulePlugIns["Periodic"]; myAnalysisTemplate.AnalysisRule.ConfigString = "Balance=Volume;Imbalance=Volume Imbalance;UOM=US gal"; myAnalysisTemplate.TimeRule.ConfigString = "Frequency=3600"; // Instantiate an Element from the Element Template AFElement myElement = myDB.Elements.Add("MyElement", myElementTemplate); // Display the Template's Name, Description, and Target Console.WriteLine("Name = {0}", myAnalysisTemplate.Name); Console.WriteLine("Description = {0}", myAnalysisTemplate.Description); Console.WriteLine("Target = {0}", myAnalysisTemplate.Target.Name); // Get the instantiated analysis from the instantiated element AFAnalysis myAnalysis = myElement.Analyses["MyAnalysisTemplate"]; // Display the Analysis's Name, Description, Target, and Template Console.WriteLine("Name = {0}", myAnalysis.Name); Console.WriteLine("Description = {0}", myAnalysis.Description); Console.WriteLine("Target = {0}", myAnalysis.Target); Console.WriteLine("Template = {0}", myAnalysis.Template.Name);
' This example demonstrates how to create an analysis template, configure its ' analysis rule And time rule, And create an analysis from the template. ' Get the Database Dim myPISystems As New PISystems Dim myPISystem As PISystem = myPISystems.DefaultPISystem Dim myDB As AFDatabase = myPISystem.Databases.DefaultDatabase ' Create an Element Template with Attributes Dim myElementTemplate As AFElementTemplate = myDB.ElementTemplates.Add("MyElementTemplate") Dim myAttributeTemplate As AFAttributeTemplate = myElementTemplate.AttributeTemplates.Add("MyAttribute") myAttributeTemplate.DataReferencePlugIn = AFDataReference.GetPIPointDataReference(myPISystem) myAttributeTemplate.DataReference.ConfigString = "\\%Server%\sinusoid" ' Create an Analysis Template and set its Target to the Element Template Dim myAnalysisTemplate As AFAnalysisTemplate = myDB.AnalysisTemplates.Add("MyAnalysisTemplate") myAnalysisTemplate.Description = "This is an analysis example" myAnalysisTemplate.Target = myElementTemplate ' Set the Analysis Rule and Time Rule myAnalysisTemplate.AnalysisRulePlugIn = myPISystem.AnalysisRulePlugIns("Imbalance") myAnalysisTemplate.TimeRulePlugIn = myPISystem.TimeRulePlugIns("Periodic") myAnalysisTemplate.AnalysisRule.ConfigString = "Balance=Volume;Imbalance=Volume Imbalance;UOM=US gal" myAnalysisTemplate.TimeRule.ConfigString = "Frequency=3600" ' Instantiate an Element from the Element Template Dim myElement As AFElement = myDB.Elements.Add("MyElement", myElementTemplate) ' Display the Template's Name, Description, and Target Console.WriteLine("Name = {0}", myAnalysisTemplate.Name) Console.WriteLine("Description = {0}", myAnalysisTemplate.Description) Console.WriteLine("Target = {0}", myAnalysisTemplate.Target.Name) ' Get the instantiated analysis from the instantiated element Dim myAnalysis As AFAnalysis = myElement.Analyses("MyAnalysisTemplate") ' Display the Analysis's Name, Description, Target, and Template Console.WriteLine("Name = {0}", myAnalysis.Name) Console.WriteLine("Description = {0}", myAnalysis.Description) Console.WriteLine("Target = {0}", myAnalysis.Target) Console.WriteLine("Template = {0}", myAnalysis.Template.Name)
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.