API.RAPID. Task

new Task(task)

This class represents a RAPID Task. It includes some usefull ready-to-use functionalities based on the the OmniCore SDK. This class cannot be directly instantiated. Therefore the API.RAPID.getTask() method instead.

Parameters:
NameTypeDescription
taskobject

A RWS.RAPID task object.

Example
const task = await API.RAPID.getTask('T_ROB1');
const modules = await task.searchModules();

Methods

(async) getModule(module) → {Promise.<object>}

Gets a module. This will retrieve the properties of the module from the controller and initialize the object.

Parameters:
NameTypeDescription
moduleobject

The name of the module

Returns:

A RWS module object.

Type: 
Promise.<object>
Example
const task = await API.RAPID.getTask('T_ROB1');
await task.getModule("MainModule")

(async) getValue(module, variable) → {Promise.<object>}

Gets the value of a RAPID variable.

Parameters:
NameTypeDescription
modulestring

The module containing the variable.

variablestring

The variable name

Returns:
Type: 
Promise.<object>
Example
// get the variable value of RAPID variable n1 in MainModule
const task = await API.RAPID.getTask('T_ROB1');
await task.getValue("MainModule", "n1")

(async) getVariableInstance(module, variable, subscribe) → {Promise.<object>}

Gets a RWS Data object variable

Parameters:
NameTypeDefaultDescription
modulestring

The module containing the variable

variablestring

The variable name

subscribebooleantrue
Returns:

API.RAPID.Variable object

Type: 
Promise.<object>
Example
const task = await API.RAPID.getTask('T_ROB1');
await task.getVariableInstance("MainModule", "aa")

(async) loadModule(path, replace)

Load a module from the controller HOME files

Parameters:
NameTypeDefaultDescription
pathstring

Path to the module file in the HOME directory (included extension of the module).

replacebooleanfalse

If true, it will replace an existing module in RAPID with the same name

Example
let url = `${this.path}/${this.name}${this.extension}`;
await task.loadModule(url, true);

(async) searchModules(isInUseopt, filteropt) → {Promise.<Array.<RWS.Rapid.SymbolSearchResult>>}

Searchs for available modules

Parameters:
NameTypeAttributesDefaultDescription
isInUseboolean<optional>
false

Only return symbols that are used in a RAPID program, i.e. a type declaration that has no declared variable will not be returned when this flag is set to true.

filterstring<optional>

Only symbols in the string pattern (not case-sensitive)

Returns:
Type: 
Promise.<Array.<RWS.Rapid.SymbolSearchResult>>
Example
const task = await API.RAPID.getTask('T_ROB1');
await task.searchModules()

(async) searchProcedures(module, isInUseopt, filteropt) → {Promise.<Array.<RWS.Rapid.SymbolSearchResult>>}

Searchs for procedures contained in a module

Parameters:
NameTypeAttributesDefaultDescription
modulestringnull

Module where the search takes place

isInUseboolean<optional>
false

Only return symbols that are used in a RAPID program, i.e. a type declaration that has no declared variable will not be returned when this flag is set true.

filterstring<optional>

Only symbols in the string pattern (not case-sensitive)

Returns:
Type: 
Promise.<Array.<RWS.Rapid.SymbolSearchResult>>
Example
const task = await API.RAPID.getTask('T_ROB1');
await task.searchProcedures()

(async) searchRoutines(module, isInUseopt, filteropt) → {Promise.<Array.<RWS.Rapid.SymbolSearchResult>>}

Search for routines contained in a module

Parameters:
NameTypeAttributesDefaultDescription
modulestringnull

Module where the search takes place

isInUseboolean<optional>
false

Only return symbols that are used in a Rapid program,

filterfilterRoutines<optional>

See filterRoutines

Returns:
Type: 
Promise.<Array.<RWS.Rapid.SymbolSearchResult>>
Example
const task = await API.RAPID.getTask('T_ROB1');
await task.searchRoutines()

(async) searchVariables(module, isInUseopt, filteropt) → {Promise.<Array.<RWS.Rapid.SymbolSearchResult>>}

Searchs for variables contained in a module

Parameters:
NameTypeAttributesDefaultDescription
modulestringnull

Module where the search takes place

isInUseboolean<optional>
false

Only return symbols that are used in a Rapid program,

filterfilterVariables<optional>

See filterVariables

Returns:
Type: 
Promise.<Array.<RWS.Rapid.SymbolSearchResult>>
Example
// list all num variables in MainModule of task T_ROB1
const task = await API.RAPID.getTask('T_ROB1');
await task.searchVariables("MainModule", false, {dataType: "num"});

(async) setValue(module, variable, value) → {Promise.<object>}

Sets the value of a variable

Parameters:
NameTypeDescription
modulestring

Module containing the variable

variablestring

Variable name

valueobject

Value of the variable

To Do
  • Valiation of value not yet applied
Returns:
Type: 
Promise.<object>
Example
// set the variable value of RAPID variable n1 in MainModule
const task = await API.RAPID.getTask('T_ROB1');
await task.setValue("MainModule", "aa",7);

(async) stopExecution(props)

Stops the RAPID execution with the settings given in the parameter object. All or any of the defined parameters can be supplied, if a value is omitted a default value will be used. The default values are: stopMode = 'stop' useTSP = 'normal'

Parameters:
NameTypeDescription
propsstopExecutionProps
Deprecated
  • since version 1.1.0, use API.RAPID.stopExecution instead
Example
const task = await API.RAPID.getTask('T_ROB1');
await task.stopExecution();

(async) unloadModule(module)

Unloads a RAPID module

Parameters:
NameTypeDescription
modulestring

Module's name

Example
await task.unloadModule("MainModule");

Type Definitions

stopExecutionProps

Properties
NameTypeAttributesDescription
stopModeRWS.Rapid.StopModes<optional>

Stop mode, valid values: 'cycle', 'instruction', 'stop' or 'quick_stop'

useTSPRWS.Rapid.UseTSPOptions.normal<optional>

Use task selection panel, valid values: 'normal' or 'all_tasks'