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.


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



TypegetType()setType()


PrioritygetPriority()setPriority()


WatchdoggetWatchdog()setWatchdog()


RategetRate()setRate()


Schedule ProgramsgetScheduledPrograms()setScheduledProgram()
deleteScheduledProgram()

Files



toText()


Name


getName()

ParametersReturns
Returns a task name.
NATask name - (string)


Example

var newTask = new kSDKv1.l5xTask();
newTask.setName("NewTask");
console.log(newTask.getName()); // -> "NewTask"



setName(newName)

ParametersReturns

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()

ParametersReturns
Returns a task type.
NATask 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)

ParametersReturns

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()

ParametersReturns
Returns a task priority.
NATask 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)

ParametersReturns

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()

ParametersReturns
Returns a task watchdog setting.
NATask watchdog setting - (string). A positive number in a string format.


Example

var newTask = new kSDKv1.l5xTask();
console.log(newTask.getWatchdog()); // -> "500"



setWatchdog(newWatchdog)

ParametersReturns

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()

ParametersReturns
Returns a task Period (Rate) setting.NATask Period (Rate) setting - (string). A positive number in a string format.


Example

var newTask = new kSDKv1.l5xTask();
console.log(newTask.getRate()); // -> "500"



setRate(newRate)

ParametersReturns

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()

ParametersReturns
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)

ParametersReturns

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)

ParametersReturns

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()

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


Example

var newTask = new kSDKv1.l5xTask();
console.log(newTask.toText());