Top  | Previous | Next

system.tag.addTag

Description

Adds a new tag in Ignition. You can add OPC, memory, expression, query, folder, and UDT instance tags.

 

information2 This function accepts keyword-style invocation. See also: Functions / Keyword Invocation

Syntax

system.tag.addTag(parentPath, name, tagType, dataType, accessRights, enabled, value, attributes, parameters, overrides, alarmList, alarmConfig)

Parameters

String parentPath - The folder to add the tag to. Leave blank for the root folder.

String name - The name of the tag.

String tagType - The type of tag to create. Possible values are OPC, MEMORY, EXPRESSION, QUERY, Folder, and UDT_INST.

String dataType - The data type of the tag. Not used for UDT instances or folders. Possible values are Int1, Int2, Int4, Int8, Float4, Float8, Boolean, String, and DateTime.

String accessRights - The access rights for a tag. Possible values are Read_Only, Read_Write, and Custom.

boolean enabled - If true, the tag will be enabled.

Object value - The value of the tag. Used for memory tags.

PyDictionary attributes - The tag's configuration attributes.

PyDictionary parameters - The parameters for a UDT instance tag.

PyDictionary overrides - All of the overrides for a UDT instance tag.

String alarmList - List of alarms for the tag.

PyDictionary alarmConfig - The alarm configuration for the tag.

Returns

nothing

Scope

All

Examples

Example 1: Add OPC tag

 

system.tag.addTag(parentPath="", name="Tag1", tagType="OPC", dataType="Int2",

attributes={"OPCServer":"Ignition OPC-UA Server", "OPCItemPath":"[MLX]N7:0"})

 

Example 2: Add OPC tag with alarm

 

system.tag.addTag(parentPath="", name="TagAlarm", tagType="OPC", dataType="Int2", 

attributes={"OPCServer":"Ignition OPC-UA Server", "OPCItemPath":"[MLX]N7:0"}, 

alarmConfig={"Alarm 1":[["name", "Value", "Alarm 1"], ["setpointA", "Value", 1.0]], 

"Alarm":[["name", "Value", "Alarm"], ["Something", "Value", "sdfsdfs"], 

["enabled", "Expression", "1=2"]]})

 

Example 3: Add Folder

 

system.tag.addTag(parentPath="", name="Folder1", tagType="Folder")

 

Example 4: Add Memory tag

 

system.tag.addTag(parentPath="", name="Tag2", tagType="MEMORY", 

dataType="Int2", value=25)

 

Example 5: Add Expression tag

 

system.tag.addTag(parentPath="", name="Tag3", tagType="EXPRESSION", dataType="Int2", 

attributes={"Expression":"{[~]Tag1} * 20.5"})

 

Example 6: Add Query tag

 

system.tag.addTag(parentPath="", name="Tag4", tagType="QUERY", 

dataType="DateTime", attributes={"Expression":"SELECT CURRENT_TIMESTAMP", 

"SQLBindingDatasource":"MySQL"})

 

Example 7: Add UDT instance tag

 

# Before running this script, there must be a UDT named 'Motor'

# that has a string parameter 'DeviceName' and an integer parameter

# 'MotorNumber'.

system.tag.addTag(parentPath="", name="Tag5", tagType="UDT_INST", 

attributes={"UDTParentType":"Motor"}, parameters={"DeviceName":"CLX", 

"MotorNumber":1})

 

Example 8: Add UDT instance tag and override multiple parameters on status tag.

 

# Before running this script, there must be a UDT named 'SecondUDT'

# that has a string parameter 'DeviceName', an integer parameter

# 'MotorNumber', and a tag named "STATUS".

system.tag.addTag(parentPath="", name="Tag8", tagType="UDT_INST", 

attributes={"UDTParentType":"SecondUDT"}, 

parameters={"DeviceName":"CLX", "MotorNumber":2}, 

overrides={"STATUS":{"ScanClass":"Default Historical", "Enabled":"false"}})

 

Example 9: Add UDT instance tag and override the scan class of a tag inside of another UDT

 

# Before running this script, there must be a UDT named 'ThirdUDT'.

# ThirdUDT must contain another UDT named 'SecondUDT', which

# that has a string parameter 'DeviceName', an integer parameter

# 'MotorNumber' and a tag named "STATUS".

system.tag.addTag(parentPath="", name="Tag9", tagType="UDT_INST", 

attributes={"UDTParentType":"ThirdUDT"}, 

parameters={"Motor/DeviceName":"CLX", "Motor/MotorNumber":1}, 

overrides={"Motor/STATUS":{"ScanClass":"Default Historical"}})