4.10 BasScript Script Program Class
Overview
BasScript is used to construct BAS instruction sequences on the host side in a structured way, including motion, logic, program control, communication, vision, and Modbus instructions.
Core Features
- Build motion instructions (
MoveJoint,MoveLine,MoveCircle, etc.) - Build logic instructions (
IF,WHILE,SWITCH,GOTO, etc.) - Build assignment, wait, pause, and abort instructions
- Build program call and management instructions
- Build Socket communication instructions
- Build Modbus register read/write instructions
- Build vision instructions
- Configure extra parameters (acceleration, RTCP, frame offset, etc.)
- Support high-level jump instructions (
JUMPseries)
Use Cases
- Automatically generate complex robot programs
- Edit and modify robot programs
- Reuse common program modules and instruction sequences
- Implement seamless integration between host and robot programs
- Build customized robot motion trajectories
- Integrate vision, communication, and Modbus functionality into robot programs
Class Constructor
| Method Name | BasScript(string name ) |
|---|---|
| Description | Constructs a BAS instruction sequence class for use in robots |
| Request Parameters | name : string Script program name |
| Compatible robot software version | Collaborative (Copper): v7.5.2.0+ Industrial (Bronze): Not supported |
| Note | All methods in this class have the same compatible version requirements as this class |
Subclass Structure
The BasScript class contains the following subclasses for organizing different instruction categories:
- ExtraParam: Extra parameter class for building complex robot control commands
- BasMotion: Motion instruction subclass, contains all robot motion-related methods
- BasLogical: Logical instruction subclass, contains all logic control-related methods
- BasStructure: Structural instruction subclass, contains all structure control-related methods
- BasSocket: Socket communication subclass, contains all Socket communication-related methods
- BasModbus: Modbus communication subclass, contains all Modbus communication-related methods
- BasVision: Vision instruction subclass, contains all vision-related methods
4.10.1 ExtraParam Class
| Method Name | ExtraParam() |
|---|---|
| Description | Extra parameter class for building complex robot control commands |
| Request Parameters | None |
| Return Value | ExtraParam object |
4.10.1.1 Set Acceleration
| Method Name | ExtraParam.Acceleration(double value ) |
|---|---|
| Description | Sets acceleration, range is 1~120% |
| Request Parameters | value : double Acceleration value, unit: % (floating point) |
| Return Value | StatusCode: Parameter setting execution result |
4.10.1.2 Set RTCP Parameter
| Method Name | ExtraParam.RTCP() |
|---|---|
| Description | Sets RTCP parameter, only supports MoveL and MoveC instructions |
| Request Parameters | None |
| Return Value | StatusCode: Parameter setting execution result |
4.10.1.3 Set Frame Offset
| Method Name | ExtraParam.Offset(int index ) |
|---|---|
| Description | Sets frame offset |
| Request Parameters | index : int Offset index (integer) |
| Return Value | StatusCode: Parameter setting execution result |
4.10.1.4 Set Time-Base Run/Assign
| Method Name | ExtraParam.TB(double second , string type , string name ) |
|---|---|
| Description | Sets time-base run or assign, range is 0.01-30s, values less than 0.01 will not save successfully |
| Request Parameters | second : double Seconds, unit: sec (floating point) type : string Execution type (string) name : string Name (for running, string) |
| Return Value | StatusCode: Parameter setting execution result |
| Method Name | ExtraParam.TB(double second , string type , int index , int status ) |
|---|---|
| Description | Sets time-base run or assign, range is 0.01-30s, values less than 0.01 will not save successfully |
| Request Parameters | second : double Seconds, unit: sec (floating point) type : string IO type (string) index : int Index (for assignment, integer) status : int Status (for assignment, integer) |
| Return Value | StatusCode: Parameter setting execution result |
4.10.1.5 Set Skip
| Method Name | ExtraParam.SKIP(int index ) |
|---|---|
| Description | Sets jump, when the jump condition set by SKIP CONDITION instruction is met, directly jumps from the current line containing SKIP instruction to the target instruction line or target program |
| Request Parameters | index : int Index of the target label (integer) |
| Return Value | StatusCode: Parameter setting execution result |
4.10.1.6 Set Departure and Approach Distance
| Method Name | ExtraParam.Approach(double departureDist , double approachingDist ) |
|---|---|
| Description | Sets departure and approach distance for gate-type motion, only used for JUMP instruction |
| Request Parameters | departureDist : double Departure distance, unit: mm (floating point) approachingDist : double Approach distance, unit: mm (floating point) |
| Return Value | StatusCode: Parameter setting execution result |
4.10.2 BasMotion Motion Instruction Subclass
BasMotion subclass contains all robot motion-related methods, used for building motion instruction sequences.
4.10.2.1 MoveJoint Motion to Point Instruction
| Method Name | BasScript.BasMotion.MoveJoint(MovePoseType poseType , int poseIndex , SpeedType speedType , double speedValue , SmoothType smoothType , double smoothDistance = 0, ExtraParam extraParam = null) |
|---|---|
| Description | Joint motion instruction, moves the robot to a specified position in the workspace with specified movement speed and method, corresponds to MoveJoint instruction in robot program writing |
| Request Parameters | poseType : MovePoseType Pose type poseIndex : int Pose index speedType : SpeedType Speed type speedValue : double Speed value, unit: % smoothType : SmoothType Smooth type smoothDistance : double Smooth distance, unit: mm, value range: 0~1000 extraParam : ExtraParam Additional parameter |
| Return Value | StatusCode: Motion instruction execution result |
4.10.2.2 MoveLine Linear Motion to Point Instruction
| Method Name | BasScript.BasMotion.MoveLine(MovePoseType poseType , int poseIndex , SpeedType speedType , double speedValue , SmoothType smoothType , double smoothDistance = 0, ExtraParam extraParam = null) |
|---|---|
| Description | Linear motion instruction, moves the robot linearly to a specified position in the workspace with specified movement speed and method, corresponds to MoveLine instruction in robot program writing |
| Request Parameters | poseType : MovePoseType Pose type poseIndex : int Pose index speedType : SpeedType Speed type speedValue : double Speed value, unit: mm/s smoothType : SmoothType Smooth type smoothDistance : double Smooth distance, unit: mm, value range: 0~1000 extraParam : ExtraParam Additional parameter |
| Return Value | StatusCode: Motion instruction execution result |
4.10.2.3 MoveCircle Arc Motion to Point Instruction
| Method Name | BasScript.BasMotion.MoveCircle(MovePoseType poseType1 , int poseIndex1 , MovePoseType poseType2 , int poseIndex2 , SpeedType speedType , double speedValue , SmoothType smoothType , double smoothDistance = 0, ExtraParam extraParam = null) |
|---|---|
| Description | Arc motion instruction, moves the robot in an arc to a specified position in the workspace with specified movement speed and method, corresponds to MoveCircle instruction in robot program writing |
| Request Parameters | poseType1 : MovePoseType First pose type poseIndex1 : int First pose index poseType2 : MovePoseType Second pose type poseIndex2 : int Second pose index speedType : SpeedType Speed type speedValue : double Speed value, unit: mm/s smoothType : SmoothType Smooth type smoothDistance : double Smooth distance, unit: mm, value range: 0~1000 extraParam : ExtraParam Additional parameter |
| Return Value | StatusCode: Motion instruction execution result |
4.10.2.4 Jump Point-to-Point Motion Instruction
| Method Name | BasScript.BasMotion.Jump(MovePoseType poseType , int poseIndex , double speedValue , double speedRatio , SpeedType limZType , double limZValue , SmoothType smoothType , double smoothDistance = 0, ExtraParam extraParam = null) |
|---|---|
| Description | Gate-type motion instruction, specifies the robot to perform gate-type motion (first vertically up, then horizontally move, finally vertically down), corresponds to JUMP instruction in robot program writing |
| Request Parameters | poseType : MovePoseType Target pose storage type poseIndex : int Target position index speedValue : double Motion speed value, unit: mm/s speedRatio : double Motion speed ratio, unit: % limZType : SpeedType Z-axis limit type limZValue : double Z-axis limit value smoothType : SmoothType Smooth type smoothDistance : double Smooth distance, unit: mm, value range: 0~1000 extraParam : ExtraParam Extra parameter |
| Return Value | StatusCode: Motion instruction execution result |
4.10.2.5 Jump3 Three-Point Jump Instruction
| Method Name | BasScript.BasMotion.Jump3(MovePoseType poseType , int poseIndex , double speedValue , double speedRatio , SmoothType smoothType , double smoothDistance = 0, ExtraParam extraParam = null) |
|---|---|
| Description | Gate-type motion instruction, specifies the robot to perform gate-type motion, including departure, approach, and target positions, corresponds to JUMP3 instruction in robot program writing |
| Request Parameters | poseType : MovePoseType Target pose storage type poseIndex : int 3 target position indices speedValue : double Motion speed value, unit: mm/s speedRatio : double Motion speed ratio, unit: % smoothType : SmoothType Smooth type smoothDistance : double Smooth distance, unit: mm, value range: 0~1000 extraParam : ExtraParam Extra parameter |
| Return Value | StatusCode: Motion instruction execution result |
4.10.2.6 Jump3CP Three-Point Jump CP Instruction
| Method Name | BasScript.BasMotion.Jump3CP(MovePoseType poseType , int poseIndex , double speedValue , SmoothType smoothType , double smoothDistance = 0, ExtraParam extraParam = null) |
|---|---|
| Description | Gate-type motion instruction, specifies the robot to perform gate-type motion, including departure, approach, and target positions, corresponds to JUMP3CP instruction in robot program writing |
| Request Parameters | poseType : MovePoseType Target pose storage type poseIndex : int 3 target position indices speedValue : double Motion speed value, unit: mm/s smoothType : SmoothType Smooth type smoothDistance : double Smooth distance, unit: mm, value range: 0~1000 extraParam : ExtraParam Extra parameter |
| Return Value | StatusCode: Motion instruction execution result |
4.10.3 BasLogical Logical Instruction Subclass
BasLogical subclass contains all logic control-related methods, used for building logic control instruction sequences.
4.10.3.1 IF Conditional Instruction
| Method Name | BasScript.BasLogical.IF(param1, index, param2, value, operatorType) |
|---|---|
| Description | Adds a logical IF statement to the script |
| Request Parameters | param1 : First parameter, type RegisterType or IOType index : Index (integer) param2 : Second parameter, type RegisterType, IOType, or OtherType value : Value, type index, number, string, or IOStatus operatorType : Boolean operator, default is equal |
| Return Value | StatusCode: Operation execution result |
4.10.3.2 ELSE_IF Conditional Branch Instruction
| Method Name | BasScript.BasLogical.ELSE_IF(param1, index, param2, value, operatorType) |
|---|---|
| Description | Adds a logical ELSE IF statement to the script |
| Request Parameters | param1 : First parameter, type RegisterType or IOType index : Index (integer) param2 : Second parameter, type RegisterType, IOType, or OtherType value : Value, type index, number, string, or IOStatus operatorType : Boolean operator, default is equal |
| Return Value | StatusCode: Operation execution result |
4.10.3.3 ELSE Instruction
| Method Name | BasScript.BasLogical.ELSE() |
|---|---|
| Description | Adds a logical ELSE statement to the script |
| Request Parameters | None |
| Return Value | StatusCode: Operation execution result |
4.10.3.4 END_IF End Conditional Instruction
| Method Name | BasScript.BasLogical.END_IF() |
|---|---|
| Description | Ends the logical IF statement |
| Request Parameters | None |
| Return Value | StatusCode: Operation execution result |
4.10.3.5 WHILE Loop Instruction
| Method Name | BasScript.BasLogical.WHILE(param1, index, param2, value, operatorType) |
|---|---|
| Description | Adds a logical WHILE statement to the script |
| Request Parameters | param1 : First parameter, type RegisterType or IOType index : Index (integer) param2 : Second parameter, type RegisterType, IOType, or OtherType value : Value, type index, number, string, or IOStatus operatorType : Boolean operator, default is equal |
| Return Value | StatusCode: Operation execution result |
4.10.3.6 END_WHILE End Loop Instruction
| Method Name | BasScript.BasLogical.END_WHILE() |
|---|---|
| Description | Ends the logical While statement |
| Request Parameters | None |
| Return Value | StatusCode: Operation execution result |
4.10.3.7 SWITCH Multi-Branch Selection Instruction
| Method Name | BasScript.BasLogical.SWITCH(param, index) |
|---|---|
| Description | Adds a logical SWITCH statement to the script |
| Request Parameters | param : Parameter, type RegisterType or IOType index : Index of the parameter |
| Return Value | StatusCode: Operation execution result |
4.10.3.8 CASE Branch Instruction
| Method Name | BasScript.BasLogical.CASE(param, value) |
|---|---|
| Description | Adds a logical CASE statement to the script |
| Request Parameters | param : Parameter, type RegisterType, IOType, or OtherType value : Value, type index, number, string |
| Return Value | StatusCode: Operation execution result |
4.10.3.9 DEFAULT Branch Instruction
| Method Name | BasScript.BasLogical.DEFAULT() |
|---|---|
| Description | Adds a logical DEFAULT statement to the script |
| Request Parameters | None |
| Return Value | StatusCode: Operation execution result |
4.10.3.10 END_SWITCH End Multi-Branch Selection Instruction
| Method Name | BasScript.BasLogical.END_SWITCH() |
|---|---|
| Description | Ends the logical SWITCH statement |
| Request Parameters | None |
| Return Value | StatusCode: Operation execution result |
4.10.3.11 SKIP_CONDITION Skip Condition Instruction
| Method Name | BasScript.BasLogical.SKIP_CONDITION(param1, index, param2, value, operatorType) |
|---|---|
| Description | Adds a logical SKIP CONDITION statement to the script |
| Request Parameters | param1 : First parameter, type RegisterType or IOType index : Index of parameter 1 param2 : Second parameter, type RegisterType, IOType, or OtherType value : Value, type index, number, string, or IOStatus operatorType : Boolean operator, default is equal |
| Return Value | StatusCode: Operation execution result |
4.10.3.12 GOTO Jump Instruction
| Method Name | BasScript.BasLogical.GOTO(index) |
|---|---|
| Description | GOTO jump statement |
| Request Parameters | index : Index of the target label |
| Return Value | StatusCode: Operation execution result |
4.10.3.13 LABEL Instruction
| Method Name | BasScript.BasLogical.LABEL(index) |
|---|---|
| Description | LABEL statement |
| Request Parameters | index : Index of the label |
| Return Value | StatusCode: Operation execution result |
4.10.3.14 BREAK Break Out of Loop Instruction
| Method Name | BasScript.BasLogical.BREAK() |
|---|---|
| Description | BREAK statement |
| Request Parameters | None |
| Return Value | StatusCode: Operation execution result |
4.10.3.15 CONTINUE Skip Loop Instruction
| Method Name | BasScript.BasLogical.CONTINUE() |
|---|---|
| Description | CONTINUE statement |
| Request Parameters | None |
| Return Value | StatusCode: Operation execution result |
4.10.4 BasStructure Structural Instruction Subclass
BasStructure subclass contains all structure control-related methods, used for building structure control instruction sequences.
4.10.4.1 WAIT Wait Condition Instruction
| Method Name | BasScript.BasStructure.WAIT(RegisterType param1 , int index , ValueType param2 , object value , BooleanOperator operatorType = BooleanOperator.EQ) |
|---|---|
| Description | Wait condition instruction, executes WAIT instruction only when the condition is met, the program can continue to execute downward, otherwise it waits until the condition is met, corresponds to WAIT COND statement in robot program writing |
| Request Parameters | param1 : RegisterType First parameter (register or IO signal) index : int Index of parameter 1 param2 : ValueType Second parameter (register, IO signal, or other type) value : object Index or value of parameter 2 operatorType : BooleanOperator Logical operator, default is equal |
| Return Value | StatusCode: Operation execution result |
4.10.4.2 WAIT_TIME Wait Time Instruction
| Method Name | BasScript.BasStructure.WAIT_TIME(ValueType param , double value ) |
|---|---|
| Description | Wait time instruction, executes WAIT TIME instruction, the robot waits for the specified time before continuing to execute subsequent instructions, corresponds to WAIT TIME statement in robot program writing |
| Request Parameters | param : ValueType Parameter type (R register or value) value : double Time value, unit: sec |
| Return Value | StatusCode: Operation execution result |
4.10.4.3 PAUSE Instruction
| Method Name | BasScript.BasStructure.PAUSE() |
|---|---|
| Description | PAUSE statement |
| Request Parameters | None |
| Return Value | StatusCode: Operation execution result |
4.10.4.4 ABORT Instruction
| Method Name | BasScript.BasStructure.ABORT() |
|---|---|
| Description | ABORT statement |
| Request Parameters | None |
| Return Value | StatusCode: Operation execution result |
4.10.4.5 CALL Synchronous Program Call Instruction
| Method Name | BasScript.BasStructure.CALL(name) |
|---|---|
| Description | CALL synchronous program call |
| Request Parameters | name : Program name |
| Return Value | StatusCode: Operation execution result |
4.10.4.6 RUN Asynchronous Program Call Instruction
| Method Name | BasScript.BasStructure.RUN(name) |
|---|---|
| Description | RUN asynchronous program call |
| Request Parameters | name : Program name |
| Return Value | StatusCode: Operation execution result |
4.10.4.7 LOAD Load Program Instruction
| Method Name | BasScript.BasStructure.LOAD(param, value) |
|---|---|
| Description | LOAD load program |
| Request Parameters | param : Parameter, R register, SR register, number, or string value : Value of the parameter, number or string |
| Return Value | StatusCode: Operation execution result |
4.10.4.8 UNLOAD Unload Program Instruction
| Method Name | BasScript.BasStructure.UNLOAD(param, value) |
|---|---|
| Description | UNLOAD unload program |
| Request Parameters | param : Parameter, R register, SR register, number, or string value : Value of the parameter, number or string |
| Return Value | StatusCode: Operation execution result |
4.10.4.9 EXEC Execute Program Instruction
| Method Name | BasScript.BasStructure.EXEC(param, value) |
|---|---|
| Description | EXEC execute program |
| Request Parameters | param : Parameter, R register, SR register, number, or string value : Value of the parameter, number or string |
| Return Value | StatusCode: Operation execution result |
4.10.5 BasSocket Socket Communication Subclass
BasSocket subclass contains all Socket communication-related methods, used for building Socket communication instruction sequences.
4.10.5.1 OPEN Open Socket Connection Instruction
| Method Name | BasScript.BasSocket.OPEN(int index ) |
|---|---|
| Description | Uses Socket Open instruction to create a Server and wait for Client connection, corresponds to SOCKET OPEN in robot program writing |
| Request Parameters | index : int SK register index |
| Return Value | StatusCode: Operation execution result |
4.10.5.2 CLOSE Close Socket Connection Instruction
| Method Name | BasScript.BasSocket.CLOSE(int index ) |
|---|---|
| Description | Closes the specified socket connection, corresponds to SOCKET CLOSE in robot program writing |
| Request Parameters | index : int SK register index |
| Return Value | StatusCode: Operation execution result |
4.10.5.3 CONNECT Socket Connection Instruction
| Method Name | BasScript.BasSocket.CONNECT(int index ) |
|---|---|
| Description | Uses Socket Connect instruction to connect to the specified socket server, corresponds to SOCKET CONNECT in robot program writing |
| Request Parameters | index : int SK register index |
| Return Value | StatusCode: Operation execution result |
4.10.5.4 SEND Send Socket Data Instruction
| Method Name | BasScript.BasSocket.SEND(int index , StrType msgType , object value ) |
|---|---|
| Description | Uses Socket Send instruction to send data to the specified socket connection, corresponds to SOCKET SEND in robot program writing |
| Request Parameters | index : int SK register index msgType : StrType Message type value : object Message content or index |
| Return Value | StatusCode: Operation execution result |
4.10.5.5 RECV Receive Socket Data Instruction
| Method Name | BasScript.BasSocket.RECV(int index , int msgLength , StrType msgType , object value ) |
|---|---|
| Description | Uses Socket Recv instruction to read characters from the specified socket connection, can specify maximum length, corresponds to SOCKET RECV in robot program writing |
| Request Parameters | index : int SK register index msgLength : int Message maximum length msgType : StrType Message type value : object Message content or index |
| Return Value | StatusCode: Operation execution result |
4.10.6 BasModbus Modbus Communication Subclass
BasModbus subclass contains all Modbus communication-related methods, used for building Modbus register read/write instruction sequences.
4.10.6.1 READ_MH Read Modbus Holding Register Instruction
| Method Name | BasScript.BasModbus.READ_MH(int index , int id , int address , int length , int rIndex ) |
|---|---|
| Description | Read Modbus holding register instruction, corresponds to READ_MH in robot program writing |
| Request Parameters | index : int Channel index id : int Modbus ID address : int Register start address length : int Register length, i.e., number of registers to read rIndex : int R register start index to write result |
| Return Value | StatusCode: Operation execution result |
4.10.6.2 READ_MI Read Modbus Input Register Instruction
| Method Name | BasScript.BasModbus.READ_MI(int index , int id , int address , int length , int rIndex ) |
|---|---|
| Description | Read Modbus input register instruction, corresponds to READ_MI in robot program writing |
| Request Parameters | index : int Channel index id : int Modbus ID address : int Register start address length : int Register length, i.e., number of registers to read rIndex : int R register start index to write result |
| Return Value | StatusCode: Operation execution result |
4.10.6.3 WRITE_MH Write Modbus Holding Register Instruction
| Method Name | BasScript.BasModbus.WRITE_MH(int index , int id , int address , int length , ValueType valueType , int value ) |
|---|---|
| Description | Write Modbus holding register instruction, corresponds to WRITE_MH in robot program writing |
| Request Parameters | index : int Channel index id : int Modbus ID address : int Register start address length : int Register length, i.e., number of registers to write valueType : ValueType Value type value : int Value or R register start index |
| Return Value | StatusCode: Operation execution result |
4.10.7 BasVision Vision Instruction Subclass
BasVision subclass contains all vision-related methods, used for building vision program instruction sequences.
4.10.7.1 FIND Find Vision Program Instruction
| Method Name | BasScript.BasVision.FIND(string name ) |
|---|---|
| Description | Executes vision find program, corresponds to VISION FIND in robot program writing |
| Request Parameters | name : string Vision program name |
| Return Value | StatusCode: Operation execution result |
4.10.7.2 GET_OFFSET Get Vision Program Offset Instruction
| Method Name | BasScript.BasVision.GET_OFFSET(string name , int index , int labelIndex ) |
|---|---|
| Description | Gets offset after vision program execution, corresponds to VISION GET OFFSET in robot program writing |
| Request Parameters | name : string Vision program name index : int Vision register index labelIndex : int Label index |
| Return Value | StatusCode: Operation execution result |
4.10.7.3 GET_QUANTITY Get Vision Program Result Instruction
| Method Name | BasScript.BasVision.GET_QUANTITY(string name , int index ) |
|---|---|
| Description | Gets result quantity after vision program execution, corresponds to VISION GET QUANTITY in robot program writing |
| Request Parameters | name : string Vision program name index : int R register index to store result |
| Return Value | StatusCode: Operation execution result |
4.10.8 AssignValue Assignment Instruction (Full Parameters)
| Method Name | BasScript.AssignValue(AssignType param1 , int index , AssignType param2 , object value , int optIndex = 0, int optValue = 0) |
|---|---|
| Description | Assignment instruction, used to assign values to registers, IO signals, etc., corresponds to ASSIGN statement in robot program writing |
| Request Parameters | param1 : AssignType First parameter (register or IO signal) index : int Index of parameter 1 param2 : AssignType Second parameter (register, IO signal, or other type) value : object Index or value of parameter 2 optIndex : int Additional index for parameter 1 when param1 is PR_ELEMENT, default 0 optValue : int Additional index for parameter 2 when param2 is PR_ELEMENT or pulse value when value is IOStatus.PULSE, default 0 |
| Return Value | StatusCode: Operation execution result |
4.10.9 AssignValue Assignment Instruction (Simplified Parameters)
| Method Name | BasScript.AssignValue(AssignType param , int index , object value ) |
|---|---|
| Description | Assignment instruction (simplified parameters), used to assign values to registers, IO signals, etc., corresponds to ASSIGN statement in robot program writing |
| Request Parameters | param : AssignType Parameter type (register or IO signal) index : int Parameter index value : object Value (IOStatus, double, or string) |
| Return Value | StatusCode: Operation execution result |
4.10.10 SetParam Set Parameter Instruction
| Method Name | BasScript.SetParam(ParamType type , ValueType valueType , object value ) |
|---|---|
| Description | Set parameter instruction, used to set various parameters of the robot, corresponds to SET PARAM in robot program writing |
| Request Parameters | type : ParamType Parameter type valueType : ValueType Value type value : object Value |
| Return Value | StatusCode: Operation execution result |