I have a memory tag with data type as dataset, it has a tag value change script associated with it
I have one row and 13 column,
Whenever I am making any change in any cell, the script is executing twice.
Why it is so ?
Perhaps show your code…
Well I can’t see that because it’s a screenshot and your code goes beyond the visible window.
Copy and paste that and put it inside a code block.
Instead of a hardcoded string, can you log the value and the tag path that are passed as parameters ?
I just happened to be working on appending a dataset tag today:
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
if not initialChange and currentValue.value != previousValue.value:
logger = system.util.getLogger("TagChangeExec_Test")
oldRowCount = previousValue.value.getRowCount()
newRowCount = currentValue.value.getRowCount()
logger.info(str(oldRowCount) + ", " + str(newRowCount))
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
logger = system.util.getLogger('TagChangeExec_Test')
logger.info('Exec')
logger.info(str(tagPath))
logger.info(str(initialChange))
logger.info(str(previousValue.value))
logger.info(str(currentValue.value))
This was not the first time I configured this dataset tag, I only changed of of the existing value of the dataset.
@svatsal77 Perhaps add this line as we’re all suggesting you do.
Updated code
logger = system.util.getLogger('TagChangeExec_Test')
if not initialChange and currentValue.value != previousValue.value:
logger.info('Exec')
logger.info(str(tagPath))
logger.info(str(initialChange))
logger.info(str(previousValue.value))
logger.info(str(currentValue.value))
Add the logger after the “if not” code…
Done, added the logger initialization under the if condition, but same behavior, triggering twice.
def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
if not initialChange and currentValue.value != previousValue.value:
logger = system.util.getLogger('TagChangeExec_Test')
logger.info('Exec')
logger.info(str(tagPath))
logger.info(str(initialChange))
logger.info(str(previousValue.value))
logger.info(str(currentValue.value))
JSON tag :
{
"valueSource": "memory",
"eventScripts": [
{
"eventid": "valueChanged",
"script": "\t\n\tif not initialChange and currentValue.value !\u003d previousValue.value:\n\t\tlogger \u003d system.util.getLogger(\u0027TagChangeExec_Test\u0027)\n\t\tlogger.info(\u0027Exec\u0027)\n\t\tlogger.info(str(tagPath))\n\t\tlogger.info(str(initialChange))\n\t\tlogger.info(str(previousValue.value))\n\t\tlogger.info(str(currentValue.value))"
}
],
"dataType": "DataSet",
"name": "Tag0",
"value": "{\"columns\":[{\"name\":\"Col0\",\"type\":\"java.lang.Boolean\"},{\"name\":\"Col1\",\"type\":\"java.lang.String\"}],\"rows\":[[true,\"0\"]]}",
"tagType": "AtomicTag"
}
You literally are telling your logger to log twice. Because you aren’t pulling the raw values out of the datasets, you can’t see the inner guts that one line is the previous value’s dataset data and the other is the current values.
Pardon, I didn't get that, as per my understanding the script should execute only once, and it is not the initial time the tag is configured or changed. I'm just logging the value of previous and current data, if you see the images, there are two sets of data getting logged
Removed the
logger.info(str(previousValue.value))
logger.info(str(currentValue.value))
Only kept :
logger.info(str(currentValue.value))
Please show the code that runs the named query (the source of the tag changes) and add logging to that code--it may be running twice also.
There's no named query, i am just observing the tag change script behavior with dataset as data type
Have you configured anything in the gateway events for a tag change as well on the tag itself? That could cause it to execute twice if you also put loggers in there.
I setup exactly what you've shown, memory dataset tag, 1x2 dataset, bool + int, with the same tag change script and it only executes once in 8.3.2. I also tested each way of changing the tag in the editor, in the browser, change one vs both columns, etc. Only executes once for me.
Though mine says PyDataset instead?
Then show the code that is changing your dataset.
Pretty sure that’s a backend change by IA between 8.1 and 8.3






