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

AF SDK Reference

AFResults Class

  • Last UpdatedNov 18, 2025
  • 9 minute read
AFResults Class
The collection of AFResult objects for an attribute created during the run of a case is maintained by the AFCase.

Inheritance Hierarchy

SystemObject
  OSIsoft.AFAFCollection
    OSIsoft.AFAFCollectionAFResult
      OSIsoft.AF.AnalysisAFResults

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

Syntax

public sealed class AFResults : AFCollection<AFResult>, 
	IAFTrace
Public NotInheritable Class AFResults
	Inherits AFCollection(Of AFResult)
	Implements IAFTrace

Dim instance As AFResults
public ref class AFResults sealed : public AFCollection<AFResult^>, 
	IAFTrace
[<SealedAttribute>]
type AFResults =  
    class
        inherit AFCollection<AFResult>
        interface IAFTrace
    end

The AFResults type exposes the following members.

Properties

  NameDescription
Public property
Case
This property returns the AFCase object which owns the result.
Public property
Count
Gets the number of items actually contained in the collection.
(Inherited from AFCollectionT.)
Public property
CountInputs
Returns the number of inputs contained in the collection of results.
Public property
CountInputsBad
Returns the number of inputs with bad status values contained in the collection of results.
Public property
CountOutputs
Returns the number of outputs contained in the collection of results.
Public property
CountOutputsBad
Returns the number of outputs with bad status values contained in the collection of results.
Public property
Database
This read-only property returns the AFDatabase where this object is defined.
Public property
Identity
This read-only property contains identity of the object.
(Inherited from AFCollection.)
Public property
IsDeleted
This read-only property indicates whether the owner of the collection has been deleted.
(Inherited from AFCollection.)
Public property
ItemGuid
Returns the item in the collection associated with the passed in ID.
(Inherited from AFCollectionT.)
Public property
ItemInt32
Returns the item located at the passed in index.
(Inherited from AFCollectionT.)
Public property
ItemAFAttribute
This property returns the specified object from the collection by AFAttribute.
Public property
ItemIdentity
This read-only property specifies the identity of the objects within the collection.
(Inherited from AFCollection.)
Public property
PISystem
This read-only property allows access to the PISystem associated with this collection.
(Inherited from AFCollection.)

Methods

  NameDescription
Public method
Add
Adds an object to the end of the collection.
(Inherited from AFCollectionT.)
Public method
Clear
Removes all items from the collection.
(Inherited from AFCollectionT.)
Public method
Contains(Guid)
This method determines whether the collection contains a specific item referenced by id.
(Inherited from AFCollectionT.)
Public method
Contains(T)
This method determines whether the collection contains a specific item.
(Inherited from AFCollectionT.)
Public method
CopyTo
Copies the entire collection to a compatible one-dimensional Array, starting at the specified index of the target array.
(Inherited from AFCollectionT.)
Public method
Equals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public method
GetEnumerator
Returns an enumerator that iterates through the collection.
(Inherited from AFCollectionT.)
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 AFCollection.)
Public method
GetType
Gets the Type of the current instance.
(Inherited from Object.)
Public method
IndexOf
Searches for the specified object and returns the zero-based index of the first occurrence within the entire collection.
(Inherited from AFCollectionT.)
Public method
IsTraced
Indicates if a specified level is being traced.
Public method
Remove(Guid)
Removes the item with the specified id from the collection.
(Inherited from AFCollectionT.)
Public method
Remove(T)
Removes the first occurrence of a specific object from the collection.
(Inherited from AFCollectionT.)
Public method
RemoveAt
Removes the item at the specified index of the collection.
(Inherited from AFCollectionT.)
Public method
Sort
Sorts the items in the entire collection using the default comparer.
(Inherited from AFCollectionT.)
Public method
Sort(IComparerT)
Sorts the items in the entire collection using the specified comparer.
(Inherited from AFCollectionT.)
Public method
Sort(Int32, Int32, IComparerT)
Sorts the items in a range of items in the collection using the specified comparer.
(Inherited from AFCollectionT.)
Public method
ToString
Returns a String that represents the current object.
(Inherited from AFCollection.)
Public method
TraceData
Output a data trace event.
Public method
TraceDetail
Output a detail trace event.
Public method
TraceError
Output an error trace event.
Public method
TraceEvent(AFTraceSwitchLevel, String)
Output a trace event with a message.
Public method
TraceEvent(AFTraceSwitchLevel, String, Int32)
Output a trace event with a message and a duration.
Public method
TraceEvent(AFTraceSwitchLevel, String, Object)
Output a trace event as a formatted message with a variable number of arguments.
Public method
TraceInformation
Output an information trace event.
Public method
TraceSummary
Output a summary trace event.
Public method
TraceWarning
Output a warning trace event.

Remarks

The collection is initialized after the AFAnalysisRule.CollectInputs method is called. The result is updated during the run of the model analysis. Case results affect the value returned from the AFAttribute.GetValue Overload methods when called with the AFCase as a context.

Examples

// This example will create a case, collect inputs,
// and then display information on one of the results.
// Note: This example assumes that there is a database called "Chocolate Milk Tutorial"
// containing a Model named "ChocolateMilkModel", with a Model Analysis
// named "Volume Balance"

// Get the Database
PISystems myPISystems = new PISystems();
AFDatabase myDB = myPISystems.DefaultPISystem.Databases["Chocolate Milk Tutorial"];

// Get the Model Analysis
AFAnalysis myAnalysis = AFAnalysis.FindAnalyses(myDB, "ChocolateMilkModel::Volume Balance",
    AFSearchField.Name, AFSortField.Name, AFSortOrder.Ascending, 1)[0];

// Create the Case
AFCase myCase = myAnalysis.AddCase();
myCase.CollectInputs();

// Display the number of Inputs and Outputs along with the number of bad inputs and outputs
Console.WriteLine("Total number of Results = {0}", myCase.Results.Count);
Console.WriteLine("Total number of Inputs = {0}", myCase.Results.CountInputs);
Console.WriteLine("Total number of Bad Inputs = {0}", myCase.Results.CountInputsBad);
Console.WriteLine("Total number of Outputs = {0}", myCase.Results.CountOutputs);
Console.WriteLine("Total number of Bad Outputs = {0}", myCase.Results.CountOutputsBad);

// Make an Adjustment to the first Result
myCase.Results[0].Adjustments.Add("Example creator", "This is an Adjustment to a Result",
    25, myCase.Results[0].Attribute.DefaultUOM);

// Display each result
Console.WriteLine();
foreach (AFResult CurResult in myCase.Results)
{
    Console.WriteLine("Name of Result = {0}", CurResult.Name);
    Console.WriteLine("Element represented by Result = {0}", CurResult.Attribute.Element.Name);
    Console.WriteLine("Attribute represented by Result= {0}", CurResult.Attribute.Name);
    Console.WriteLine("Value of Result = {0}", CurResult.Value.Value);
    Console.WriteLine();
}
' This example will create a case, collect inputs,
' and then display information on one of the results.
' Note: This example assumes that there is a database called "Chocolate Milk Tutorial"
' containing a Model named "ChocolateMilkModel", with a Model Analysis
' named "Volume Balance"

' Get the Database
Dim myPISystems As New PISystems
Dim myDB As AFDatabase = myPISystems.DefaultPISystem.Databases("Chocolate Milk Tutorial")

' Set the Model Analysis
Dim myAnalysis As AFAnalysis = AFAnalysis.FindAnalyses(myDB, "ChocolateMilkModel::Volume Balance",
    AFSearchField.Name, AFSortField.Name, AFSortOrder.Descending, 1)(0)

' Create the Case
Dim myCase As AFCase = myAnalysis.AddCase
myCase.CollectInputs()

' Display the number of Inputs and Outputs along with the number of bad inputs and outputs
Console.WriteLine("Total number of Results = {0}", myCase.Results.Count)
Console.WriteLine("Total number of Inputs = {0}", myCase.Results.CountInputs)
Console.WriteLine("Total number of Bad Inputs = {0}", myCase.Results.CountInputsBad)
Console.WriteLine("Total number of Outputs = {0}", myCase.Results.CountOutputs)
Console.WriteLine("Total number of Bad Outputs = {0}", myCase.Results.CountOutputsBad)

' Make an Adjustment to the first Result
myCase.Results(0).Adjustments.Add("Example creator", "This is an Adjustment to a Result",
    25, myCase.Results(0).Attribute.DefaultUOM)

' Display each result
Console.WriteLine()
Dim CurResult As AFResult
For Each CurResult In myCase.Results
    Console.WriteLine("Name of Result = {0}", CurResult.Name)
    Console.WriteLine("Element represented by Result = {0}", CurResult.Attribute.Element.Name)
    Console.WriteLine("Attribute represented by Result= {0}", CurResult.Attribute.Name)
    Console.WriteLine("Value of Result = {0}", CurResult.Value.Value)
    Console.WriteLine()
Next CurResult

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

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