State changing Tag

Hi! I have 2 OPC tags that return bool values when a certain component of a machine runs or not.

I want to create a new tag(class) where an output of integers 0-3 is returned automatically in the tag.


when mode and status change, I would like this new tag to change to the int values of 0 to 3 (depending on the case)

I tried making a UDT with the mode and status parameter but (as far as I could tell) they do not inherit or can be binded to the respective OPC tags.

I tried making a expression tag with nested if statements for the four cases but kept returning error (I am fairly new to ignition and its scripting), perhaps I should use a case or switch statement (and I tried) but I have trouble for assigning the value argument, as I have more than just one case and I would like it to see both states (true or false) for the 2 input tags and change the value of the new tag to the corresponding new state (0-3).

Could someone give me some guidance or advise as to what could possibly be done to achieve what I want? perhaps some reference examples could be helpful (the documentation does not show many deep examples)

Thank you in advance


Take a look at the binEnc() expression function.


Thanks! I ended up using an if nested expression, I was having trouble with the syntax I guess.
I now gave the binEnc a look, and I was able to obtain the same result combined with the switch function (and now that I see it, it would be much easier and less prone to errors later down the road when more variables are added)

1 Like