AF SDK basics
- Last UpdatedMay 16, 2023
- 3 minute read
- PI System
- AF SDK 2.10
- PI Server
AF SDK presents a hierarchical model of objects and collections that represent underlying PI System features and concepts. Using AF SDK, you use the PISystem object as an abstraction for your PI System.
The PISystem object is the top-level object used to represent a logical PI AF server. Each PISystem can have one or more separate AFDatabase objects. Each AFDatabase object may contain any number of child AFElement objects, which are sometimes referred to as assets.
Each AFElement object may have child AFElements or child AFAttributes. AFAttributes of an AFElement may represent values from a data stream, table, or descriptive values (either static or dynamically changing). The PISystem object is ideal for organizing assets that may be grouped in hierarchies and classified using templates created to describe similar objects across the database.
Note that the UOM (unit of measure) database is attached to a PISystem object. In addition, only one UOM database exists in a PI System.
Objects and collections
Many PI AF objects have associated collections. For example, each AFElement may contain any number of child elements. The group of child elements is represented as an AFElements object. The reference between an object and its child collection is used to build the hierarchical structure of PI AF. Note that AF SDK employs a consistent naming convention for collections; for example, a collection of AFElement objects is named AFElements.
The programmatic object hierarchy is very similar to the visual hierarchy displayed in PI System Explorer. Therefore, understanding how objects are related within PI System Explorer greatly facilitates learning AF SDK.
Namespaces
AF SDK is organized into several namespaces. The most common namespaces and their basic functions are listed here. A block diagram of the PISystem Hierarchy is available in help.
-
OSIsoft.AF
The AF namespace contains the main classes used by all the other namespaces within AF SDK. It provides base class implementations and methods for connecting to PI AF servers. The primary classes are PISystem and AFDatabase. Each PI System is composed of any number of distinct databases. For more information see the OSIsoft Tech Support page PISystem hierarchy.
-
OSIsoft.AF.Asset
The Asset namespace provides a set of classes for representing assets within an organization. It allows the creation of hierarchies of assets and their attributes. Additionally, it provides features for dealing with common requirements such as remote data access, unit-of-measure conversion, and defining and enforcing asset definitions. Templates for assets ensure consistency among attributes. In the AF namespace, you will find AFElement, AFAttribute, AFElementTemplates, and so on, along with their associated collections (such as AFElements). In addition, AFValue, used to represent a time-series event, is located in the AF namespace. For more information see the OSIsoft Tech Support page Asset namespace.
-
OSIsoft.AF.Data
The Data namespace provides classes for obtaining rich data access (RDA) from assets within an organization. Both historical and real-time data access are provided. Data access across asset types allow for simpler architecture as well as helpful functionality such as unit-of-measure conversions. For more information see the OSIsoft Tech Support page Data namespace.
-
OSIsoft.AF.PI
The PI namespace provides classes that are used to manage connections and access information about PI Data Archive. It provides direct access to PI Data Archive and can be used to find or edit PI points and read or write data directly to PI Data Archive. See the AF SDK online reference for more information. For more information see the OSIsoft Tech Support page AF.PI namespace.
-
OSIsoft.AF.Time
The AF.Time namespace provides classes for performing time operations with the PI System. It provides methods for converting time strings including abbreviations in the PI time syntax (such as "*-5m") to an AFTime and converting .NET DateTime structures to and from AF time structures. Time, time range, and time interval classes also facilitate accurate representation across time zones and across daylight transitions. For more information see the OSIsoft Tech Support page AF.Time namespace.
-
OSIsoft.AF.EventFrame
The EventFrame namespace provides classes for reading and writing PI AF Event Frames. These objects can be tied to PI AF elements and represent events that occur over a time period, such as equipment downtime or abnormal behavior. For more information see the OSIsoft Tech Support page EventFrame namespace.
Namespaces are brought into scope in your application by adding the appropriate directives at the top of the class file. For example:
using OSIsoft.AF;
using OSIsoft.AF.Asset;
using OSIsoft.AF.Data;