AnsweredAssumed Answered

PI ACE: Total function with filter

Question asked by leonard Champion on Oct 5, 2016
Latest reply on Oct 5, 2016 by leonard


I want calculate a volume of water over a period  for only value>20m3/h. With Ace Total function we can't use filter but with PI SDK we can. So in my project I implement a Module ModPisdk and I copy the example from live library: . It looks like this:


Private _piServer As Server   
Private _sdk As New PISDK.PISDK() 
Public Sub GetTotalFilteredValues(tagName As String) 
     Dim srv As Server
     Dim pt As PIPoint       
     Dim pdata As PIData  
     Dim ipid2 As IPIData2, ipiCalc As IPICalculation       
     Dim nvsSum As NamedValues, nvsFilSum As NamedValues 
     Dim valsum As PIValues, valfilsum As PIValues, valfiltime As PIValues, valtimetrue As PIValues       
     Dim filexpr As String, startTime As String, endTime As String, duration As String
     startTime = "y-2d" ' three days ago   
     endTime = "t" ' today         duration = "1d" ' one day calculation period   
     'filexpr = ""         filexpr = "('CC1BH01C_ST01_Value' > 20)"  
      srv = _sdk.Servers(PI_SERVER_NAME)      
      ipiCalc = srv                         ' get pointer to IPICalculation Interface       
     pt = srv.PIPoints("CC1BH01C_ST01_Value") ' perform summary calls on tag sinusoid       
     pdata = pt.Data       
     ipid2 = pdata                        ' get pointer to IPIData2 Interface       
      ' calculate daily total for three days on sinusoid
      nvsSum = ipid2.Summaries2(startTime, endTime, duration, ArchiveSummariesTypeConstants.asTotal, CalculationBasisConstants.cbTimeWeighted)       
     ' extract the pivalues for total from the result       
     valsum = nvsSum("Total").Value       
      ' calculate the daily summary for sinusoid only when the batches are at phase1       
     ' do all the summary types in one call       
     ' note that fstExpRecordedValues is only supported by PI 3.4 and above       
     nvsFilSum = ipid2.FilteredSummaries(startTime, endTime, duration, filexpr, ArchiveSummariesTypeConstants.asAll, CalculationBasisConstants.cbTimeWeighted, FilterSampleTypeConstants.fstExpRecordedValues)       
        '' extract the time-weighted total from the FilteredSummaries result       
      valfilsum = nvsFilSum("Total").Value
     End Sub
End Module

There is data over the period an when I call this procedure within my Ace Project, when make a step by step , looks like I have no "total" but only count:

So here I want the total values for each days.


Can you help me to solve this issue? please.

Thanks in agvance.