Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename changes from adh to cds and updated links #65

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions BartIngress/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,37 @@ public class AppSettings

#endregion

#region AVEVA Data Hub Settings
#region CONNECT data services Settings

/// <summary>
/// Specifies whether this application should send to AVEVA Data Hub
/// Specifies whether this application should send to CONNECT data services
/// </summary>
public bool SendToAdh { get; set; }
public bool SendToCds { get; set; }

/// <summary>
/// AVEVA Data Hub OMF Endpoint URI
/// CONNECT data services OMF Endpoint URI
/// </summary>
public Uri AdhUri { get; set; }
public Uri CdsUri { get; set; }

/// <summary>
/// AVEVA Data Hub Tenant ID
/// CONNECT data services Tenant ID
/// </summary>
public string AdhTenantId { get; set; }
public string CdsTenantId { get; set; }

/// <summary>
/// AVEVA Data Hub Namespace ID
/// CONNECT data services Namespace ID
/// </summary>
public string AdhNamespaceId { get; set; }
public string CdsNamespaceId { get; set; }

/// <summary>
/// AVEVA Data Hub Client ID
/// CONNECT data services Client ID
/// </summary>
public string AdhClientId { get; set; }
public string CdsClientId { get; set; }

/// <summary>
/// AVEVA Data Hub Client Secret
/// CONNECT data services Client Secret
/// </summary>
public string AdhClientSecret { get; set; }
public string CdsClientSecret { get; set; }

#endregion

Expand Down
44 changes: 22 additions & 22 deletions BartIngress/OmfServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
namespace BartIngress
{
/// <summary>
/// Manages sending OMF data to the ADH, EDS, and/or PI Web API OMF endpoints
/// Manages sending OMF data to the Cds, EDS, and/or PI Web API OMF endpoints
/// </summary>
public class OmfServices : IDisposable
{
private OmfMessage _typeDeleteMessage;
private OmfMessage _containerDeleteMessage;

private AuthenticationHandler AdhAuthenticationHandler { get; set; }
private HttpClient AdhHttpClient { get; set; }
private AuthenticationHandler CdsAuthenticationHandler { get; set; }
private HttpClient CdsHttpClient { get; set; }
private HttpClient EdsHttpClient { get; set; }
private HttpClientHandler PiHttpClientHandler { get; set; }
private HttpClient PiHttpClient { get; set; }
Expand All @@ -30,23 +30,23 @@ public void Dispose()
}

/// <summary>
/// Configure ADH OMF Ingress Service
/// Configure Cds OMF Ingress Service
/// </summary>
/// <param name="adhUri">AVEVA Data Hub OMF Endpoint URI</param>
/// <param name="tenantId">AVEVA Data Hub Tenant ID</param>
/// <param name="namespaceId">AVEVA Data Hub Namespace ID</param>
/// <param name="clientId">AVEVA Data Hub Client ID</param>
/// <param name="clientSecret">AVEVA Data Hub Client Secret</param>
internal void ConfigureAdhOmfIngress(Uri adhUri, string tenantId, string namespaceId, string clientId, string clientSecret)
/// <param name="CdsUri">CONNECT data services OMF Endpoint URI</param>
/// <param name="tenantId">CONNECT data services Tenant ID</param>
/// <param name="namespaceId">CONNECT data services Namespace ID</param>
/// <param name="clientId">CONNECT data services Client ID</param>
/// <param name="clientSecret">CONNECT data services Client Secret</param>
internal void ConfigureCdsOmfIngress(Uri CdsUri, string tenantId, string namespaceId, string clientId, string clientSecret)
{
AdhAuthenticationHandler = new AuthenticationHandler(adhUri, clientId, clientSecret)
CdsAuthenticationHandler = new AuthenticationHandler(CdsUri, clientId, clientSecret)
{
InnerHandler = new HttpClientHandler(),
};

AdhHttpClient = new HttpClient(AdhAuthenticationHandler)
CdsHttpClient = new HttpClient(CdsAuthenticationHandler)
{
BaseAddress = new Uri(adhUri.AbsoluteUri + $"api/v1/tenants/{tenantId}/namespaces/{namespaceId}/omf"),
BaseAddress = new Uri(CdsUri.AbsoluteUri + $"api/v1/tenants/{tenantId}/namespaces/{namespaceId}/omf"),
};
}

Expand Down Expand Up @@ -144,9 +144,9 @@ internal void SendOmfMessage(OmfMessage omfMessage)
{
SerializedOmfMessage serializedOmfMessage = OmfMessageSerializer.Serialize(omfMessage);

if (AdhHttpClient != null)
if (CdsHttpClient != null)
{
_ = SendOmfMessageAsync(serializedOmfMessage, AdhHttpClient).Result;
_ = SendOmfMessageAsync(serializedOmfMessage, CdsHttpClient).Result;
}

if (EdsHttpClient != null)
Expand All @@ -168,10 +168,10 @@ internal void CleanupOmf()
SerializedOmfMessage serializedTypeDelete = OmfMessageSerializer.Serialize(_typeDeleteMessage);
SerializedOmfMessage serializedContainerDelete = OmfMessageSerializer.Serialize(_containerDeleteMessage);

if (AdhHttpClient != null)
if (CdsHttpClient != null)
{
_ = SendOmfMessageAsync(serializedContainerDelete, AdhHttpClient).Result;
_ = SendOmfMessageAsync(serializedTypeDelete, AdhHttpClient).Result;
_ = SendOmfMessageAsync(serializedContainerDelete, CdsHttpClient).Result;
_ = SendOmfMessageAsync(serializedTypeDelete, CdsHttpClient).Result;
}

if (EdsHttpClient != null)
Expand All @@ -191,14 +191,14 @@ protected virtual void Dispose(bool includeManaged)
{
if (includeManaged)
{
if (AdhAuthenticationHandler != null)
if (CdsAuthenticationHandler != null)
{
AdhAuthenticationHandler.Dispose();
CdsAuthenticationHandler.Dispose();
}

if (AdhHttpClient != null)
if (CdsHttpClient != null)
{
AdhHttpClient.Dispose();
CdsHttpClient.Dispose();
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions BartIngress/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public static void LoadConfiguration()

OmfServices = new OmfServices();

if (Settings.SendToAdh)
if (Settings.SendToCds)
{
OmfServices.ConfigureAdhOmfIngress(Settings.AdhUri, Settings.AdhTenantId, Settings.AdhNamespaceId, Settings.AdhClientId, Settings.AdhClientSecret);
OmfServices.ConfigureCdsOmfIngress(Settings.CdsUri, Settings.CdsTenantId, Settings.CdsNamespaceId, Settings.CdsClientId, Settings.CdsClientSecret);
}

if (Settings.SendToEds)
Expand Down
12 changes: 6 additions & 6 deletions BartIngress/appsettings.placeholder.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"BartApiOrig": "SANL",
"BartApiDest": "DALY",

"SendToAdh": false,
"AdhUri": "https://uswe.datahub.connect.aveva.com",
"AdhTenantId": "PLACEHOLDER_REPLACE_WITH_TENANT_ID",
"AdhNamespaceId": "PLACEHOLDER_REPLACE_WITH_NAMESPACE_ID",
"AdhClientId": "PLACEHOLDER_REPLACE_WITH_CLIENT_ID",
"AdhClientSecret": "PLACEHOLDER_REPLACE_WITH_CLIENT_SECRET",
"SendToCds": false,
"CdsUri": "https://uswe.datahub.connect.aveva.com",
"CdsTenantId": "PLACEHOLDER_REPLACE_WITH_TENANT_ID",
"CdsNamespaceId": "PLACEHOLDER_REPLACE_WITH_NAMESPACE_ID",
"CdsClientId": "PLACEHOLDER_REPLACE_WITH_CLIENT_ID",
"CdsClientSecret": "PLACEHOLDER_REPLACE_WITH_CLIENT_SECRET",

"SendToEds": false,
"EdsPort": 5590,
Expand Down
14 changes: 7 additions & 7 deletions BartIngressTests/UnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ public void BartIngressTest()
{
Program.RunIngress();

// Wait for data to be processed by ADH
// Wait for data to be processed by Cds
Thread.Sleep(5000);

// Edge Data Store and PI Web API process OMF before sending a response, and will return an error code if there is a problem
// In this test, the call to RunIngress above will result in an exception if there is a failure on either of those endpoints

// ADH does not validate OMF before sending a success response, so the test must check that the messages were successful
using AuthenticationHandler adhAuthenticationHandler = new (Program.Settings.AdhUri, Program.Settings.AdhClientId, Program.Settings.AdhClientSecret);
SdsService adhSdsService = new (Program.Settings.AdhUri, null, HttpCompressionMethod.GZip, adhAuthenticationHandler);
ISdsDataService adhDataService = adhSdsService.GetDataService(Program.Settings.AdhTenantId, Program.Settings.AdhNamespaceId);
BartStationEtd adhValue = adhDataService.GetLastValueAsync<BartStationEtd>(streamId).Result;
Assert.True(adhValue.TimeStamp > verifyTimestamp);
// Cds does not validate OMF before sending a success response, so the test must check that the messages were successful
using AuthenticationHandler CdsAuthenticationHandler = new (Program.Settings.CdsUri, Program.Settings.CdsClientId, Program.Settings.CdsClientSecret);
SdsService cdsSdsService = new (Program.Settings.CdsUri, null, HttpCompressionMethod.GZip, CdsAuthenticationHandler);
ISdsDataService cdsDataService = cdsSdsService.GetDataService(Program.Settings.CdsTenantId, Program.Settings.CdsNamespaceId);
BartStationEtd cdsValue = cdsDataService.GetLastValueAsync<BartStationEtd>(streamId).Result;
Assert.True(cdsValue.TimeStamp > verifyTimestamp);
}
finally
{
Expand Down
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

**Version:** 1.2.7

[![Build Status](https://dev.azure.com/osieng/engineering/_apis/build/status/product-readiness/OMF/aveva.sample-omf-bart_ingress-dotnet?branchName=main)](https://dev.azure.com/osieng/engineering/_build/latest?definitionId=2633&branchName=main)
[![Build Status](https://dev.azure.com/AVEVA-VSTS/Cloud%20Platform/_apis/build/status%2Fproduct-readiness%2FOMF%2FAVEVA.sample-omf-bart_ingress-dotnet?branchName=main)](https://dev.azure.com/AVEVA-VSTS/Cloud%20Platform/_build/latest?definitionId=16158&branchName=main)

This sample uses OSIsoft Message Format to send real time data from the Bay Area Rapid Transit (BART) API to AVEVA Data Hub, 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.
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

Expand All @@ -27,15 +27,15 @@ The [.NET Core CLI](https://docs.microsoft.com/en-us/dotnet/core/tools/) is refe

Configure desired OMF endpoints to receive the data in `appsettings.json`.

#### AVEVA Data Hub
#### CONNECT data services

If sending to AVEVA Data Hub, set `SendToAdh` to true.
If sending to CONNECT data services, set `SendToCds` to true.

1. `AdhUri` can usually be left as default, but should be the host specified at the beginning of the URL in the [ADH API Console](https://datahub.connect.aveva.com/apiconsole)
1. `AdhTenantId` should be the ID that comes after `/Tenants/` in the same URL
1. `AdhNamespaceId` should be the name of the ADH Namespace to receive the data
1. `AdhClientId` should be the ID of a [Client Credentials Client](https://datahub.connect.aveva.com/clients). 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](https://datahub.connect.aveva.com/connections) page.
1. `AdhClientSecret` should be the secret from the Client Credentials Client that was specified
1. `CdsUri` can usually be left as default, but should be the host specified at the beginning of the URL in the [Cds API Console](https://datahub.connect.aveva.com/apiconsole)
1. `CdsTenantId` should be the ID that comes after `/Tenants/` in the same URL
1. `CdsNamespaceId` should be the name of the Cds Namespace to receive the data
1. `CdsClientId` should be the ID of a [Client Credentials Client](https://datahub.connect.aveva.com/clients). 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](https://datahub.connect.aveva.com/connections) page.
1. `CdsClientSecret` should be the secret from the Client Credentials Client that was specified

#### Edge Data Store

Expand All @@ -46,7 +46,7 @@ If sending to the local Edge Data Store, set `SendToEds` to true, and update `Ed
If sending to PI Web API, set `SendToPi` to true.

1. `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
1. PI Web API should have Basic authentication turned on as one of the allowed authentication methods, see [AVEVA Live Library](https://livelibrary.osisoft.com/LiveLibrary/web/ui.xql?action=html&resource=publist_home.html&pub_category=PI-Web-API)
1. PI Web API should have Basic authentication turned on as one of the allowed authentication methods, see [AVEVA Live Library](https://docs.aveva.com/bundle/omf-with-pi-web-api/page/1017430.html)
1. `Username` and `Password` should be the domain user/password that will be used to perform Basic authentication against PI Web API
1. `ValidateEndpointCertificate` 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.

Expand All @@ -72,9 +72,9 @@ 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 AVEVA Data Hub. 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.
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](https://github.com/osisoft/OSI-Samples-OMF)
For the main AVEVA samples page [ReadMe](https://github.com/osisoft/OSI-Samples)
For the main OMF samples page [ReadMe](https://github.com/AVEVA/AVEVA-Samples-OMF)
For the main AVEVA samples page [ReadMe](https://github.com/AVEVA/AVEVA-Samples)
12 changes: 6 additions & 6 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ jobs:
name: ${{ parameters.pool }}
demands: ${{ parameters.containerDemands }}
variables:
- name: AdhTenantId
- name: CdsTenantId
value: $(TenantId)
- name: AdhNamespaceId
- name: CdsNamespaceId
value: $(NamespaceId)
- name: AdhClientId
- name: CdsClientId
value: $(ClientId)
- name: AdhClientSecret
- name: CdsClientSecret
value: $(ClientSecret)
- name: PiWebApiUri
value: $(PIWebAPI)
- name: AdhUri
- name: CdsUri
value: $(Resource)
- name: SendToAdh
- name: SendToCds
value: true
- name: SendToEds
value: true
Expand Down