Multiple instances of popups in Perspective

Hi guys,

I’m trying to prepare base of project and I’m working on devices faceplates (valves, motors, DI,AI, etc.). I prepared nice popup already so only thing I need is to send Device name and it is connecting popup to correct UDT instance. Problem I found is that I cannot use multiple instances of one window in Perspective. I found solution that I have multiple windows called “Sample_Motor_i1”, “Sample Motor_i2” and small script which is checking which instances are already opened and which one should be open next. Problem is that my script is not working as it should:

This is beginning of my script so variable inst1 is read from array of memory Booleans. Every member of that array is set and reset in corresponding popup instance so:
Instances[1] is set when Simple_Motor_i1 opens and reset when it closes. If is open then if condition is not true and it is checking Instances[2] and so on.

What is interesting it is not opening popups at all. What is more interesting I used “New Tag to” display current Instance[1] value and if it is displaying false first if should be right and it is not.

I’m using Ignition 8.1.9


Haha it was funny to read “Prospective” so many times.

Well this is a terrible approach starting by the fact you are using gateway tags as a memory collector of opened views. This means that all opened sessions won’t work as expected because if session A has popup opened, session B might not but still will be interpreted as open because of that memory Boolean Array.

You should create a session custom prop that appends all the ids of opened popups.

The Pseudo Code should be: (make sure to send the id as a parameter also)

openedPopups = self.session.custom.openedPopups
if 'Simple_Motor_i1' not in openedPopups:
	system.perspective.openPopup(...x, params = {....'id' : 'Simple_Motor_i1'})
elif 'Simple_Motor_i2' not in openedPopups:
	system.perspective.openPopup(...y, params = {....'id' : 'Simple_Motor_i2'})

Finally, on the popup view a script on the view when it shutdowns to basically remove from the session array the popup id.

Sorry for “Prospective” no idea why I called it like this. Thanks for explanation - that is really good point I missed!

Still I’m curious why simple read tag is working in one line and is not in second line in if statement.

You are missing .value method. I think, to read the actual value

Unfortunately that is not true. I was trying it

There are lots of things going on here.

  1. Per the documentation, readBlocking expects a list of tag paths, but you’re only sending a string.
  2. openPopup needs access to a Perspective thread which has a page context, OR it needs a specific pageId to target so that it can open the Popup on that page. To get this working, you’ll either need to pass a pageId argument into this function or you’ll need this function to return some value that you can use inside of a component or session Event.

In both cases, these errors should be immediately visible if you look into the logs present on your Gateway.

But still, you won’t need that since you should not use it.

Many thanks. All is working like it should!