Search

User Manual

GETTING STARTED


MODULES AND PLATFORM


APPENDIX


TUTORIALS & HELPFUL TRICKS


GLOSSARY


STRATEGIC PARTNER LINKS

Sepasoft - MES Modules
Cirrus Link - MQTT Modules

RESOURCES

Inductive University
Ignition Demo Project
Knowledge Base Articles
Forum
IA Support
SDK Documentation
SDK Examples

ALL MANUAL VERSIONS

Ignition 8
Ignition 7.9
Ignition 7.8

Deprecated Pages

Skip to end of metadata
Go to start of metadata


This function is used in Python Scripting.

Description

Creates Tags from a given list of Python dictionaries or from a JSON source string. Can be used to overwrite a current Tag's configuration.

When utilizing this function, the tag definitions must specify the names of properties with their scripting/JSON name. A reference of these properties can be found on the Tag Properties and Tag Alarm Properties pages.

Client Permission Restrictions

Permission Type: Tag Editing

Client access to this scripting function is blocked to users that do not meet the role/zone requirements for the above permission type. This function is unaffected when run in the Gateway scope.

Syntax

system.tag.configure(basePath, tags[, collisionPolicy])

  • Parameters

String basePath - The starting point where the new Tags will be created. When making changes to existing tags with this function, you want to set the path to the parent folder of the exiting tag(s), not the tag(s) themselves.

Object tags A list of Tag definitions, where each Tag definition is a Python dictionary. Alternately, a JSON source string may be passed to this parameter. When editing existing tags, it is generally easier to retrieve the tag configurations with system.tag.getConfiguration, modify the results of the getConfiguration call, and then write the new configuration to the parent folder of the existing tag(s).

String collisionPolicy - The action to take when a tag or folder with the same path and name is encountered. Possible values include

    • a - Abort and throw an exception
    • o - Overwrite and replace existing Tag's configuration
    • i - Ignore that item in the list.
    • m - merge, modifying values that are specified in the definition, without impacting values that aren't defined in the definition. Use this when you want to apply a slight change to tags, without having to build a complete configuration object.
    • Defaults to Overwrite. [optional]
  • Returns

List - A List of QualityCode objects, one for each tag in the list, that is representative of the result of the operation.

  • Scope

Gateway, Vision Client, Perspective Session

Code Examples
Python - Edit Multiple Tags
# This example will retrieve some existing tag configurations, make changes to the configurations, 
#  and write the new configurations to the original tags. 


# Define a a base path. Sometime useful, but we could hardcode the paths
#   in the getConfiguration() and configure() calls
parentPath = "[NewProvider]SomeFolder"

# Get the current configurations recursivly, which is useful when targeting
#  folders and UDT Instances
configs = system.tag.getConfiguration(parentPath + "/AnotherFolder", True)

# The getConfiguration() above always returns a list of dictionaries, and our results
#  are inside of the first dictionary. 
for tag in configs[0]['tags']:

	# Check each node. At this point we may get folders or other nodes
	# that we're uninterested in. Examine tagType to figure it out.
    # Note that we're making sure the tagType is in fact a string for this comparison.	
	if str(tag['tagType']) != 'Folder':
		
		# Make a change to the tag. If we're iterating over UDT instances,
		#  then we can change the parameters here. Commented example below:
		# tag['parameters']['myParam'] = foo
		
		# In our case, we'll just disable the tags
		tag['enabled'] = False

system.tag.configure(parentPath, configs, "o")
Python - Adding a New Tag
# This example will add a new OPC tag. It can be further expanded to modify more
#   properties on the tag. Additionally, this example can be used to edit an existing tag
#   by setting the baseTagPath to a tag that already exists, and by modifying the collision policy.

# The provider and folder the tag will be placed at.  
baseTagPath = "[default]MyFolder"

# Properties that will be configured on that tag.
tagName = "myNewTag"
opcItemPath = "ns=1;s=[Simulator]_Meta:Sine/Sine0"
opcServer = "Ignition OPC-UA Server"
valueSource = "opc"
sampleMode = "TagGroup"
tagGroup = "Default"

# Configure the tag.
tag = {
			"name": tagName,			
			"opcItemPath" : opcItemPath,
			"opcServer": opcServer,
			"valueSource": valueSource,
			"sampleMode" : sampleMode,
			"tagGroup" : tagGroup
		}

# Set the collision policy to Abort. Thus, if a tag already exists at the base path, 
#    we will not override the tag. If you are overwriting an existing tag, then set this to "o"
collisionPolicy = "a"

# Create the tag. 
system.tag.configure(baseTagPath, [tag], collisionPolicy)
Python - Interacting with Alarms
# The provider and folder the tag will be placed at.  
baseTagPath = "[default]"

# Create a list of alarms, where each alarm is a Python Dictionary. 
alarms = [
			{
				"name":"My scripting alarm",				
				"mode":"AboveValue",				
				"setpointA":10
			}
		]

# Configure the list of tags. We're only interacting with a single tag, but still need to pass
#	a list as an argument. 
tags = [
			{ 
				"alarms":alarms,
				"name":"myTag"
			}
		]

# Abort if this example attempts to overwrite any of your existing tags. 
collisionPolicy = "a"

# Create the tag. 
system.tag.configure(baseTagPath, tags, collisionPolicy)


Python - Add UDT Instance
# This example will add a new UDT Instance. It can be further expanded to modify more
# properties on the tag. Additionally, this example can be used to edit an existing tag
# by setting the baseTagPath to a tag that already exists, and by modifying the collision policy.
 
# The provider and folder the tag will be placed at.
baseTagPath = "[default]Motors"
 
# Properties that will be configured on that tag.
tagName = "Motor 1"
typeId = "Motor"
tagType = "UdtInstance"
# Parameters to pass in.
motorNum = "1"
 
# Configure the tag.
tag = {
            "name": tagName,          
            "typeId" : typeId,
            "tagType" : tagType,
            "parameters" : {
              "motorNum" : motorNum
              }
       }

# Set the collision policy to Abort. That way if a tag already exists at the base path,
# we will not override the tag. If you are overwriting an existing tag, then set this to "o"
collisionPolicy = "a"
 
# Create the tag.
system.tag.configure(baseTagPath, [tag], collisionPolicy) 

Python - Adding Folders in other Folders
# Folders are nodes with a 'tagType' set to 'Folder'
# Each folder can contain a 'tags' value, which containers other tags and folders. 

Tags={'tagType': 'Folder',
		'name': 'NewFolderName',
		'tags' : [ 
					{ 
					'name': 'anotherfolder',
					'tagType': 'Folder',
					'tags': [{}]			# There aren't any objects defined here, so this will just be an empty folder. 					
					}
				]
		}

system.tag.configure( 	basePath = '',
						tags = Tags,
						collisionPolicy = "o"
					)

Python - Writing to Parameters in UDT Definition

In this example, we're going to change the value on a UDT Definition parameter with a script. It assumes there is a UDT Definition already configured at the root of the Data Types folder (in this case, named "myUdtDef"), and contains a parameter (named "myParam" ).

 Click here to see example images...

# UDT Definitions reside in the "_types_" folder, which can be retrieved 
#	via the Tag Browser : right-click > Copy Tag Path
# Retrieving the existing configuration is much easier than typing it all out
tag = system.tag.getConfiguration("[default]_types_/myUdtDef")

# This line is accessing the first tag in our results (the UDT Definition), then returns the
#	'parameters' dictionary, which then provides access to individual parameters
tag[0]['parameters']['myParam'] = '300'

# Overwrite the existing configuration
collisionPolicy = "o"
 
# Write the new configuration to our existing UDT Definition
#	Note that the first parameter is to the parent folder of the Definition,
#	not a path to the Definition.
system.tag.configure("[default]_types_", tag, collisionPolicy)

# Once the configure call finishes, myParam on the Definition should have a value of 300.
Keywords

system tag configure, tag.configure

  • No labels