Below is a simple version of the actual UDT, but the functionality is:
- During a period of time, count on certain conditions (check once per second)
- On the hour clock the results into a dataset and reset the count to 0
What I am observing is that the part of archiving the data and zeroing out the value happens only sometimes but other times it never occurs. So if the maximum seconds in an hour is 3600, I start to see values going to 5000 etc. because the reset is not happening.
What could be causing part of the code never to execute of execute only sometimes?
The trigger is just a second counter:
Which activates this tag change script
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents): count = system.tag.read("[.]value").value updatedCount = count + 1 system.tag.write("[.]value", updatedCount) if currentValue.value == 0 and system.date.getMinute(system.date.now()) == 0: history = system.tag.read("[.]history").value history = system.dataset.addRow( history, [system.date.now(), updatedCount] ) system.tag.writeBlocking( ["[.]history", "[.]value"], [history, 0] )
The UDT structure is like this: