ETP Adapter Sample

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

Prerequisites

Note

The ETP adapters are provided for Microsoft Windows systems only.

In order to run correctly, the adapters in this sample require that the Microsoft .NET Framework 4.8 or later be installed on your machine.

The sample's configuration file must be edited prior to running the sample to point to a working, accessible ETP server (with, optionally, additional settings to specify any required authentication credentials).

To configure the sample to connect to a different server, modify the server-url entry of src/main/configurations/ETP.conf to point to the ETP server of your choice. If this server requires authentication or use of a proxy server, you will also need to modify these values as applicable:

  • username

  • password

  • proxy-host

  • proxy-port

  • proxy-username

  • proxy-password

Sample Overview

This sample demonstrates the adapters in the ETP adapter suite:

  • Control

  • Discovery

  • Get

  • Streaming

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 etp to narrow the list of options.

  • Select ETP adapters from the IoT Adapters category.

  • Click Import Now.

StreamBase Studio creates a project for the ETP 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 this sample's folder.

    Keep an eye on the bottom right status bar of the Studio window. Make sure any Updating, Downloading, Building, or Rebuild project messages finish before you proceed.

  2. Open the src/main/configurations folder.

  3. Open the ETP.conf configuration file, and edit the server-url setting to point to a running ETP server. You may also need to edit other settings such as username and password, or the proxy-related entries, depending on your ETP server's connection requirements.

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

  5. Open the etp.sbapp file and click the Run button. This opens the SB Test/Debug perspective and starts the module.

  6. Wait for the Control operator to issue a status tuple indicating the connection was successful. If a connection problem occurs the console will provide more information.

  7. In the Manual Input view, select the DiscoveryIn input stream, and enter eml:// in the uri field, then click Send. This will return one or more tuples on the DiscoveryResults output stream containing the entries representing all the top-level nodes available on your ETP server. For each of these entries, you can feed the value of the resource.uri field back to the DiscoveryIn stream to drill down and browse that node's children nodes.

  8. In the manner described in the previous step, drill down to a child node whose contentType is included in the list returned initially by the Control operator's Connected status tuple in its serverInfo.supportedObjects field. Use the node's uri field's value as the input for the GetIn stream's uri field, to query the node's value.

  9. In the Manual Input view, select the StreamingIn input stream, and enter the following field values:

    • command: describe

    • uris: The value of the DiscoveryResults' uri field that you used in the previous step

    Click Send Data, and observe that StreamingStatus output stream acknowledged the success of the operation, and the StreamingMetadataResults output stream also emitted a tuple containing the description of the requested node. Its channels field contains a list of all subscribable values. You can use the channelID value of one or more of these entries to subscribe to real-time updates of these values by setting the StreamingIn stream's command field to streamingStart and create entries in the channelInfos list field, taking care to also set the receiveNotifications field's value to true (otherwise only a snapshot value will be returned rather than real-time updates). To initiate a subscription and start getting real-time updates on those value from the operator's StreamingDataResult output port.

  10. You can stop the subscriptions initiated in the previous step by setting the command field to streamingstop and filling in the channelIDs field with the list of channelID values for which you no longer wish to receive updates.

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

This Sample's Files

This sample contains the following files:

  • The sample EventFlow application, etp.sbapp, located in the src/main/eventflow/packageName folder.

  • The adapter configuration file, ETP.conf, located in src/main/configurations.

  • 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_etp

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