Binding other tag to Enable in UDT

I have a UDT and I would like to bind the enable to a tag in that UDT. I can't figure out how to do it. I thought it was like this but that doesn't work.

I don't think you can access values from other members of the UDT (or other tags for that matter) in a binding on that property. I believe you only have access to UDT parameters there.

I'm struggling to find where in the documentation this is actually called out. I know that alarm properties on a tag can access values from other UDT members and tags.

If you right click on the binding icon for the property and select edit, the right side of the editor popup will show you what data you have access to.

What is the purpose of you enabling/disabling a tag off of what I assume is a machine status value? Can't you just hide the value of the tag in whatever interface you are making?

1 Like

Correct, and only in UDTs. Configuration properties of tags are not eligible to receive live bound values. Alarm properties can have more complex bindings, but they aren't live. Those evaluate only when there's an event for the given alarm. (Which means a binding to an alarm enable can only turn it off--there won't be any more events for that alarm that could turn it back on.)

Only actual expression tags can have full-function bindings. Only scripted value changes on actual tag values can propagate them to tag configuration properties.

1 Like

This is what I was afraid of. Basically whenever they take a machine down for maintenance or whatever. I need to disable the tags. For some reason it's affect the communication with Kepware causing me to miss information whenever a tag goes bad like that or not found

How could I dynamically disable a tag then?

Use a tag value change event instead to write to the UDT instance's enabled property

Oh how would I do that? Do you have an example of this?

On the "Status" tag, add a Value Change script with:

udtInstanceTagPath = '/'.join(tagPath.split('/')[:-2]) # modify the "-2" to suit your UDT to get you back to the root UDT instance level
system.tag.writeAsync('{}.Enabled'.format(udtInstanceTagPath), currentValue.value)

Sorry just a little confused how does this script work?

It missing the comparison to determine if you need to enable or disable the tag in question, but when configuring the tag in the UDT, you should be able to right click the tag in the left window of the UDT editor and select scripting and then select valueChanged, that's where you would place their script.

Ohhhh hang on... disabling the UDT Instance will also disable the tags within the UDT instance, so you actually won't be able to get it to re-enable if you rely on a tag within the UDT instance itself. You'll have to put this tag value change event on a tag outside of the UDT

It doesn't need it, it just uses the current value of the status tag (which seems to be a boolean)

But this is the config anyway in my UDT definition (again, note that this will not be able to re-enable the UDT Instance!):

1 Like

Ah, I was assuming status was a number like how typically pull status.

Can't they put this on the status tag and just write to the the enabled property of the UDT member? Or is that not a thing? As long as they are aware of the path to the tag in the UDT they can just build the path to the UDT member and only disable that member.

Ok yes this is what I was thinking. Ok I will give something like this a try. I was thinking more of disabling certain tags when this occurs. I think that should do the trick instead of the whole UDT

Ok, that will work then :+1:

In this case, use relative referencing in your tagpath:

system.tag.writeAsync('[.]New Tag 1.Enabled', currentValue.value)
or 
system.tag.writeAsync('[.]../../New Tag 1.Enabled', currentValue.value) # go up 2 parent folders

Keep in mind that if the tag you want to disable is marked as read only this will not work. Just confused myself with this by trying on a read only member of a UDT. Changing it off of read only allowed me to write to the UDT member's enabled property

In that case, you'll need to use system.tag.configure, but be careful if you decide to use system.tag.getConfiguration to get the tags' config, as this will contain all of the non-default values from the UDT definition itself, not just the non-default values set on the UDT instance. If you write this back to the UDT instance, it will effectively solidify all of the non-default settings applied to the UDT definition, meaning any updates to those values won't come through into that instance.

Maybe i'll get you an example...

You can use this to disable a tag within a UDT instance if it's set to readOnly (you can use this for any tag if you want, even if it's set to read/write):

system.tag.configure('[.]', tags=[{'name': 'New Tag 1', 'Enabled': currentValue.value}], collisionPolicy='m')

or if the tag to disable is in a parent folder:

system.tag.configure('[.]../', tags=[{'name': 'New Tag 1', 'Enabled': currentValue.value}], collisionPolicy='m')

ENSURE THAT YOU USE collisionPolicy='m', OTHERWISE YOU COULD DELETE YOUR TAGS

1 Like

That worked. Thank you!

1 Like

Just be careful to include the collisionPolicy='m' otherwise you could wipe out your tags... I edited above to include that warning for others