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

AF SDK Reference

AFModelAnalysis Class

  • Last UpdatedNov 18, 2025
  • 14 minute read
AFModelAnalysis Class
The AFModelAnalysis is used to execute an analysis on a set of data values for a Target that is an AFModel.

Inheritance Hierarchy

SystemObject
  OSIsoft.AFAFObject
    OSIsoft.AF.AnalysisAFAnalysis
      OSIsoft.AF.AnalysisAFModelAnalysis

Namespace:  OSIsoft.AF.Analysis
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182

Syntax

[SerializableAttribute]
public sealed class AFModelAnalysis : AFAnalysis, 
	IComparable<AFModelAnalysis>
<SerializableAttribute>
Public NotInheritable Class AFModelAnalysis
	Inherits AFAnalysis
	Implements IComparable(Of AFModelAnalysis)

Dim instance As AFModelAnalysis
[SerializableAttribute]
public ref class AFModelAnalysis sealed : public AFAnalysis, 
	IComparable<AFModelAnalysis^>
[<SealedAttribute>]
[<SerializableAttribute>]
type AFModelAnalysis =  
    class
        inherit AFAnalysis
        interface IComparable<AFModelAnalysis>
    end

The AFModelAnalysis type exposes the following members.

Constructors

  NameDescription
Public method
AFModelAnalysis Obsolete.
Initializes a new instance of the class with default values.
Public method
AFModelAnalysis(String) Obsolete.
Initializes a new instance of the class with the specified name.
Public method
AFModelAnalysis(AFDatabase)
Initializes a new instance of the class with default values.
Public method
AFModelAnalysis(String, AFAnalysisTemplate) Obsolete.
Initializes a new instance of the class with the specified name.
Public method
AFModelAnalysis(AFDatabase, String)
Initializes a new instance of the class with the specified name.
Public method
AFModelAnalysis(AFDatabase, String, AFAnalysisTemplate)
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 AFAnalysis to run the analysis.
(Inherited from AFAnalysis.)
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.
(Inherited from AFAnalysis.)
Public property
AutoCreated
This read-only property indicates if this analysis was automatically created by the server.
(Inherited from AFAnalysis.)
Public property
CaseTemplate
The AFElementTemplate that is used when creating a new AFCase using one of the AddCase Overload methods.
(Inherited from AFAnalysis.)
Public property
Categories
This is a user-defined collection of categories for the object that can be used for querying and/or reporting purposes.
(Inherited from AFAnalysis.)
Public property
CategoriesString
This read-only property returns the list of categories in a string separated by semicolons.
(Inherited from AFAnalysis.)
Public property
CheckOutInfo
This read-only property returns the checked out status information for the object.
(Inherited from AFAnalysis.)
Public property
Database
This read-only property returns the AFDatabase where this object is defined.
(Inherited from AFAnalysis.)
Public property
Description
Read/write property that provides a more detailed description of the object.
(Inherited from AFAnalysis.)
Public property
ExtendedProperties
A dictionary of extended properties that can be used to store application specific information.
(Inherited from AFAnalysis.)
Public property
GroupID
Indicates the group identifier for the analysis.
(Inherited from AFAnalysis.)
Public property
HasNotification
This read-only property indicates if there is an AFNotification associated with this analysis.
(Inherited from AFAnalysis.)
Public property
HasTarget
This read-only property indicates if there is a target associated with this analysis.
(Inherited from AFAnalysis.)
Public property
HasTemplate
This read-only property indicates if this analysis is defined by an AFAnalysisTemplate.
(Inherited from AFAnalysis.)
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
IsConfigured
This method returns if the analysis rule instance is properly configured.
(Inherited from AFAnalysis.)
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.
(Inherited from AFAnalysis.)
Public property
IsNew
This read-only property indicates whether the object is new and has never been saved to the PI AF Server.
(Inherited from AFAnalysis.)
Public property
IsTimeRuleDefinedByTemplate
This read-only property indicates if the TimeRule is fully defined by the AFAnalysisTemplate.
(Inherited from AFAnalysis.)
Public property
MaximumQueueSize
The maximum queue size for the analysis.
(Inherited from AFAnalysis.)
Public property
Model
This read-only property returns the AFModel that is the Target of this analysis.
Public property
Name
This property defines the name that identifies the object.
(Inherited from AFAnalysis.)
Public property
Notification
This property returns the AFNotification that is associated with this AFAnalysis.
(Inherited from AFAnalysis.)
Public property
OutputTime
The analysis output time offset.
(Inherited from AFAnalysis.)
Public property
PISystem
This read-only property allows access to the PISystem associated with this object.
(Inherited from AFObject.)
Public property
Priority
The priority of the analysis.
(Inherited from AFAnalysis.)
Public property
PublishResults
This property indicates if the case results should automatically be published after an analysis is run.
(Inherited from AFAnalysis.)
Public property
Security
This read-only property returns the AFSecurity information for the object.
(Inherited from AFAnalysis.)
Public property
Status
The current analysis status.
(Inherited from AFAnalysis.)
Public property
Target
Gets and sets the target of the analysis.
(Inherited from AFAnalysis.)
Public property
Template
This property returns the AFAnalysisTemplate that was used to create this AFAnalysis.
(Inherited from AFAnalysis.)
Public property
TimeRule
The instance of the time rule used by the AFAnalysis to determine when the next analysis should be run.
(Inherited from AFAnalysis.)
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.
(Inherited from AFAnalysis.)
Public property
UniqueID
Read-only property that provides the object's ID as a String.
(Inherited from AFObject.)

Methods

  NameDescription
Public method
AddCase
The AddCase method creates a new AFCase for the analysis based upon the TimeRule and PreviousCase.
(Inherited from AFAnalysis.)
Public method
AddCase(AFTime)
The AddCase method creates a new AFCase for the analysis after the specified start time.
(Inherited from AFAnalysis.)
Public method
AddCase(AFTimeRuleEvent)
The AddCase method creates a new AFCase for the analysis after the specified AFTimeRuleEvent.
(Inherited from AFAnalysis.)
Public methodCode example
ApplyChanges
This method applies the changes to the object and makes those changes available to other objects for the current user.
(Inherited from AFAnalysis.)
Public methodCode example
CheckIn
This method checks in (commits) all the changes to the object by saving the information to persistent storage.
(Inherited from AFAnalysis.)
Public method
CheckOut
This method locks the object so that its configuration can be modified.
(Inherited from AFAnalysis.)
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 method
CreateAnalysisTemplate
Create an AFAnalysisTemplate based upon the analysis.
(Inherited from AFAnalysis.)
Public method
Delete
Deletes this analysis from the AFDatabase.
(Inherited from AFAnalysis.)
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 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
GetLastCase
Use this method to get the case with the latest start time for the analysis.
(Inherited from AFAnalysis.)
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
GetResults(Object, Int32, Boolean, AFAttribute, UOM)
Use this method to get all the stored results for the attribute of cases of the analysis limited to the specified count beginning at the requested start time in the specified direction.
(Inherited from AFAnalysis.)
Public method
GetResults(AFSearchMode, Object, Object, Double, AFAttribute, UOM) Obsolete.
Use this method to get all the stored results for the attribute of cases of the analysis based upon the specified search criteria.
(Inherited from AFAnalysis.)
Public method
GetResults(AFSearchMode, Object, Object, Int32, AFAttribute, UOM)
Use this method to get all the stored results for the attribute of cases of the analysis between the specified start and end times.
(Inherited from AFAnalysis.)
Public method
GetSecurity
Gets the AFSecurity information of the specified security item associated with the object.
(Inherited from AFAnalysis.)
Public method
GetStatus
Get the analysis Status property immediately from the PI AF Server.
(Inherited from AFAnalysis.)
Public method
GetType
Gets the Type of the current instance.
(Inherited from Object.)
Public method
IsTraced
Indicates if a specified level is being traced.
(Inherited from AFAnalysis.)
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.
(Inherited from AFAnalysis.)
Public method
RemoveCase
Removes an existing AFCase from the analysis.
(Inherited from AFAnalysis.)
Public method
ResetToTemplate
This method will reset the AFAnalysis back to its template default values.
(Inherited from AFAnalysis.)
Public method
Run
Execute the analysis with default values.
(Inherited from AFAnalysis.)
Public method
Run(AFCase)
Execute the analysis for the specific AFCase.
(Inherited from AFAnalysis.)
Public method
SetStatus(AFStatus)
Set the analysis Status property immediately in the server.
(Inherited from AFAnalysis.)
Public method
ToString
Returns a String that represents the current object.
(Inherited from AFObject.)
Public method
TraceData
Output a data trace event.
(Inherited from AFAnalysis.)
Public method
TraceDetail
Output a detail trace event.
(Inherited from AFAnalysis.)
Public method
TraceError
Output an error trace event.
(Inherited from AFAnalysis.)
Public method
TraceEvent(AFTraceSwitchLevel, String)
Output a trace event with a message.
(Inherited from AFAnalysis.)
Public method
TraceEvent(AFTraceSwitchLevel, String, Int32)
Output a trace event with a message and a duration.
(Inherited from AFAnalysis.)
Public method
TraceEvent(AFTraceSwitchLevel, String, Object)
Output a trace event as a formatted message with a variable number of arguments.
(Inherited from AFAnalysis.)
Public method
TraceInformation
Output an information trace event.
(Inherited from AFAnalysis.)
Public method
TraceSummary
Output a summary trace event.
(Inherited from AFAnalysis.)
Public method
TraceWarning
Output a warning trace event.
(Inherited from AFAnalysis.)
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.
(Inherited from AFAnalysis.)

Events

  NameDescription
Public eventCode example
Changed
Event is raised when the object or one of its sub-objects is changed.
(Inherited from AFAnalysis.)

Remarks

The AFAnalysis uses the configured TimeRule to determine when the next analysis should be executed and the configured AnalysisRule provide the logic to execute the analysis on a set of data values for a Target that is an AFModel.

Use the PISystem.Supports method to check if the PISystem supports the ModelAnalysis feature.

Examples

// This example demonstrates how to create a model analysis and configure
// its analysis rule and time rule.

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

// Create an Element with an Attribute
AFElement myElement = myDB.Elements.Add("MyElement");
AFAttribute myAttribute = myElement.Attributes.Add("MyAttribute");
myAttribute.DataReferencePlugIn = AFDataReference.GetPIPointDataReference(myPISystem);
myAttribute.DataReference.ConfigString = @"\\%Server%\sinusoid";

// Create an Analysis and set its Target to the Element
AFAnalysis myAnalysis = new AFAnalysis(myDB, "MyAnalysis");
myAnalysis.Description = "This is an analysis example";
myAnalysis.Target = myElement;

// Set the Analysis Rule and Time Rule
myAnalysis.AnalysisRulePlugIn = myPISystem.AnalysisRulePlugIns["Imbalance"];
myAnalysis.TimeRulePlugIn = myPISystem.TimeRulePlugIns["Periodic"];
myAnalysis.AnalysisRule.ConfigString = "Balance=Volume;Imbalance=Volume Imbalance;UOM=US gal";
myAnalysis.TimeRule.ConfigString = "Frequency=3600";

// Display the Name, Description, and Target
Console.WriteLine("Name = {0}", myAnalysis.Name);
Console.WriteLine("Description = {0}", myAnalysis.Description);
Console.WriteLine("Target = {0}", myAnalysis.Target);
' This example demonstrates how to create a model analysis And configure
' its analysis rule and time rule.

' Get the Database
Dim myPISystems As New PISystems
Dim myPISystem As PISystem = myPISystems.DefaultPISystem
Dim myDB As AFDatabase = myPISystem.Databases.DefaultDatabase

' Create an Element with an Attribute
Dim myElement As AFElement = myDB.Elements.Add("MyElement")
Dim myAttribute As AFAttribute = myElement.Attributes.Add("MyAttribute")
myAttribute.DataReferencePlugIn = AFDataReference.GetPIPointDataReference(myPISystem)
myAttribute.DataReference.ConfigString = "\\%Server%\sinusoid"

' Create an Analysis and set its Target to the Element
Dim myAnalysis As New AFAnalysis(myDB, "MyAnalysis")
myAnalysis.Description = "This is an analysis example"
myAnalysis.Target = myElement

' Set the Analysis Rule and Time Rule
myAnalysis.AnalysisRulePlugIn = myPISystem.AnalysisRulePlugIns("Imbalance")
myAnalysis.TimeRulePlugIn = myPISystem.TimeRulePlugIns("Periodic")
myAnalysis.AnalysisRule.ConfigString = "Balance=Volume;Imbalance=Volume Imbalance;UOM=US gal"
myAnalysis.TimeRule.ConfigString = "Frequency=3600"

' Display the Name, Description, and Target
Console.WriteLine("Name = {0}", myAnalysis.Name)
Console.WriteLine("Description = {0}", myAnalysis.Description)
Console.WriteLine("Target = {0}", myAnalysis.Target)

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