Triggering popup

I have tag S201_Run. I would like for it to trigger a popup to open if remains false for at least 15 minutes. The popup view is called "Senntech 201 Popup". The view for the popup to appear on is called "Senntech 201". I have tried using a gateway event script and the function:

system.perspective.openPopup("Machine Downtime windows/Senntech 201 Popup view", "Machine Downtime windows/Senntech 201")

How do i accomplish this if nothing has worked.

You have to split your task into the parts that need to run all the time (timing) from the parts that run in your user interface.

First, make a memory tag of type datetime to hold the timestamp when the tag of interest changed to false. Use a value change script on the boolean tag that checks if does nothing on initial change, but writes the timestamp from system.date.now() when not currentValue.value.

Then, in your perspective UI, probably in a docked view appropriate to your application, bind both the boolean and the timestamp tags to custom properties. Add another custom property with an expression binding that computes timeBetween() now and that timestamp. Use a valueChange on that to trigger your popup.

So, i have gotten everything to work, but the popup.
image
How do I get the popupTrigger parameter value to open a popup. I currently can toggle my popup using an on click popup event on the "Downtime reason" button.

You would use a value change event script on the popup trigger boolean property.

1 Like

Hello, that makes a lot of sense. What kind of script is that and where do I put it? It is not something I am familiar with. I mainly ask, because I see no way of putting a value change event script on a property. I am currently using the timeElapsed to count the time since it has stopped. the popupTrigger property is then output true or false depending on the amount of time it has been off.

Just a comment on the expression. It can be simplified to
{view.custom.timeElapsed} >= 15

That will be either true or false and that will be the result of the expression. No if required.


For the change event,

  • Right-click on view.custom.popupTrigger.
  • Select "Add Change Script".

You should consider making the popup background dismissable. The user can then click anywhere outside the popup to have it disappear. It's much easier than trying to hit the X or Close button.

1 Like

would this work?

# Property change script for the popupTrigger property
def valueChanged(self, previousValue, currentValue, origin, missedEvents):
    # Check if the property value changes to true
    if currentValue:
        # Get a reference to the current view
        view = self.view

        # Open the popup when the property value changes to true
        system.perspective.openPopup(viewPath="Machine Downtime windows/Senntech 201 Popup", target=view)

Maybe this topic will be helpful for you? If you trigger from a tag, you will need to get the session and page.

I am attempting to open a popup in only one view. I'm not sure that this topic is similar.

1 Like

It's a qualified value so, currentValue.value.

Sorry, didn't read the entire topic, just made some assumptions.

1 Like

Unfortunately, I keep getting this error no matter what i do.

com.inductiveautomation.ignition.common.script.JythonExecException
Traceback (most recent call last):
  File "<function:valueChanged>", line 8, in valueChanged
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: 'view' argument must be provided.

	caused by org.python.core.PyException
Traceback (most recent call last):
  File "<function:valueChanged>", line 8, in valueChanged
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: 'view' argument must be provided.

	caused by IllegalArgumentException: 'view' argument must be provided.

Ignition v8.1.32 (b2023091211)
Java: Azul Systems, Inc. 11.0.18

system.perspective.openPopup | Ignition User Manual doesn't have a target parameter.

def valueChanged(self, previousValue, currentValue, origin, missedEvents):
    # Check if the property value changes to true
    if currentValue.value:
        # Open the popup when the property value changes to true
        system.perspective.openPopup(
            id="popupId",
            view="Machine Downtime windows/Senntech 201 Popup",
            title="Popup Title",
            position={"left": 100, "top": 100},
            showCloseIcon=True
        )

I am getting much closer. I am no longer getting errors, but am still not seeing a popup.

  1. You need to be testing this in the browser. Designer won't display popups.
  2. If you're doing that already then it's time to start digging in the logs, I'm afraid. Gateway | Status | DIAGNOSTICS | Logs.

Thank you. Do you think I need to include the view that it will be open with,

pageId=self.page.pageId

I'm not sure if I should be using sessionId or pageId.

I did test this popup script in the event script action and it functions when I click a button.

def runAction(self, event):
    system.perspective.openPopup(
	    id="manualTestPopup",
	    view="Machine Downtime windows/Senntech 201 Popup",
	    title="Manual Test Popup",
	    position={"left": 100, "top": 100},
	    showCloseIcon=True,
	    
	)

Perhaps use a logger or print to make sure the event is working.

Good. Code should be OK then.

Let's step back a bit. The thread has got a bit long. Please confirm or correct:

  1. You're using a custom property popupTrigger.
  2. popupTrigger is a custom property of a view and you only expect the popup to work if this view happens to be open.
  3. You have the valueChanged script on custom.popupTrigger.

One other trick to speed up testing: Add a checkbox to the view. Create the same valueChanged script onto the checkbox selected property. You can then toggle it for testing without any time delay.

  1. the custom property popupTrigger is correct
  2. That is correct
  3. the value changed script is on the custom.popupTrigger

I have button, but I will try this.
Other details:

  1. The popup is on its own view.
  2. the popupTrigger is either true or false, bound to my custom.timeElapsed property

here is the code once again:

def valueChanged(self, previousValue, currentValue, origin, missedEvents):
    # Check if the property value changes to true
    if currentValue.value:
        # Open the popup when the property value changes to true
        system.perspective.openPopup(
            id="popupId",
            view="Machine Downtime windows/Senntech 201 Popup",
            title="Popup Title",
            position={"left": 100, "top": 100},
            showCloseIcon=True,
            
        )

The check box works