Retrieving Values
- Last UpdatedNov 18, 2025
- 2 minute read
- PI System
- AF SDK 2024 R2
- Developer
Retrieving values from AF Attributes is also best done in bulk, in particular, if any of the data is coming from the PI Data Archive. By bulk retrieving the data, the calls to the PI Data Archive server can be batched. This example uses the AFAttributeList to illustrate how to retrieve attribute values in bulk.
1internal static int CountBadData(AFElement element, int depth) 2{ 3 int count = 0; 4 5 // we can use the AFAttributeList to retrieve values from 6 // multiple attributes at one time. This is useful when the 7 // data is coming from a data reference, such as a PI Point, which 8 // supports retrieving the data in bulk. 9 AFAttributeList attributes = new AFAttributeList(element.Attributes); 10 AFValues values = attributes.GetValue(); 11 12 // count the bad values returned 13 foreach (AFValue v in values) 14 { 15 if (!v.IsGood) 16 count++; 17 } 18 19 // count bad data in child elements too 20 if (depth > 0) 21 { 22 foreach (AFElement childElement in element.Elements) 23 { 24 count += CountBadData(childElement, depth - 1); 25 } 26 } 27 28 return count; 29}
1Friend Shared Function CountBadData(ByVal element As AFElement, ByVal depth As Integer) As Integer 2 Dim count As Integer = 0 3 ' we can use the AFAttributeList to retrieve values from 4 ' multiple attributes at one time. This is useful when the 5 ' data is coming from a data reference, such as a PI Point, which 6 ' supports retrieving the data in bulk. 7 Dim attributes As AFAttributeList = New AFAttributeList(element.Attributes) 8 Dim values As AFValues = attributes.GetValue 9 ' count the bad values returned 10 For Each v As AFValue In values 11 If Not v.IsGood Then 12 count = (count + 1) 13 End If 14 Next 15 ' count bad data in child elements too 16 If (depth > 0) Then 17 For Each childElement As AFElement In element.Elements 18 count = (count + CountBadData(childElement, (depth - 1))) 19 Next 20 End If 21 Return count 22End Function
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.