Version: 1.2.7
This sample uses OSIsoft Message Format to send real time data from the Bay Area Rapid Transit (BART) API to CONNECT data services, Edge Data Store, and/or PI Web API. Once the sample is started, a timer polls the BART API every 10 seconds for the latest real time estimated times of departure, and sends that data to the configured OMF endpoints.
Developed against DotNet 6.0
The .NET Core CLI is referenced in this sample, and should be installed to run the sample from the command line.
- Review the BART Developer License Agreement and get an API validation key from the BART API website, or use their public API key
- 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. - Enter the API key into the
BartApiKey
field ofappsettings.json
- (Optional) Update the
BartApiOri
and/orBartApiDest
fields- These fields specify the origin and destination stations to collect route data for
- These should either be a station abbreviation or the special value
"ALL"
, to use all origins and/or destinations - The default is to monitor only the San Leandro (
"SANL"
) - Daly City ("DALY"
) route - A full list of station abbreviations can be found here
Configure desired OMF endpoints to receive the data in appsettings.json
.
If sending to CONNECT data services, set SendToCds
to true.
CdsUri
can usually be left as default, but should be the host specified at the beginning of the URL in the Cds API ConsoleCdsTenantId
should be the ID that comes after/Tenants/
in the same URLCdsNamespaceId
should be the name of the Cds Namespace to receive the dataCdsClientId
should be the ID of a Client Credentials Client. This client will need to have an OMF Connection configured to the specified Namespace in order to successfully send data. To configure one, pick "OMF" from the "Type" dropdown in the Connections page.CdsClientSecret
should be the secret from the Client Credentials Client that was specified
If sending to the local Edge Data Store, set SendToEds
to true, and update EdsPort
if using a non-default port. Sending to a remote Edge Data Store is not supported.
If sending to PI Web API, set SendToPi
to true.
PiWebApiUrl
should be updated with the machine name or fully qualified domain name of the PI Web API server; if possible choose whatever value matches the certificate of the machine- PI Web API should have Basic authentication turned on as one of the allowed authentication methods, see AVEVA Live Library
Username
andPassword
should be the domain user/password that will be used to perform Basic authentication against PI Web APIValidateEndpointCertificate
may be set to false in order to bypass certificate validation when PI Web API is configured to use a self-signed certificate. This will generate a warning; this should only be done for testing with a self-signed PI Web API certificate as it is insecure.
From the command line, run
dotnet restore
dotnet run
If the appsettings.json
file has been set up, the sample will first send an OMF type message for BART estimated time of departure (ETD) data (BartStationEtd.cs) and an OMF container message for the desired routes. Then, every 10 seconds, the sample will collect real time data and send data messages to the configured OMF endpoints, until the sample is stopped.
To run the automated test, all three OMF endpoint types must be fully configured.
From the command line, run
dotnet restore
dotnet test
The test sends a single OMF type, container, and data message to each of the configured OMF endpoints. Then, the test checks that a value with a recent timestamp is found in CONNECT data services. The Edge Data Store and PI Web API OMF endpoints return an HTTP error response if they fail to process an OMF message, so it is not necessary to perform an explicit check against those endpoints.
For the main OMF samples page ReadMe For the main AVEVA samples page ReadMe