Open dock on active alarm

I have a gateway script that counts active alarms, if the alarm count is greater than 0 , I would like to open a dock for all sessions on any page.
What is best way to go about this?

Whenever the condition meets, write some value to tag. bind the tag to a session variable.
On change of this session variable, open a popup.

This thread lead me to the answer as I finally realized it is no different from a common alarm pop-up use case :

@cmallonee supplied a function that got the community started.
@wakatipu discovered that (On Ignition Edge designer 8.1.22) if the designer is running the code would exit the for loop before getting to the true sessions so the designer was excluded.

 if session.userAgent != "<designer>":

This is the script after reworking it for docked view system functions:

def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
	dockId = "alarm" #dock ID
	logger = system.util.getLogger("dock") #optional logging 
	sessions = system.perspective.getSessionInfo()
	for session in sessions:
		for pageId in session.pageIds:
			logger.info("{0} | {1}".format(session.id, pageId))
			if session.userAgent != "<designer>": #exclude designer
				if currentValue and currentValue.value:
					system.perspective.openDock(dockId, sessionId=session.id, pageId=pageId)
				else:
					system.perspective.closeDock(dockId, sessionId=session.id, pageId=pageId)

(I also ditched my gateway script to evaluate active alarms for a Boolean reference tag on [System]Gateway/Alarming/Active and Unacked as I have only one project on this Gateway)

2 Likes