2 State Toggle button not working with Template

I made a UDT and one of the tags inside is a boolean OPC tag. On my template, I set up the custom property to link it to my UDT type then I added a 2-state toggle button and linked it to the proper boolean tag property. When I add this template to a vision window, the 2 state toggle button doesn’t write any value, it doesn’t toggle. If I do the same thing with two separate buttons on the template, it works fine. If I add the 2 state toggle button directly to the window and link it to the UDT instance directly, it works fine.
What gives?

Also I tried playing around with the “driving property”. If I switch the Driving Property to Control Value, instead of Current State(the default), then it will toggle one time only but the indicator state won’t update properly.

I’ll try again. I’ve been browsing the manual and forum, trying to make sense of passing UDTS as the parameter type versus an indirect tag binding, thinking that might solve my button problem. However I can not figure out how to do the indirect tagpath. The examples in the manual and university videos only show indirect bindings for something as simple as changing the tank number (ie tank 1, tank 2), but I need something that will populate the entire UDT tagpath and the UDT tags won’t be in the same root folder.
This is obviously possible since many users (@nminchin) here have commented several times that they do the tagpath way instead of the UDT parameter way. Do I need to be doing scripting?

I tried making a string parameter and then binding it to a UDT instance, but the resulting string looks more like an xml tag export than a tagpath. Can someone screen shot me an example?

Thanks so much, feeling in way over my head when something that should be easy just seems so hard.

Lets say you have two production lines, (Line 1 and Line 2), and each Line has two tanks (Tank 1 and Tank 2).

You can build a Tank UDT, and each Tank is an instance of that UDT.

Lets also say that inside the Tank UDT you have a Level tag.

Now you want to have a template that will work across both lines and each tank.

You would create 2 Template Parameters on the Template (Line Number and Tank Number).

That way you can pass the appropriate values to the template. Now inside the template all that is needed is an indirect tag binding.

If say the tag paths looked like Line 1/Tanks/Tank 1/Level you would substitute the references in the tag path so that it looks like this, Line {1}/Tanks/Tank {2}/Level.

Then for each reference you assign the properties you created as appropriate.

When you add the template to your window you set the template parameters so that they point to the appropriate place and you’re done.

Hope that helps, didn’t have time to build up a proper example.

1 Like

You can also do indirect where the path is {1}/SomeLeafTag, so the linked property #1 supplies the entire folder path.


Ok, I think I’ve got it working now. I was trying to bind the property on my window, but I guess I just have to manually type out the tagpath.
So next issue, I’ve got the labels working with a “tagpath” custom property, but how do I do it in button scripts? There is no wizard in the scripting to get to indirect tags.

My UDT is named Generator, my Template is named Generator. I want to send a “1” via the button to my “Gen_Test” command which is a OPC tag in my UDT. But this isn’t working.
I started with the hardcoded tag to try and get the syntax

But when i try and manually insert the tagpath indirection instead I get an error message.


You are inserting "Generator.TagPath" as a string in the script. The write won’t work as
"Generator.TagPath"/Gen_Test isn’t a vaild tag path. Instead you have to get the value of the property.

This is done the easiet by using the property selector in the top right corner of the script editor dialog.

I would expect your script to look something like:

path = event.source.parent.TagPath
system.tag.writeBlocking([path + '/Gen_Test'],[1])

Better yet, would be to have a property that is bi-directionally bound with an indirect tag binding to the Gen_Test tag, then your button would simply set that value to 1. That might look something like this:

Again, use the property selector to insure that the path to your property is correct.

1 Like

Thanks! it was that “event.source” code that I didn’t know. I missed the little property selector in the corner. So many little things to pick up here and I’m finding it hard as I didn’t even know what to search for in the manual to figure out what I needed to use to reference that tagpath property. My iFIX VB coding background is not helping as I kept trying something like “me.tagpath”. haha.

Have you done all of the (free) lessons at Inductive University yet? Highly recommended for newbies.

I wouldn’t do this as it limits your template’s usage. I would always pass in the parent path to the UDT and the name of the UDT. For example, you might have lines in different areas of the plant

Yes for sure I have. I just find the examples are more simple than what I’m trying to do, or they are close to what I’m looking for but not exact. Thanks!