Pipe Fill Color per Expression Binding of Tag value

Trying to change pipe color based off a tag value, my experimental tag is a voltage tag averaging around 480. The Pipe fill color looks to be changing in the Perspective property editor correctly when I set some experssion logic, when checking true condition, if(tag>0,toColor("red")), and then checking false if(tac>490,toColor("black")), see code and images. However, the pipe view is not changing within my coordinate container. Please advise. I do have a broken icon next to the fill property stating "The value of this property will not be saved with the view".

if({[Sample_Tags]ESIF-A207-RS910/UnitId 4/4_Vab0-4_Vab0/4_Vab0}>0,toColor("red"),toColor("black"))


if({[Sample_Tags]ESIF-A207-RS910/UnitId 4/4_Vab0-4_Vab0/4_Vab0}>490,toColor("red"),toColor("black"))


  • think you must *use tag() function to read value of a tag path

https://docs.inductiveautomation.com/display/DOC81/tag

Eww! No! Not in user interfaces.

Instead, add a custom property to hold your live tag value, using an indirect tag binding. In your original expression, use that property.

(There are pathological behaviors associated with the tag() function. Use it only in actual expression tags.)

2 Likes

Unfortunately, the color values you get out of the expression language don't adapt to the web environment - they're somewhat "legacy" holdovers from Vision, which uses a Java specific color model.

Try returning a literal string "red" or "black", as a test (as in, drop toColor entirely) - or a hex color string like "#FF0000".

2 Likes

Reformatting:

if(
    {[Sample_Tags]ESIF-A207-RS910/UnitId 4/4_Vab0-4_Vab0/4_Vab0} > 0,
    "red",
    "black"
)

Be kind to yourself and those who have to maintain your code!
Also see Wiki - how to post code on this forum.

2 Likes

@PGriffith & @Transistor looks like removing the Vision java code worked, "red", "black" for true/false. The pipe within the containter is now changing. Thank you, I knew it was something simple.

@Sebastiao_Nankuta_Ga & @pturmel - Functions. I am definately looking into using funcitons, but I still need more experience to deploy them in my project. Right now, our system is so newbie that I just need simple graphics and navigation to deploy a draft and use case to get more funding for equipment at locations on our facility that we need visibility. I will reach out with any Function questions at a later date. Thank you for responding with suggestions, they are noted!!