Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AF SDK Reference

AFAnalysisTemplate Class

  • Last UpdatedNov 18, 2025
  • 12 minute read
AFAnalysisTemplate Class
The AFAnalysisTemplate represents a template of information used to create an AFAnalysis.

Inheritance Hierarchy

SystemObject
  OSIsoft.AFAFObject
    OSIsoft.AF.AnalysisAFAnalysisTemplate

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

  NameDescription
Public method
AFAnalysisTemplate
Initializes a new instance of the class with default values.
Public method
AFAnalysisTemplate(String)
Initializes a new instance of the class with the specified name.

Properties

  NameDescription
Public property
AnalysisRule
The instance of the analysis rule used by the AFAnalysisTemplate to configure an analysis rule in an AFAnalysis created from this template.
Public property
AnalysisRulePlugIn
The analysis rule plugin property is used to specify which analysis rule will be used by the AFAnalysis to run the analysis.
Public property
CaseTemplate
The AFElementTemplate that is used when creating a new AFCase using one of the AFAnalysis.AddCase Overload methods.
Public property
Categories
This is a user-defined collection of categories for the object that can be used for querying and/or reporting purposes.
Public property
CategoriesString
This read-only property returns the list of categories in a string separated by semicolons.
Public property
CheckOutInfo
This read-only property returns the checked out status information for the object.
Public property
CreateEnabled
This property indicates whether any AFAnalysis created from this template will have the initial Status property set to Enabled or Disabled.
Public property
Database
This read-only property returns the AFDatabase where this object is defined.
Public property
Description
Read/write property that provides a more detailed description of the object.
Public property
ExtendedProperties
A dictionary of extended properties that can be used to store application specific information.
Public property
GroupID
Indicates the group identifier for the AFAnalysis created from this template.
Public property
HasNotificationTemplate
This read-only property indicates if there is an AFNotificationTemplate associated with this analysis template.
Public property
HasTarget
This read-only property indicates if there is a target associated with this analysis template.
Public property
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.)
Public property
Identity
This read-only property contains identity of the object.
(Inherited from AFObject.)
Public property
IsDeleted
This read-only property indicates whether the object has been deleted.
(Inherited from AFObject.)
Public property
IsDirty
This read-only property indicates whether the object has been modified since the last save to the PI AF Server.
Public property
IsNew
This read-only property indicates whether the object is new and has never been saved to the PI AF Server.
Public property
Name
Read/write property that identifies the name of the object.
Public propertyStatic member
None
An AFAnalysisTemplate that represents no analysis template.
Public property
NotificationTemplate
This property returns the AFNotificationTemplate that is associated with this AFAnalysisTemplate.
Public property
OutputTime
The analysis output time offset.
Public property
PISystem
This read-only property allows access to the PISystem associated with this object.
(Inherited from AFObject.)
Public property
Security
This read-only property returns the AFSecurity information for the object.
Public property
Target
The target of the analysis template.
Public property
TimeRule
The instance of the time rule used by the AFAnalysisTemplate to configure a time rule in an AFAnalysis created from this template.
Public property
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.
Public property
UniqueID
Read-only property that provides the object's ID as a String.
(Inherited from AFObject.)

Methods

  NameDescription
Public methodCode example
ApplyChanges
This method applies the changes to the object and makes those changes available to other objects for the current user.
Public methodCode example
CheckIn
This method checks in (commits) all the changes to the object by saving the information to persistent storage.
Public method
CheckOut
This method locks the object so that its configuration can be modified.
Public methodStatic member
CheckOutAnalysisTemplates
Check out the objects with the specified unique identifiers at the specified query date.
Public method
CompareTo(Object)
Compares this instance with a specified Object.
(Inherited from AFObject.)
Public method
CompareTo(AFObject)
Compares this instance with a specified AFObject.
(Inherited from AFObject.)
Public methodStatic member
DeleteAnalysisTemplates
Delete the objects with the specified unique identifiers.
Public method
Equals(Object)
Determines whether the specified Object is equal to the current object.
(Inherited from AFObject.)
Public method
Equals(AFObject)
Indicates whether the current object is equal to another object of the same type.
(Inherited from AFObject.)
Public methodStatic member
FindAnalysisTemplate(PISystem, Guid)
Retrieves the AFAnalysisTemplate object with the specified unique identifier at the AFTime.MaxValue query date.
Public methodStatic member
FindAnalysisTemplate(PISystem, Guid, Object)
Retrieves the AFAnalysisTemplate object with the specified unique identifier at the specified query date.
Public methodStatic member
FindAnalysisTemplates(PISystem, Guid, Object)
Performs a search within the PISystem to retrieve a collection of AFAnalysisTemplate objects with the specified list of unique identifiers.
Public methodStatic member
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.
Public method
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.)
Public method
GetPath
Returns the full path to the object, using just the names.
(Inherited from AFObject.)
Public method
GetPath(AFObject)
Returns the path to the object relative from another object.
(Inherited from AFObject.)
Public method
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.)
Public method
GetSecurity
Gets the AFSecurity information of the specified security item associated with the object.
Public method
GetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodStatic member
LoadAnalysisTemplates(IListAFAnalysisTemplate)
Loads the specified list AFAnalysisTemplate objects.
Public methodStatic member
LoadAnalysisTemplates(PISystem, Guid, Object)
Loads the AFAnalysisTemplate objects with the specified unique identifiers at the specified query date.
Public method
Persist
This method returns the persistence string for the object.
(Inherited from AFObject.)
Public method
Refresh
Refreshes the client with any changes that have been made to the object since loaded.
Public method
ToString
Returns a String that represents the current object.
(Inherited from AFObject.)
Public method
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

  NameDescription
Public eventCode example
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.

Important note Important
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.

Version Information

AFSDK


See Also

TitleResults for “How to create a CRG?”Also Available in