I have a couple hundred of on change scripts within my tag browser and a couple hundred (some overlapping with tag browser but different scripts) on my gateway events, these scripts only fire off when the tag changes. However, I am noticing that whenever we do redundancy testing and master node gets restarted, when master becomes active again the first value change does not execute but the second onwards executes.
On my gateway event scripts I have
if not initialChange and event.currentValue.value:
On tag browser scripts I have
if not initialChange and currentValue.value:
this prevents scripts from firing right away when we switch between master and backup nodes.
however there are times when my scripts still fire off because the tags goes from NULL to True so I updated to become
if not initialChange and event.previousValue and event.currentValue.value:
if not initialChange and previousValue and currentValue.value:
now whenever we switch from backup to master or restart master the very first tag change the script does not execute but the second time it changes it does.
I cant figure out how to get the redundancy to work correctly, what I am trying to do is whenever we switch to a different node regardless of restarts/which node is active, the script does not fire only until the tag changes values.
So far, the only thing I can think of which might work is to remove any tag browser scripts and move them all to the gateway, then create a new 'lastknownvalue' tag for each tag that requires an onchange and store the last value to this tag and when my scripts fires off regardless on restarts/saves/node switches it will check the 'lastknownvalue' tag value and compare with the current tag
tag changes:
a = get value of lastknowvalue tag
if currentValue.value and currentValue.value != a:
run code
if currentValue.value != a:
lastknowvalue tag = currentValue.value
would this be a working case and is there any other cases that might work. Im running on version 8.3