-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathFindEventFramesExample.cs
More file actions
57 lines (49 loc) · 2.05 KB
/
FindEventFramesExample.cs
File metadata and controls
57 lines (49 loc) · 2.05 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
using System;
using OSIsoft.AF;
using OSIsoft.AF.Asset;
using OSIsoft.AF.EventFrame;
namespace ExamplesLibrary
{
/// <summary>
/// This example retrieves 2 event frames created previously by CreateEventFramesExample.
/// </summary>
/// <prerequisite-examples>
/// BuildSimpleDatabaseExample, CreateEventFramesExample
/// </prerequisite-examples>
public class FindEventFramesExample : IExample
{
public void Run()
{
PISystems piSystems = new PISystems();
PISystem piSystem = piSystems["<AFSERVER>"];
AFDatabase afDatabase = piSystem.Databases["Basic-AFSDK-Sample"];
const int pageSize = 1000;
int startIndex = 0;
int returnLimit = 100000;
do
{
AFElementTemplate efTemplate = afDatabase.ElementTemplates["BasicEventFrameTemplate"];
// Get event frames that started the past two days.
AFNamedCollectionList<AFEventFrame> eventFrames = AFEventFrame.FindEventFrames(
database: afDatabase,
searchRoot: null,
startTime: "t-2d",
startIndex: startIndex,
maxCount: pageSize,
searchMode: AFEventFrameSearchMode.ForwardFromStartTime,
nameFilter: "*",
referencedElementNameFilter: "BoilerA",
elemCategory: null,
elemTemplate: efTemplate,
searchFullHierarchy: true);
foreach (AFEventFrame ef in eventFrames)
{
//Note: We should make a bulk call on the attribute values via AFAttributeList if we had many event frames.
Console.WriteLine("Name: {0}, Start: {1}, End: {2}, Max temp: {3}",
ef.Name, ef.StartTime, ef.EndTime, ef.Attributes["Maximum temperature"].GetValue());
}
startIndex += pageSize;
} while (startIndex < returnLimit);
}
}
}