Skip to content

Commit

Permalink
updated osisoft links to aveva
Browse files Browse the repository at this point in the history
  • Loading branch information
prajwal-aveva committed Aug 2, 2024
1 parent c708aae commit 0674b79
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

**Version:** 1.1.7

[![Build Status](https://dev.azure.com/osieng/engineering/_apis/build/status/product-readiness/PI-System/aveva.sample-afsdk-event_triggered_calculation-dotnet?branchName=main)](https://dev.azure.com/osieng/engineering/_build/latest?definitionId=3928&branchName=main)
[![Build Status](https://dev.azure.com/AVEVA-VSTS/Cloud%20Platform/_apis/build/status%2Fproduct-readiness%2FAFSDK%2FAVEVA.sample-afsdk-event_triggered_calculation-dotnet?repoName=AVEVA%2Fsample-afsdk-event_triggered_calculation-dotnet&branchName=main)](https://dev.azure.com/AVEVA-VSTS/Cloud%20Platform/_build/latest?definitionId=16182&repoName=AVEVA%2Fsample-afsdk-event_triggered_calculation-dotnet&branchName=main)

Built with:
- .NET Framework 4.8
Expand All @@ -16,7 +16,7 @@ Previously, this use case was handled by either PI Advanced Computing Engine (AC

## Calculation Work Flow

The sample code is intended to provide a starting point that matches the feel of a naturally scheduled (event-triggered) ACE calculation executing on snapshot updates of the input tag(s). To demonstrate scalability by reusing the same calculation logic for a large number of calculations, any number AF Elements can be specified in [appsettings.json](EventTriggeredCalc/appsettings.placeholder.json). The calculation will build a client-side [AF data cache](https://docs.osisoft.com/bundle/af-sdk/page/html/T_OSIsoft_AF_Data_AFDataCache.htm) of the calculation's input attributes for each element. The data cache stays current by subscribing to updates from the AF Server via the cache's internal [AFDataPipe object](https://docs.osisoft.com/bundle/af-sdk/page/html/T_OSIsoft_AF_Data_AFDataPipe.htm), and these updates will selectively trigger new calculations for its corresponding element. The output tag is written to via the client-side cache as well so that when its previous value is read in, it's guaranteed to be the previous value as its read is not in a race condition with the internal workings of the Data Archive to store the previous value in the snapshot or the archive file.
The sample code is intended to provide a starting point that matches the feel of a naturally scheduled (event-triggered) ACE calculation executing on snapshot updates of the input tag(s). To demonstrate scalability by reusing the same calculation logic for a large number of calculations, any number AF Elements can be specified in [appsettings.json](EventTriggeredCalc/appsettings.placeholder.json). The calculation will build a client-side [AF data cache](https://docs.aveva.com/bundle/af-sdk/page/html/T_OSIsoft_AF_Data_AFDataCache.htm) of the calculation's input attributes for each element. The data cache stays current by subscribing to updates from the AF Server via the cache's internal [AFDataPipe object](https://docs.aveva.com/bundle/af-sdk/page/html/T_OSIsoft_AF_Data_AFDataPipe.htm), and these updates will selectively trigger new calculations for its corresponding element. The output tag is written to via the client-side cache as well so that when its previous value is read in, it's guaranteed to be the previous value as its read is not in a race condition with the internal workings of the Data Archive to store the previous value in the snapshot or the archive file.

A [Cancellation Token](https://docs.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken?view=netframework-4.8) is used to end the calculation loop so that it can run indefinitely but be cancelled on demand. In this sample, the cancellation occurs when the user hits `ENTER`, but this is a demonstration of how to cancel the operation gracefully.

Expand All @@ -25,7 +25,7 @@ Overall Flow:
1. If blank, the application will use the user's default AF Server and the AF Server's default database
1. The connection is made implicitly under the identity of the Windows account executing the code
1. For each element in the context list:
1. The element name is resolved into an [AFElement](https://docs.osisoft.com/bundle/af-sdk/page/html/T_OSIsoft_AF_Asset_AFElement.htm) object
1. The element name is resolved into an [AFElement](https://docs.aveva.com/bundle/af-sdk/page/html/T_OSIsoft_AF_Asset_AFElement.htm) object
1. The `Temperature`, `Pressure`, `Volume`, and `Moles` attributes are resolved
1. If successful, the attributes are added to the data cache's attribute list
1. If the element or any attribute could not be resolved, a warning is outputted to the console and the application moves on to the next context. This allows the application to work against all resolvable contexts
Expand All @@ -36,21 +36,21 @@ Overall Flow:
1. The sample loops until cancelled

On each update:
1. The observer passes the [AFDataPipeEvent](https://docs.osisoft.com/bundle/af-sdk/page/html/T_OSIsoft_AF_Data_AFDataPipeEvent.htm) to the ProcessUpdate() method one at a time
1. The observer passes the [AFDataPipeEvent](https://docs.aveva.com/bundle/af-sdk/page/html/T_OSIsoft_AF_Data_AFDataPipeEvent.htm) to the ProcessUpdate() method one at a time
1. The ProcessUpdate() method determines if the updating attribute should trigger a new calculation

Calculation Logic:
*Note*: The calculation logic itself is not the main purpose of the sample, but it demonstrates a complex, conditional, looping calculation that is beyond the functionality of Asset Analytics.

1. A [RecordedValuesByCount](https://docs.osisoft.com/bundle/af-sdk/page/html/M_OSIsoft_AF_Data_AFData_RecordedValuesByCount.htm) call returns the 100 most recent values each for both `Temperature` and `Pressure`, backwards in time from the triggering timestamp
1. Bad values are removed from the [AFValues](https://docs.osisoft.com/bundle/af-sdk/page/html/T_OSIsoft_AF_Asset_AFValues.htm) object.
1. A [RecordedValuesByCount](https://docs.aveva.com/bundle/af-sdk/page/html/M_OSIsoft_AF_Data_AFData_RecordedValuesByCount.htm) call returns the 100 most recent values each for both `Temperature` and `Pressure`, backwards in time from the triggering timestamp
1. Bad values are removed from the [AFValues](https://docs.aveva.com/bundle/af-sdk/page/html/T_OSIsoft_AF_Asset_AFValues.htm) object.
1. Looping indefinitely for each attribute:
1. The standard deviation of the list of remaining values is determined
1. Any value outside of 1.75 standard deviations is eliminated
1. Once no new values are eliminated, the mean of the remaining values is determined
1. `Volume` is a static attribute, so its [end of stream](https://docs.osisoft.com/bundle/af-sdk/page/html/M_OSIsoft_AF_Data_AFData_EndOfStream.htm) value is returned
1. `Volume` is a static attribute, so its [end of stream](https://docs.aveva.com/bundle/af-sdk/page/html/M_OSIsoft_AF_Data_AFData_EndOfStream.htm) value is returned
1. Each of these values are used, with the [Gas Constant](https://en.wikipedia.org/wiki/Gas_constant) to determine the number of moles in the reactor
1. [AF Units of Measure](https://docs.osisoft.com/bundle/af-sdk/page/html/N_OSIsoft_AF_UnitsOfMeasure.htm) are used to ensure the values are the expected units, regardless of how they are stored in the underlying PI Points
1. [AF Units of Measure](https://docs.aveva.com/bundle/af-sdk/page/html/N_OSIsoft_AF_UnitsOfMeasure.htm) are used to ensure the values are the expected units, regardless of how they are stored in the underlying PI Points
1. This value is written to the output attribute's data cache, which makes it immediately available for robust reads and also starts the process of writing the value to the Data Archive
1. The previous value for the output attribute is read in, and a rate of change is determined
1. This value is written to the `MolarFlowRate` attribute. This is not cached as this attribute is not an input for the calculation, and therefore the client-side caching is not necessary
Expand Down Expand Up @@ -86,7 +86,7 @@ The sample is configured using the file [appsettings.placeholder.json](EventTrig
}
```

The sample uses an implicit connection to the PI Data Archive under the context of the account running the application. For guidance on using an explicit connection, see the [Connecting to a PI Data Archive AF SDK reference](https://docs.osisoft.com/bundle/af-sdk/page/html/connecting-to-a-pi-data-archive.htm).
The sample uses an implicit connection to the PI Data Archive under the context of the account running the application. For guidance on using an explicit connection, see the [Connecting to a PI Data Archive AF SDK reference](https://docs.aveva.com/bundle/af-sdk/page/html/connecting-to-a-pi-data-archive.htm).

1. Clone the sample repository to a local folder
1. In the EventTriggeredCalc directory, create appsettings.json from [appsettings.placeholder.json](EventTriggeredCalc/appsettings.placeholder.json) and edit the configuration as necessary
Expand All @@ -108,9 +108,9 @@ The sample uses an implicit connection to the PI Data Archive under the context

The test in [EventTriggeredCalcTests](EventTriggeredCalcTests/UnitTests.cs) tests the sample's purpose of providing a framework for calculations to loop indefinitely on snapshot updates by doing the following:
1. Connects to the specified AF Server
1. Creates an [AFElementTemplate](https://docs.osisoft.com/bundle/af-sdk/page/html/T_OSIsoft_AF_Asset_AFElementTemplate.htm) with the necessary [AFAttributeTemplates](https://docs.osisoft.com/bundle/af-sdk/page/html/T_OSIsoft_AF_Asset_AFAttributeTemplate.htm)
1. Creates an [AFElementTemplate](https://docs.aveva.com/bundle/af-sdk/page/html/T_OSIsoft_AF_Asset_AFElementTemplate.htm) with the necessary [AFAttributeTemplates](https://docs.aveva.com/bundle/af-sdk/page/html/T_OSIsoft_AF_Asset_AFAttributeTemplate.htm)
1. Creates an element with this template for each name in the context list
1. Creates the attributes' underlying PI Points with [AFDataReference.CreateConfig](https://docs.osisoft.com/bundle/af-sdk/page/html/M_OSIsoft_AF_Asset_AFDataReference_CreateConfig_1.htm)
1. Creates the attributes' underlying PI Points with [AFDataReference.CreateConfig](https://docs.aveva.com/bundle/af-sdk/page/html/M_OSIsoft_AF_Asset_AFDataReference_CreateConfig_1.htm)
1. Writes to the input attributes to prepare them for the calculation
1. Creates a cancellation token source and calls the sample, passing it the token
1. Writes three values to each input trigger attribute and one value to the non-triggering input attribute
Expand All @@ -130,6 +130,6 @@ dotnet test
- Note: The above command uses the [nuget CLI](https://docs.microsoft.com/en-us/nuget/consume-packages/install-use-packages-nuget-cli)
---

For the main AF SDK Custom Calculations Samples landing page [ReadMe](https://github.com/osisoft/OSI-Samples-PI-System/tree/main/docs/AF-SDK-Custom-Calculations-Docs)
For the main PI System Samples landing page [ReadMe](https://github.com/osisoft/OSI-Samples-PI-System)
For the main AVEVA Samples landing page [ReadMe](https://github.com/osisoft/OSI-Samples)
For the main AF SDK Custom Calculations Samples landing page [ReadMe](https://github.com/AVEVA/AVEVA-Samples-PI-System/tree/main/docs/AF-SDK-Custom-Calculations-Docs)
For the main PI System Samples landing page [ReadMe](https://github.com/AVEVA/AVEVA-Samples-PI-System)
For the main AVEVA Samples landing page [ReadMe](https://github.com/AVEVA/AVEVA-Samples)

0 comments on commit 0674b79

Please sign in to comment.