RAPID

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.

Alias: API.RAPID


Instance Methods

getValRecordTypes(task?: string): Promise.<object>

Gets available value-type RAPID RECORDs.

Alias: getValRecordTypes

Parameters

  • task (string, optional) — The task name.

Returns

  • Promise.<object>

Example

CODE
await API.RAPID.getVariableTypes('T_ROB1')

searchTasks( filter?: string, caseSensitive?: boolean, ): Promise.<object>

Searchs for available tasks.

Alias: searchTasks

Parameters

  • 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.

Returns

  • Promise.<object>

Example

CODE
await API.RAPID.searchTasks()

monitorExecutionState(callback?: function)

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.

Alias: monitorExecutionState

Parameters

  • callback (function, optional) — The callback function that is called when the execution state changes.

Example

CODE
// The callback will be executed when execution status is changed
const execStatus = (value)=>{console.log("Execution status is:",value);}
await API.RAPID.monitorExecutionState(execStatus);

setPPToMain()

Sets program pointer to main

Alias: setPPToMain

Example

CODE
await API.RAPID.setPPToMain()

setPPToRoutine()

Sets program pointer to routine

Alias: setPPToRoutine

Example

CODE
await API.RAPID.setPPToRoutine("MainModule","proc1")

getProgramPointer(): Promise.<objecy>

Gets the program pointer

Alias: getProgramPointer

Returns

  • Promise.<objecy> — A promise with an object containing the program pointer information.

Example

CODE
await API.RAPID.getProgramPointer()

createVariableInstance( module: string, name: string, task: string, )

Creates a variable instance.

Alias: createVariableInstance

Parameters

  • module (string) — The name of the module where the variable locates..
  • name (string) — The variable name.
  • task (string) — The task name.

Example

CODE
let variableInstance = await API.RAPID.createVariableInstance("MainModule","aa");

getVariableType(module: string, name: string, task: string)

Gets the data type of a RAPID variable

Alias: getVariableType

Parameters

  • module (string) — The name of the module where the variable locates.
  • name (string) — The variable name
  • task (string) — The task name

Example

CODE
let type = await API.RAPID.getVariableType("MainModule","aa");

getVariableProperties( module: string, name: string, task: string, )

Gets the properties of a variable

Alias: getVariableProperties

Parameters

  • module (string) — The name of the module where the variable locates.
  • name (string) — The variable name
  • task (string) — The task name

Example

CODE
let props = await API.RAPID.getVariableProperties("MainModule","aa");

getVariableValue(module: string, name: string, task: string)

Get the value of a variable

Alias: getVariableValue

Parameters

  • module (string) — The name of the module where the variable locates.
  • name (string) — The variable name
  • task (string) — The task name

Example

CODE
let value = await API.RAPID.getVariableValue("MainModule","aa");

setVariableValue( module: string, name: string, value: any, task: string, options: setVariableValueOptions, )

Sets the value of a RAPID variable

Alias: setVariableValue

Parameters

  • 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

Example

CODE
await API.RAPID.setVariableValue("MainModule","aa", 2,"T_ROB1",{syncPers:true});

getTask(task: string): Promise.<object>

Gets an instance of a API.RAPID.Task class

Alias: getTask

Parameters

  • task (string) — Task name

Returns

  • Promise.<object>

Example

CODE
await API.RAPID.getTask();

loadModule( path: string, replace: boolean, taskName: string, requestMsh?: boolean, )

async

Load a module from the controller HOME files

Alias: loadModule

Parameters

  • path (string) — Path to the module file in the HOME directory (included extension of the module).
  • replace (boolean, default: false) — f true, it will replace an existing module in RAPID with the same name
  • taskName (string, default: "T_ROB1") — The name of the task to which the module belongs.
  • requestMsh (boolean, optional, default: true) — Edit mastership needs to be requested before loading the module.

Example

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

unloadModule(moduleName: string, taskName?: string)

async

Unloads a RAPID module

Alias: unloadModule

Parameters

  • moduleName (string) — The module name.
  • taskName (string, optional, default: "T_ROB1") — The task name.

Example

CODE
await API.RAPID.unloadModule("Module1")

setCycleMode(cycleMode: string)

Sets cycle mode

Alias: setCycleMode

Parameters

  • cycleMode (string) — The value can be 'forever' or 'once'.

Example

CODE
await API.RAPID.setCycleMode("once")

startExecution( cycleMode: string, execMode: string, regainMode: string, setPP: boolean, moduleName: string, procName: string, taskName: string, )

Starts program execution

Alias: startExecution

Parameters

  • 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

Example

CODE
await API.RAPID.startExecution({moduleName: "Wizard", procName: "test1"});

stopExecution(props: stopExecutionProps)

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'

Alias: stopExecution

Parameters

  • props (stopExecutionProps)

Example

CODE
await API.RAPID.stopExecution();

searchRoutines( allread: boolean, taskName: string, ): Promise.<Array.<API.RAPID.routines>>

Searchs all routines

Alias: searchRoutines

Parameters

  • allread (boolean) — If the value is set to true, the non-service routines will also be included.
  • taskName (string) — The task name

Returns

  • Promise.<Array.<API.RAPID.routines>> — A list of API.RAPID.routines

Example

CODE
await task.searchRoutines();

Enums

MODULETYPE: string

enumreadonly

Alias: MODULETYPE

Properties

  • Program (enum) — Program module
  • System (enum) — System module
  • Program (string, default: "program")
  • System (string, default: "system")

Other

searchSymbolProps

static

Properties

  • 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:
     undefined: 0
     constant: 1
     variable: 2
     persistent: 4
     function: 8
     procedure: 16
     trap: 32
     module: 64
     task: 128
     routine: 8 + 16 + 32
     rapidData: 1 + 2 + 4
     any: 255
  • name (string | Array, optional) — Name of the data symbol (not case-sensitive)

Task

static

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

  • task (object) — A RWS.RAPID task object.

Example

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

VariableSymbolType: 'constant' | 'variable' | 'persistent'

static

;

filterVariables

static

Properties

  • 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.

RoutineSymbolType: 'procedure' | 'function' | 'trap'

static

;

filterRoutines

static

Properties

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

VariableProps

static

Properties

  • 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

Variable

static

This class represents a RAPID variable.

Parameters

Properties

  • var (object) — Object returned by RWS.Rapid.getData().

VariableString

static

This class represents a RAPID variable in "string" type.

Parameters

VariableBool

static

This class represents a RAPID variable in "bool" type.

Parameters

VariableNum

static

This class represents a RAPID variable in "num" or "dnum" type.

Parameters

VariableRobTarget

static

This class represents a RAPID variable in "robtarget" type.

Parameters

VariableJointTarget

static

This class represents a RAPID variable in "jointtarget" type.

Parameters

RecordData

static

This class represents a RAPID RECORD data type. This class includes some necessary properties to modelize RAPID RECORD and methods to handle RAPID RECORD, such as the methods to parse RECORD's data structure.

Parameters

  • type (string) — RECORD type
  • name (string) — RECORD component name
  • blockUrl (string) — The URL to the source RECORD.
  • isAtom (boolean) — True if the RECORD is one of the RAPID atomic data types: num, bool, string, dnum, byte
  • children (array.<API.RAPID.RecordData>) — The child parts owned by the RECORD
  • isUnknownAtom (boolean) — True if the RECORD is in atomic type that does not included by any known ones.
  • value (any) — The value of the RECORD data

setVariableValueOptions

static

Properties

  • syncPers (boolean, optional, default: 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;

stopExecutionProps

static

Properties

  • stopMode (RWS.Rapid.StopModes, optional) — Stop mode, valid values: 'cycle', 'instruction', 'stop' or 'quick_stop'
  • useTSP (RWS.Rapid.UseTSPOptions.normal, optional) — Use task selection panel, valid values: 'normal' or 'all_tasks'