Evaluating tag write quality codes in scripts

What are the options for evaluating the quality code returned from system.tag.writeBlocking? I would rather have a comparison to a meaningful value like “Good” than a number like 192. Do we have access to built-in constants, or would I need to write my own?

Also, I see that in the expression language, there’s an isGood() function which returns True for any of the good tag quality values. Is there an equivalent available in scripting?

You can compare to the enum if you really want to:

from com.inductiveautomation.ignition.common.sqltags.model.types import DataQuality
if tag.quality == DataQuality.GOOD_DATA:
   ...

The values are available in the javadocs. Search for Quality, and then open DataQuality from the known implementing classes.

E.g.
DISABLED
GOOD_DATA
OPC_BAD_DATA
NOT_FOUND
… etc.

Otherwise, you can also use str() to convert the DataQuality to a string and simply compare to “Good”, “Disabled”, “Not Found”, etc.

Also yes, you can use isGood() on the quality as well (also visible from the javadocs):

val.quality.isGood()

Thanks, Nick. The isGood method is exactly what I need.

Psst! Nick!

val.quality.good

Haha, i thought there might have been a Javabeans method, but the ‘is’ tripped me up. Cheers! And happy new year

1 Like