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.
METHODS | Click on Methods for further information | ||||
Category | get | set | add | delete | Special |
Name | getName() | setName() | |||
Data | getData() | setData() | |||
Tag Type | getTagType() | setTagType() | |||
Data Type | getDataType() | setDataType() | |||
Value | getValue() | setValue() | |||
Attribute | getAttribute() | setAttribute() | |||
Alias | getAlias() | setAlias() | |||
Description | getDescription() | setDescription() | |||
Consumed Info | getConsumedInfo() | setConsumedInfo() | |||
Produced Info | getProducedInfo() | setProducedInfo() | |||
MSG Attribute | getMSGAttribute() | setMSGAttribute() | |||
ALM Attribute | getALMAttribute() | setALMAttribute() | |||
ALM Message | getALMMessage() | setALMMessage() | |||
ALM Class | getALMClass() | setALMClass() | |||
HMI Command | getHMICommand() | setHMICommand() | |||
Files | toText() | ||||
AOI Tags | fixAOITags() | ||||
UDT Tags | fixUDTTags() |
Name |
getName() | Parameters | Returns |
Returns a tag name. | NA | Tag name - (string) |
Example
var newTag = new kSDKv1.l5xTag(); newTag.setName("NewTag"); console.log(newTag.getName()); // -> "NewTag"
setName(newName) | Parameters | Returns |
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() | Parameters | Returns |
Returns a default value for tag (XML Attribute “Data”). | NA | Tag default value - (string) |
Example
var newTag = new kSDKv1.l5xTag();
newTag.setData("1");
console.log(newTag.getData()); // -> "1"
setData(newData) | Parameters | Returns |
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() | Parameters | Returns |
Returns current tag type for tag (Base, Alias, Produce, or Consumed). | NA | Tag type - (string) |
Example
var newTag = new kSDKv1.l5xTag(); newTag.setTagType("Base"); console.log(newTag.getTagType()); // -> "Base"
setTagType(newTagType) | Parameters | Returns |
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() | Parameters | Returns |
Returns current data type for tag (BOOL, SINT, INT, DINT, LINT, REAL etc.). | NA | Tag data type - (string) |
Example
var newTag = new kSDKv1.l5xTag();
newTag.setDataType("sint");
console.log(newTag.getDataType()); // -> "SINT"
setDataType(newDataType, dimension) | Parameters | Returns |
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:
- 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.
- Kiptr will auto-capitalize newDataType.
- Kiptr will automatically add necessary attributes if the new data type is ALARM_ANALOG, ALARM_DIGITAL, MESSAGE or TIMER.
- 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) | Parameters | Returns |
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:
- 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) | Parameters | Returns |
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:
- Kiptr does not check if the value matches the type of the tag.
- 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) | Parameters | Returns |
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) | Parameters | Returns |
Sets new value for tag attribute. | attribName - (string) Name of attribute to set. newValue - (string) Value of attribute to set. | NA |
Note:
- 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() | Parameters | Returns |
Returns current value of tag alias setting. | NA | Alias setting - (string) |
Example
var newTag = new kSDKv1.l5xTag(); newTag.setTagType("Alias"); newTag.setAliasFor("SomeTag"); console.log(newTag.getAliasFor()); // -> "SomeTag"
setAliasFor(newAlias) | Parameters | Returns |
Sets new value for tag alias setting. | newAlias - (string) Value of alias setting. | NA |
Note:
- Kiptr does not check if the alias exists.
- 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() | Parameters | Returns |
Returns tag description. | NA | Tag description - (string) |
Example
var newTag = new kSDKv1.l5xTag();
newTag.setDescription("New Tag Description");
console.log(newTag.getDescription()); // -> "New Tag Description"
setDescription(newDescription) | Parameters | Returns |
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) | Parameters | Returns |
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) | Parameters | Returns |
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) | Parameters | Returns |
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) | Parameters | Returns |
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) | Parameters | Returns |
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) | Parameters | Returns |
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) | Parameters | Returns |
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) | Parameters | Returns |
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() | Parameters | Returns |
Returns values of attributes related to Alarm tag. | NA | Message 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) | Parameters | Returns |
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() | Parameters | Returns |
Returns the value of Alarm class. | NA | Value of Alarm class - (string) |
Example
var newTag = new kSDKv1.l5xTag();
newTag.setDataType("Alarm_Analog");
newTag.setALMClass("NewAlmClass");
console.log(newTag.getALMClass()); // -> "NewAlmClass"
setALMClass(newClass) | Parameters | Returns |
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() | Parameters | Returns |
Returns the value of HMI command from Alarm. | NA | HMI 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) | Parameters | Returns |
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() | Parameters | Returns |
Returns contents of XMLDocument stored in variable.l5xdata as a text. | NA | XML in a text format. |
Example
var newPrj = new kSDKv1.l5xProject(); console.log(newPrj.toText());
AOI Tags |
fixAOITags(AOI) | Parameters | Returns |
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) | Parameters | Returns |
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"