Hi everyone,
I'm trying to understand some behavior I'm observing with Memory Tags and Tag Event Scripts (Value Changed) in Ignition 8.1.
Test Setup
I created a new Boolean Memory Tag with a Value Changed script:
logger = system.util.getLogger("testmemTag")
logger.info(str(initialChange))
logger.info(str(previousValue))
logger.info(str(currentValue))
I did not change the tag value after creating the tag.
Logs Observed
Immediately after creating the tag:
[null, Uncertain_InitialValue, Thu Jul 02 12:38:36 UTC 2026]
[false, Good, Thu Jul 02 12:38:36 UTC 2026]
Then another event:
True
[false, Good, Thu Jul 02 12:38:36 UTC 2026]
[false, Good, Thu Jul 02 12:38:36 UTC 2026]
No actual value change occurred.
Similar Behavior After Gateway Restart
On another Memory Tag, after a Gateway restart, the Value Changed script logs:
previousValue = [null, Uncertain_InitialValue]
currentValue = [true, Good]
followed by another invocation where:
previousValue = [true, Good]
currentValue = [true, Good]
Again, no actual change in the Memory Tag value.
Questions
1. Is this expected behavior for Tag Event Scripts?
Can a Value Changed script on a tag be invoked during:
- Tag creation?
- Tag initialization?
- Gateway startup?
- Provider restart?
even when the underlying value does not actually change?
2. What exactly does initialChange mean in a Tag Event Script?
The documentation says it is intended to indicate initialization, but I'm unclear on:
- Why there can be multiple invocations with
initialChange=True - Whether it is guaranteed that the first real value transition will have
initialChange=False
3. Is previousValue = [null, Uncertain_InitialValue] the expected startup state?
In my tests, the current value is already:
Good
while only the previous value is:
null
Uncertain_InitialValue
Is this the normal way Ignition represents the initialization event?
4. Recommended Pattern to Ignore Startup Events?
If the requirement is:
"Do not execute business logic during Gateway startup or tag initialization, but do execute on the first genuine value change."
which pattern is recommended?
Option A:
if initialChange:
return
Option B:
if not previousValue.quality.isGood():
return
Option C:
if previousValue.value is None:
return
Option D:
if initialChange or previousValue.value == currentValue.value:
return
5. Any Known Differences for Memory Tags?
Is there any special behavior for Memory Tags regarding:
- Restoring persisted values on startup
- Tag event execution during restoration
- Multiple initialization events
compared to OPC or Expression Tags?
I'm mainly looking for the most reliable way to prevent startup-triggered executions while ensuring the first real tag change is never missed.
Thanks!