AnsweredAssumed Answered

AF SDK: Questionable flag not read correctly; IndexOutOfRange in FindPIPoints

Question asked by pst-octavesoft on Sep 9, 2015
Latest reply on Sep 14, 2015 by pst-octavesoft

Hello all

 

I'm trying to create a script which reads all values with all infos from a PI server. The problem is, the Questionable-Flag is sometimes not set when it should be.

 

My environment: PI Server 2012 on Win2008R2, AF SDK v4.0.30319 on Win7

 

E.g. I have those values in PI: (Fragwürdig == Questionable)

 

And here is a test script with the wrong output:

[System.Reflection.Assembly]::LoadWithPartialName("OSIsoft.AFSDK") | Out-Null

$pi = (New-Object OSIsoft.AF.PI.PIServers).DefaultPIServer
$pi.Connect()

$pipoint = [OSIsoft.AF.PI.PIPoint]::FindPIPoint($pi, "YOUR TAG HERE");

$aftime = $time = New-Object OSIsoft.AF.Time.AFTime -ArgumentList @("1.1.2000")

$values = $pipoint.RecordedValuesByCount($aftime, 2, $true, [OSIsoft.AF.Data.AFBoundaryType]::Inside, "", $false)

$values | ft Timestamp,Value,Questionable

 

Output:

Timestamp                     Value                                        Questionable
---------                     -----                                        ------------
30.03.2015 14:23:20           Pt Created                                          False
31.03.2015 15:00:49           Normal                                               True

 

It seems like the questionable flag is not correctly read from values with system states. Is this a bug or am I doing something wrong?

 

=====

 

Also, I'm getting an IndexOutOfRangeException with this bit:

$list = New-Object System.Collections.Generic.List[string]
$list.Add("sinusoid")
[OSIsoft.AF.PI.PIPoint]::FindPIPoints($pi, $list)

Output:

Index was outside the bounds of the array.
At C:\script.ps1:20 char:1
+ [OSIsoft.AF.PI.PIPoint]::FindPIPoints($pi, $list)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], IndexOutOfRangeException
    + FullyQualifiedErrorId : System.IndexOutOfRangeException

I use the function as described here: PIPoint.FindPIPoints Method (PIServer, IEnumerable(String), IEnumerable(String))

I don't know how to fix this... As a workaround I'm using FindPIPoint in a loop. But would be nice if I could use the function.

 

 

Thanks,

Piero

Outcomes