This class allows creation and modification of l5x Add On Instruction.

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


Example 1:

Creating an empty l5x UDT with default project parameters:

const myNewUDT = new kSDKv1.l5xUDT();

New UDT is a complete (though empty) l5x UDT that can be modified with methods (see below) or it can be immediately transformed into an l5x file (see "saveToFile()" method below) and imported into Studio5000 software.


Example 2:

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

const myNewCustomUDT = new kSDKv1.l5xUDT(`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
          <RSLogix5000Content SomeParam="1.0" SomeOtherParam = "2.0">
          <Controller Use="Context" Name="Kiptr" SomeParam="1.0"         
 SomeOtherParam ="2.0">
          <DataTypes Use="Context">
          <DataType Use="Target" Name="CustomUDT">
          <CustomXML/>
          </DataType>
          </DataTypes>
          </Controller>
          </RSLogix5000Content>

It is important to inject XML with the DataType attribute "Use" = "Target". An error is generated if this condition is not satisfied.


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



UDT
getUDT()
getUDTNames()

addUDT()
deleteUDT()
AOIgetAOI()
getAOINames() 

addAOI()deleteAOI()
Order



orderify()
Files



toText()
saveToFile()

Name


getName()

ParametersReturns
Returns an UDT name.
NAUDT name - (string)


Example

var newUDT = new kSDKv1.l5xUDT();
newUDT.setName("NewUDT");
console.log(newUDT.getName()); // -> "NewUDT"



setName(newName)

ParametersReturns

Sets new UDT name.

newName – (string) New UDT name.
NA


Example

var newUDT = new kSDKv1.l5xUDT();
newUDT.setName("NewUDT");
console.log(newUDT.getName()); // -> "NewUDT"


UDT


getUDT(UDTName)

ParametersReturns

Returns the UDT (User-defined Data Type) with name UDTName from the existing UDT. All the dependencies (AOIs and UDTs) will be automatically taken out of the UDT and saved with the UDT. This method works similar to "Export UDT" in Studio 5000.

UDTName - (string) Name of UDT to be returned.UDT (l5xUDT)


Example

var newUDT = new kSDKv1.l5xUDT();
var anotherUDT = new kSDKv1.l5xUDT();
anotherUDT.setName("MyNewUDT");
newUDT.addUDT(anotherUDT);
var exisitngUDT = newUDT.getUDT("MyNewUDT");
console.log(exisitngUDT.getName()) // -> MyNewUDT



getUDTNames()

ParametersReturns

Returns names of all the UDTs (User-defined Data Types) found in the existing UDT.

NAUDT names ([string])


Example

var newUDT = new kSDKv1.l5xUDT();
console.log(newUDT.getUDTNames().length) // -> 0
var anotherUDT = new kSDKv1.l5xUDT();
anotherUDT.setName("MyNewUDT");
newUDT.addUDT(anotherUDT);
console.log(newUDT.getUDTNames()[0]) // -> MyNewUDT



addUDT(UDT)

ParametersReturns

Adds the UDT (User-defined Data Type) to the existing UDT. This also adds all the dependencies - AOIs and UDTs from the UDT to the existing UDT. This method works similar to "Import UDT" in Studio 5000.

UDT - (l5xUDT) UDT to be added.NA


Example

var newUDT = new kSDKv1.l5xUDT();
var anotherUDT = new kSDKv1.l5xUDT();
anotherUDT.setName("MyNewUDT");
newUDT.addUDT(anotherUDT);
var exisitngUDT = newUDT.getUDT("MyNewUDT");
console.log(exisitngUDT.getName()) // -> MyNewUDT



deleteUDT()

ParametersReturns

Deletes the UDT (User-defined Data Type) with name UDTName from the existing UDT.

UDTName - (string) Name of UDT to be deleted.UDT (l5xUDT)


Example

var newUDT = new kSDKv1.l5xUDT();
var anotherUDT = new kSDKv1.l5xUDT();
anotherUDT.setName("MyNewUDT");
newUDT.addUDT(anotherUDT);
console.log(newUDT.getUDTNames().length) // -> 1
newUDT.deleteUDT("MyNewUDT");
console.log(newUDT.getUDTNames().length) // -> 0

AOI


getAOI(AOIName)

ParametersReturns

Returns the AOI (Add On Instruction) with name AOIName from the existing UDT. All the dependencies (AOIs and UDTs) will be automatically taken out of the UDT and saved with the AOI. This method works similar to "Export UDT" in Studio 5000. Supports encoded AOIs.

AOIName - (string) Name of AOI to be returned.AOI (l5xAOI)


Example

var newUDT = new kSDKv1.l5xUDT();
var anotherAOI = new kSDKv1.l5xAOI();
anotherAOI.setName("MyNewAOI");
newUDT.addAOI(anotherAOI);
var exisitngAOI = newUDT.getAOI("MyNewAOI");
console.log(exisitngAOI.getName()) // -> MyNewAOI



getAOINames()

ParametersReturns

Returns names of all the AOIs (Add On Instructions) found in the existing UDT. Supports encoded AOIs.

NAAOI names ([string])


Example

var newUDT = new kSDKv1.l5xUDT();
console.log(newUDT.getAOINames().length) // -> 0
var anotherAOI = new kSDKv1.l5xAOI();
anotherAOI.setName("MyNewAOI");
newUDT.addAOI(anotherAOI);
console.log(newUDT.getAOINames()[0]) // -> MyNewAOI



addAOI(AOI)

ParametersReturns

Adds the AOI (Add On Instruction) to the existing UDT. This also adds all the dependencies - AOIs and UDTs from the AOI to the existing UDT. This method works similar to "Import AOI" in Studio 5000. Supports encoded AOIs.

AOI - (l5xAOI) AOI to be added.NA


Example

var newUDT = new kSDKv1.l5xUDT();
var anotherAOI = new kSDKv1.l5xAOI();
anotherAOI.setName("MyNewAOI");
newUDT.addAOI(anotherAOI);
var exisitngAOI = newUDT.getAOI("MyNewAOI");
console.log(exisitngAOI.getName()) // -> MyNewAOI



deleteAOI(AOIName)

ParametersReturns

Deletes the AOI (Add On Instruction) with name AOIName from the existing UDT. Supports encoded AOIs.

AOIName - (string) Name of AOI to be deleted.AOI (l5xAOI)


Example

var newUDT = new kSDKv1.l5xUDT();
var anotherAOI = new kSDKv1.l5xAOI();
anotherAOI.setName("MyNewAOI");
newUDT.addAOI(anotherAOI);
console.log(newUDT.getAOINames().length) // -> 1
newUDT.deleteAOI("MyNewAOI");
console.log(newUDT.getAOINames().length) // -> 0

Files



toText()

ParametersReturns

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

NA
XML in a text format.


Example

var newUDT = new kSDKv1.l5xUDT();
console.log(newUDT.toText());



saveToFile(fileName)

ParametersReturns

Saves the UDT to a L5X file with the name fileName.

fileName - (string) optional. File name will be assigned to “kiptr_gen.l5x”. File name should include extension.NA


Example

var newUDT = new kSDKv1.l5xUDT();
newUDT.saveToFile("myNewUDT.l5x");