So I have a (well actually I have dozens, but I've narrowed down the problem to just one) Integer memory tag (and some reference and expression tags pointing at it), and its value stays constant most of the time. I have a script running every 8 seconds to ask a server on the network for the latest value, and I use a block of code like this to update the tag:
TESTING_OFFSET = -1000
from com.inductiveautomation.ignition.common.model.values import BasicQualifiedValue
# Create a BasicQualifiedValue with value 100
bqv = BasicQualifiedValue(100)
bqv.timestamp = system.date.addYears(system.date.now(), TESTING_OFFSET )
# Write the BasicQualifiedValue to a Tag path
system.tag.writeBlocking(["[ThermotronDev]ThermatronDev/integer"], [bqv])
I use the timestamp in another script to confirm that the other script ran successfully within the past 8 seconds.
Here's a test I wrote to confirm that Ignition isn't saving my timestamp:
TESTING_OFFSET = -1000
from com.inductiveautomation.ignition.common.model.values import BasicQualifiedValue
# Create a BasicQualifiedValue with value 100
bqv = BasicQualifiedValue(100)
bqv.timestamp = system.date.addYears(system.date.now(), TESTING_OFFSET )
print("input timestamp: {}".format(bqv.timestamp))
# Write the BasicQualifiedValue to a Tag path
system.tag.writeBlocking(["[ThermotronDev]ThermatronDev/integer"], [bqv])
#confirm that the bqv's timestamp was saved in the Ignition Tag
tagsTimestamp = system.tag.readBlocking(["[ThermotronDev]ThermatronDev/integer"])[0].timestamp
print("output timestamp: {}".format(tagsTimestamp))
assert tagsTimestamp == bqv.timestamp, "the timestamp wasn't saved! :("
#if assertion succeeded:
print("the timestamp was saved! :)")
The assertion only succeeds if the value of the BasicQualifiedValue is changed from the number it was last time I ran this test script. If the value of the BasicQualifiedValue is the same, or if just a value is used instead of a BasicQualifiedValue (like True or False, and the value is the same as last time), then the assertion fails.
Should I try to work around this? e.g. by setting all of my tags' values to null for a few milliseconds before writing new values? Or maybe I'm using the timestamps feature wrong?