I would like the create in PI Ace one code for sum the values the one tag , example period: 01/05/2015 until 28/05/2015.
It is possible?
Are you hoping to get a time-weighted total or event-weighted total?
For time-weighted total, you can use the built-in ACE function PIACEPoint.Total Method to find the totalized value (time integral) over the time period.
For event-weighted total, I haven't found a way to do it with native PI ACE function without pulling it all the values and summing it client-side. However, you can use PI SDK to do an event-weighted total (sum) on the server-side.
As an example:
Public Class AFSDKTest
Private SINUSOID As PIACEPoint
' Tag Name/VB Variable Name Correspondence Table
' Tag Name VB Variable Name
' SINUSOID SINUSOID
Public Overrides Sub ACECalculations()
Dim startTime As String = "1-May-2015"
Dim endTime As String = "28-May-2015"
Dim total_tw As Double
Dim total_ew As Double
Dim pisdk As PISDK.PISDK
Dim svr As Server
Dim val As PIValue
total_tw = SINUSOID.Total(startTime, endTime)
pisdk = New PISDK.PISDK()
svr = pisdk.Servers("DNG-PI2012")
val = svr.PIPoints("sinusoid").Data.Summary(startTime, endTime, ArchiveSummaryTypeConstants.astTotal, CalculationBasisConstants.cbEventWeighted)
total_ew = val.Value
For new development project, we normally suggest using the PI AF SDK over PI SDK (see the announcement on the future of PI SDK here). However, the PI namespace is not available in the .NET 2.0 version of PI AF SDK (the .NET version where PI ACE uses). If you would like to sum the values of an AF Attribute, we can use the AF SDK instead. An alternative would be to get all values and sum them on the client-side (might make sense if there are only a few values per month). Depending on your use case, we can propose alternative methods that work.
Similar to PI Performance Equation, there's no function for the event weighted total with PI ACE but the solution that works with PI Performance Equations should be applicable with PI ACE too. PIPoint.Mean(startTime, endTime) returns the event weighted average. Multiply this with the amount of archived events for the same period and you get the event weighted total. For the event count a reference to PI SDK is required:
Output.Value = Input.Mean(startTime, endTime) * Input.Values(startTime, endTime).Count
A quick note on using PIACEPoint.Values().Count. I believe PIACEPoint.Values() requires getting all the values into client, the .Count operation then count the number of values. Even though ACE caches its data, PIACEPoint.Values do not use the data in the cache. From the manual:
All PIACEPoint data calls (for example, Value, Avg, and PrevEvent) except the Values method are evaluated using the data in the cache, if the cache contains enough data. Otherwise, the equivalent calls to a PI Server are made.
The choice of which data call to make depends on your data frequency. Just something to keep in mind
Alternatively, you can also see if you can use Asset-Based Analytics handle your calculations.
Thanks Daphne and Gregor, the two answers they Worked.
Retrieving data ...