How to implement Accumulator

EDIT: 2020-09-11 Edited to new forum format

Using only SQLTags:
The Trigger tag doas all the work.

In the Expression/SQL section:

if({[.]Filling},
   (if((dateextract(now(),"sec")/2)=toInt((dateextract(now(),"sec")/2)),1,0)+1),
   0)

In the Tag Events/Value Changed Script:

if currentValue>0:
	flow=system.tag.read("[Client]Accumulator Test (JC)/Flow").value/60
	total=system.tag.read("[Client]Accumulator Test (JC)/Total").value
	system.tag.write("[Client]Accumulator Test (JC)/Total",total+flow)

The file below will import the tags into [Client]Accumulator Test (JC) (because I’m pretty sure you won’t already have a folder with that name… :laughing: )

On last thing: when the tags import, the Trigger tag will show an error. This is because it couldn’t initially bind to the Filling tag. Just open the tag in the editor and click Apply, and that should be taken care of. :thumb_right:

Hope this helps!
Accumulator Test (JC) sqltags.xml (1.32 KB)

4 Likes