Can anyone give example code for vb to use AFData.Summaries method ?
Assuming you have PI System Explorer installed, you can go to "Help", "AF SDK Reference" and search within the reference.
Searching for "AFData.Summaries" brought me to the AFData.Summaries Method page with a VB.Net declaration.
At the bottom of the page, under references, is AFData Class with a hyperlink to the class; the class has a VB.Net example.
You may be able to extrapolate from there.
Thank you for your reply! I found what you suggested.... I'm close, I can't get the error (see pic below) cleared.. I think I'm getting too old.
Either add an Import to bring the definition in or add the class name to the declaration.
I tried to import the name space and none of these worked...
Old dog wanting to learn new... I'll work on it more in the morning.. Thanks Tim.
From the top of the help:
A number of the parameters that you need to pass to the Summaries method are enumerations - you don't need to declare them as variables. Specifically the AFSummaryType, AFCalculationBasis, AFSampleType, and AFTimeStampCalculation - these are all enumerations.
The way that I would declare your code is as follows:
Dim instance As PIPoint
Dim intervalDefinitions As ILIst(Of AFTimeIntervalDefinition)
Dim reverseTime As Boolean
returnValue = instance.Summaries(intervalDefinitions, reverseTime, AFSummaryTypes.Average, AFCalculationBasis.TimeWeighted, AFTimestampCalculation.Auto)
The only namespaces you need to import for this are OSIsoft.AF, OSIsoft.AF.Data and OSIsoft.AF.PI.
You will also need to import the OSIsoft.AF.Time namespace - almost forgot that one!
Thank you for your response. though I'm not quite there yet....
I want to write a few lines of vb.net code to return number of minutes a tag was in a given state.
1. Tag name
2. Filter for the tag
3 A start and Stop time
I want the return value to be total time the filter criteria was met. I know I can do this in excel but I need it in vb.net.
Thanks again for your time.
I would recommend that you look at the AFCalculation.CalculateAtTimes method, and just pass in an IList(Of AFTime) with a single AFTime object. For your expression, use the TimeEq function (if comparing to a digital state), or one of TimeGE, TimeGT, TimeLE or TimeGT functions depending on what condition you are looking for. Note that these functions return a value in seconds, so you will need to perform your own conversion to minutes.
Retrieving data ...