Have a tag with data type set as string.
Just encounter a phenomenon/behavior using Tag Events - Value Changed. When the data string sent to this tag is a chuck of data separated by delimiter. However every time the data received by the tag, the only changes is in small delta, the tag Value Change is unable to recognize as Value Change and thus, the script written in there would not be executed.
eg from
“!abc, 1234.12345,A,4567.45678,B”
to
“!abc, 1234.12312,A,4567.45612,B”
Had tried changing its Metadata - format string to more decimal places such as #,##0.#######
But it still wont work - still unable to detect the minor changes and the script inside Value Change will not execute.
I’m thinking it’s less to do with the format string, more to do with an issue on the script. Mind posting it? If you check Tag Diagnostics, do you see any script execution errors?
Side note, since your script is in a Tag Event, your code should initially be tabbed over.
Had change the Metadata - format string as per ‘#,##0.#######’ using data type as double
Cannot set as ‘#,##0.0000000’.
Had tested data with less than two decimal places value differences, the script will fire out
But with data that has more than two decimal places value differences, the script will not fire off.
So i dont think it is the scripting issue.
I just created a memory tag of double type.
Set its deadband to 0
Set its metadata format to #,##0.000000
Created a memory tag of string type to write to
Created a numberic field on a test window and proceeded to change the value from 1.500001 to 1.500002 to 1.500006 and every time it wrote the values to the string field.
Then this is my code
path = tagPath
prev = previousValue.value
cur = currentValue.value
init = initialChange
missed = missedEvents
if prev<>cur:
system.tag.write('TestStr','value changed from ' + str(prev) + ' to ' + str(cur))
@mic This is the part you were missing in your latest attempt. Tag Editor > Numeric > Deadband
Small note, when the datatype was a string (in your original post) it should have worked regardless of number format, since that property isn't really applied to strings: the value of a string can be anything, even non-numeric.