Axiom Script for Retrieving Parent Asset Tag
This Axiom script allows you to automatically visualize the correct tag belonging to the parent asset of your selected asset.
I have an Axiom application using screen-level assets called completions, and it's primarily being used by passing in URL parameters for asset instances of completions. However, one issue I ran into is that I wanted a tag from the parent asset, a well, and I wanted that tag path to update according to whichever completion was selected. A well can have multiple children completions associated with it, and the application had to keep using screen-level completion assets for the URL parameters (and the majority of the tags are completion level).
The desired tag, Supply Pressure, exists only once from the historian, and it exists on the well level, like SourceInfo.Well.Supply Pressure.PV.
In this scenario, I created the above script to trigger "OnEndAssetChange" for the screen, named "CompletionsOverview", and update the "valSupplyPressure" Value Box on my screen to use the source tag of whichever well is the parent of the newly selected completion asset.
valSupplyPressure is the Name for the Value Box on my screen for the Supply Pressure.
The largest block takes the newAsset, which will be a completion, and it returns the wellAsset path. In our View architecture, that means SourceInfo.Well.Completion becomes SourceInfo.Well. It does this by removing the final level in the tag path then returning that string.
Next, since I know the tag I'm looking for is Supply Pressure, I append the remainder of its tag path to wellAsset.
Lastly, I update the value box on the screen to use the supply pressure for the parent well as its source tag. Since I am updating the source tag property and not setting the value, error handling is performed by Axiom already. For example, a NoData would simply show as NoData in the value box, without any errors occurring in the script.
Here's another example explanation using one of Canary's View examples:
Creating a Virtual View (version 22) - Views and Asset Models - Canary Community (canarylabs.com)
A script like this would allow a Boiler-level screen to automatically update a value box for a tag only associated with a Line such as a setpoint or pressure since a Line is a parent to multiple Boiler children.
Here are some considerations. I'm fairly novice at C# still, so there's probably a better way to implement the assetPath trimming. For example, if you needed to trim off two levels instead of one, you must remember that pieceList.Count (length of the list, essentially) will update after you do the first RemoveAt(). This method also assumes your view is accurate and that parents will always be one level above the parents.
1 reply
-
Nice work bmhargis !
Thanks for sharing!