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 AOI with default project parameters:

const myNewAOI = new kSDKv1.l5xAOI();

New AOI is a complete (though empty) l5x AOI 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 an AOI from custom XML (this will overwrite all default parameters):

const myNewCustomAOI = new kSDKv1.l5xAOI(`<?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">
          <AddOnInstructionDefinitions Use="Context">
          <AddOnInstructionDefinition Use="Target" Name="CustomAOI">
          <CustomXML/>
          </AddOnInstructionDefinition>
          </AddOnInstructionDefinitions>
          </Controller> </RSLogix5000Content>
`);

It is important to inject XML with the AddOnInstructionDefinition 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 AOI name.
NAAOI name - (string)


Example

var newAOI = new kSDKv1.l5xAOI();
newAOI.setName("NewAOI");
console.log(newAOI.getName()); // -> "NewAOI"



setName(newName)

ParametersReturns

Sets new AOI name.

newName – (string) New AOI name.
NA


Example

var newAOI = new kSDKv1.l5xAOI();
newAOI.setName("NewAOI");
console.log(newAOI.getName()); // -> "NewAOI"


UDT


getUDT(UDTName)

ParametersReturns

Returns the UDT (User-defined Data Type) with name UDTName from the existing AOI. All the dependencies (AOIs and UDTs) will be automatically taken out of the AOI 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 newAOI = new kSDKv1.l5xAOI();
var newUDT = new kSDKv1.l5xUDT();
newUDT.setName("MyNewUDT");
newAOI.addUDT(newUDT);
var exisitngUDT = newAOI.getUDT("MyNewUDT");
console.log(exisitngUDT.getName()) // -> MyNewUDT



getUDTNames()

ParametersReturns

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

NAUDT names ([string])


Example

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



addUDT(UDT)

ParametersReturns

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

UDT - (l5xUDT) UDT to be added.NA


Example

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



deleteUDT()

ParametersReturns

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

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


Example

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

AOI


getAOI(AOIName)

ParametersReturns

Returns the AOI (Add On Instruction) with name AOIName from the existing AOI. All the dependencies (AOIs and UDTs) will be automatically taken out of the AOI 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 newAOI = new kSDKv1.l5xAOI();
var anotherAOI = new kSDKv1.l5xAOI();
anotherAOI.setName("MyNewAOI");
newAOI.addAOI(anotherAOI);
var exisitngAOI = newAOI.getAOI("MyNewAOI");
console.log(exisitngAOI.getName()) // -> MyNewAOI



getAOINames()

ParametersReturns

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

NAAOI names ([string])


Example

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



addAOI(AOI)

ParametersReturns

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

AOI - (l5xAOI) AOI to be added.NA


Example

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



deleteAOI(AOIName)

ParametersReturns

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

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


Example

var newAOI = new kSDKv1.l5xAOI();
var anotherAOI = new kSDKv1.l5xAOI();
anotherAOI.setName("MyNewAOI");
newAOI.addAOI(anotherAOI);
console.log(newAOI.getAOINames().length) // -> 1
newAOI.deleteAOI("MyNewAOI");
console.log(newAOI.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 newAOI = new kSDKv1.l5xAOI();
console.log(newAOI.toText());



saveToFile(fileName)

ParametersReturns

Saves the AOI 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 newAOI = new kSDKv1.l5xAOI();
newAOI.saveToFile("myNewAOI.l5x");