Pop up on BOOL change to True

All,

We have a window that monitors a certain piece of equipment. Basically, this is a material transporter that runs all day and night autonomously when the plant plc’s call for more stuff. I don’t expect anyone to ever look at this page unless an alarm bit (BOOL) gets thrown.

The page has an additional window which describes alarm issues in more detail. I want to pop this window when an operator visits the equipment page and an error is present.

We already have a BOOL that goes true if any of the 20+ faults occur, so following others here we set up a timer on the equipment page and tried this code in the script editor as noted:

[code]TransportAlarmPresent=system.tag.read(“Jello1/Faults/Fault - Errors Present”).value

try:
if TransportAlarmPresent==1:
print “Alarm Value=1”
system.nav.openWindow(‘ALARM’)
system.nav.centerWindow(‘ALARM’)
else:
if TransportAlarmPresent==0:
system.nav.closeWindow(‘ALARM’)
except:
#Window is already open/closed
pass

[/code]

This pops the window, but the window will not close (go away) no matter what we do short of closing the client. I would have thought that once the tag went back to FALSE (or 0) the window would close per this script.

What the heck are we doing wrong?

Thanks for the help!!!

John

So two things. First, the if statement after the else statement is redundant. You can remove it completely.

Second, spacing of individual lines is really important, and your spacing looks a little off. Try something like what I have, where each line after the if and else statements are just a single tab further. In your code, it looked like the line after the else statement was 2 or 3 tabs further.

[code]
TransportAlarmPresent=system.tag.read(“Jello1/Faults/Fault - Errors Present”).value

try:
if TransportAlarmPresent==1:
print “Alarm Value=1”
system.nav.openWindow(‘ALARM’)
system.nav.centerWindow(‘ALARM’)
else:
system.nav.closeWindow(‘ALARM’)
except:
#Window is already open/closed
pass[/code]

Thanks. I tried the code exactly as you posted but have the same issue.

When the tag goes True the window pops as desired, but can’t ever be closed short of logging out of the client and back in. even when the tag goes False again.

Any other suggestions on what to check? All help would be greatly appreciated!!!

John

You are not expecting this script to close the popup automatically when the tag goes back to 0 are you?

The tag value will only be evaluated when the script is run. If you have the script in the internal frame opened event it will only run when the window is opened or a user clicks on a different window and then back on the original window.

Do you have any event handlers on the popup window to allow the user to close the window?

@jkelleyus - Although I wasn’t able to completely reproduce your issue, I did find an odd behavior. I found that although my test window did open an close, it would at times lock up the Client.

My suggestion is to make a Client Tag and bind it to your Errors Present tag. Then use a Tag Event script on the Client Tag to open/close your window.

Client Tag Event - Value Changed script if currentValue.value == 1: try: system.gui.getWindow('EquipmentWindow') system.nav.openWindow('EquipmentWindowAlarms') system.nav.centerWindow('EquipmentWindowAlarms') except ValueError: pass else: try: window = system.gui.getWindow('EquipmentWindowAlarms') system.gui.closeWindow(window) except ValueError: pass
You’ll also need to put in a script in the EquipmentWindow’s internalFrameActivated to check if you should open your EquipmentWindowAlarms window as well.

P.S. - Don’t use a mixture of Tabs and Spaces when indenting your code, use one or the other.

Thanks all. After messing with this over the weekend I discovered the pop window was set at layer 1. After changing this the script at the parent window worked as expected: The window popped on the parent screen when a machine alarm was present and closed when the machine alarm was reset.

It was very helpful to learn the client Help>diagnostics window is there to look at console output. Somehow I had missed that in other videos… so for beginners… particularly those of us coming from VB-type products (like RSView) this was a wonderful discovery. I knew the script was doing what I wanted but did not close. This caused me to look elsewhere for the problem…

Thanks again!

John