-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathFindElementAttributesExample.cs
More file actions
62 lines (52 loc) · 2.06 KB
/
FindElementAttributesExample.cs
File metadata and controls
62 lines (52 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using OSIsoft.AF;
using OSIsoft.AF.Asset;
namespace ExamplesLibrary
{
/// <summary>
/// This example uses FindElementAttributes to return a list of AFAttribute objects to the client.
/// </summary>
/// <prerequisite-examples>
/// none
/// </prerequisite-examples>
public class FindElementAttributesExample : IExample
{
public void Run()
{
PISystems piSystems = new PISystems();
PISystem piSystem = piSystems["<AFSERVER>"];
AFDatabase afDatabase = piSystem.Databases["NuGreen"];
AFCategory elementCategory = afDatabase.ElementCategories["Equipment Assets"];
AFCategory attributeCategory = afDatabase.AttributeCategories["Real-Time Data"];
AFElementTemplate elementTemplate = afDatabase.ElementTemplates["Boiler"];
const int pageSize = 1000;
int startIndex = 0;
int totalCount;
do
{
// Find all "Water Flow" attributes in the NuGreen database.
AFAttributeList attrList = AFAttribute.FindElementAttributes(
database: afDatabase,
searchRoot: null,
nameFilter: "*",
elemCategory: elementCategory,
elemTemplate: elementTemplate,
elemType: AFElementType.Any,
attrNameFilter: "*",
attrCategory: attributeCategory,
attrType: TypeCode.Double,
searchFullHierarchy: true,
sortField: AFSortField.Name,
sortOrder: AFSortOrder.Ascending,
startIndex: startIndex,
maxCount: pageSize,
totalCount: out totalCount);
foreach (AFAttribute attr in attrList)
{
Console.WriteLine("Parent element name: {0}", attr.Element);
}
startIndex += pageSize;
} while (startIndex < totalCount);
}
}
}