Perspective expression binding

Ok after a a couple of days of messing with this I am coming to the experts for some advice.

This is what I am trying to setup

I have a diodeoncolor in a 14 segment LED “TAG2” that I want to change change color based on the tag value of a different tag let’s call it “TAG1”

so for example:

if TAG1 = 1 and TAG2 > 80 then diodeoncolor will be red or #FF0000
if TAG1 = 2 and TAG2 < 80 then diodeoncolor will be green or #00FF00

I have been messing around with expression bindings and I know the syntax is not like python but I can’t get anything but errors. Am I on the right path with trying to use an expression binding or is there a better way?

Thanks!

If statements work a bit differently in the expression language:

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

if(condition,trueReturn,falseReturn)

What do you want to happen if the value of TAG2 = 80?
What do you want to happen if TAG1 = 1 and TAG2 < 80?
What do you want to happen if TAG1 = 2 and TAG2 > 80?
What do you want to happen if TAG1 is not 1 or 2?

... diodeoncolor in a 14 segment LED ...

Why anyone would want to make a difficult to read 1970s looking HMI when Ignition gives the possibility of using clear Truetype character display is beyond me but anyway ...

  • Create an expression binding on props.diodeOnColor.
  • Add in the expression,
if(
	({[default]path/TAG1} = 1) && ({../Slider.props.value} > 80),
	'red',
	if(
		({[default]path/TAG1} = 2) && ({../Slider.props.value} < 80),
		'green',
		'blue'
	)
)

As @lrose has pointed out you have not considered all the possible cases.

To be fair he did say this was just an example.

@Tom.roberts
I'm not quite sure what it is you're trying to do, could you clarify your inputs and expected output ?
Are you setting up a tag ? A display component in a view ? What's the possible range on your variables ?

This example helped me figure out my issue! Thanks everyone for the quick responses!