This class allows creation and modification of l5x Task.
XML data is stored in variablename.l5xdata (XMLDocument format).
Example 1:
Creating an empty l5x Task with default parameters:
const myNewTask = new kSDKv1.l5xTask();
New task is a complete (though empty) l5x task that can be modified with methods (see below). It can not be transformed into an l5x file as Studio5000 software does not allow import/export of tasks.
Example 2:
Creating a task from custom XML (this will overwrite all default parameters):
const myNewCustomTask = new kSDKv1.l5xTask( '<Task Name="SomeTask" Type="Periodic" Rate = "500" Priority="10" Watchdog="500" DisableUpdateOutputs="false" InhibitTask="false">'+ '<ScheduledPrograms>'+ '</ScheduledPrograms>'+ '</Task>');
It is important to inject XML with the root node “Task”. 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() | |||
Type | getType() | setType() | |||
Priority | getPriority() | setPriority() | |||
Watchdog | getWatchdog() | setWatchdog() | |||
Rate | getRate() | setRate() | |||
Schedule Programs | getScheduledPrograms() | setScheduledProgram() | deleteScheduledProgram() | ||
Files | toText() |
Name |
getName() | Parameters | Returns |
Returns a task name. | NA | Task name - (string) |
Example
var newTask = new kSDKv1.l5xTask(); newTask.setName("NewTask"); console.log(newTask.getName()); // -> "NewTask"
setName(newName) | Parameters | Returns |
Sets new task name. | newName – (string) New task name. | NA |
Example
var newTask = new kSDKv1.l5xTask(); newTask.setName("NewTask"); console.log(newTask.getName()); // -> "NewTask"
Type |
getType() | Parameters | Returns |
Returns a task type. | NA | Task type - (string). One of the following values will be returned: Continuous, Periodic, Event. |
Example
var newTask = new kSDKv1.l5xTask(); console.log(newTask.getType()); // -> "Periodic"
setType(newType) | Parameters | Returns |
Sets new task type. | newType – (string) New task type. Can only be one of the following values: Continuous, Periodic, Event. An error will be generated if any other value is passed. | NA |
Note:
Studio5000 will generate an error if more than one continuous tasks are present in Controller. Kiptr does NOT check if more than one continuous tasks are existing.
Example
var newTask = new kSDKv1.l5xTask(); newTask.setType("Continuous"); console.log(newTask.getType()); // -> "Continuous"
Priority |
getPriority() | Parameters | Returns |
Returns a task priority. | NA | Task priority - (string). A number from 1 to 15 will be returned in a string format. |
Example
var newTask = new kSDKv1.l5xTask();
console.log(newTask.getPriority()); // -> "10"
setPriority(newPriority) | Parameters | Returns |
Sets new task priority. | newPriority – (string or number) New task priority. Must be a number from 1 to 15. An error will be generated if the value is out of range. | NA |
Example
var newTask = new kSDKv1.l5xTask(); newTask.setPriority(5) console.log(newTask.getPriority()); // -> "5"
Watchdog |
getWatchdog() | Parameters | Returns |
Returns a task watchdog setting. | NA | Task watchdog setting - (string). A positive number in a string format. |
Example
var newTask = new kSDKv1.l5xTask();
console.log(newTask.getWatchdog()); // -> "500"
setWatchdog(newWatchdog) | Parameters | Returns |
Sets new task watchdog setting. | newWatchdog – (string or number) New task watchdog setting. Must be a positive number. An error will be generated if the value is 0 or negative. | NA |
Example
var newTask = new kSDKv1.l5xTask();
newTask.setWatchdog("1000");
console.log(newTask.getWatchdog()); // -> "1000"
Rate |
getRate() | Parameters | Returns |
Returns a task Period (Rate) setting. | NA | Task Period (Rate) setting - (string). A positive number in a string format. |
Example
var newTask = new kSDKv1.l5xTask();
console.log(newTask.getRate()); // -> "500"
setRate(newRate) | Parameters | Returns |
Sets new task Period (Rate) setting. | newRate – (string or number) New task Period (Rate) setting. Must be a positive number. An error will be generated if the value is 0 or negative. | NA |
Example
var newTask = new kSDKv1.l5xTask();
newTask.setRate("1000");
console.log(newTask.getRate()); // -> "1000"
Scheduled Program |
getScheduledPrograms() | Parameters | Returns |
Returns an array of scheduled programs as strings. | attribName - (string) Name of attribute to read. | Scheduled Programs - ([string]). |
Example
var newTask = new kSDKv1.l5xTask();
var scPrg = newTask.getScheduledPrograms();
console.log(scPrg.length); // -> "0"
newTask.addScheduledProgram("NewProgram");
console.log(newTask.getScheduledPrograms()[0]); // -> "NewProgram"
addScheduledProgram(programName) | Parameters | Returns |
Adds a program to the list of scheduled programs. | programName - (string) Name of the program to schedule. | NA |
Example
var newTask = new kSDKv1.l5xTask(); var scPrg = newTask.getScheduledPrograms(); console.log(scPrg.length); // -> "0" newTask.addScheduledProgram("NewProgram"); console.log(newTask.getScheduledPrograms()[0]); // -> "NewProgram"
deleteScheduledProgram(programName) | Parameters | Returns |
Deletes a program from the list of scheduled programs. | programName - (string) Name of the program to be deleted from list of scheduled programs. | NA |
Example
var newTask = new kSDKv1.l5xTask();
newTask.addScheduledProgram("NewProgram1");
newTask.addScheduledProgram("NewProgram2");
console.log(newTask.getScheduledPrograms().length); // -> "2"
newTask.deleteScheduledProgram("NewProgram2");
console.log(newTask.getScheduledPrograms().length); // -> "1"
Files |
toText() | Parameters | Returns |
Returns contents of XMLDocument stored in variable.l5xdata as a text. | NA | XML in a text format. |
Example
var newTask = new kSDKv1.l5xTask();
console.log(newTask.toText());