Ignition Expressions compare quality values

The problem de jour is taking an existing tag, and testing for a particular quality value with an Ignition expression.

With the expression function library, I can use the qualityOf function to pull out just the QualityCode value. At the moment, I am only successfully able to test against this quality code with the integer value representation - which is workable, just cryptic.

For instance, if I want to return different values based off of the quality code using a case statement, I would write that as:

case(qualityOf({<tag_path>}), -2147483124, "Out of range!", "")

Ideally, I’d like to have the enumerated value used in this case statement for better readability when combining many quality codes into a single case statement, like so:

case(qualityOf({<tag_path>}), QualityCode.Bad_OutOfRange, “Out of range!”, “”)

I understand it is also possible to dive into a Python script and expose quality codes via an import: from com.inductiveautomation.ignition.common.model.values import QualityCode

I am trying to avoid using a script for this logic for performance reasons.

Thank you,

- Paul

But an enumerated value is not a number that could be used with the result of qualityOf(). They are objects. Ignition’s expression language doesn’t really do objects, other than a few special cases. That’s a big part of what makes them fast.

1 Like

I figured as much. Thanks for the response.

I was wishing that there was a builtin #define in the expression language interpreter that would be able to swap out friendly symbols with the associated integer values, and I was just being blind to those symbols. Another item for the wishlist then :slight_smile:

I don’t know if I’d call this a good idea, necessarily, but toString(qualityOf()) returns the human readable string for our predefined codes. You could still have values that fall out of our expected range, but as long as they’re appropriately handled by the case that could work.

1 Like