I’m running Ignition 7.9.14 and trying to write tag change event scripts to tags with script.
https://docs.inductiveautomation.com/display/DOC79/system.tag.editTag
Documentation tells me that I can write attributes, great. It says these attributes are defined here:
https://docs.inductiveautomation.com/display/DOC79/Tag+Properties
If I wanted to do literally any other attribute, there’s good documentation here for that, but there are three lines under Tag Events that let me know it’s possible without providing any information on how to format that when I pass through system.tag.editTag.
I used system.tag.browseConfiguration to parse out the script that I want to pass and try to get some idea of the formatting of the dictionary I need to pass into system.tag.editTag’s attributes… it also converts this java hash object to a list, and then the list object from a SQL type to a string, before printing the original text and parsed script so I don’t have to deal with escaping all the script characters myself.
sourceTag = "***tag***"
tagConfig = system.tag.browseConfiguration(sourceTag,False)
propertyList = []
for tag in tagConfig:
propList = tag.getProperties()
print propList
for prop in propList:
#if prop == 'eventScripts':
#print "Property '%s' has a value of '%s'" % (prop, tag.get(prop))
#print propList[4]
propertyList.append(tag.get(prop))
#for property in propertyList:
# print property
#print propertyList.index("TagEventScripts[]")
#print propertyList[4]
tagChangeScript1 = str(propertyList[4])
print "------------------------------------------------"
print tagChangeScript1
print "------------------------------------------------"
tagChangeScript2 = tagChangeScript1.replace("TagEventScripts[scripts={valueChanged=(","")
#print type(tagChangeScript)
#print type(propertyList[4])
tagChangeScript = tagChangeScript2.replace(", enabled=true)}]","")
print "------------------------------------------------"
print tagChangeScript
print "------------------------------------------------"
That gives me some clues…
[HistoricalDeadband, HistoricalScanclass, InterpolationMode, tagType, eventScripts, path, HistoryTimestampSource, name, HistoryEnabled, PrimaryHistoryProvider, value, HistoryMaxAgeMode]
------------------------------------------------
TagEventScripts[scripts={valueChanged=( ***SCRIPT*** , enabled=true)}]
and this is where I’m stuck - I can’t seem to format the PyDictionary attributes correctly to feed in my script. Does anyone have a reference example using system.tag.editTag to pass eventScripts / TagEventScripts for valueChanged?