I have 10 UDT instances (tank1/tank2/tank3/....etc) of UDT called "tank" and I want to create just one popup instead of ten and use it with the 10 tanks in perspective, i could do it in vision but not in perspective
The process isn't much different between the two. This doc might be helpful, Popup Views | Ignition User Manual.
The idea, create a view (popup) and add params "tagPath" (this is what I usually call it - you can call it whatever you want). Then add a component in the view. Use an indirect tag binding using the param "tagPath". When you open the popup you simply reference the appropriate parameter. This doc shows how to call the popup, system.perspective.openPopup | Ignition User Manual
yes, i did it but there is still a small problem, data is moved from UDT instance to popup only on button trigger, i want to move values constantly
Show your bindings. If you used an indirect tag binding the values will continually update.
i have a problem in referencing a value to popup param
Without code snippets, screenshots of your bindings, etc. we won't be able to help much.
i want to open the popup of two udt instances using two buttons
Hum, this is weird.
Is this "POPUP_UDT" param in the output direction ?
What are you trying to do ? Specify the params in the "POPUP_NUM" ?
I would move your "POPUP_UDT" binding into the "custom property" section of the view.
Then, in the params section, I would add a param "POPUP_NUM" and just use it in the indirect tag binding I suggested you to move.
The "POPUP_NUM" param would then be referenced like this in your binding: {view.params.POPUP_NUM}
.
When opening your popup, you just have to specify the value of your param "POPUP_NUM".
If you want to keep things how they are at the minute, I would still move your "POPUP_UDT" in the custom section of your view.
Then if you really want to use your "session custom" POPUP_NUM, have a script somewhere that sets this value as you open the popup.
EDIT: I've just seen your last message.
If you want to open TWO popups, the ONLY way to do this is with what I've described above.
If you keep using the "session custom" property, both popups will change according to this value as it is "global" to your session.
EDIT again:
Another way to do it would be to specify the path to your tank instance in your view params instead of just the tank number. This will be much more flexible in the future if you change the name of your tanks, etc.
To open multiple the IDs need to be unique, otherwise only one will open.
maybe i have some conflict between custom properties and params, please can you give me steps to make more than instance of popup open at the same time using buttons
@jlandwerlen is right, you need different IDs if you want to open the same popup twice.
If you are using the standard, non-scripted, way of opening a popup, just bind the "identifier" to something dynamic for instance.
Else, use the scripting function system.perspective.openPopup
and provide a dynamic ID to your function.
I usually use the path as the ID since these will be unique.
Please don't do this. Do NOT use session customs to pass parameters. This is HIGHLY unmaintainable, and also WILL (not might, it WILL) bring problems when you open a second tab on the same session.
Also, what's the binding on the popup's params ?
Here's what you're supposed to do:
Make your popup take a tag path as parameter. Not a UDT, not the tag's data: Its path and its path only.
When you open the popup, pass it the path of the tag you want to display.
Now in the popup, use indirect tag bindings to read the tag's data at the path passed through the parameters.
popup:
opening the popup:
If you need to be able to open more than one instance of the same popup, I suggest you put that script in your library:
from uuid import uuid4
def random_id():
""" Generate a random id to be used for popups or other things that need to be uniquely identified. """
return str(uuid4())
Then open your popups with a script (instead of the popup action):
def runAction(self, event):
popup_id = lib.utils.random_id()
system.perspective.openPopup(
id = popup_id,
view = "path?to/your/popup/view",
params = {
'popup_id': popup_id,
'tag_path': "path/to/tank1"
}
)
While not strictly necessary, I suggest you pass the popup id as a parameter to your popup. It's not always useful, but it often is.
ok, what will give the value to the popup view parameter "tag_path" ?
You.
That really depends on where these come from.
It could be a user-maintained list of tags, the result of a tag browse, or pretty much anything.
How did you set the session custom up until now ?
it's working! ,i connected the popup components with the popup custom property with the same shape as the udt and then connected this custom property to popup view parameter instead of session param,and i used two buttons to open popup (without script) and pass number 1,2,....etc to popup param and it worked!