Hello! I need to retrieve Time Weighted, Averaged data for a month at a time, at a granularity of 1 minute intervals - hence the desire to use the Summaries function for my first time. I'm writing the program in VB (I can also write it in C), and I am fine with everything up until I try and retrieve the summary data and associated timestamps. I need to retrieve this data and save it into a dataset, which will be compared with other data and exported as a report.
The following code is a part of a form, where a user can select a start and end date (DateTimePicker1 & 2). Hopefully everything else is fairly self explanatory - I just need help with being able to retrieve each of the 1 minute interval averages and their associated timestamps. The v.Timestamp and v.ValueAsDouble are the function's I'd typically use in an AFValue/values or PIPoint, but it does not work in the case of Summaries.
Private Sub getMeterDataTest() Dim mtrpnt As String = "Test Point" Dim ttstmp As DateTime Dim mtrval As Double Dim sharedPIServer As PIServer Dim tmrng As New Time.AFTimeRange(DateTimePicker1.Value, DateTimePicker2.Value) sharedPIServer = New PIServers().DefaultPIServer Dim myPointMtr As PIPoint = PIPoint.FindPIPoint(sharedPIServer, mtrpnt) Dim ts As Time.AFTimeSpan = New Time.AFTimeSpan(minutes:=1) Dim valuesMeter As IEnumerable(Of IDictionary(Of Data.AFSummaryTypes, Asset.AFValues)) valuesMeter = myPointMtr.Summaries(tmrng, ts, Data.AFSummaryTypes.Average, Data.AFCalculationBasis.TimeWeighted, Data.AFTimestampCalculation.Auto) 'Dim v As IEnumerable(Of IDictionary(Of Data.AFSummaryTypes, Asset.AFValues)) 'looping through the PI data and storing it in the correct bucket For Each v In valuesMeter ttstmp = v.Timestamp.ToString mtrval = v.ValueAsDouble Next End Sub