I would like a change script of some kind to fire anytime I write a value to a memory tag, even if I write the value to the tag that it already has.
When I run:
from com.inductiveautomation.ignition.common.model.values import BasicQualifiedValue as qval, QualityCode as qc
currentTagValue = system.tag.readBlocking(["[default]Tests/QualityChangeCheck"])[0].value
value = qval(currentTagValue, qc.Good, system.date.now())
system.tag.writeBlocking(["[default]Tests/QualityChangeCheck"], [value])
The timestamp doesn't change, no scripts run, etc. I understand why that might be, but is there any way for me to work around this?
I could read the tag, change it to something different, then change it back, but that could have plenty of side effects of its own.
You'll need to set your tag deadband mode to Off so that value changes without change in the actual value ... confusing ... still make it into the tag value. Otherwise, the deadband will see no change outside of it's range and discard the new value.
That makes sense, and so I changed it to deadband off, and then the timestamp changed, even when I wrote the same value to the tag. Even when I just wrote the value, not the full qualified value. Seemed like a good sign.
However, neither the Value Changed nor Quality Changed scripts fired.
It is something I want to run whenever this tag is written to, even if it doesn't change the tag value. I thought changing the timestamp would fire the value change, since the timestamp is one of the values in the qualified value, but it looks like I misread that.
So yes, I will call a function in the project script to run the logic and write to the tag.
The other workaround is to put an expression tag referring to the timestamp of the tag I am wanting to fire on timestamp changes. When that fires I know the timestamp changed. I even combined it with the value of the tag I am monitoring, so I can get previousValue/currentValues of that tag