Functions for background

Is there a way in ignition to create kind of a function that will receive parameters as the value of a tag and inside of that function it will compare the value with other tag values(limits) and depending of that logic it should return a "color" to be assigned as example to the background of a box. Inside of the function I need to receive some parametrs that will be used in the logic of the function, the logic inside of that function will have more than 4 comparisons to properly select the color to return.

Note , the intention of this function is to be utilized by several controls on screen that have to paint the background depending of the value and limits, so if the logic changes I only have to change it in one place.

I think you're describing the functionality of templates.

In vision you can create templates and add custom properties to them which function as parameters. You can also pass in parameters that are partial tag paths that can be used in indirect tag bindings.

Imagine a scenario where you have 20 pumps that are all animated using the same type of logic. You can create a UDT or organize your tags in folders where the tags in the folders have the same name for the same functionality (case sensitive). Then you can use indirect tag bindings in your template and simply change the tag path you pass in to an instance of the template to indirectly bind all of the animations.

You can also reference custom properties in scripts so you could do this in scripts but it is better to do it with indirect tag bindings (performance and more intuitive).

Also, avoid using the "tag" expression. Instead, create custom properties and do indirect bindings on them to assign values. You'll get much better performance this way.

I hope that makes sense but I'm finding this a little difficult to explain. Key terms to search for in documentation:
Indirect binding
Template
UDT

3 Likes

Also: Style Customizer

4 Likes

thanks I will check both ways.

Consider using an expression-driven Vision Client tag.

2 Likes

thank you