I’m running into an issue with remote gateway notification profiles where I can’t determine the source gateway the tag lives on from the AlarmEvent object. I have two gateways: FE, and IO1. The FE gateway hosts the alarm pipelines. The IO1 gateway has a remote gateway notification connection.
On the host gateway, when the alarm on a tag named frontEndAlarmTester alarms, this is the event object:
We do this all the time, but our remote gateways alarm tag use the gateway name in the Display Path of the alarm. Then on the notification profile, we extract the gateway name from this property.
That’s clever. Unfortunately, I ran into this problem too late into construction to have a well-thought out solution like that, lol.
For anyone else in this predicament, here’s what I ended up doing:
def resolveTagProvider(pathToTag):
# List of all remote tag providers the front-end has access to.
tagProviders = [
'[tagProviderA]',
'[tagProviderB]',
]
for tagProvider in tagProviders:
try:
quality = system.tag.readBlocking('{}{}'.format(tagProvider, pathToTag))[0].quality
if str(quality) == 'Good': return tagProvider
except:
continue
return '[default]'
I get the source tagPath from the AlarmEvent, then try making a read as if the tag exists in each provider. Only the read() made to the tagProvider the tag actually exists in will return a Good quality, so we know that is the correct provider.
I don’t like having to make so many read() calls, especially if this pipeline is to run often. If there is a better solution, I’m all ears.
Not much better, but should be a little bit faster.
I'd also recommend making your method accept a list of paths so you can batch calls. system.tag.exists actually doesn't accept a list, but "under the hood" all it's doing is a read of the .Name property (and checking that the returned quality is not "Bad_NotFound").
This particular line is also inefficient:
if str(quality) == 'Good':
QualityCode objects are rich objects with their own methods - you could instead do if quality.isGood():
The other thing is to perhaps create multiple alarm notification pipelines and have each gateway send alarms to their own pipeline. I know this seems like duplicating the same thing…but, in our case, we have multiple remote edge installs and if they all go to the same pipeline, there are times when consolidated alarms mixes multiple sites together. To prevent this, we create an ANP for each remote site in a dedicated project called Alarming or Alarms.