Value Changed Tag Event Data Quality

#1

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!

0 Likes

#2
if currentValue.quality.isGood():
    *code here*
0 Likes

#3

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

0 Likes

#4

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.

0 Likes

#5

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

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

#6

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?

0 Likes

#7

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: http://files.inductiveautomation.com/sdk/javadoc/ignition79/795/index.html) 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.

0 Likes