Jerome Lefebvre

Dealing with paths in PI Vision 2020 Extensibility

Blog Post created by Jerome Lefebvre on Oct 20, 2020

** Added warning**

I was pointed out that the usage of PV.utils is not documented in the extensibility docs and thus may fall outside of what is supported within the extensibility framework. To see this guideline, please see this section of the extensibility docs:

OSI-Samples-PI-System/PI Vision Extensibility Guide.md at master · osisoft/OSI-Samples-PI-System · GitHub 

****

 

PI Vision 2020 brought a change to how paths are encoded, the change is great as it makes the display more resilient to changes to the AF structure. But, this impact custom symbols such as manual data entry symbols. Let's see what is the current situation and how we can resolve it.

 

Here is how a path is stored in PI Vision 2020, with additional IDs for the element and the attribute itself. These IDs are randomly generated GUIDs guaranteed to be unique on your AF server. Note this isn't enough information to create a Full WebID as that would require the ID of everything in the path. 

pathComponents = scope.symbol.DataSources[0]
"af:\\piserver\NuGreen\NuGreen\Houston\Cracking Process?7e611ef4-de82-11e9-b0b5-dcfb485d8422|Feedrate?98264fae-08e0-5a52-18be-0ca9962364ff"

As you can see there is only two GUID, thus it wouldn't be too hard to remove them by simply looking at the placements of the question marks in the path. But PV comes with utilities to help you parse this path with the PV.Utils object.

 

PV.Utils.parsePath(path)
{
  "scheme": "af",
  "path": "piserver\\NuGreen\\NuGreen\\Houston",
  "sortId": "piserver\\nugreen\\nugreen\\houston\\cracking process|feedrate?98264fae-08e0-5a52-18be-0ca9962364ff",
  "fullPath": "\\\\piserver\\NuGreen\\NuGreen\\Houston\\Cracking Process|Feedrate?98264fae-08e0-5a52-18be-0ca9962364ff",
  "label": "Cracking Process|Feedrate?98264fae-08e0-5a52-18be-0ca9962364ff",
  "parts": [
    "piserver",
    "NuGreen",
    "NuGreen",
    "Houston",
    "Cracking Process?7e611ef4-de82-11e9-b0b5-dcfb485d8422"
  ]
}

Using this, we can start to rebuild a path as you would have in previous versions of PI Vision which I do in the next few lines.

 

pathCompontent.fullPath
"\\piserver\NuGreen\NuGreen\Houston\Cracking Process|Feedrate?98264fae-08e0-5a52-18be-0ca9962364ff"
PV.Utils.removePersistId(pathCompontent.fullPath)
"\\piserver\NuGreen\NuGreen\Houston\Cracking Process|Feedrate"
path = pathCompontent.scheme + ":" + PV.Utils.removePersistId(pathCompontent.fullPath)
"af:\\piserver\NuGreen\NuGreen\Houston\Cracking Process|Feedrate"

Similarly you can build a path or webid 2.0 that you can use in PI Web API.

Outcomes