cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
Theresa3003
Level II

How do I get the PI tag names from the PI Web Server?

Dear JMP user community, 

me an my colleague are currently working on an JMP add-in that would allow our internal users to query PI tags as they want and have them all in one table with a few scripts attached and some data manipulation steps done in advance. 

So essentially, we want to reproduce and utilise the "Import from OSIsoft PI server" feature in JMP but with some adjustments to our needs.

We are currently stuck in dynamically retrieving the desired PI tag names from the PI Web server which we then want to store in a list to run the PI Client on. For now, we have a hard-coded list of some PI tags, but since the naming may change or new Pi tags might be added, that is not an ideal solution.

Using a wildcard like % would help us create finer categories of pitags - those categories will depend on prior user selection of e.g. process step, production line - but we did not have any luck finding a counterpart in jsl for lists.

Also, we cannot use SQL to query the PI web server.

This is our AF path:

Theresa3003_0-1714045705730.png

Asset_DB and Stat_DB are lists, whose content is based on user selection. Pitags is currently a hard-coded list of a few pi tags, but we want it to be based on user selection too.

My question: How did you (JMP developers) retrieve the pi tag names from the web server based on user selection?

Thanks a lot in advance!

Theresa 

2 ACCEPTED SOLUTIONS

Accepted Solutions
hecht_jmp
Staff

Re: How do I get the PI tag names from the PI Web Server?

Theresa,

 

To get the child elements at a particular level of the AF hierarchy, JMP uses the "Element - Get Elements" web API method, which is documented here: https://docs.aveva.com/bundle/pi-web-api-reference/page/help/controllers/element/actions/getelements...

 

JMP makes a request that looks something like this:
GET elements/{webId}/elements?webidtype=idonly&selectedfields=items.webid;items.name;items.description;items.path;items.haschildren;items.templatename

 

The {webId} is replaced by the webId of the path hierarchy for which you want the children. This returns a JSON description of the child elements including their names, descriptions, webIds, whether they have children, and what template they belong to, if any. You might not need all those attributes so you could trim down the 'selectedfields' query parameter to just what you need. You should be able to send a request like this using JSL's 'HTTP Request' methods. You could then parse the result using JSL's 'Parse JSON' function.

 

Hope this helps!

--Michael

View solution in original post

Re: How do I get the PI tag names from the PI Web Server?

Does your Pi Server require say, Basic authorization? if so then you'd want to use:

 

PI_web = New HTTP Request(
URL([your url]),
Method("GET"),
Secure(0),
Username([your username]),
Password([your password]),
Authentication Method("BASIC"), QueryString(qrry) ) << Send

 

View solution in original post

7 REPLIES 7
Byron_JMP
Staff

Re: How do I get the PI tag names from the PI Web Server?

I haven't done this in a while... I recall that there was a way to get an excel table of all the pi tags. Once you have that, then open it in JMP and transpose it so the tag names are in the first column. From there you can parse and filter the names to generate lists that you can use in your scripts.  

..sorry I couldn't be more specific. 

JMP Systems Engineer, Health and Life Sciences (Pharma)
Theresa3003
Level II

Re: How do I get the PI tag names from the PI Web Server?

Hi Byron, 

thank you very much for you reply!

I also had that option in the back of my head but I was hoping there is an easier way.

Best,

Theresa 

hecht_jmp
Staff

Re: How do I get the PI tag names from the PI Web Server?

Theresa,

 

To get the child elements at a particular level of the AF hierarchy, JMP uses the "Element - Get Elements" web API method, which is documented here: https://docs.aveva.com/bundle/pi-web-api-reference/page/help/controllers/element/actions/getelements...

 

JMP makes a request that looks something like this:
GET elements/{webId}/elements?webidtype=idonly&selectedfields=items.webid;items.name;items.description;items.path;items.haschildren;items.templatename

 

The {webId} is replaced by the webId of the path hierarchy for which you want the children. This returns a JSON description of the child elements including their names, descriptions, webIds, whether they have children, and what template they belong to, if any. You might not need all those attributes so you could trim down the 'selectedfields' query parameter to just what you need. You should be able to send a request like this using JSL's 'HTTP Request' methods. You could then parse the result using JSL's 'Parse JSON' function.

 

Hope this helps!

--Michael

Theresa3003
Level II

Re: How do I get the PI tag names from the PI Web Server?

Hi Michael, 

thank you very much for this neat solution!

We will go ahead and try implementing that method.  

Best wishes,

Theresa 

 

Theresa3003
Level II

Re: How do I get the PI tag names from the PI Web Server?

Hello Michael,

we have tried the "New HTTP Request" function to retrieve the pi tags from the AF hierarchy. 

Like this: 

Theresa3003_1-1714726034247.png

 

The script is being executed, but we get the following error message. Are you familiar with that error?

Theresa3003_2-1714726129305.png

 

Since we can query PI tags with the "New PI Client" function, missing authorization does not seem to be the problem. Our PI systems manager confirmed our access rights and could not find an issue with missing access rights. 

 

Thanks a lot in advance!

Theresa 

 

 

Re: How do I get the PI tag names from the PI Web Server?

Does your Pi Server require say, Basic authorization? if so then you'd want to use:

 

PI_web = New HTTP Request(
URL([your url]),
Method("GET"),
Secure(0),
Username([your username]),
Password([your password]),
Authentication Method("BASIC"), QueryString(qrry) ) << Send

 

Theresa3003
Level II

Re: How do I get the PI tag names from the PI Web Server?

Thank you Bryan, we implemented you solution using Kerberos.