Tag Events - Value Changed unable to detect changes more than four decimal places

Dear All

Good day

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.

Wonder if anyone encounter the same ?

Appreciate any advice or comments

thank you

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.

Also if you want to force a certain number of decimals using format you should replace the # with 0

'#,##0.000000'

1 Like

Thanks for kind reply

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 test with simple script as follows:

	path = tagPath
	prev = previousValue
	cur = currentValue
	init = initialChange
	missed = missedEvents
	print "path =", path
	print "prev.value = ", prev.value
	print "prev.quality = ", prev.quality
	print "cur.value = ",cur.value
	print "cur.quality = ", cur.quality
	print "init = ", init
	print "missed = ", missed

the result is

INFO   | jvm 3    | 2018/11/16 18:49:48 | path = [default]SSRVDDU/Input/dgps/CounterGPGGA
INFO   | jvm 3    | 2018/11/16 18:49:48 | prev.value =  3.1235688
INFO   | jvm 3    | 2018/11/16 18:49:48 | prev.quality =  Good
INFO   | jvm 3    | 2018/11/16 18:49:48 | cur.value =  3.1237778
INFO   | jvm 3    | 2018/11/16 18:49:48 | cur.quality =  Good
INFO   | jvm 3    | 2018/11/16 18:49:48 | init =  False
INFO   | jvm 3    | 2018/11/16 18:49:48 | missed =  False

so anything beyond 4 decimal place, it wont fire off
3.1237778 to 3.1234778 => yes
3.1237778 to 3.1237123 => no

Try it out to see for yourself :slight_smile:

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))

1 Like

@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.

2 Likes

Dear All

Thanks a lot for all the kind replies and advises and testing tries

Yes, with the right setting, it is finally working

Have a wonderful day ahead and a great weekend

cheers