This class allows the creation and modification of l5x Project.
XML data is stored in variablename.l5xdata (XMLDocument format).
Example 1:
Creating an empty l5x Project with default project parameters:
const myNewProj = new kSDKv1.l5xProject();
New project is a complete (though empty) l5x project that can be modified with methods (see below) or it can be immediately transformed into a l5x file (see "saveToFile()" method below) and imported into Studio5000 software.
Example 2:
Creating a project from custom XML (this will overwrite all default parameters):
const myNewCustomProj = new kSDKv1.l5xProject(` <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <RSLogix5000Content SomeParam="1.0" SomeOtherParam = "2.0"> <Controller Use="Target" Name="Kiptr" SomeParam="1.0" SomeOtherParam = "2.0"> <CustomXML/> </Controller> </RSLogix5000Content> `);
It is important to inject XML with the Controller attribute "Use" = "Target". 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() | |||
Program | getProgram() getProgramNames() | addProgram() | deleteProgram() | ||
Tag | getTag() getTags() getTagNames() | addTag() | deleteTag() | ||
UDT | getUDT() getUDTNames() | addUDT() | deleteUDT() | ||
AOI | getAOI() getAOINames() | addAOI() | deleteAOI() | ||
Module | getModule() getModuleNames() | addModule() | deleteModule() | ||
Task | getTask() getTaskNames() | addTask() | deleteTask() | ||
Order | orderify() | ||||
Files | toText() saveToFile() |
Name |
getName() | Parameters | Returns |
Returns a project name. | NA | Project name - (string) |
Example
var newPrj = new kSDKv1.l5xProject();
newPrj.setName("NewProject");
console.log(newPrj.getName()); // -> "NewProject"
setName(newName) | Parameters | Returns |
Sets new project name. | newName – (string) New project name. | NA |
Example
var newPrj = new kSDKv1.l5xProject();
newPrj.setName("NewProject");
console.log(newPrj.getName()); // -> "NewProject"
Program |
getProgram(prgName) | Parameters | Returns |
Returns a program with the name prgName (if it exists). All the dependencies (tags, AOIs and UDTs) will be automatically taken out of the project and saved with the program. This method works similar to the "Export Program" in Studio 5000. | prgName – (string) Name of program. | Program (l5xProgram). |
Example
var newPrj = new kSDKv1.l5xProject();
var mainPrg = newPrj.getProgram("MainProgram");
console.log(mainPrg.getName()); // -> MainProgram
getProgramNames() | Parameters | Returns |
Returns an array of names of programs found in the project. | NA | Program names - ([string]) |
Example
var newPrj = new kSDKv1.l5xProject(); var prgNames = newPrj.getProgramNames(); console.log(prgNames[0]); // -> "MainProgram"
addProgram(newProgram) | Parameters | Returns |
Adds a new program to an existing project. This also adds all the tags, AOIs and UDTs from the new program to the existing project. This method works similar to "Import Program" in Studio 5000. | newProgram – (l5xProgram) Program being added. | NA |
Example
var newPrj = new kSDKv1.l5xProject(); console.log(newPrj.getProgramNames().length) // -> 1 var newPrg = new kSDKv1.l5xProgram(); newPrj.addProgram(newPrg); console.log(newPrj.getProgramNames().length) // -> 2
deleteProgram(programName) | Parameters | Returns |
Deletes a program from an existing project. This method only deletes the logic. No dependencies will be deleted. | programName – (string) Name of program being deleted. | NA |
Example
var newPrj = new kSDKv1.l5xProject(); console.log(newPrj.getProgramNames().length) // -> 1 newPrj.deleteProgram("MainProgram"); console.log(newPrj.getProgramNames().length) // -> 0
Tag |
getTag(tagName, programName) | Parameters | Returns |
Returns an existing tag from the project | 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.l5xProject(); 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) | Parameters | Returns |
Returns all the tags found in the existing project. | 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.l5xProject(); console.log(newPrj.getTags().length) // -> 0 var newTag = new kSDKv1.l5xTag(); newPrj.addTag(newTag); console.log(newPrj.getTags().length) // -> 1
getTagNames(programName) | Parameters | Returns |
Returns names of all the tags found in the existing project. | 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.l5xProject(); 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) | Parameters | Returns |
Adds a new tag to an existing project. 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.l5xProject(); // 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) | Parameters | Returns |
Deletes a tag from the project. | 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.l5xProject(); 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) | Parameters | Returns |
Returns the UDT (User-defined Data Type) with name UDTName from the existing project. 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.l5xProject(); var newUDT = new kSDKv1.l5xUDT(); newUDT.setName("MyNewUDT"); newPrj.addUDT(newUDT); var exisitngUDT = newPrj.getUDT("MyNewUDT"); console.log(exisitngUDT.getName()) // -> MyNewUDT
getUDTNames() | Parameters | Returns |
Returns names of all the UDTs (User-defined Data Types) found in the existing project. | NA | UDT names ([string]) |
Example
var newPrj = new kSDKv1.l5xProject(); 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) | Parameters | Returns |
Adds the UDT (User-defined Data Type) to the existing project. 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.l5xProject(); var newUDT = new kSDKv1.l5xUDT(); newUDT.setName("MyNewUDT"); newPrj.addUDT(newUDT); var exisitngUDT = newPrj.getUDT("MyNewUDT"); console.log(exisitngUDT.getName()) // -> MyNewUDT
deleteUDT() | Parameters | Returns |
Deletes the UDT (User-defined Data Type) with name UDTName from the existing project. | UDTName - (string) Name of UDT to be deleted. | UDT (l5xUDT) |
Example
var newPrj = new kSDKv1.l5xProject(); 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) | Parameters | Returns |
Returns the AOI (Add On Instruction) with name AOIName from the existing project. 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.l5xProject(); var newAOI = new kSDKv1.l5xAOI(); newAOI.setName("MyNewAOI"); newPrj.addAOI(newAOI); var exisitngAOI = newPrj.getAOI("MyNewAOI"); console.log(exisitngAOI.getName()) // -> MyNewAOI
getAOINames() | Parameters | Returns |
Returns names of all the AOIs (Add On Instructions) found in the existing project. Supports encoded AOIs. | NA | AOI names ([string]) |
Example
var newPrj = new kSDKv1.l5xProject(); 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) | Parameters | Returns |
Adds the AOI (Add On Instruction) to the existing project. 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.l5xProject(); var newAOI = new kSDKv1.l5xAOI(); newAOI.setName("MyNewAOI"); newPrj.addAOI(newAOI); var exisitngAOI = newPrj.getAOI("MyNewAOI"); console.log(exisitngAOI.getName()) // -> MyNewAOI
deleteAOI(AOIName) | Parameters | Returns |
Deletes the AOI (Add On Instruction) with name AOIName from the existing project. Supports encoded AOIs. | AOIName - (string) Name of AOI to be deleted. | AOI (l5xAOI) |
Example
var newPrj = new kSDKv1.l5xProject(); 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
Modules |
getModule(moduleName) | Parameters | Returns |
Returns the Module with name moduleName from the existing project. | moduleName - (string) Name of Module to be returned. | Module (l5xModule) |
Example
var newPrj = new kSDKv1.l5xProject(); var existingModuleName = newPrj.getModuleNames()[0]; var existingModule = newPrj.getModule(existingModuleName); console.log(existingModule.getName()); // -> Local
getModuleNames() | Parameters | Returns |
Returns names of modules from the existing project. | NA | Module names ([string]) |
Example
var newPrj = new kSDKv1.l5xProject(); console.log(newPrj.getModuleNames().length) // -> 1 console.log(newPrj.getModuleNames()[0]) // -> Local
addModule(module) | Parameters | Returns |
Adds Module to the existing project. | Module - (l5xModule) Module to be added. | NA |
Example
var newPrj = new kSDKv1.l5xProject(); console.log(newPrj.getModuleNames().length); // -> 1 var newModule = new kSDKv1.l5xModule(); newPrj.addModule(newModule); console.log(newPrj.getModuleNames().length); // -> 2
deleteModule(moduleName) | Parameters | Returns |
Deletes the Module with name moduleName from the existing project. | moduleName - (string) Name of Module to be deleted. | NA |
Example
var newPrj = new kSDKv1.l5xProject(); var moduleNames = newPrj.getModuleNames(); console.log(moduleNames.length); // -> 1 newPrj.deleteModule(moduleNames[0]); console.log(newPrj.getModuleNames().length); // -> 0
Task |
getTask(taskName) | Parameters | Returns |
Returns the Task with name taskName from the existing project. | taskName - (string) Name of Task to be returned. | Task (l5xTask) |
Example
var newPrj = new kSDKv1.l5xProject(); var existingTaskName = newPrj.getTaskNames()[0]; var existingTask = newPrj.getTask(existingTaskName);
getTaskNames() | Parameters | Returns |
Returns names of Tasks from the existing project. | NA | Task names ([string]) |
Example
var newPrj = new kSDKv1.l5xProject(); console.log(newPrj.getTaskNames().length) // -> 1 console.log(newPrj.getTaskNames()[0]) // -> MainTask
addTask(task) | Parameters | Returns |
Adds Task to the existing project. | task - (l5xTask) Task to be added. | NA |
Example
var newPrj = new kSDKv1.l5xProject(); console.log(newPrj.getTaskNames().length); // -> 1 var newTask = new kSDKv1.l5xTask(); newTask.setName("NewTask"); newPrj.addTask(newTask); console.log(newPrj.getTaskNames().length); // -> 2
deleteTask(taskName) | Parameters | Returns |
Deletes the Task with name taskName from the existing project. | taskName - (string) Name of Task to be deleted. | NA |
Example
var newPrj = new kSDKv1.l5xProject(); var TaskNames = newPrj.getTaskNames(); console.log(TaskNames.length); // -> 1 newPrj.deleteTask(TaskNames[0]); console.log(newPrj.getTaskNames().length); // -> 0
Order |
orderify() | Parameters | Returns |
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.l5xProject(); newPrj.orderify();
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());
saveToFile(fileName) | Parameters | Returns |
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.l5xProject(); newPrj.saveToFile("myNewProject.l5x");