I’m running into a strange issue with a tag change script on an expression tag in Ignition. The script is supposed to run when the value of the tag becomes True. However, the script never fires when the tag type is set to "Expression." But when I switch the tag to a memory tag and manually set the value to True, the script runs perfectly.
Here's the code:
if not initialChange and previousValue.quality.isGood() and currentValue.quality.isGood():
if currentValue.value:
# do something..
The value is the same in both cases, so I’m not sure why the script won’t execute when it’s an expression tag. Are tag change scripts handled differently for expression tags, or am I missing something?
No, but when restarting a tag, it is possible (likely, even) for a truly new value to be delivered with initialChange true, in which case you won't get an event with that value separately.
When the initial change flag is true, it means "I can't tell you anything about any previous value", and you have to fall back on other persistence if you need to identify a new value that arrives in that event.
You should not unconditionally ignore the initial change.