Indirect Tag binding using a Script?

Is it possible to create an indirect tag binding using a script? I am using a mouseClicked event on a button to change the value of a tag, however I am using this in a template that will have 10 of these buttons total. It would be like Motor 1 thru Motor 10 and each has a button to control ON and OFF.

There are a few options.

The option that mostly closely resembles your question might be to make a custom property on the button and do an indirect binding on it (bi-directional). In your script you can write to the property, which will write through to the indirectly bound tag.

Another option would be to dynamically create the string for tagPaths in system.tag.writeBlocking(). As long as you end up with a list of strings, how the strings went together doesn’t really matter.

# distinguish your buttons here is some interesting way
motorNumber = 1

tagPath = "[default]plant/area/motor{}".format(motorNumber)
writeValue = 1
system.tag.writeBlocking([tagPath],[writeValue])

I would be passing in the device tag path into the template, then you can use that in your script as @zacht mentioned. I never like to hard code the device tag paths of a template, as then can can’t use them again for the same thing in a different location

1 Like