Click or drag to resize
OSIsoft, LLC

AFSearchBinnedSummaryTBin Method

Generates a summary broken down by the specified bins for items matching the search criteria.

Namespace:  OSIsoft.AF.Search
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version:
public AFBinnedResult<TBin> BinnedSummary<TBin>(
	string field,
	IEnumerable<TBin> bins,
	UOM binUOM,
	string summaryField,
	AFSummaryTypes summaryTypes
where TBin : Object, IComparable<TBin>


Type: SystemString
The field whose value should be binned.
Type: System.Collections.GenericIEnumerableTBin
The bins the field should be sorted into.
Type: OSIsoft.AF.UnitsOfMeasureUOM
The unit of measure associated with bin values.
Type: SystemString
The field that should be summarized for each group.
Type: OSIsoft.AF.DataAFSummaryTypes
The types of summaries to perform for each group.

Type Parameters

The type of bins the summary is broken into.

Return Value

Type: AFBinnedResultTBin
A result containing the requested summaries broken down by bin or an error if the summaries could not be performed.
// Get the Database
PISystems myPISystems = new PISystems();
PISystem myPISystem = myPISystems.DefaultPISystem;
if (myPISystem == null)
    throw new InvalidOperationException("Default PISystem was not found.");
AFDatabase myDB = myPISystem.Databases[dbName];
if (myDB == null)
    throw new InvalidOperationException("Database was not found.");

// Create a search to find all the event frames created from the 'Event'
// template in the last year.
using (AFEventFrameSearch eventSearch = new AFEventFrameSearch(myDB, "EventFrameSearch", @"Template:'Event' Start:>'t-1y'"))
    eventSearch.CacheTimeout = TimeSpan.FromMinutes(10);
    // Get the average duration binned by start month
    AFBinnedResult<AFTime> binnedSummary = eventSearch.BinnedSummary("StartTime",
        new AFTimeSpan(months: 1).GetIntervalTimes(new AFTimeRange("1-1y", "1+1mo")), binUOM: null,
        summaryField: "Duration", summaryTypes: AFSummaryTypes.Average);
    foreach (var bin in binnedSummary.BinnedResults)
        Console.WriteLine("Month: {0}, Average: {1}",
            bin.Key, bin.Value[AFSummaryTypes.Average]);
Version Information


Supported in: 2.10.5, 2.10, 2.9.5, 2.9
See Also
Enabling Operational Intelligence