Remote Tag Provider History Queries

No. Given an RTP name or RTP object, something has to cough up a gateway name. How would you know what IP to point that URL at?

Makes me wonder how difficult it would be to write a message function that broadcasts to all servers on the GAN, as opposed to assuming the local server unless a remote server is provided.

hmmm....

1 Like

What about automating the documentation by having a couple of tags in the remote provider that are auto-populated (not sure what the best trigger would be to be honest) with the originating gateway's name and real provider name?

Still a hack but hopefully a little less error-prone that way. The trigger is kind of an issue though because if someone renames the upstream provider we want to know about it right away.

My plan is to use reflection on the non-public fields for now, and agitate for a public API in v8.3. This is for a generic utility (coming to the Exchange soon) for which such work-arounds are not really appropriate.

3 Likes

Well, if 8.3 does have a full RESTful API, then I would think you could get everything you need even if it is just communicating with itself to grab the data (although it wouldn't be as efficient as being able to pull it directly via a script).

1 Like

Good point.

Could you just inject a custom property string inside the realtime tag provider's tags, then read its value over the gateway network?
Edit nvm that looks like what @Felipe_CRM suggested upthread.

I just ran into this issue this afternoon and came up with the following solution for my application. This runs as a script transform on an expression binding.

I query the database tables in the historian to collect the required info an use that to concatenate a historical tag path.

This script produces this path as an output. histprov:HistDB:/drv:Site_023:edge:/tag:gln/gln_lit_051_li/ind pv

		# Query the historian database tables for required information.
		query = """
			SELECT TOP 1
				te.tagpath,
				drv.name AS driver_name,
				drv.provider as provider
			FROM 
			    sqlth_te AS te
			JOIN 
			    sqlth_scinfo AS scinfo ON te.scid = scinfo.id
			JOIN 
			    sqlth_drv AS drv ON scinfo.drvid = drv.id
			WHERE 
			    te.tagpath = ?
			"""
	
		# Get default DB connection for this project. 
		database = system.db.getConnectionInfo().getValueAt(0, "name")
		
		# Execute query against the default DB for this project. Replace tag path with your own. I use a custom property to pass the tag just showing it as an example. 
		results = system.db.runPrepQuery(query, ['GLN/GLN_LIT_051_LI/ind pv'], database)
		
		# Extract driver name and provider from query result. 
		drive_name = results.getValueAt(0,'driver_name')
		provider = results.getValueAt(0,'provider')
		tagpath = results.getValueAt(0,'tagpath')
		
		#Concatenate  tag history path. 
	  	return 'histprov:' + database + ':/drv:'+drive_name + ':' + provider + ':/tag:'+ tagpath

Over here, BTW:

1 Like

At a risk of sounding stupid...
The historical tag provider originating connection names are stored in the internal DB. Could you cache this? Obviously using an API method to get this would be better, but in a pinch..

Meh. If given the choice between reflection and touching the internal DB, I'm going to use reflection every time.

1 Like