[feature-9544]Query a list of tag providers in a gateway?

Hi,
I’d like to get a list of tag providers in a gateway.
I use system.tag.browseTags to [System]Gateway/Tags
However, there’s not all tag providers in there.
Is there any other way to do to achieve that?

Thanks

The [System]Gateway/Tags/ folder has entries for each general tag provider. You might find the attached shared script module helpful. First published last year.

I’m curious which providers are missing?

Remote tag providers do not get listed here…

There’s a feature request pending for this - but you can use a message handler to ask the gateway for this information:

	from com.inductiveautomation.ignition.gateway import SRContext
	context = SRContext.get()
	output = []
	for provider in context.getTagManager().getTagProviders():
		output.append(provider.getInformation().getName())
	return output

Awesome! Thanks, that was easy

Hey – just wondering if there is a way to do this in version 8? Doesn’t look like SRContext is in com.inductiveautomation.ignition.gateway anymore:
com.inductiveautomation.ignition.gateway

think i have it sorted out now – took a while to get my head wrapped around the various “contexts” and discover which packages/modules are available from the various contexts…

I was trying to populate a provider list in the designer/client – seems like I just need to access the “context” of the object running the script – e.g.:

context = event.source.getAppContext()
# context = event.source.getAccessibleContext()

or

context = self.getAppContext()
# context = self.getAccessibleContext()

from there – all of what is mentioned above applies (e.g. getting the tag manager, getting the provider props):

provs = []
tm = context.getTagManager()
provprops = tm.getProviderProperties()
for p in provprops:
        provs.append(p.getName())

Hi PGriffith …Was the feature request you mentioned ever implemented?

Not yet. Our low priority feature backlog is pretty long. There might be another way to back into the same information in 8.0 via system.tag.browse; I’m not sure.

Thanks for the quick reply!

PGriffen, this doesn’t seem to be working for me I have configured a gateway message handler with the following code:

from com.inductiveautomation.ignition.gateway.tags.model import GatewayTagManager as tm
provider = tm.getTagProviderNames()
payload = {'key':provider}

I then use a button to request the message handler to run script and give me this messages so i can display it to a label. When checking gateway script status for the handler it doesn’t seem to work or want to run?

GatewayTagManager doesn’t have a static method getTagProviderNames(), it has an instance method getTagProviderNames - you need to obtain an instance of GatewayTagManager before you can call the method; that’s what the SRContext import in the snippet I posted is for. SRContext was renamed IgnitionGateway in 8.0 and up.

2 Likes

You’ve imported the gateway tag manager class, not an instance. You’re probably going to have to import IgnitionGateway and use its static method to get its singleton, and then get its tag manager instance.

Where in the JavaDoc are you pulling that ? I’m confused where the package is ?

Thought I’d add for completeness as I was googling this question. Maybe someone can use it.

A script to list all tag providers can be simply done with system.tag.browse as below.

def tagProviders():
	tags=system.tag.browse(filter={"tagType":"Provider"}).results
	a=[]
	for result in tags:
		providers=str(result['fullPath'])
		a.append(providers)
	return a	
6 Likes