OSI PI Adapter Sample

This topic describes the use of the OSI PI Adapter suite in a sample application to query and update data in a PI server. For more information about this operator, see OSIsoft PI Adapters.

Prerequisites

In order to run correctly, the adapters in this sample require that the OSIsoft PI Asset Framework (AF) Client version 2018 R2 or later, and the OISsoft PI SDK version 2018 or later, be installed on development and deployment machines that are expected to run StreamBase applications that call these adapters. The OSIsoft software can be obtained from OSIsoft.

When you install and configure the OSIsoft software, you establish a set of defaults for server name, user name, and password. Those defaults are used if not explicitly defined in the adapter properties.

Sample Overview

This sample demonstrates the adapters in the OSI PI adapter suite:

  • Snapshot

  • Write

  • Delete

  • Summaries

  • DataPipe

  • Attributes

  • Elements

  • EventFrames

Each adapter connects a .NET Operator which loads a .NET class. This class has been written to extend StreamBase's StreamBase.SB.Operator class, and is invoked whenever a tuple is received by the operator.

Importing This Sample into StreamBase Studio

In StreamBase Studio, import this sample with the following steps:

  • From the top-level menu, select File>Import Samples and Community Content.

  • Enter osi to narrow the list of options.

  • Select OSI PI Adapters from the ioT Adapters category.

  • Click Import Now.

StreamBase Studio creates a project for the OSI PI adapter sample in your current Studio workspace.

Running This Sample in StreamBase Studio

The steps to run this sample in Studio are as follows:

  1. In the Project Explorer view, open the sample you just loaded.

    if you see red marks on a project folder, wait a moment for the project to load its features.

    If the red marks do not resolve themselves after a minute, select the project, right-click, and select Maven>Update Project from the context menu.

  2. Open the src/main/eventflow/packageName folder.

  3. Make sure each adapter's server tab uses the correct values for your PI and PI AF installations.

  4. Open the OsiPiSample.sbapp

  5. Open the Parameters tab and enter the server connection details

  6. Click the Run button. This opens the SB Test/Debug perspective and starts the module. All the adapters are configured to connect to the PI server at startup.

  7. In the Manual Input view, select the SnapshotQuery input stream, and enter a list of tag names to query.

    Click Send Data, and observe that the output stream that received the data is the SnapshotOutput stream, with one tuple emitted for every tag name requested.

  8. In the Manual Input view, select the WriteData input stream, and enter a list of tags to update. (WARNING: This updates/inserts data)

    Click Send Data, and observe that the output stream that received the data is the WriteOutput stream. The tuple contains the results of the write operation for every requested tag.

  9. In the Manual Input view, select the DeleteData input stream, and enter a list of tags to delete. (WARNING: This deletes data)

    Click Send Data, and observe that the output stream that received the data is the DeleteOutput stream. The tuple contains the results of the write operation for every requested tag.

  10. In the Manual Input view, select the SummariesQuery input stream, and enter a list of tag names to query, and some summary types (by setting the summaryTypes field to "minimum, maximum, average", for example).

    Click Send Data, and observe that the output stream that received the data is the SummaryOutput stream, with one tuple emitted for every tag name requested. Once these tuples are emitted, one more tuple follows with its tagName field set to null, to indicate the end of the list.

  11. In the Manual Input view, select the Subscribe input stream, and enter a list of tag names to query.

    Click Send Data, and observe that the output stream that received the data is the DataPipeOut stream, with one tuple emitted for every tag name requested. Once these tuples are emitted, one more tuple follows with its tagName field set to null, to indicate the end of the list.

  12. In the Manual Input view, select the AttributesQuery input stream and enter values for fields you would like to search on. If not values are provided a search of the entire database will result and all values returned.

    Click Send Data, and observe that the output stream that received the data is the AttributesOutput stream

  13. In the Manual Input view, select the ElementsQuery input stream and enter values for fields on which you would like to search. If no values are provided, a search of the entire database will result and all values are returned.

    Click Send Data, and observe that the output stream that received the data is the ElementsOutput stream

  14. In the Manual Input view, select the EventFramesQueries input stream and enter values for fields on which you would like to search. If no values are provided, a search of the entire database will result and all values are returned.

    Click Send Data, and observe that the output stream that received the data is the EventFramesOut stream

  15. When done, press F9 or click the Terminate EventFlow Fragment button.

This Sample's Files

This sample has the following files:

  • The sample EventFlow application and its layout file, OsiPiSample.sbapp and OsiPiSample.sblayout, respectively.

  • This Readme file, in plain text and HTML formats.

Sample Location

When you load the sample into StreamBase Studio, Studio copies the sample project's files to your Studio workspace, which is normally part of your home directory, with full access rights.

Important

Load this sample in StreamBase Studio, and thereafter use the Studio workspace copy of the sample to run and test it, even when running from the command prompt.

Using the workspace copy of the sample avoids permission problems. The default workspace location for this sample is:

studio-workspace/sample_osipi

See Default Installation Directories for the default location of studio-workspace on your system.