This class allows creation and modification of l5x Tag.

XML data is stored in variablename.l5xdata (XMLDocument format).


Example 1:

Creating an l5x Tag with default parameters:

const myNewTag = new kSDKv1.l5xTag();

New tag is a BOOL tag with name “Kiptr” and default value FALSE that can be modified with methods (see below).


Example 2:

Creating a project from custom XML (this will overwrite all default parameters):

const myNewCustomProj = new kSDKv1.l5xProject('<Tag Name="SomeTag" TagType="Base" DataType="BOOL" Constant="false" ExternalAccess="Read/Write">'+
'<Description>'+
'<![CDATA[]]>'+
'</Description>'+
'<Data Format="Decorated">'+
'<DataValue DataType="BOOL" Value="0"/>'+
'</Data>'+
'</Tag>');

It is important to inject XML with the root node "Tag". An error is generated if this condition is not satisfied.


METHODSClick on Methods for further information
Category
getsetadddeleteSpecial
NamegetName()setName()



DatagetData()setData()


Tag TypegetTagType()setTagType()


Data TypegetDataType()setDataType()


ValuegetValue()setValue()


AttributegetAttribute()setAttribute()


AliasgetAlias()setAlias()


DescriptiongetDescription()setDescription()


Consumed InfogetConsumedInfo()setConsumedInfo()


Produced InfogetProducedInfo()setProducedInfo()


MSG AttributegetMSGAttribute()setMSGAttribute()


ALM AttributegetALMAttribute()setALMAttribute()


ALM MessagegetALMMessage()setALMMessage()


ALM ClassgetALMClass()setALMClass()


HMI CommandgetHMICommand()setHMICommand()


Files



toText()
AOI Tags



fixAOITags()
UDT Tags



fixUDTTags()


Name


getName()

ParametersReturns
Returns a tag name.
NATag name - (string)


Example

var newTag = new kSDKv1.l5xTag();
newTag.setName("NewTag");
console.log(newTag.getName()); // -> "NewTag"



setName(newName)

ParametersReturns

Sets new tag name.

newName – (string) New tag name.NA


Example

var newTag = new kSDKv1.l5xTag();
newTag.setName("NewTag");
console.log(newTag.getName()); // -> "NewTag"


Data


getData()

ParametersReturns
Returns a default value for tag (XML Attribute “Data”).
NATag default value - (string)


Example

var newTag = new kSDKv1.l5xTag();
newTag.setData("1");
console.log(newTag.getData()); // -> "1"



setData(newData)

ParametersReturns

Sets new default value for tag (XML Attribute “Data”).

newName – (string) New tag default value.NA


Example

var newTag = new kSDKv1.l5xTag();
newTag.setData("1");
console.log(newTag.getData()); // -> "1"


Tag Type


getTagType()

ParametersReturns
Returns current tag type for tag (Base, Alias, Produce, or Consumed).
NATag type - (string)


Example

var newTag = new kSDKv1.l5xTag();
newTag.setTagType("Base");
console.log(newTag.getTagType()); // -> "Base"



setTagType(newTagType)

ParametersReturns

Sets new type for tag (Base, Alias, Produce, or Consumed).

newTagType – (string) New tag type. Has to be one of the following: Base, Alias, Produce, or Consumed. Error is generated if value is anything else.NA


Example

var newTag = new kSDKv1.l5xTag();
newTag.setTagType("Base");
console.log(newTag.getTagType()); // -> "Base"


Data Type


getDataType()

ParametersReturns
Returns current data type for tag (BOOL, SINT, INT, DINT, LINT, REAL etc.).
NATag data type - (string)


Example

var newTag = new kSDKv1.l5xTag();
newTag.setDataType("sint");
console.log(newTag.getDataType()); // -> "SINT"



setDataType(newDataType, dimension)

ParametersReturns

Sets new data type for tag (BOOL, SINT, INT, DINT, LINT, REAL etc.).

newDataType – (string) New tag data type.

dimension - (string) optional. Dimension of the array. Can be multidimensional (“2,2,2”) or single-dimensional (“5”). Should be up to three numbers separated by a comma.

NA


Note:

  1. Kiptr does not check the validity of the data type entry. You will get an error when importing an l5x file into Studio5000 software if tag is assigned a data type that is not existing in the project.
  2. Kiptr will auto-capitalize newDataType.
  3. Kiptr will automatically add necessary attributes if the new data type is ALARM_ANALOG, ALARM_DIGITAL, MESSAGE or TIMER.
  4. Kiptr has currently limited support for organizing parameters for several kinds of tag (e.g. arrays of UDTs, motion related tags). We are working on improving this function. Contact tech support if you experience difficulties.

Example

var newTag = new kSDKv1.l5xTag();
newTag.setDataType("sint");
console.log(newTag.getDataType()); // -> "SINT"

Creating an array of tags with data type of AOI:

var newPrj = new kSDKv1.l5xProject();
var myXML = "<SomeXMLcode/>" // Assuming you use your own AOI with parameters defined
var myAOI = new kSDKv1.l5xAOI(myXML);
var newTag = new kSDKv1.l5xTag(); // Creating a default BOOL
newTag.setName("myArray"); // Setting new tag name
newtag.fixAOITag(myAOI); // This will set the Data Type = AOI name
// and will update the structure of the tag to match AOI parameters
newTag.setDataType(newTag.getDataType(), 10); // This will modify the tag to an array of 10 tags with same Data Type




Value


getValue(tag)

ParametersReturns
Returns current tag value.
tag - (string) optional.
Tag for complex structures and arrays. Not needed (but OK to include) for atomic types (BOOL, SINT, INT, DINT, LINT, REAL, STRING).
Tag value - (string)


Note:

  1. String length (stringTag.LEN) and individual characters are not supported (stringTag.DATA[xx]). You can reference the whole string only (see example below). This is the limitation of L5X format.

Example


Atomic types:

var newTag = new kSDKv1.l5xTag();
newTag.setValue("1");
console.log(newTag.getValue()); // -> "1"
console.log(newTag.getValue(newTag.getName())); // -> "1"
newTag.setDataType("String");
console.log(newTag.getValue()); // -> ""
newTag.setValue("SomeText");
console.log(newTag.getValue()); // -> "SomeText"

Array:

var newTag = new kSDKv1.l5xTag();
newTag.setDataType("sint", "5,5");
newTag.setName("myNewTag");
newTag.setValue("15", "myNewTag[1,3]");
console.log(newTag.getValue("myNewTag[1,3]")); // -> "15"
console.log(newTag.getValue()); // -> Error. Tag name is missing for complex structure

Complex Structures:

var newTag = new kSDKv1.l5xTag();
newTag.setDataType("someUDT"); // Creation of data type "SomeUDT" is not shown here
newTag.setName("myNewTag");
newTag.setValue("1", "myNewTag.tagBranch1.tagBranch2[0].Enable");
console.log(newTag.getValue("myNewTag.tagBranch1.tagBranch2[2].Enable")); // -> "1"



setValue(newValue,tag)

ParametersReturns

Sets new value for tag.

newValue – (string) New tag value.

tag - (string) optional. Tag for complex structures and arrays. Not needed (but OK to include) for atomic types (BOOL, SINT, INT, DINT, LINT, REAL, STRING). 

NA


Note:

  1. Kiptr does not check if the value matches the type of the tag.
  2. String length (stringTag.LEN) and individual characters are not supported (stringTag.DATA[xx]). You can reference the whole string only (see example below). This is the limitation of L5X format.

Example 


Atomic types:

var newTag = new kSDKv1.l5xTag();
newTag.setValue("1");
console.log(newTag.getValue()); // -> "1"
console.log(newTag.getValue(newTag.getName())); // -> "1"
newTag.setDataType("String");
console.log(newTag.getValue()); // -> ""
newTag.setValue("SomeText");
console.log(newTag.getValue()); // -> "SomeText"

Array:

var newTag = new kSDKv1.l5xTag();
newTag.setDataType("sint", "5,5");
newTag.setName("myNewTag");
newTag.setValue("15", "myNewTag[1,3]");
console.log(newTag.getValue("myNewTag[1,3]")); // -> "15"
console.log(newTag.getValue()); // -> Error. Tag name is missing for a complex structure

Complex Structures:

var newTag = new kSDKv1.l5xTag();
newTag.setDataType("someUDT"); // Creation of data type "SomeUDT" is not shown here
newTag.setName("myNewTag");
newTag.setValue("1", "myNewTag.tagBranch1.tagBranch2[0].Enable");
console.log(newTag.getValue("myNewTag.tagBranch1.tagBranch2[2].Enable")); // -> "1"




Attribute


getAttribute(attribName)

ParametersReturns
Returns current value of tag attribute with name attribName. Can be used to read any tag attribute. Kiptr does not provide methods for accessing all possible attributes of a tag. This method can be used to get values for attributes that are not natively supported.
attribName - (string) Name of attribute to read.Tag value - (string)


Example

var newTag = new kSDKv1.l5xTag();
newTag.setAttribute("ExternalAccess", "None");
console.log(newTag.getAttribute("ExternalAccess")); // -> "None"



setAttribute(attribName, newValue)

ParametersReturns

Sets new value for tag attribute.

attribName - (string) Name of attribute to set.

newValue - (string) Value of attribute to set.

NA


Note:

  1. Kiptr does not check if the value matches the type of the tag.

Example

var newTag = new kSDKv1.l5xTag();
newTag.setAttribute("ExternalAccess", "None");
console.log(newTag.getAttribute("ExternalAccess")); // -> "None"


Alias For


getAliasFor()

ParametersReturns
Returns current value of tag alias setting.
NAAlias setting - (string)


Example

var newTag = new kSDKv1.l5xTag();
newTag.setTagType("Alias");
newTag.setAliasFor("SomeTag");
console.log(newTag.getAliasFor()); // -> "SomeTag"



setAliasFor(newAlias)

ParametersReturns

Sets new value for tag alias setting.

newAlias - (string) Value of alias setting.NA


Note:

  1. Kiptr does not check if the alias exists.
  2. Kiptr will automatically change the tag type to “Alias”.

Example

var newTag = new kSDKv1.l5xTag();
newTag.setTagType("Alias");
newTag.setAliasFor("SomeTag");
console.log(newTag.getAliasFor()); // -> "SomeTag"


Description


getDescription()

ParametersReturns
Returns tag description.
NATag description - (string)


Example

var newTag = new kSDKv1.l5xTag();
newTag.setDescription("New Tag Description");
console.log(newTag.getDescription()); // -> "New Tag Description"



setDescription(newDescription)

ParametersReturns

Sets new tag description.

newDescription - (string) New tag description.NA


Example

var newTag = new kSDKv1.l5xTag();
newTag.setDescription("New Tag Description");
console.log(newTag.getDescription()); // -> "New Tag Description"


Consumed Info


getConsumedInfo(attribute)

ParametersReturns
Returns values of attributes related to Consumed tag.
attribute - (string) Name of attribute to read. Can be either of: Producer, RemoteTag, RemoteFile, RPI. Any other value will result in an error message.Attribute value - (string)


Example

var newTag = new kSDKv1.l5xTag();
newTag.setTagType("Consumed");
newTag.setConsumedInfo("Producer", "RemotePLC");
console.log(newTag.getConsumedInfo("Producer")); // -> "RemotePLC"



setConsumedInfo(attribute, newVal)

ParametersReturns

Sets new values of attributes related to Consumed tag.

attribute - (string) Name of attribute to read. Can be either of: Producer, RemoteTag, RemoteFile, RPI. Any other value will result in an error message.

newVal - (string) New value of attribute.

NA


Example

var newTag = new kSDKv1.l5xTag();
newTag.setTagType("Consumed");
newTag.setConsumedInfo("Producer", "RemotePLC");
console.log(newTag.getConsumedInfo("Producer")); // -> "RemotePLC"


Produced Info


getProducedInfo(attribute)

ParametersReturns
Returns values of attributes related to Produced tag.
attribute - (string) Name of attribute to read. Can be either of: ProduceCount, MinimumRPI, MaximumRPI, DefaultRPI. Any other value will result in an error message.Attribute value - (string)


Example

var newTag = new kSDKv1.l5xTag();
newTag.setTagType("Produced");
newTag.setProducedInfo("ProduceCount", "20");
console.log(newTag.getProducedInfo("ProduceCount")); // -> "20"



setProducedInfo(attribute, newVal)

ParametersReturns

Sets new values of attributes related to Produced tag.

attribute - (string) Name of attribute to read. Can be either of: ProduceCount, MinimumRPI, MaximumRPI, DefaultRPI. Any other value will result in an error message.

newVal - (string) New value of attribute.

NA


Example

var newTag = new kSDKv1.l5xTag();
newTag.setTagType("Produced");newTag.setProducedInfo("ProduceCount","20");
console.log(newTag.getProducedInfo("ProduceCount")); // -> "20"


MSG Attribute


getMSGAttribute(attribute)

ParametersReturns
Returns values of attributes related to Message tag.
attribute - (string) Name of attribute to read.Attribute value - (string)


Example

var newTag = new kSDKv1.l5xTag();
newTag.setDataType("Message");newTag.setMSGAttribute("RequestedLength", "2");
console.log(newTag.getMSGAttribute("RequestedLength")); // -> "2"



setMSGAttribute(attribute, newVal)

ParametersReturns

Sets new values of attributes related to Message tag.

attribute - (string) Name of attribute to read.

newVal - (string) New value of attribute.

NA


Example

var newTag = new kSDKv1.l5xTag();
newTag.setDataType("Message");
newTag.setMSGAttribute("RequestedLength", "2");
console.log(newTag.getMSGAttribute("RequestedLength")); // -> "2"


ALM Attribute


getALMAttribute(attribute)

ParametersReturns
Returns values of attributes related to Alarm tag.attribute - (string) Name of attribute to read.Attribute value - (string)


Example

var newTag = new kSDKv1.l5xTag();
newTag.setDataType("Alarm_Digital");
newTag.setALMAttribute("Severity", "200");
console.log(newTag.getALMAttribute("Severity")); // -> "200"



setALMAttribute(attribute, newVal)

ParametersReturns

Sets new values of attributes related to Alarm tag.

attribute - (string) Name of attribute to read.
newVal - (string) New value of attribute.
NA


Example

var newTag = new kSDKv1.l5xTag();
newTag.setDataType("Alarm_Digital");
newTag.setALMAttribute("Severity", "200");
console.log(newTag.getALMAttribute("Severity")); // -> "200"


ALM Message


getALMMessage()

ParametersReturns
Returns values of attributes related to Alarm tag.
NAMessage type and corresponding value - (Array of objects; Object: two strings. First type of message, second - Message text)


Example

var newTag = new kSDKv1.l5xTag();
newTag.setDataType("Alarm_Analog");
newTag.setALMMessage("HH", "New message for High High alarm");
console.log(newTag.getALMMessages()[0].Type); // -> "HH"
console.log(newTag.getALMMessages()[0].Text); // -> "New message for High High alarm"



setALMMessage(msgType, msgText)

ParametersReturns

Sets new values of attributes related to Alarm tag.

msgType - (string) Type of message to set.

msgText - (string) New value of attribute.

NA


Note:

Message type can be any value if working with Alarm Digital. Kiptr will automatically replace it with “AM” (the only option available for Alarm Digital). Type for Alarm Analog can be any of: “HH” (high-high alarm), “H” (high alarm), “L” (low alarm), “LL” (low-low alarm), “POS” (rate-of-change positive alarm), “NEG” (rate-of change negative alarm).


Example

var newTag = new kSDKv1.l5xTag();
newTag.setDataType("Alarm_Analog");
newTag.setALMMessage("HH", "New message for High High alarm");
console.log(newTag.getALMMessages()[0].Type); // -> "HH"
console.log(newTag.getALMMessages()[0].Text); // -> "New message for High High alarm"


ALM Class


getALMClass()

ParametersReturns
Returns the value of Alarm class.
NAValue of Alarm class - (string)


Example

var newTag = new kSDKv1.l5xTag();
newTag.setDataType("Alarm_Analog");
newTag.setALMClass("NewAlmClass");
console.log(newTag.getALMClass()); // -> "NewAlmClass"



setALMClass(newClass)

ParametersReturns

Sets new value of Alarm class.

newClass - (string) New alarm class to set.NA


Example

var newTag = new kSDKv1.l5xTag();
newTag.setDataType("Alarm_Analog");
newTag.setALMClass("NewAlmClass");
console.log(newTag.getALMClass()); // -> "NewAlmClass"


HMI Command


getHMICommand()

ParametersReturns
Returns the value of HMI command from Alarm.
NAHMI command - (string)


Example

var newTag = new kSDKv1.l5xTag();
newTag.setDataType("Alarm_Analog");
newTag.setHMICommand("{[PLC]SomeAction = 0}");
console.log(newTag.getHMICommand()); // -> "{[PLC]SomeAction = 0}"



setHMICommand(newCommand)

ParametersReturns

Sets new value of HMI command.

newCommand - (string) New HMI command.NA


Example

var newTag = new kSDKv1.l5xTag();
newTag.setDataType("Alarm_Analog");
newTag.setHMICommand("{[PLC]SomeAction = 0}");
console.log(newTag.getHMICommand()); // -> "{[PLC]SomeAction = 0}"



Files


toText()

ParametersReturns
Returns contents of XMLDocument stored in variable.l5xdata as a text.
NAXML in a text format.


Example

var newPrj = new kSDKv1.l5xProject();
console.log(newPrj.toText());

AOI Tags


fixAOITags(AOI)

ParametersReturns
Sets tag data type as the AOI name and modifies the tag structure to match AOI parameters. Default values from AOI parameters will be assigned to corresponding tag sections.
AOI - (l5xAOI) AOI to get parameters and name from.NA


Example

var newTag = new kSDKv1.l5xTag();
var newAOI = new kSDKv1.l5xAOI();
newAOI.setName("SomeAOI");
console.log(newTag.getDataType()); // -> "BOOL"
newTag.fixAOITag(newAOI);
console.log(newTag.getDataType()); // -> "SOMEAOI"


UDT Tags


fixUDTTags(UDT)

ParametersReturns

Sets tag data type as the UDT name and modifies the tag structure to match UDT structure.

UDT - (l5xUDT) UDT to get structure and name from.NA


Note:

Kiptr has limited support for updating the structure for UDTs. You may get a warning when importing your project to Studio5000 saying that data for this tag will not be imported. We are working on improving this feature. Contact tech support if you experience difficulties.


Example

var newTag = new kSDKv1.l5xTag();
var newUDT = new kSDKv1.l5xUDT();
newUDT.setName("SomeUDT");
console.log(newTag.getDataType()); // -> "BOOL"
newTag.fixUDTTag(newUDT);
console.log(newTag.getDataType()); // -> "SOMEUDT"