This class allows the creation and modification of l5x Program.

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


Example 1:

Creating an empty l5x Program with default parameters:

const myNewProgram = new kSDKv1.l5xProgram();

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


Example 2:

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

const myNewCustomPrg = new kSDKv1.l5xProgram(`
             <?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">
             <Programs Use="Context"> <Program Use="Target" Name="Kiptr" TestEdits="false" MainRoutineName="Schedule" Disabled="false" UseAsFolder="false">
             <CustomXML/>
             </Program>
             </Programs>
             </Controller>
             </RSLogix5000Content>
`);

It is important to inject XML with the attribute “Use”="Target" of node “Program”. An error is generated if this condition is not satisfied.


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



Routine

getRoutine()
getMainRtnName()
getRoutineNames()

setMainRtnName() 
addRoutine()deleteRoutine()
TaggetTag()
getTags()
getTagNames()

addTag()deleteTag()
UDT
getUDT()
getUDTNames()

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

addAOI()deleteAOI()
Order



orderify()
Files



toText()
saveToFile()

Name


getName()

ParametersReturns
Returns a program name.
NAProgram name - (string)

Example

var newProgram = new kSDKv1.l5xProgram();
newProgram.setName("NewProgram");
console.log(newProgram.getName()); // -> "NewProgram"



setName(newName)

ParametersReturns

Sets new program name.

newName – (string) New program name.
NA


Example

var newProgram = new kSDKv1.l5xProgram();
newProgram.setName("NewProgram");
console.log(newProgram.getName()); // -> "NewProgram"

Routine


getRoutine(routineName)

ParametersReturns

Returns the routine with name routineName from the existing program.

routineName - (string) Name of routine to be returned.

Routine (l5xRoutine)


Example

var newPrg = new kSDKv1.l5xProgram();
var existingRoutineName = newPrg.getRoutineNames()[0];
var existingRoutine = newPrg.getRoutine(existingRoutineName);
console.log(existingRoutine.getName()) // -> Schedule


getMainRtnName(newName)

ParametersReturns

Sets the name of the main routine.

newName - (string) New main routine name.

NA


Example

var newProgram = new kSDKv1.l5xProgram();
newProgram.setMainRtnName("NewRoutine");
console.log(newProgram.getMainRtnName()); // -> "NewRoutine"



getRoutineNames()

ParametersReturns

Returns names of routines from the existing program.

NARoutine names ([string])


Example

var newPrg = new kSDKv1.l5xProgram();
console.log(newPrg.getRoutineNames().length) // -> 1
console.log(newPrg.getRoutineNames()[0]) // -> Schedule


setMainRtnName(newName)

ParametersReturns
Sets the name of the main routine.newName - (string) New main routine name.
NA


Example

var newProgram = new kSDKv1.l5xProgram();
newProgram.setMainRtnName("NewRoutine");
console.log(newProgram.getMainRtnName()); // -> "NewRoutine"


addRoutine(routine)

ParametersReturns

Adds routine to the existing project.

routine - (l5xRoutine) Routine to be added.NA


Example

var newPrg = new kSDKv1.l5xProgram();
console.log(newPrg.getRoutineNames().length) // -> 1
var newRoutine = new kSDKv1.l5xRoutineLD();
newPrg.addRoutine(newRoutine);
console.log(newPrg.getRoutineNames().length) // -> 2


deleteRoutine(routineName)

ParametersReturns

Deletes the Routine with name routineName from the existing project.

routineName - (string) Name of Routine to be deleted.NA


Example

var newPrg = new kSDKv1.l5xProgram();
var RtnNames = newPrg.getRoutineNames();
console.log(RtnNames.length) // -> 1
newPrg.deleteRoutine(RtnNames[0]);
console.log(newPrg.getRoutineNames().length) // -> 0

Tag


getTag(tagName, programName)

ParametersReturns

Returns an existing tag from the program

tagName –  (string) Name of tag to be returned.

programName - (string) optional. Name of program to get tag from. Controller scoped tag will be returned if the parameter is missing.

Tag (l5xTag)


Example

var newPrj = new kSDKv1.l5xProgram();
var newTag = new kSDKv1.l5xTag();
newTag.setName("MyNewTag");
newPrj.addTag(newTag);
newPrj.addTag(newTag, "MainProgram");
// Controller scope:
var existingTag = newPrj.getTag("MyNewTag");
console.log(existingTag.getName()) // -> MyNewTag
// Program scope:
console.log(newPrj.getTag("MyNewTag",
"MainProgram").getName()) // -> MyNewTag



getTags(programName)

ParametersReturns

Returns all the tags found in the existing program.

programName – (string) optional. Name of program to get tags from. Controller scoped tags will be returned if the parameter is missing. Tags ([l5xTag])


Example

var newPrj = new kSDKv1.l5xProgram();
console.log(newPrj.getTags().length) // -> 0
var newTag = new kSDKv1.l5xTag();
newPrj.addTag(newTag);
console.log(newPrj.getTags().length) // -> 1



getTagNames(programName)

ParametersReturns

Returns names of all the tags found in the existing program.

programName – (string) optional. Name of program to get tag names from. Controller scoped tag names will be returned if the parameter is missing.Tag names ([string])


Example

var newPrj = new kSDKv1.l5xProgram();
console.log(newPrj.getTagNames().length) // -> 0
var newTag = new kSDKv1.l5xTag();
newTag.setName("MyNewTag");
newPrj.addTag(newTag);
console.log(newPrj.getTagNames()[0]) // -> MyNewTag



addTag(newTag, programName)

ParametersReturns

Adds a new tag to an existing program.

Note: If the tag type has to belong to AOI or UDT and you want to update some of its parameters - use fixAOITag(AOI) and fixUDTTag(UDT) methods of l5xTag class. This will create the parameters in a new tag that match AOI and UDT structure.

newTag – (l5xTag) Tag being added.

programName - (string) optional. Name of program to add tag to. Controller scoped tag will be created if the parameter is missing.

NA


Example

var newPrj = new kSDKv1.l5xProgram();
// Controller scope:
console.log(newPrj.getTags().length) // -> 0
var newTag = new kSDKv1.l5xTag();
newPrj.addTag(newTag);
console.log(newPrj.getTags().length) // -> 1
// Program scope:
console.log(newPrj.getTags("MainProgram").length) // -> 0
newPrj.addTag(newTag, "MainProgram");
console.log(newPrj.getTags("MainProgram").length) // -> 1



deleteTag(tagName, programName)

ParametersReturns

Deletes a tag from the program.

tagName – (string) Name of tag to be deleted.

programName - (string) optional. Name of program to delete tag from. Controller scoped tag will be deleted if the parameter is missing.

NA


Example

var newPrj = new kSDKv1.l5xProgram();
var newTag = new kSDKv1.l5xTag();
newTag.setName("MyNewTag");
newPrj.addTag(newTag);
newPrj.addTag(newTag, "MainProgram"); // Controller scope:
console.log(newPrj.getTags().length) // -> 1
newPrj.deleteTag("MyNewTag");
console.log(newPrj.getTags().length) // -> 0
// Program scope:
console.log(newPrj.getTags("MainProgram").length) // -> 1
newPrj.deleteTag("MyNewTag", "MainProgram");
console.log(newPrj.getTags("MainProgram").length) // -> 0

UDT


getUDT(UDTName)

ParametersReturns

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



getUDTNames()

ParametersReturns

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

NAUDT names ([string])


Example

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



addUDT(UDT)

ParametersReturns

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

UDT - (l5xUDT) UDT to be added.NA


Example

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



deleteUDT()

ParametersReturns

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

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


Example

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

AOI


getAOI(AOIName)

ParametersReturns

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



getAOINames()

ParametersReturns

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

NAAOI names ([string])


Example

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



addAOI(AOI)

ParametersReturns

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

AOI - (l5xAOI) AOI to be added.NA


Example

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



deleteAOI(AOIName)

ParametersReturns

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

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


Example

var newPrj = new kSDKv1.l5xProgram();
var newAOI = new kSDKv1.l5xAOI();
newAOI.setName("MyNewAOI");
newPrj.addAOI(newAOI);
console.log(newPrj.getAOINames().length) // -> 1
newPrj.deleteAOI("MyNewAOI");
console.log(newPrj.getAOINames().length) // -> 0

Order


orderify()

ParametersReturns

Puts XML nodes in correct order. Studio5000 software generates an error if main XML nodes are not in the right order. You will not have to use this function if you use methods from Kiptr library. But you will have to make sure that the following order of nodes is kept if you modify XML directly:

RedundancyInfo -> Security -> SafetyInfo -> DataTypes -> Modules -> AddOnInstructionDefinitions -> Tags -> Programs -> Tasks -> CommPorts -> CST -> WallClockTime -> Trends -> DataLogs -> TimeSynchronize orderify method is sorting all the nodes in the XMLDocument in the correct order

NA
NA


Example

var newPrj = new kSDKv1.l5xProgram();
newPrj.orderify();

Files



toText()

ParametersReturns

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

NA
XML in a text format.


Example

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



saveToFile(fileName)

ParametersReturns

Saves the project 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


var newPrj = new kSDKv1.l5xProgram();
newPrj.saveToFile("myNewProject.l5x");