Contents
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.
In order run correctly, the adapters require that the OSIsoft PI Asset Framework (AF) Client version 2016 R2 or later and the OISsoft PI SDK version 2014 R2 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, password; those defaults are used if not explicitly defined in the adapter properties.
This sample includes all six different adapters in the OSI PI adapter suite:
-
Snapshot
-
Write
-
Summaries
-
DataPipe
-
AF
-
Event Frames
Each adapter connects a .NET Operator which loads a .NET class called DotNETOperatorSample.DotNETSample from an assembly located in the .\DotNETCode\bin\Release subdirectory of the project. This class has been written to extend StreamBase's StreamBase.SB.Operator class, and is invoked whenever a tuple is received by the operator. The .NET class then processes the tuple (using the StreamBase
.NET Client API facilities) and sends another tuple to the operator which is emitted to its output port. In this sample the
processing performed by the .NET class is simple: the tuple's intValue value is squared and set in the output tuple's field named answer.
This sample has the following files:
-
The sample EventFlow application,
OsiPiSample.sbapp. -
This
Readmefile, in plain text and HTML formats.
The steps to run this sample in Studio are as follows:
-
In the Package Explorer, double-click to open the
OsiPiSample.sbappapplication. -
Make sure each adapter's server tab uses the correct values for your PI and PI AF installations.
-
Make sure the application is the currently active tab in the EventFlow Editor, then click the
Run button. This opens the SB Test/Debug perspective and starts the application. All the adapters are configured to connect to
the PI server at startup.
-
In the Manual Input view, select the
SnapshotQueryinput stream, and enter a list of tag names to query.Click , and observe that the output stream that received the data is the
PISnapshotOutputstream, with one tuple emitted for every tag name requested. Once these tuples are emitted, one more tuple follows with itstagNamefield set to null, to indicate the end of the list. -
In the Manual Input view, select the
WriteDatainput stream, and enter a list of tags to update.Click , and observe that the output stream that received the data is the
PIWriteOutputstream. The tuple contains the results of the write operation for every requested tag. -
In the Manual Input view, select the
SummariesQueryinput 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 , and observe that the output stream that received the data is the
SummaryOutputstream, with one tuple emitted for every tag name requested. Once these tuples are emitted, one more tuple follows with itstagNamefield set to null, to indicate the end of the list. -
In the Manual Input view, select the
AFCommandsinput stream and set thecommandfield to QUERY and thequeryBasefield to a string representing the element to query.Click , and observe that the output stream that received the data is the
AFOutputstream, with one tuple emitted for every attribute found under the element. Once these tuples are emitted, one more tuple follows with itstagNamefield set to null, to indicate the end of the list. -
In the Manual Input view, select the
EFQueriesinput stream and enter a value for thesearchNameandstartTimefields, e.g.MySearch1and*.Click , and observe that the output stream that received the data is the
EFOutputstream, with one tuple emitted for every Event Frame found by the query. Once these tuples are emitted, one more tuple follows with itsevtframeIDfield set to null, to indicate the end of the list. -
In the Manual Input view, select the
SnapshotQueryinput stream, and enter a list of tag names to query.Click , and observe that the output stream that received the data is the
PIOutputstream, with one tuple emitted for every tag name requested. Once these tuples are emitted, one more tuple follows with itstagNamefield set to null, to indicate the end of the list. -
When done, press F9 or click the
Stop Running Application button.
In StreamBase Studio, import this sample with the following steps:
-
From the top menu, select → .
-
Select
OSI PIfrom the StreamBase Messaging Adapters category. -
Click OK.
StreamBase Studio creates a project for the OSI PI adapter sample in your current Studio workspace.
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 the permission problems that can occur when trying to work with the initially installed location of the sample. The default workspace location for this sample is:
studio-workspace/sample_osipiSee Default Installation Directories for the location of studio-workspace on your system.
In the default TIBCO StreamBase installation, this sample's files are initially installed in:
streambase-install-dir/sample/osipiSee Default Installation Directories for the default location of studio-workspace on your system.
