How to find active alarm on page

I have templates for Motor,Valves,A_In etc in my project. I have placed objects on different screens. Now suppose I have a motor fault in one particular motor which is placed in Screen A. Now I want to show the status of active alarm on the navigation bar. So I need to change the color of navigation button for Screen A if any alarm is active on that page.

Thanks in advance.

You can’t do this dynamically if that’s what you’re asking. You will need produce a list of alarm filters to use for each screen yourself, whether by hand, or your tags for each page might be located in their own folders (could work for pages that belong to an area with 1 page per area, but you’ll need to consider long term if they will remain 1 page), or it could be semi-automatically via a script that pulls out the device paths. You could technically copy the page’s XML and pull out tag paths from that…

To pull out the tag paths from the page XML, assuming they all have “/” in them, you could use this regex:
(?<=>)[\w\d ]+\/[/\w\d ]+(?=<)

E.g. "<str>Pigging/Pig Launchers/Red Line 1</str>"
(?<=>) # search for a '>' before the search result without including it in the result (positive lookbehind)
[\w\d ]+ # look for 1 or more of any character, number, or space character
\/ # escape special character '/' and search for 1 '/'
[/\w\d ]+ # look for 1 or more of a /, and character, number, or space character
(?=<) # search for a '<' after the search result without including it in the result (positive lookahead)

You can use the below script in the Script Console which uses the regex above to pull out the tags (again, assuming there is at least one “/” in the tagPath) from the XML copied to the clipboard (Shift+right click on the window and select Copy XML to Clipboard):
image

def readClipboard():
	from java.awt.datatransfer import StringSelection
	from java.awt.datatransfer import Clipboard
	from java.awt import Toolkit 
	
	toolkit = Toolkit.getDefaultToolkit()
	clipboard = toolkit.getSystemClipboard()
	from java.awt.datatransfer import DataFlavor
	contents = clipboard.getContents(None)
	return contents.getTransferData(DataFlavor.stringFlavor)

XML = readClipboard()

import re
pattern = '(?<=>)[\w\d ]+[/][/\w\d ]+(?=<)'

tags = re.findall(pattern, XML)
for tag in tags: print tag

Thank you very much…I will try this solution

I find the use of lookahead an lookbehind interesting, however I have never needed that syntax (so I also didn’t recognise it at first).

I normally define what should be captured, like this: >([\w\d ]+/[/\w\d ]+)</
To me, it’s more readable what do you think?

PS. the / also isn’t a special character in regexes. It’s only special in JS where it’s used as regex delimitor (instead of quotes).

Use of '/' as a regex delimiter long precedes javascript. I used it a few times this week with sed.