Two Gateway Tag Change Scripts fire simultaneously when the PLC changes shift:
PLC
|
|── Shift tag changes ──► Script A
| writes memoryTag(Mtag1)
|
|── Machine status changes ──► Script B
reads memoryTag(Mtag1)
The race
Both scripts fire at the same instant. Script B reads the memory tag before Script A has finished writing it.
Script A Script B
| |
starts writing starts reading
memoryTag memoryTag
| |
| reads OLD value ← stale
| |
finishes writing writes DB row
memoryTag (new value) with OLD Mtag1 value
Script B gets the old value. The DB row is filed under the wrong production period.
Question
Is there a supported pattern to guarantee Script B reads the memory tag only after Script A has finished writing it?
Is there any better Approach to achieve it