Gateway Tag Change Event That Repeats Message While Tag Is True

I'm trying to create a setup where when a specific tag changes to true, an event will run that sends a message to a session event message handler that then opens the popup. I have the initial message/popup part working, but I want to add to it so that this message/popup repeats every 30 seconds.

Has anyone tried something similar? And if so, how did you accomplish this? My thought was to create a while loop that repeats while the tag value is true and has a delay and sendMessage in it, but I couldn't get that working. I also need the potential of this happening to multiple different tags at once (i.e. multiple gateway tag change events running) as a worse case scenario, so ideally the solution doesn't bog down the gateway too much.

If it helps, here is the current code for the gateway event:

if previousValue.value == False and initialChange == False:
	projectName = system.project.getProjectName()
	warnInfo = {'message': "Bool_On Checked", 'id': "feanordidnothingwrong"}
	system.util.sendMessage(project=projectName, messageHandler="popup_sessionevent", payload=warnInfo, scope="S")

and this is the session event:

def handleMessage(session, payload):
	for user_session in system.perspective.getSessionInfo():
		if user_session.id == session.props.id:  # if potential user session is this session
			for pageId in user_session.pageIds:  # for every page of this session
				system.perspective.openPopup(payload["id"],'General/Popups/Warning Popup', 
				params={'Message':payload["message"]}, 
				showCloseIcon = False,
				draggable = False,
				modal = True,
				pageId = pageId)

Under no circumstance should you have any indefinite looping in Ignition event scripts. That ties up a thread, and usually burns CPU wastefully.

What do you want to happen if the user doesn't close the popup?

1 Like

It's a warning that I want to popup. I'd like the user to be able to close the warning popup to see other stuff on the screen, but I want that warning popup to essentially be a constant nuisance until the thing causing the warning is fixed. So I need it to pop up again after a set amount of time if it hasn't been resolved.

There's no simple way to do that. You will have to keep track in your session if a popup is still open before opening another, or you will get more and more of them.

I would not use a popup. Add an annoying banner to a shared dock, and control visibility of the banner with a tag binding.

Unfortunately it needs to be a popup. For my understanding, if I set the popup ID to be say "1", and that popup tries to open multiple times, doesn't that mean it'll only open once since it'd be the same ID? So if it's already open, it wouldn't then open more instances, right?

I don't know. Try it.

It only seems to open the one instance. Wasn't sure if there was something bad about me trying to open it multiple times, but it doesn't look like it causes an issue. I'll have to see if there's another solution to making the popup reappear.

You could have a gateway timer script that runs every 30 seconds and opens the popup if the condition is still active. That way you're not tying up a gateway event thread.