This repository provides self-contained and reproducible samples of basic operations using AF SDK.
Each example is a separate class and outputs results to the Console.
PI-AF-SDK-Basic-Samples-Console
contains the Console application that runs the examples.
ExamplesLibrary
contains the examples.
- AF Client 2.5+
- .NET Framework 4+
- Visual Studio 2012+
- AF Server and PI Data Archive
Many of the examples uses the NuGreen database. To use the NuGreen database, follow these steps:
- Create an AF Database named "NuGreen".
- Import the database from the provided NuGreen.xml via PI System Explorer>File>Import from File.
- Verify that a root element "NuGreen" is created inside the NuGreen database.
- Check in the changes if not done so already.
The code examples come with simple placeholders such as <AFSERVER>
and <PISERVER>
.
Please replace these with your server names before starting.
Some examples depend on having run prior examples successfully. This is because these dependent examples require AF objects and/or PI Points to have been created by the prior examples. The comments in the code above each class will explicitly list out the dependencies of each example. For instance,
/// <prerequisite-examples>
/// BuildSimpleDatabaseExample, CreateEventFramesExample
/// </prerequisite-examples>
To run a particular example, simply instantiate a new object from the example type and call its Run() method.
To run the AFConnectionExample, for instance, use:
IExample example = new AFConnectionExample();
example.Run()
A recommended learning path for going through the examples is as follows:
- AFElementExamples/FindElementsExample
- AFElementExamples/PartialLoadElementsExample
- AFElementExamples/LoadElementsExample