The oldData=0 so equal to old value, is a request from client’s engineers, so we have to have that.
I then used a tag event script to write my previous value to the old Data tag.
if initialChange == True:
return
system.tag.writeBlocking(["[.]Old Data/oldData1"],[previousValue.value])`
When I simulate it, the expression is triggered when my previous value is written by the script and bounces around and breaks.
This happens even when I used a derived tag, replacing INFLOW_COUNTER with {source}.
How can I this tag driven by a single tag change other than using tag groups, we’ve got a lot of these calcs and I don’t want a tag group for each. I want it event based if possible
When I say break, I’m meaning that it would switch so fast that it would on occassion write a null value to our OldData tag and stop the loop as the expression tag errored.
I’ll try using the scripting, we had originally put this entire set of calculations into gateway timer script, but had some performance issues as it wouldn’t execute as we expected. I’ll try using a similiar script though with some changes.
Main issue is this the first of several calcs and a lot of these reference other calcs
This triggers only on a change of my Inflow Counter and I can then use my event change script to write to the old data tag.
Bit annoying that this is the only way to cleanly do it using expression tags only. I can’t be the only one calculating changes in a similar way. I would have thought the point of the derived tag was to have one driving reference and then an expression to calculate with, I have to wonder what is the use of the derived tag over a normal expression other than some kind of scaling.
I agree it’s not needed in this case, some of the other calculations aren’t as simple as using previous value into the oldData, some other calcs will use a small sum so will calculate an “old Data”. This just happened to be the calc I was working on first.
I’ve kept it simply as it’s part of the client request and also keeps all of the tags similar to each other. It may also be used for setting the value to 0 for diagnostics etc.