Issues with Vision Template Binding

I used this expression bound to a multistate indicator's state property within my template:
getBit({PointIO.Data::Data},toInt({PointIO.0.name},0))

I'm trying to do something similar with a different template, and it works as far as allowing me to submit the expression without an error popping up, but there is a fx overlay on the multistate indicator. Here is the expression:

getBit(toInt("PointIO_IOLink2." + {PointIO_IOLink2.Ch0.name} + "Data::Data"), toInt({PointIO_IOLink2.Ch0.Ch 0 to 7.0.name}))

Does anyone know how I can adjust this to work properly?
Please let me know if additional information is needed :slight_smile:

First, please see Wiki - how to post code on this forum.

Second, toInt requires a fallback value, you have not provided such to either call in the second expression that you posted. This is an optional parameter.

You look like you are attempting to create an indirect tag path, is this correct? If so you are approaching it incorrectly, your current expression is just creating a string of PointIO_IOLink2.SomeValueHereData::Data instead of pointing to a tag.
Instead, create a custom internal property on the template and apply an indirect tag binding to that.

Configure the tag binding path to be PointIO_IOLink2.{1}Data::Data, and configure the {1} to be assigned a value of {PointIO_IOLink2.Ch0.name}.

From there, your binding would be adjusted to

getBit(
	toInt({template.customInternalProperty}),
	toInt({PointIO_IOLink2.Ch0.Ch 0 to 7.0.name})
)

Additionally, if these are indeed tag paths, . is not a valid character for tag names.

The failover value is optional.

Consider also skipping out entirely on 'custom' type properties (direct bindings to UDTs) in Vision. They're a bit of a performance footgun, because a UDT type binding brings in everything in the UDT at whatever the binding's subscription rate is. If you make string-type parameters for your templates, it's trivial to bring in an indirect path via an expression doing the concatenation, and then use indirect tag bindings for all the specific subpaths you care about within the template.

5 Likes

Noted on posting code appropriately in this forum.

I'm trying to create a path to this Data UDT property:

I'd like the part "Ch0" to be named depending on the container name:

That way, the names will update the path dynamically.

I tried your solution, but wouldn't I have to make multiple internal custom properties for this to work or it'll always go back to Ch0?

If i understood it correctly, in your binding you try to use CH0.name as a parameter, right?

I think the problem might be: How can you use CH0.name as a binding if you plan on changing its name and therefore its path?
Maybe add a custom property to CH0 and bind to it instead of the.name property.
Or if you want to use the Data Integer inside your UDT to drive your multistate indicator, instead of having a template udt custom property, just use a string custom property with the path to the root of your udt tag instance and use a indirect binding in your multistate indicator to find your tag with a binding like {PathToTagHere}/Data and any other component should have a smiliar binding scheme.