Add support for AFElement Versions
Add support for AFElement versions to PI Web API.
1. Create a new Element Version by defining the effective date and an optional version comment. 2. Add Get and Find methods which support querying AFElements by setting a QueryDate.
See also https://pisquare.osisoft.com/message/122510-re-how-to-create-a-new-af-element-version-with-pi-web-api and https://pisquare.osisoft.com/message/59027
I'm working in a business where asset changes are performed in a daily basis , and versioning is the only way to keep track and quickly compare the changes with real time process data. Versioning is a must in a controlled environment.
After several tests on working with Element Versions I went out with the following statements, please feel free to comment on that :
In order to keep track of relationship between real time data and their correspondent metadata stored in AF Element Attributes at a certain point in time the only simple solution is to create a new Element Version when this metadata changes. Another solution is to create a PI Point for every attribute that can be potentially altered during the asset change ( extremely expensive ).
Element Versioning impact heavily in the database size as every new version is a new element ( new id ), but this depends on the size of the elements and the kind of data recorded on it
Only PIAF SDK has methods to works with element versions, PI WEB API doesn't actually expose versioned elements but only the ones responding to default behaviour ( there is a bug in 2016R2 where PI Web API and PIAF SDK searches retrieves different element versions from the same query : PI Web API always show the latest one , or none )
Enabling Audit Trail ( supported only by the Enterprise versions of MS SQL Server ) give you the ability to record all the changes in the elements and attributes, it will also heavily impact the database size and performance, but doesn't satisfy requirements in statement 1 until you use versioning too.
Our current idea is to keep one AF database as element historian, and one AF database for realtime where only "active" element versions are kept.
When we activate ( we have a configuration attribute "Status" for that ) one Element Version in the AF Historian it will be transferred to the AF Realtime database overriding the existing one.
In this way if we want to make historical comparision between realtime data and metadata we will use the AF Historian Database, otherwise we will point to the AF Realtime database with the Active data.
One of the pending issues is still the simplicity of getting and writing AF Element Versions with the web interfaces, PI Web API are not yet supporting element versions and we are looking forward to have that functionality
Mahyar Sepehr commented
Thank you & here is my requirement:
I need to create Relationship between Assets (Weak References) and once it is done (several Weak References to be added).
Once, the assets linked, I would like to create one (only one) version with a given Time which might not be the current time.