I am creating a project that has over 100 valves. When you click on any valve, a pop-up window appears and tells you if that valve is open or closed and allows for manual manipulation of the valve. If I didn't have hundreds of valves I could make a separate pop-up window for each valve, however, with the amount we have, we are looking to have one pop-up window that is dynamic and displays the status of the valve you click on. When you close the window and click another valve, the same window pops up displaying that valves status. I need help with scripting to accomplish this. Thank you.
Never do this, the power of indirect bindings in Ignition is one of its most powerful points. You can create a single popup that can work across several variations of valves and is still maintenance friendly if you ever need to update it. Imagine having to update 100 valve popups because you added a status tag.
Design your popup in the following way: (this assumes all your valves have a UDT instance)
Create a custom property on the popup's root container with the name of tagPath
or similar.
Next, create a custom property for every udt member that you will use on your popup window on the root container of the popup.
Indirectly bind these to the associated UDT member using the tagPath
custom property as the first part of the indirection. Your indirect binding path would look something like {1}/udtMember
, with {1} = {rootContainer.tagPath} in the mapping below it.
Then bind any visuals on the popup to the custom property associated with the udt member you are displaying.
This design also allows you to hide visuals if the associated UDT member doesn't exist on a particular valve. You just check the member binding's quality code and hide the visual if its a bad value.
When opening the popup, you can use a fairly simple script of system.nav.openWindowInstance('designer/path/to/popup', {"tagPath": "path/to/valve/UDTtag"})
on a button's onActionPerformed
script.
Ryan, this is great information. Thank you for this. I am going to give this a shot and hopefully all goes well! Thank you!