-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathAFConnectionExample.cs
More file actions
43 lines (36 loc) · 1.29 KB
/
AFConnectionExample.cs
File metadata and controls
43 lines (36 loc) · 1.29 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
using OSIsoft.AF;
using OSIsoft.AF.Asset;
namespace ExamplesLibrary
{
/// <summary>
/// This example demonstrates making a connection to an AF Server using an implicit connection and an explicit connection.
/// </summary>
/// <prerequisite-examples>
/// none
/// </prerequisite-examples>
public class AFConnectionExample : IExample
{
public void Run()
{
ImplicitConnection();
ExplicitConnection();
}
private void ImplicitConnection()
{
PISystems piSystems = new PISystems();
PISystem piSystem = piSystems["<AFSERVER>"];
// At this point, no connection is made.
AFAttribute afAttribute = AFAttribute.FindAttribute(@"NuGreen\NuGreen\Houston|Environment", piSystem);
// Now a connection is made by first data access.
}
private void ExplicitConnection()
{
PISystems piSystems = new PISystems();
PISystem piSystem = piSystems["<AFSERVER>"];
// At this point, no connection is made.
piSystem.Connect();
// Now a connection is made by explicit call.
AFAttribute afAttribute = AFAttribute.FindAttribute(@"NuGreen\NuGreen\Houston|Environment", piSystem);
}
}
}