EventScripts on a addTag Method

Gurus ,
Can i create a tag with EventScript in attributes ? if yes may i know the right way please.

            event_changed_script = [
				{
				  "eventid": "valueChanged",
				  "script": "\tif 1 \u003d\u003d 1:\n\t\tpass"
				}
			]
			system.tag.addTag(
				parentPath = parent_path,
				name = tag_name,
				tagType = tagType,
				dataType = dataType,
				attributes={
					"OPCServer":"Ignition OPC UA Server", 
					"OPCItemPath":"%s"%(OPCItemPath),
					"EventScripts" : event_changed_script
				}
			)

Considering you appear to be trying to set change events on a large number of tags through scripting you are very likely going to bog down your tag system with those scripts.

Unless what you are planning to do in that event changed script will execute in single digit milliseconds or less, put the main driving logic in a project library script and use a Gateway Tag Change event instead. You can define a Gateway Tag Change Event to monitor multiple tags and use the same script.

What is the actual script that you plan on applying to those tags?

3 Likes

What Ryan said, but also,

  • Use system.tag.configure, not the outdated addTag function.

  • If you do actually have a use case for repeating the same script on many tags, use the project library of your gateway scripting project to define repetitive scripts, so you only have to define the actual logic in one place (and can easily change it from there if needed).

1 Like

Thank you for the Right direction.

Gateway Events >> Tag Change is what i am going to use in my case,
just wondering if i can create those tag changes dynamically through script ?