Daniel Takara

error number on Value property of NamedValues object returned by IPIData2.FilteredSummaries method

Discussion created by Daniel Takara on Jul 22, 2009
Latest reply on Jul 1, 2010 by andersonbraz

Hi everybody,

 

I am not sure if I should be submitting this question to TechSupport first, as it is not a question on best practices, but on the behavior of a PI-SDK method unexpected by me. In any case, since it is related to programming, I thought it would be more appropriate to raise it here first.

 

I was testing the PI-SDK 1.3.6.363 IPIData2.FilteredSummaries method to get a filtered average in a ProcessBook 3.1.1.0 display. I added a CommandButton object and a Label object to the display and this was my code for the click event of the CommandButton:

Private Sub CommandButton1_Click()
    Dim nvsFilt As NamedValues
    Dim execTime As PITime
    Dim g_PISDK As New PISDK.PISDK                     ' PISDK object
    Dim myServer As Server
    Dim myPoints As PIPoints
    Dim sdkCorrente As PIPoint
    Dim sdkCiclo As PIPoint
    Dim pData As PIData
    Dim ipid2 As IPIData2
    Dim filterExpr As String
    Dim avgPIValues As PIValues

    Set execTime = New PITime
    execTime.LocalDate = Now
   
    Set myServer = g_PISDK.Servers.DefaultServer
    Set myPoints = myServer.PIPoints
    Set sdkCorrente = myPoints("CBM-561-SC-CORRENTECC1")
    Set sdkCiclo = myPoints("CBM-561-SC-BATCH_ID_CIT")
    Set pData = sdkCorrente.Data
    Set ipid2 = pData
    filterExpr = "('CBM-561-SC-CORRENTECC1'>3 AND 'CBM-561-SC-TENSAOGRCIT'>3)"
    Set nvsFilt = ipid2.FilteredSummaries(sdkCiclo.Data.Snapshot.TimeStamp, _
                                          execTime, _
                                          "", _
                                          filterExpr, _
                                          ArchiveSummariesTypeConstants.asAverage, _
                                          CalculationBasisConstants.cbTimeWeighted, _
                                          FilterSampleTypeConstants.fstPIPointRecordedValues)

    If Not nvsFilt Is Nothing Then
        Set avgPIValues = nvsFilt("Average").Value
        Label1.Caption = "filtered average electric current value is " & CStr(avgPIValues(1).Value)
    End If
    Set execTime = Nothing
    Set g_PISDK = Nothing
    Set cicloVals = Nothing
    Set nvsFilt = Nothing
    Set myServer = Nothing
    Set myPoints = Nothing
    Set sdkCorrente = Nothing
    Set sdkCiclo = Nothing
    Set pData = Nothing
    Set ipid2 = Nothing
    Set avgPIValues = Nothing
End Sub

When I click on the CommandButton in the display, I get this in the label:

 

filtered average electric current value is Error -2147219947

 

I used the Advanced Calculated Data feature of DataLink 4.1 in Excel to get the same average. This is what I got as the output in the Excel cell:

 

[-11101] All data events are filtered in summary calculation

 

What I got in DataLink makes sense and seems to be consistent with what I got in ProcessBook, as all the events were indeed filtered and no average could be calculated.

 

My question is:

 

Error -2147219947 is not critical, but is it expected that it be returned by the PI-SDK as if it was the actual value in the NamedValues object returned by the IPIData2.FilteredSummaries method? Shouldn't an error event be raised instead to interrupt the code execution, so that it be properly handled by the programmer as if it was an actual error?

 

Before I tried this in ProcessBook VBA, I was using equivalent commands in an ACE 2.1.32 calculation to get the filtered average and assign it as the value to a PIACEPoint:

 

MediaCorrenteCiclo.Value = avgPIValues(1).Value

 

where MediaCorrenteCiclo is my PIACEPoint object.

 

Similarly an in ProcessBook, I also did not get an actual error event in the ACE calculation. Furthermore, MediaCorrenteCiclo.Value simply received the negative value -2147219947, as if it was not an error number at all.

Outcomes