So, the driver is actually part of the full tag path. It is possible if you are using remote tag providers to use a gateway message handler in conjunction with this function to get what you’re looking for.
If you put this function in a shared script on the same gateway as the tag provider, then it should return your historical tag path.
Inspired heavily from the script provided by @PGriffith
def getHistoricalTagPath(path):
from com.inductiveautomation.ignition.common import QualifiedPath, WellKnownPathTypes,QualifiedPathUtils
from com.inductiveautomation.ignition.common.tags.paths.parser import TagPathParser
qPath = QualifiedPathUtils.fromTagPathNew(TagPathParser.parseSafe('default',path))
histProv, gateway = system.tag.readBlocking([path + '.historyProvider','[System]Gateway/SystemName'])
driver = ':'.join([gateway.value,qPath.getPathComponent('prov')])
return QualifiedPath.Builder().set(WellKnownPathTypes.HistoryProvider,histProv.value).setDriver(driver).setTag(qPath.getPathComponent('tag')).build().toString()
So using the following assumptions:
- The system name of the gateway this function is run on is
controller
- The historical provider of the tag is set to
DB
- You provide the path
'[default]simulater/turbine 3'
or 'simulater/turbine 3'
Then this function will return histprov:DB:/drv:controller:default:/tag:simulater/turbine 3
You could also just hard code the gateway in if it isn’t going to change often.
I chose to use system.tag.readBlocking()
here because system.tag.getConfiguration()
only returns non-default properties, since a historical provider is not provided by default it should always be returned, but better safe than sorry. Also, I needed to call the function anyway to get the gateway name, so just as easy to get it from there.
You may want to consider either verifying that history is enabled for the provided path, or coalescing to a default if a ‘historical provider’ is not provided.
If you take out the toString()
and instead return just a QualifiedPath then you could use this function to do a lot of things, for instance checking for incorrect configurations.
print [tag['fullPath'] for tag in system.tag.browse('path/to/folder',{'tagType':'Atomic Tag'}).getResults() if getHistoricalTagPath(tag['fullPath']).getPathComponent('prov') in ('null','SomeOtherIncorrectProvider')]