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
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
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
// 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
await API.RAPID.setPPToMain()setPPToRoutine()
Sets program pointer to routine
Alias: setPPToRoutine
Example
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
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
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 nametask(string) — The task name
Example
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 nametask(string) — The task name
Example
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 nametask(string) — The task name
Example
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 namevalue(any) — The value to settask(string) — The task nameoptions(setVariableValueOptions) — object
Example
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
await API.RAPID.getTask();loadModule(
path: string,
replace: boolean,
taskName: string,
requestMsh?: boolean,
)
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 nametaskName(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
let url = `${this.path}/${this.name}${this.extension}`;
await API.RAPID.loadModule(url, true);unloadModule(moduleName: string, taskName?: string)
Unloads a RAPID module
Alias: unloadModule
Parameters
moduleName(string) — The module name.taskName(string, optional, default: "T_ROB1") — The task name.
Example
await API.RAPID.unloadModule("Module1")setCycleMode(cycleMode: string)
Sets cycle mode
Alias: setCycleMode
Parameters
cycleMode(string) — The value can be 'forever' or 'once'.
Example
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|onceexecMode(string) — Execution mode: continue|stepin|stepover|stepout|stepback|steplast|stepmotionregainMode(string) — Regain mode: continue|regain|clearsetPP(boolean) — Set program pointer to main if has no ppmoduleName(string) — Module nameprocName(string) — Procedure nametaskName(string) — Task name
Example
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
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
await task.searchRoutines();Enums
MODULETYPE: string
Alias: MODULETYPE
Properties
Program(enum) — Program moduleSystem(enum) — System moduleProgram(string, default: "program")System(string, default: "system")
Other
searchSymbolProps
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: 255name(string | Array, optional) — Name of the data symbol (not case-sensitive)
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
task(object) — A RWS.RAPID task object.
Example
const task = await API.RAPID.getTask('T_ROB1');
const modules = await task.searchModules();- See:
VariableSymbolType: 'constant' | 'variable' | 'persistent'
;
filterVariables
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'
;
filterRoutines
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
Properties
taskName(string, optional) — The task namemoduleName(string, optional) — The module namesymbolName(string, optional) — The symbol namedataType(string, optional) — The symbol's data typesymbolType(string, optional) — The declaration type of the data, valid values: 'constant' 'variable' 'persistent'dimensions(Array.<number>) — List of dimensions for arraysscope(string, optional) — The data's scope, valid values: 'local' 'task' 'global'dataTypeURL(string, optional) — RWS URL to the data’s type symbol
Variable
This class represents a RAPID variable.
Parameters
variable(RWS.Rapid.Data)props(VariableProps) — See VariableProps
Properties
var(object) — Object returned by RWS.Rapid.getData().
- See:
VariableString
This class represents a RAPID variable in "string" type.
Parameters
variable(RWS.Rapid.Data)props(VariableProps) — See VariableProps
- See:
VariableBool
This class represents a RAPID variable in "bool" type.
Parameters
variable(RWS.Rapid.Data)props(VariableProps) — See VariableProps
- See:
VariableNum
This class represents a RAPID variable in "num" or "dnum" type.
Parameters
variable(RWS.Rapid.Data)props(VariableProps) — See VariableProps
- See:
VariableRobTarget
This class represents a RAPID variable in "robtarget" type.
Parameters
variable(RWS.Rapid.Data)props(VariableProps) — See VariableProps
- See:
VariableJointTarget
This class represents a RAPID variable in "jointtarget" type.
Parameters
variable(RWS.Rapid.Data)props(VariableProps) — See VariableProps
- See:
RecordData
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 typename(string) — RECORD component nameblockUrl(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, bytechildren(array.<API.RAPID.RecordData>) — The child parts owned by the RECORDisUnknownAtom(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
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
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'