Scripting tag change event scripts

Has anyone had any success reading tag change event scripts?

I can read the EventScripts property for a given tag and get the event name for each script by iterating through the results of calling getDefinedEvents on the read value of the EventScripts property but I don’t know how to get the actual text of the event script.

This code prints out “valueChanged” but I also need the text of the script. Any ideas?

path = "Devices/SOME_DEVICE/lastupdate.EventScripts"

res = system.tag.read(path)
for e in res.value.getDefinedEvents():
	print e

Output of:

print dir(e)

is

['__add__', '__class__', '__cmp__', '__contains__', '__delattr__', '__doc__', '__eq__', '__getattribute__', '__getitem__', '__getnewargs__', '__getslice__', '__hash__', '__init__', '__len__', '__mod__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__rmul__', '__setattr__', '__str__', 'capitalize', 'center', 'count', 'decode', 'encode', 'endswith', 'expandtabs', 'find', 'index', 'isalnum', 'isalpha', 'isdecimal', 'isdigit', 'islower', 'isnumeric', 'isspace', 'istitle', 'isunicode', 'isupper', 'join', 'ljust', 'lower', 'lstrip', 'partition', 'replace', 'rfind', 'rindex', 'rjust', 'rpartition', 'rsplit', 'rstrip', 'split', 'splitlines', 'startswith', 'strip', 'swapcase', 'title', 'translate', 'upper', 'zfill']

getDefinedEvents() just returns a set of Strings. I think they’re meant to be the event id / key. Try calling get() on the TagEventScripts value with each of those ids.

I tried using:

print res.value.get("ValueChanged")

The output is None.

:scratch:

EDIT: nevermind, I called get() on the object (e) and that returns the script.

Thanks Kevin.

Hi,

We are having some issues.Basically suddenly the tag write value change script are not running.We see the values are changing.We see new time stamps.We see no errors.All the connections device,mysql are fine.Let me know if anyone has idea.It would ge great help.

Thanks,

Khashey

Start a new topic. Show more information.