The API.RAPID namespace provides a comprehensive set of interfaces for managing and interacting with RAPID programs on the controller. It includes methods for controlling program execution, managing tasks, modules, and variables, as well as monitoring execution states and subscribing to variable changes. This class simplifies the development and integration of RAPID-based automation solutions, enabling developers to efficiently interact with and control RAPID programs.
- Source
Classes
Members
(constant) MODULETYPE :string
- string
| Name | Type | Description |
|---|---|---|
Program | enum | Program module |
System | enum | System module |
Program | string | |
System | string |
- Source
Methods
createVariableInstance(module, name, task)
Creates a variable instance.
| Name | Type | Description |
|---|---|---|
module | string | The name of the module where the variable locates.. |
name | string | The variable name. |
task | string | The task name. |
- Source
let variableInstance = await API.RAPID.createVariableInstance("MainModule","aa");getProgramPointer() → {Promise.<objecy>}
Gets the program pointer
- Source
A promise with an object containing the program pointer information.
- Type:
- Promise.<objecy>
await API.RAPID.getProgramPointer()getTask(task) → {Promise.<object>}
Gets an instance of a API.RAPID.Task class
| Name | Type | Description |
|---|---|---|
task | string | Task name |
- Source
- API.RAPID.Task
- Type:
- Promise.<object>
await API.RAPID.getTask();getValRecordTypes(taskopt) → {Promise.<object>}
Gets available value-type RAPID RECORDs.
| Name | Type | Attributes | Description |
|---|---|---|---|
task | string | <optional> | The task name. |
- Source
- Type:
- Promise.<object>
await API.RAPID.getVariableTypes('T_ROB1')getVariableProperties(module, name, task)
Gets the properties of a variable
| Name | Type | Description |
|---|---|---|
module | string | The name of the module where the variable locates. |
name | string | The variable name |
task | string | The task name |
- Source
let props = await API.RAPID.getVariableProperties("MainModule","aa");getVariableType(module, name, task)
Gets the data type of a RAPID variable
| Name | Type | Description |
|---|---|---|
module | string | The name of the module where the variable locates. |
name | string | The variable name |
task | string | The task name |
- Source
let type = await API.RAPID.getVariableType("MainModule","aa");getVariableValue(module, name, task)
Get the value of a variable
| Name | Type | Description |
|---|---|---|
module | string | The name of the module where the variable locates. |
name | string | The variable name |
task | string | The task name |
- Source
let value = await API.RAPID.getVariableValue("MainModule","aa");(async) loadModule(path, replace, taskName, requestMshopt)
Load a module from the controller HOME files
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
path | string | Path to the module file in the HOME directory (included extension of the module). | ||
replace | boolean | false | f true, it will replace an existing module in RAPID with the same name | |
taskName | string | T_ROB1 | The name of the task to which the module belongs. | |
requestMsh | boolean | <optional> | true | Edit mastership needs to be requested before loading the module. |
- Source
let url = `${this.path}/${this.name}${this.extension}`;
await API.RAPID.loadModule(url, true);monitorExecutionState(callbackopt)
Monitors the state change of the RAPID program execution. It is possible to call a callback function every time the state is changed. Current state is stored in executionState variable. Additionally, isRunning is updated correspondingly.
| Name | Type | Attributes | Description |
|---|---|---|---|
callback | function | <optional> | The callback function that is called when the execution state changes. |
- Source
// The callback will be executed when execution status is changed
const execStatus = (value)=>{console.log("Execution status is:",value);}
await API.RAPID.monitorExecutionState(execStatus);searchRoutines(allread, taskName) → {Promise.<Array.<API.RAPID.routines>>}
Searchs all routines
| Name | Type | Description |
|---|---|---|
allread | boolean | If the value is set to true, the non-service routines will also be included. |
taskName | string | The task name |
- Source
A list of API.RAPID.routines
- Type:
- Promise.<Array.<API.RAPID.routines>>
await task.searchRoutines();searchTasks(filteropt, caseSensitiveopt) → {Promise.<object>}
Searchs for available tasks.
| Name | Type | Attributes | Description |
|---|---|---|---|
filter | string | <optional> | Only symbols in the string pattern. |
caseSensitive | boolean | <optional> | If the value is set to the default "false", non-case-sensitive is applied for the filter; otherwise, case-sensitive is applied. |
- Source
- Type:
- Promise.<object>
await API.RAPID.searchTasks()setCycleMode(cycleMode)
Sets cycle mode
| Name | Type | Description |
|---|---|---|
cycleMode | string | The value can be 'forever' or 'once'. |
- Source
await API.RAPID.setCycleMode("once")setPPToMain()
Sets program pointer to main
- Source
await API.RAPID.setPPToMain()setPPToRoutine()
Sets program pointer to routine
- Source
await API.RAPID.setPPToRoutine("MainModule","proc1")setVariableValue(module, name, value, task, options)
Sets the value of a RAPID variable
| Name | Type | Description |
|---|---|---|
module | string | The name of the module where the variable locates. |
name | string | The variable name |
value | any | The value to set |
task | string | The task name |
options | setVariableValueOptions | object |
- Source
await API.RAPID.setVariableValue("MainModule","aa", 2,"T_ROB1",{syncPers:true});startExecution(cycleMode, execMode, regainMode, setPP, moduleName, procName, taskName)
Starts program execution
| Name | Type | Description |
|---|---|---|
cycleMode | string | Cycle mode: forever|as_is|once |
execMode | string | Execution mode: continue|stepin|stepover|stepout|stepback|steplast|stepmotion |
regainMode | string | Regain mode: continue|regain|clear |
setPP | boolean | Set program pointer to main if has no pp |
moduleName | string | Module name |
procName | string | Procedure name |
taskName | string | Task name |
- Source
await API.RAPID.startExecution({moduleName: "Wizard", procName: "test1"});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', and useTSP = 'normal'
| Name | Type | Description |
|---|---|---|
props | stopExecutionProps |
- Source
await API.RAPID.stopExecution();(async) unloadModule(moduleName, taskNameopt)
Unloads a RAPID module
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
moduleName | string | The module name. | ||
taskName | string | <optional> | T_ROB1 | The task name. |
- Source
await API.RAPID.unloadModule("Module1")Type Definitions
RoutineSymbolType
;
- 'procedure' |
'function' | 'trap'
- Source
VariableProps
Properties| Name | Type | Attributes | Description |
|---|---|---|---|
taskName | string | <optional> | The task name |
moduleName | string | <optional> | The module name |
symbolName | string | <optional> | The symbol name |
dataType | string | <optional> | The symbol's data type |
symbolType | string | <optional> | The declaration type of the data, valid values: 'constant' 'variable' 'persistent' |
dimensions | Array.<number> | List of dimensions for arrays | |
scope | string | <optional> | The data's scope, valid values: 'local' 'task' 'global' |
dataTypeURL | string | <optional> | RWS URL to the data’s type symbol |
- Source
VariableSymbolType
;
- 'constant' |
'variable' | 'persistent'
- Source
filterRoutines
Properties| Name | Type | Attributes | Description |
|---|---|---|---|
name | string | <optional> | Name of the data symbol (not case-sensitive) |
symbolType | RoutineSymbolType | <optional> | Valid values: 'procedure', 'function', 'trap' , 'routine'(array with multiple values is supported) |
- Source
filterVariables
Properties| Name | Type | Attributes | Description |
|---|---|---|---|
name | string | <optional> | Name of the data symbol (not case-sensitive) |
symbolType | VariableSymbolType | <optional> | Valid values: 'constant', 'variable', 'persistent' (array with multiple values is supported) |
dataType | string | <optional> | Type of the data, e.g. 'num'(only one data type is supported) i.e. a type declaration that has no declared variable will not be returned when this flag is set true. |
- Source
searchSymbolProps
Properties| Name | Type | Attributes | Description |
|---|---|---|---|
task | string | <optional> | The task where the searching runs. (default: 'T_ROB1') |
module | string | <optional> | The module where the searching runs. |
isInUse | boolean | <optional> | 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. |
dataType | object | <optional> | Type of the data, e.g. 'num'(only one data type is supported) |
symbolType | number | <optional> | Can be the following values: |
name | string | | <optional> | Name of the data symbol (not case-sensitive) |
- Source
setVariableValueOptions
Properties| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
syncPers | boolean | <optional> | false | If the value is set to true, the variable value is synchronized immediately; otherwise, the variable value will be synchronized until next synchronization action; Set to false if RAPID program is running; |
- Source
stopExecutionProps
Properties| Name | Type | Attributes | Description |
|---|---|---|---|
stopMode | RWS. | <optional> | Stop mode, valid values: 'cycle', 'instruction', 'stop' or 'quick_stop' |
useTSP | RWS. | <optional> | Use task selection panel, valid values: 'normal' or 'all_tasks' |
- Source