flanapa_wipro

Not getting values from AF GetValues

Discussion created by flanapa_wipro on Dec 13, 2012
Latest reply on Dec 19, 2012 by flanapa_wipro

Hi,

 

The below code snippet (in bold) is my attempt at getting an array of values from an AF attribute over a given time range using the GetValues call.  The AF attribute is a simple PIPoint holding the Sinsoid tag and so definitely has values.

 

However when I run it I get the below printout (in italics).  It seems among other things that the time range is not getting through the call.  Stepping through shows tr to have proper values prior to call.  Similar code using GetValue and a loop works fine but I would like to do this the proper way and use the full power of AFSDK.

 

Any suggestions?

 

Regards

 

Paul

 

 

 

CODE:

 

' Set the Time Range

 

Dim st = New AFTime(DateTime.UtcNow.AddDays(-1))

 

Dim et = New AFTime(DateTime.Now)

 

Dim tr = New AFTimeRange(st, et)

 

Dim myValues As AFValues

 

 

 

'Reading the af attributes

 

Dim ic As Integer

 

For ic = 0 To lstAFAttr.Count

 

       theAttr = lstTagAttr(ic)

 

       myValues = theAttr.GetValues(tr, 0, theAttr.DefaultUOM)

 

   For Each val As AFValue In myValues
      Console.WriteLine(val.Timestamp.LocalTime.ToString())

 

      Console.WriteLine(val.Value.ToString())
   Next
Next

 

--------------------------------------------------------------------------

 

 

 

Start uploading data
Connecting to AF Server OMSWT06
Connecting to PI Server OMSWT05
Processing elements in the template reservoir
1/1/1970 12:00:00 AM
OSIsoft.AF.Asset.DataReference.TagException: Cannot retrieve PI Point 'sinusoid'
 for attribute 'reservoir3|TagResFlow'.
   at OSIsoft.AF.Asset.DataReference.PIBaseDR.CheckBaseConfig()
   at OSIsoft.AF.Asset.DataReference.PIPointDR.CheckConfig()
   at OSIsoft.AF.Asset.DataReference.PIPointDR.GetValues(Object context, AFTimeR
ange timeContext, Int32 numberOfValues, AFAttributeList inputAttributes, AFValue
s[] inputValues)
   at OSIsoft.AF.Asset.AFAttribute.GetValuesInternal(AFTimeRange timeRange, Int3
2 numberOfValues, UOM desiredUOM, Stack`1 processedInputArguments) in c:\Dev\AF\
AF 2.3\Sources\SDK\Asset\AFAttribute.Value.cs:line 1246

 

 

Outcomes