Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AF SDK Reference

Retrieving Values

  • Last UpdatedJan 12, 2026
  • 1 minute read
Retrieving Values

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}

See Also

In This Topic
Related Links
TitleResults for “How to create a CRG?”Also Available in