-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathFindAttributeWalkDownExample.cs
More file actions
40 lines (33 loc) · 1.47 KB
/
FindAttributeWalkDownExample.cs
File metadata and controls
40 lines (33 loc) · 1.47 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
using System;
using OSIsoft.AF;
using OSIsoft.AF.Asset;
namespace ExamplesLibrary
{
/// <summary>
/// This example "walks-down" the AF hierarchy to locate an attribute of interest and then get its current value.
/// The target attribute is \\Server\NuGreen\NuGreen\Houston\Cracking Process\Equipment\B-210|Process Feedrate.
/// There are more direct methods to find this attribute, but this example is merely to demonstrate the behavior of
/// some basic operations.
/// Contrast this example with DirectLocateExample.
/// </summary>
/// <prerequisite-examples>
/// none
/// </prerequisite-examples>
public class FindAttributeWalkDownExample : IExample
{
public void Run()
{
PISystems piSystems = new PISystems();
PISystem piSystem = piSystems["<AFSERVER>"];
AFDatabase afDatabase = piSystem.Databases["NuGreen"];
AFElement nuGreen = afDatabase.Elements["NuGreen"];
AFElement houston = nuGreen.Elements["Houston"];
AFElement crackingProcess = houston.Elements["Cracking Process"];
AFElement equipment = crackingProcess.Elements["Equipment"];
AFElement b210 = equipment.Elements["B-210"];
AFAttribute processFeedRate = b210.Attributes["Process Feedrate"];
AFValue val = processFeedRate.GetValue();
Console.WriteLine("Timestamp: {0}, Value: {1}", val.Timestamp, val.Value.ToString());
}
}
}