Pop up window when one of multiple tags changes value v7.8

Hello Inductive Community,

I have three heat trace systems that I am adding to my Ignition system. Each of the three Heat trace systems has multiple heat trace circuits but to keep things simple we'll just pretend that each heat trace has two circuits. each circuit has an integer tag that is used to indicate alarms for that circuit. If the tags value is zero the circuit has no alarms. If the value changes to greater than zero there is an alarm of some type on that circuit. The alarm type is not important, I just want the operator to know that an alarm exists on that circuit. My goal is to make one window per heat trace. Each window will pop up when either of the heat traces two circuits alarm tags change value to a value that is greater than zero. When the window pops up no matter what the value of the alarm tag is the operator will be able to close the pop up window. If either of the two alarm tags changes value again to any number greater than zero the window will pop up again but remain closable. The window will automatically close if at anytime both of the circuits alarm tags have a value of zero. So my question is how do I make a pop up window that will pop up when either of two tags changes value and that value is greater than zero. Thanks

Make the popup window as usual, preferably with a "tagpath" custom property in the root container, so you can open it with a pointer to the tag that is in alarm.

Then make a client tag change event script and have it monitor the tags of interest. This script should do the following:

  • Retrieve and loop through the open window objects, checking for the popup, and if a match, checking if the tagpath in its root container is a match. Hold onto this window object if found. Then,

  • If the tag is zero, and the window object was found, close the window.

  • If the tag is non-zero, and the window object was not found, use system.nav.openWindowInstance() to open a new popup, and pass the tag path as a parameter.

Phil

Thank you for the response. I have to admit that my experience with Ignition is very limited. I have used WonderWare a lot but very very little Ignition. I was able to make a pop up window with a “TagPath” custom property. After that I’m lost. I don’t understand how to “retrieve and Loop through the window objects” I don’t understand “hold on to this if the window object is found”. I’m embarrassed to ask this but could you explain this as if you are explaining this to someone with little to no experience with Ignition? Thank you.

image002.jpg

You would loop through the result from system.gui.getOpenedWindows()

#Grab all opened window objects
openedWindows = system.gui.getOpenedWindows()
existingWindow = None
sourceTagPath = event.tagPath

#Loop through the window objects
for window in openedWindows:
	# Check window path to see if matches the path of the popup we are using
	if window.path == "PathToYourCustomPopup":
		# Check that the tagpath property on the popup's root container matches the event source's tagpath
		if window.root.tagPathProperty == sourceTagPath:
			# if the tag path matches, grab that window object
			existingWindow = window
			break

# if the tag value is true and we don't have a window open for this tag, open a new window for it
if newValue.value and not existingWindow:
	system.nav.openWindowInstance("PathToYourCustomPopup", {"tagPathProperty": sourceTagPath})

# If we have a window open for this tag and the tag is now false, close the window
elif existingWindow and not newValue.value:
	system.nav.closeWindow(existingWindow)

2 Likes

I did that and I have a configuration error on the client tag.

(TagPath custom property and binding)

(Client tag expression (Datatype?))

No, don't bind to the tagpath. Leave it unbound, and make sure it is a String. For testing purposes, put OPC/HeatTrace1.... in it. Wherever you need the actual tag value in your UI, use "Indirect Tag" binding, where the path is just {1} and the reference points at the tagpath property.

In the script where you open the popup, the tagpath is a parameter to be supplied in the openWindowInstance() call, as Ryan shows. (Adjust the names.)

Thank you Phil. I don't understand what you mean by this: " In the script where you open the popup, the tagpath is a parameter to be supplied in the openWindowInstance()` call, as Ryan shows. (Adjust the names.)"

This is what Ryan sent me regarding that:
system.nav.openWindowInstance("PathToYourCustomPopup", {"tagPathProperty": sourceTagPath})

I understand you to mean that I have the "tagPathProperty" wrong when I use the custom property "TagPath" but I don't understand what you are telling me to replace it with.

Also not sure what you mean by this: "Wherever you need the actual tag value in your UI, use "Indirect Tag" binding, where the path is just {1} and the reference points at the tagpath property.". The only thing I need this tag for is to pop up the window when it changes value and is greater than zero.

I think I at least might have got this part right:
"No, don't bind to the tagpath. Leave it unbound, and make sure it is a String . For testing purposes, put OPC/HeatTrace1.... in it"

I changed the custom property data type to string. What should the data type of the client tag be?

The quoted key in that parameters dictionary needs to match your custom property name TagPath. That's how window parameters work. (Exact match, case sensitive.)

The variable sourceTagPath is assigned a value at the top of the sample script.

You misunderstood. There's no client tag. There's a client tag change event script. Defined in the the client scripting events section of your project. The list of tags to monitor will include your three gateway tags.

I still have something wrong. I made the client tag change script. Notice the highlights, I believe I have the parameter correct.

I've tried it both with and without this tag here.

I am testing by hitting the play button in designer and disabling the circuit, which clears the alarm. Then I enable the circuit again which brings the alarm back. At this point the window should open but it does not.

"Grab all opened window objects"
openedWindows = system.gui.getOpenedWindows()
existingWindow = None
sourceTagPath = event.tagPath

"Loop through the window objects"
for window in openedWindows:
"Check window path to see if matches the path of the popup we are using"
if window.path == SouthMez_HT_Alm:
"Check that the tagpath property on the popup's root container matches the event source's tagpath"
if window.root.tagPathProperty == sourceTagPath:
"if the tag path matches, grab that window object"
existingWindow = window
break

"if the tag value is true and we don't have a window open for this tag, open a new window for it"
if newValue.value and not existingWindow:
system.nav.openWindowInstance(SouthMez_HT_Alm, {HT1TagPath: sourceTagPath})
elif existingWindow and not newValue.value:
system.nav.closeWindow(existingWindow)

The path to the window should be in " " ie, "SouthMex_HT_Alm". The script is probably assuming that SouthMex_HT_Alm is a variable, and is then throwing an error that the variable is being called before assignment.

Also, that window path string should be the full path to the window as shown in the designer. If the window is in any folders, the folder names need to be included in the path string. Ie, If I have a window called Warning in a folder called Popups, the window path is "Popups/Warning"

#Grab all opened window objects
openedWindows = system.gui.getOpenedWindows()
existingWindow = None
sourceTagPath = event.tagPath

#Loop through the window objects
for window in openedWindows:
	# Check window path to see if matches the path of the popup we are using
	if window.path == "SouthMez_HT_Alarm":
		# Check that the tagpath property on the popup's root container matches the event source's tagpath
		if window.root.HT1TagPath == sourceTagPath:
			# if the tag path matches, grab that window object
			existingWindow = window
			break

# if the tag value is true and we don't have a window open for this tag, open a new window for it
if newValue.value and not existingWindow:
	system.nav.openWindowInstance("SouthMez_HT_Alarm", {"HT1TagPath": sourceTagPath})

# If we have a window open for this tag and the tag is now false, close the window
elif existingWindow and not newValue.value:
	system.nav.closeWindow(existingWindow)

I might be wrong but I think you'll need to test this in an actual client. Designer behavior is close to client, but navigation and showing popups is not the same.

Also, when posting snippets of code use the </> button to format it.

Success! Thanks you two!

2 Likes