Value Changed Tag Event Data Quality

I’ve been chasing this one for a while and haven’t been able to get it figured out. I’m looking to condition a value changed script on a tag event with the value, initial change, and quality and can’t figure out the proper syntax.

Here’s what I have right now:

if currentValue.value == 1 and initialChange == 0:
   # do stuff

What do I need to do to also condition based on data quality? I haven’t been able to successfully use

currentValue.quality == "Good"

or

currentValue.quality == 192

What’s the proper syntax?

Also, is there a good place to look up the members of a data type (for example, the “dataQuality” data type)?

Thanks!

if currentValue.quality.isGood():
    *code here*

I forgot to mention that I’m using 7.9.9. My understanding is the “isGood()” function was introduced in 7.9.11.

The isGood() expression function was added in 7.9.11, but the actual quality object returned by QualifiedValue.getQuality() has had an isGood() method for a lot longer. You can also simplify @Duffanator’s a little bit more; if currentValue.quality.good: will do the same thing.

That worked, thank you. What I ended up with is:

if currentValue.value == 1 and currentValue.quality.good and initialChange == 0:
    # do stuff

One other related thing - is there a good place to find the addition members of Ignition defined data types? For example, what’s the best way to figure out that “xxx.quality.good” even exists?

Some general advice:

More specifically:
Printing the type of currentValue.quality (literally, just print type(currentValue.quality) will probably give you something like com.inductiveautomation.ignition.common.sqltags.model.types.DataQuality - the name of the Java class in our codebase. While I'd highly recommend the introspection tools I outline in the above post, you can also just go straight to the reference material (for example: ignition 7.9.5 API) and just look for DataQuality there. You'll see that this class implements the underlying Quality interface, which is where the isGood() method is actually defined.

1 Like