# Enum values e.g. for DataQuality

**URL:** <https://forum.inductiveautomation.com/t/enum-values-e-g-for-dataquality/16371>\
**Category:** Ignition\
**Created:** [December 20, 2017, 5:46am UTC](https://forum.inductiveautomation.com/t/enum-values-e-g-for-dataquality/16371 "2017-12-20T05:46:46Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [December 20, 2017, 5:46am UTC](https://forum.inductiveautomation.com/t/enum-values-e-g-for-dataquality/16371/1 "2017-12-20T05:46:46Z")

</div>

This might be an obvious question to some, but my java knowledge is lacking…

(excuse the horrible terminology) In Python scripting, how can I compare a value that is returned as an enum, to a value within the enum ‘variable’ (class?).

E.g.  
qual = system.tag.read(‘tagpath’).quality returns a DataQuality enum member, for example NOT\_FOUND.  
how can I compare this enum value to one of the members in the enum?  
E.g. qual == DataQuality.NOT\_FOUND

Cheers!

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [December 20, 2017, 3:50pm UTC](https://forum.inductiveautomation.com/t/enum-values-e-g-for-dataquality/16371/2 "2017-12-20T15:50:14Z")

</div>

The easiest way is to import the class from Java:

```auto
#import DataQuality
from com.inductiveautomation.ignition.common.sqltags.model.types import DataQuality

#use DataQuality
qual = system.tag.read("bogus").quality
if qual == DataQuality.NOT_FOUND:
  print "not found"
else:
  print "found, qual is", qual

```

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [December 20, 2017, 3:57pm UTC](https://forum.inductiveautomation.com/t/enum-values-e-g-for-dataquality/16371/3 "2017-12-20T15:57:14Z")

</div>

And to anticipate your next question, which is “how on earth would I know what package to import DataQuality from?”, you’d go to the [SDK Javadocs](http://files.inductiveautomation.com/sdk/javadoc/ignition79/790-beta1/index.html) for DataQuality:  
[http://files.inductiveautomation.com/sdk/javadoc/ignition79/790-beta1/com/inductiveautomation/ignition/common/sqltags/model/types/DataQuality.html](http://files.inductiveautomation.com/sdk/javadoc/ignition79/790-beta1/com/inductiveautomation/ignition/common/sqltags/model/types/DataQuality.html) . 😀

---

<div class="post-metadata">

**Author:** ![mrogers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mrogers/32/4110_2.png) [@mrogers](https://forum.inductiveautomation.com/u/mrogers)\
**Post date:** [December 20, 2017, 4:56pm UTC](https://forum.inductiveautomation.com/t/enum-values-e-g-for-dataquality/16371/4 "2017-12-20T16:56:11Z")

</div>

I don’t know if theres a specific reason you want to compare to the enum, but if you’re just looking to see if a tag is Good, Not Found, Disabled, etc - you can wrap str() around the .quality value and it’ll give you a string with the quality.

An example using most of Kathy’s example code:

```auto
qual = system.tag.read("bogus").quality
if str(qual) == "Not Found":
  print "not found"
else:
  print "found, qual is", qual

```

---

<div class="post-metadata">

**Author:** ![rpulsifer](https://avatars.discourse-cdn.com/v4/letter/r/e9a140/32.png) [@rpulsifer](https://forum.inductiveautomation.com/u/rpulsifer)\
**Post date:** [July 30, 2018, 6:31pm UTC](https://forum.inductiveautomation.com/t/enum-values-e-g-for-dataquality/16371/5 "2018-07-30T18:31:02Z")

</div>

Thanks Kathy! I’ve been beating against this all afternoon! And thanks for the anticipation of my next question, though I’'m still enough of a novice that it’d be a long while before I thought to go there!  
As to mrogers comment - I never would have thought of using “str” - I did spend a considerable amount of time trying to coerce the freaking thing into an int (specifically I was looking for any 410’s - DISABLED) since the manual _insists_ that quality is an integer and proceeds to give the whole list of corresponding numerical values.  
Seriously, if you’re going to go to the trouble of making that nice comprehensive chart in the manual ([https://docs.inductiveautomation.com/display/DOC79/Tag+Quality+and+Overlays](https://docs.inductiveautomation.com/display/DOC79/Tag+Quality+and+Overlays)) , you REALLY ought to mention that it isn’t of any use without the DataQuality enumeration!

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [July 30, 2018, 8:07pm UTC](https://forum.inductiveautomation.com/t/enum-values-e-g-for-dataquality/16371/6 "2018-07-30T20:07:11Z")

</div>

The int value is used a lot of places in Ignition. For example, if you use `system.gui.getQuality`, you’ll get the int value from the nice comprehensive chart in the manual. Then you’ll have your choice of writing code like

````auto
if qualityCode != 192:```

or 

```qualityCode = system.gui.getQuality(event.source.parent.getComponent('Numeric Label'), "value")
if qualityCode != DataQuality.GOOD_DATA.getIntValue()```

The first way is more compact, the second way is easier to grok the meaning of six months later. Your choice. :slight_smile:
````

---

<div class="post-metadata">

**Author:** ![rpulsifer](https://avatars.discourse-cdn.com/v4/letter/r/e9a140/32.png) [@rpulsifer](https://forum.inductiveautomation.com/u/rpulsifer)\
**Post date:** [August 3, 2018, 3:46pm UTC](https://forum.inductiveautomation.com/t/enum-values-e-g-for-dataquality/16371/7 "2018-08-03T15:46:27Z")

</div>

Thanks for the clarification. However, in my case, the script in question doesn't have any specific components to reference as it is a rather "headless" script used as a template. But I used your enum with much satisfaction....

> ```
> tagAttribs = system.tag.read(tagPath)
> tagQual = tagAttribs.quality
> Dissed = DataQuality.getQualityFor(410)
> if tagQual == Dissed: 
> system.tag.write("thisTagEnabled",False)
> else:
> system.tag.write("thisTagEnabled",True)
> 
> ```

Thank you!
