I am trying to add multiple tags in one piece of conveyor

"For example, I want to be able to use a tag for MF_LAT = 1 and all my conveyor sections will be flashing red, but when UNIT_EN is equal to 1, that will run my conveyor and everything will be green. And when F_BK = 1, then I can use another type of lighting like orange. In summary, running mode will be green with a tag for that, MF_LAT will be flashing red and that is another tag, and F_BK will be flashing orange and that is the third tag."

I would create a UDT for your conveyor. Have your four tags in that UDT plus an additional expression tag and name that "state" and setup a nested if or case statement in that expression tag.

or you setup that state tag in the PLC and feed that up to Ignition.

You can have that state tag drive your front end styling. Assuming I understand what, you are trying to achieve.

1 Like

In the case statement, you might want to use binEnc to binary encode the various tags to then get your state

can you show me an example on how to do it ?

It's in the docs.

Something like this. I like to reuse binEnc in the compares so that I can easily relate the tags, but it'd be slightly less performant...

case(binEnc({...MF_LAT}, {...F_BK}, {...AUX}, {...UNIT_EN}),
   binEnc(0,0,0,0), 0,
   binEnc(0,0,0,1), 1,
   binEnc(0,0,1,0), 2,
   binEnc(0,1,0,0), 3,
   binEnc(1,0,0,0), 4,
   -1
)

If the values should all be mutually exclusive as in the above case, then you could more simply use binEnum:

binEnum({...MF_LAT}, {...F_BK}, {...AUX}, {...UNIT_EN})
// => Result would be 0, 1, 2, 3, 4 based on what tag is on.
//Precedence is given to the values in the order of the args. e.g. if arg2 and 3 are on, arg2 wins and will result in 2

Don't mind me, just making a mental note to support binary literals in the expression language at some point...

4 Likes

Hex literals too :slight_smile:

Hex literals already work? 0x124 worked for me :slight_smile:

2 Likes