Complex Dynamic OMF NodeJS Sample

February 2, 2024 ยท View on GitHub

Version: 1.1.13

ADH Test StatusEDS Test StatusPI Test Status
Build StatusBuild StatusBuild Status

This sample uses AVEVA Message Format to send data to AVEVA Data Hub, Edge Data Store, or PI Web API.

Requirements

  "dependencies": {
    "axios": "^0.21.1"
  },
  "devDependencies": {
    "jasmine": "^3.9.0",
    "jasmine-reporters": "^2.5.0"
  }

Sample Details

See ReadMe

Running the Sample

  1. Clone the GitHub repository

  2. Install node.js, installation instructions are available at node.js.

  3. Install dependencies, using the command line:

    npm ci
    
  4. Open Command Prompt in Windows

  5. Go to the folder where js files are located

  6. Rename the placeholder config file appsettings.placeholder.json to appsettings.json

  7. Update appsettings.json with the credentials for the enpoint(s) you want to send to. See Configure endpoints and authentication below for additional details

  8. Type the following command to run the test file in the local server

    node sample.js
    

Running the test

  1. Make a local copy of the git repo

  2. Install node.js, installation instructions are available at node.js.

  3. Install dependencies, using the command line:

    npm ci
    
  4. Open Command Prompt in Windows

  5. Go to the folder where js files are located

  6. Rename the placeholder config file appsettings.placeholder.json to appsettings.json

  7. Update appsettings.json with the credentials for the enpoint(s) you want to send to. See Configure endpoints and authentication below for additional details

  8. Type the following command to run the test file in the local server

    npm test
    

Configuration

The sample is configured using the file appsettings.placeholder.json. Before editing, rename this file to appsettings.json. This repository's .gitignore rules should prevent the file from ever being checked in to any fork or branch, to ensure credentials are not compromised.

The application can be configured to send to any number of endpoints specified in the endpoints array within appsettings.json. In addition, there are three types of endpoints: ADH, EDS, and PI. Each of the 3 types of enpoints are configured differently and their configurations are explained in the sections below.

ADH Endpoint Configuration

An OMF ingress client must be configured. On our AVEVA Learning Channel on YouTube we have a video on Ceating an OMF Connection.

The format of the configuration for an ADH endpoint is shown below along with descriptions of each parameter. Replace all parameters with appropriate values.

{
  "Selected": true,
  "EndpointType": "ADH",
  "Resource": "https://uswe.datahub.connect.aveva.com",
  "NamespaceId": "PLACEHOLDER_REPLACE_WITH_NAMESPACE_ID",
  "Tenant": "PLACEHOLDER_REPLACE_WITH_TENANT_ID",
  "clientId": "PLACEHOLDER_REPLACE_WITH_CLIENT_ID",
  "ClientSecret": "PLACEHOLDER_REPLACE_WITH_CLIENT_SECRET",
  "ApiVersion": "v1",
  "VerifySSL": true,
  "UseCompression": false,
  "WebRequestTimeoutSeconds": 30
}
ParametersRequiredTypeDescription
SelectedrequiredbooleanTells the application if the endpoint should be sent to
EndpointTyperequiredstringThe endpoint type. For ADH this will always be "ADH"
ResourcerequiredstringThe endpoint for ADH if the namespace. If the tenant/namespace is located in NA, it is https://uswe.datahub.connect.aveva.com and if in EMEA, it is https://euno.datahub.connect.aveva.com
NamespaceIDrequiredstringThe name of the Namespace in ADH that is being sent to
TenantrequiredstringThe Tenant ID of the Tenant in ADH that is being sent to
ClientIdrequiredstringThe client ID that is being used for authenticating to ADH
ClientSecretrequiredstringThe client secret that is being used for authenticating to ADH
ApiVersionrequiredstringThe API version of the ADH endpoint
VerifySSLoptionalbooleanA feature flag for verifying SSL when connecting to the ADH endpoint. By defualt this is set to true as it is strongly recommended that SSL be checked
UseCompressionoptionalbooleanA feature flag for enabling compression on messages sent to the ADH endpoint
WebRequestTimeoutSecondsoptionalintegerA feature flag for changing how long it takes for a request to time out

EDS Endpoint Configurations

The format of the configuration for an EDS endpoint is shown below along with descriptions of each parameter. Replace all parameters with appropriate values.

{
  "Selected": true,
  "EndpointType": "EDS",
  "Resource": "http://localhost:5590",
  "ApiVersion": "v1",
  "UseCompression": false
}
ParametersRequiredTypeDescription
SelectedrequiredbooleanTells the application if the endpoint should be sent to
EndpointTyperequiredstringThe endpoint type. For EDS this will always be "EDS"
ResourcerequiredstringThe endpoint for EDS if the namespace. If EDS is being run on your local machine with the default configuration, it will be http://localhost:5590
ApiVersionrequiredstringThe API version of the EDS endpoint
UseCompressionoptionalbooleanA feature flag for enabling compression on messages sent to the ADH endpoint
WebRequestTimeoutSecondsoptionalintegerA feature flag for changing how long it takes for a request to time out

PI Endpoint Configuration

The format of the configuration for a PI endpoint is shown below along with descriptions of each parameter. Replace all parameters with appropriate values.

{
  "Selected": true,
  "EndpointType": "PI",
  "Resource": "PLACEHOLDER_REPLACE_WITH_PI_WEB_API_URL",
  "DataArchiveName": "PLACEHOLDER_REPLACE_WITH_DATA_ARCHIVE_NAME",
  "Username": "PLACEHOLDER_REPLACE_WITH_USERNAME",
  "Password": "PLACEHOLDER_REPLACE_WITH_PASSWORD",
  "VerifySSL": true,
  "UseCompression": false
}
ParametersRequiredTypeDescription
SelectedrequiredbooleanTells the application if the endpoint should be sent to
EndpointTyperequiredstringThe endpoint type. For PI this will always be "PI"
ResourcerequiredstringThe URL of the PI Web API
DataArchiveNamerequiredstringThe name of the PI Data Archive that is being sent to
UsernamerequiredstringThe username that is being used for authenticating to the PI Web API
PasswordrequiredstringThe password that is being used for authenticating to the PI Web API
VerifySSLoptionalboolean/stringA feature flag for verifying SSL when connecting to the PI Web API. Alternatively, this can specify the path to a .pem certificate file if a self-signed certificate is being used by the PI Web API. By defualt this is set to true as it is strongly recommended that SSL be checked.
UseCompressionoptionalbooleanA feature flag for enabling compression on messages sent to the ADH endpoint
WebRequestTimeoutSecondsoptionalintegerA feature flag for changing how long it takes for a request to time out

For the main OMF Complex Dynamic samples page ReadMe
For the main OMF samples page ReadMe
For the main AVEVA samples page ReadMe