IRC5-Rapid Kernel Reference Manual 3HAC16585-1 - Revb - en - Library PDF
IRC5-Rapid Kernel Reference Manual 3HAC16585-1 - Revb - en - Library PDF
IRC5-Rapid Kernel Reference Manual 3HAC16585-1 - Revb - en - Library PDF
+$&
5HYLVLRQ%
&RQWUROOHUVRIWZDUH,5&
5$3,'NHUQHO 7DEOHRIFRQWHQWV
5RERW:DUH
5$3,'.HUQHOUHIHUHQFHPDQXDO
,QGH[
5$3,'NHUQHO
The information in this manual is subject to change without notice and should not be construed as a commitment by ABB. ABB
assumes no responsibility for any errors that may appear in this manual.
Except as may be expressly stated anywhere in this manual, nothing herein shall be construed as any kind of guarantee or
warranty by ABB for losses, damages to persons or property, fitness for a specific purpose or the like.
In no event shall ABB be liable for incidental or consequential damages arising from use of this manual and products described
herein.
This manual and parts thereof must not be reproduced or copied without ABB’s written permission, and contents thereof must
not be imparted to a third party nor be used for any unauthorized purpose. Contravention will be prosecuted.
Additional copies of this manual may be obtained from ABB at its then current charge.
5$3,'NHUQHO
&RQWHQWV
,QWURGXFWLRQ
1.1 Design objectives.............................................................................................................. 1
1.2 Language summary........................................................................................................... 1
Task - modules ................................................................................................................. 1
Routines ........................................................................................................................... 2
User routines .................................................................................................................... 2
Predefined routines .......................................................................................................... 2
Data objects...................................................................................................................... 2
Statements ........................................................................................................................ 2
Backward execution......................................................................................................... 3
Error recovery .................................................................................................................. 3
Interrupts .......................................................................................................................... 4
Data types......................................................................................................................... 4
Built-in data types ............................................................................................................ 4
Installed data types........................................................................................................... 5
User-defined data types.................................................................................................... 5
Placeholders ..................................................................................................................... 5
1.3 Syntax notation ................................................................................................................. 5
1.4 Error classification............................................................................................................ 6
/H[LFDOHOHPHQWV
2.1 Character set ..................................................................................................................... 7
2.2 Lexical units ..................................................................................................................... 8
2.3 Identifiers.......................................................................................................................... 8
2.4 Reserved words................................................................................................................. 9
2.5 Num literals ...................................................................................................................... 9
2.6 Bool literals..................................................................................................................... 10
2.7 String literals................................................................................................................... 10
2.8 Delimiters ....................................................................................................................... 10
2.9 Placeholders.................................................................................................................... 11
2.10 Comments..................................................................................................................... 11
2.11 Data types ..................................................................................................................... 12
2.12 Scope rules.................................................................................................................... 13
2.13 Atomic types................................................................................................................. 13
Num type........................................................................................................................ 14
Bool type ........................................................................................................................ 14
String type ...................................................................................................................... 14
2.14 Record types ................................................................................................................. 14
Pos type .......................................................................................................................... 15
5$3,'NHUQHO I
&RQWHQWV
II 5$3,'NHUQHO
&RQWHQWV
5$3,'NHUQHO III
&RQWHQWV
Code example................................................................................................................. 68
Nostepin move instructions and asynchronously raised errors...................................... 70
UNDO handler ............................................................................................................... 71
7.5 SkipWarn ........................................................................................................................ 71
,QWHUUXSWV
8.1 Interrupt recognition and response ................................................................................. 73
8.2 Interrupt manipulation .................................................................................................... 73
8.3 Trap routines................................................................................................................... 74
7DVNPRGXOHV
9.1 Module declarations ....................................................................................................... 78
9.2 System modules.............................................................................................................. 80
6\QWD[VXPPDU\
%XLOWLQURXWLQHV
%XLOWLQGDWDREMHFWV
%XLOWLQREMHFWV
13.1 Object scope ................................................................................................................. 95
13.2 The value of a built in data object durability................................................................ 96
13.3 The way to define user installed objects ...................................................................... 96
,QWHUWDVNREMHFWV
14.1 Symbol levels ............................................................................................................... 99
14.2 Data object handling................................................................................................... 100
14.3 The way to define Built in shared object.................................................................... 100
14.4 System global persistent data object .......................................................................... 100
7H[WILOHV
15.1 Syntax for a text file ................................................................................................... 103
15.2 RAPID identifier ........................................................................................................ 104
15.3 Retrieving text during program execution.................................................................. 105
15.4 Loading text files........................................................................................................ 105
6WRUDJHDOORFDWLRQIRU5$3,'REMHFWV
16.1 Module, routine, program flow and other basic instruction ....................................... 107
16.2 Move instructions ....................................................................................................... 108
16.3 I/O instructions ........................................................................................................... 108
IV 5$3,'NHUQHO
,QWURGXFWLRQ
,QWURGXFWLRQ
This manual contains a formal description of the ABB Robotics robot programming
language RAPID.
'HVLJQREMHFWLYHV
The RAPID language is aimed to support a levelled programming concept where new
routines, data objects and data types may be installed at a specific IRB site. This
concept makes it possible to customize (extend the functionality of) the programming
environment and must be fully supported by the programming language.
/DQJXDJHVXPPDU\
7DVNPRGXOHV
5$3,'NHUQHO 1
,QWURGXFWLRQ
While small applications usually are contained in a single task module (besides the
system module/s), larger applications may have a "main" task module that in turn
references routines and/or data contained in one or more other, "library" task modules.
One task module contains the HQWU\procedure of the task. 5XQQLQJ the task really
means that the entry routine is executed. Entry routines must be parameterless.
5RXWLQHV
There are three types of routines - IXQFWLRQV, SURFHGXUHV and WUDSV. A function returns
a value of a specific type and is used in expression context. A procedure does not return
any value and is used in statement context. Trap routines provide a means to respond
to interrupts. A trap routine can be associated with a particular interrupt and is then later
automatically executed if that interrupt occurs.
8VHUURXWLQHV
An RAPID routine declaration specifies the routine name, routine parameters, data
declarations, statements and possibly a backward handler or/and error handler.
3UHGHILQHGURXWLQHV
There are two types of predefined routines - EXLOWLQroutines and LQVWDOOHG routines.
Built-in routines (like arithmetic functions) are a part of the RAPID language while
installed routines are application/equipment dependent routines used for the control of
the robot arm, grippers, sensors etc. Note that from the users point of view there is no
difference between built-in routines and installed routines.
'DWDREMHFWV
There are four types of data objects - FRQVWDQWV, YDULDEOHV, SHUVLVWHQWV and SDUDPHWHUV.
A persistent (data object) can be described as a "persistent" variable. While a variable
value is lost (re-initialized) at the beginning of each new session - at module load
(module variable) or routine call (routine variable) - a persistent keeps its value
between sessions. Data objects can be structured (record) and dimensioned (array,
matrix etc.).
6WDWHPHQWV
2 5$3,'NHUQHO
,QWURGXFWLRQ
The JRWR statement causes the execution to continue at a position specified by a label.
The FRQQHFW statement is used to allocate an interrupt number and associate it with a
trap (interrupt service) routine.
The UHWU\ and WU\QH[W statements are used to resume evaluation after an error.
The LI and WHVW statements are used for selection. The if statement allows the selection
of a statement list based on the value of a condition. The test statement selects one (or
none) of a set of statement lists, depending on the value of an expression.
The IRU and ZKLOHstatements are used for iteration. The for statement repeats the
evaluation of a statement list as long as the value of a loop variable is within a specified
value range. The loop variable is updated (with selectable increment) at the end of each
iteration. The while statement repeats the evaluation of a statement list as long as a
condition is met. The condition is evaluated and checked at the beginning of each
iteration.
%DFNZDUGH[HFXWLRQ
(UURUUHFRYHU\
5$3,'NHUQHO 3
,QWURGXFWLRQ
,QWHUUXSWV
'DWDW\SHV
Any RAPID object (value, expression, variable, function etc.) has a GDWDW\SH. A data
type can either be a EXLOWLQ type or an LQVWDOOHG type (compare installed routines) or a
XVHUGHILQHG (defined in RAPID) type. Built-in types are a part of the RAPID language
while the set of installed oruser-defined types may differ from site to site. From the
users point of view there is no difference between built-in, installed and user-defined
types. There are three different kinds of types - DWRPLF typesUHFRUG types and DOLDV
types. The definition of an atomic type must be built-in or installed, but a record oralias
type could also be user-defined.
Atomic types are "atomic" in the sense that they are not defined upon any other type
and they cannot be divided into parts or components. Record types are built up by a set
of named, ordered components. An alias type is by definition equal to another type.
Alias types make it possible to classify data objects.
In addition to the atomic, record or alias classification of types, each type has a YDOXH
FODVV. There are three value classes of types - YDOXH types, QRQYDOXH types and VHPLYDOXH
types. An object of value type is simply considered to represent some form of "value"
(e.g, 3.55 or "John Smith". A nonvalue (type) object instead represents a hidden/
encapsulated description of some physical or logical object, e.g. a file. Semivalue
objects are somewhat special. They really have two types, one "basic" nonvalue type
and one DVVRFLDWHG value type that may be used to represent some property of the
nonvalue type.
%XLOWLQGDWDW\SHV
The built-in atomic types are ERRO, QXP and VWULQJ. Bool is an enumerated type with the
value domain {758(, )$/6(} and provides a means of performing logical and
relational computations. The num type supports exact and approximate arithmetic
computations. The string type represents character sequences.
The built-in record types are SRV,RULHQWDnd SRVH. The pos type represents a position in
space (vector). The orient type represents an orientation in space. The pose type
represents a coordinate system (position/orientation combination).
The built-in alias types are HUUQXP and LQWQXP. Errnum and intnum are both aliases for
num and are used to represent error and interrupt numbers.
4 5$3,'NHUQHO
,QWURGXFWLRQ
,QVWDOOHGGDWDW\SHV
The concept of installed types supports the use of installed routines by making it
possible to use appropriate parameter types. An installed type can be either an Atomic,
Record or Alias type.
8VHUGHILQHGGDWDW\SHV
The user-defined types make it easier to customise an application program. They also
make it possible to write a RAPID program which is more readable.
3ODFHKROGHUV
6\QWD[QRWDWLRQ
The context-free syntax of the RAPID language is described using a modified variant
of the Backus-Naur Form - EBNF:
5$3,'NHUQHO 5
,QWURGXFWLRQ
(UURUFODVVLILFDWLRQ
Based on the time of detection errors may be divided into:
- 6WDWLFerrors
- ([HFXWLRQerrors
Static errors are detected either when a module is loaded into the task buffer (see 9) or
prior to program execution after program modification.
The error handler concept of RAPID makes it possible to recover from nonfatal
execution errors. Refer to 7.
6 5$3,'NHUQHO
/H[LFDOHOHPHQWV
/H[LFDOHOHPHQWV
This chapter defines the lexical elements of RAPID.
&KDUDFWHUVHW
Sentences of the RAPID language are constructed using the standard ISO 8859-1
character set. In addition QHZOLQH, WDE and IRUPIHHG control characters are recognized.
5$3,'NHUQHO 7
/H[LFDOHOHPHQWV
/H[LFDOXQLWV
An RAPID sentence is a sequence of lexical units - tokens. The RAPID tokens are:
- identifiers
- reserved words
- literals
- delimiters
- placeholders
- comments
Tokens are indivisible. Except for string literals and comments, space must not occur
within tokens.
,GHQWLILHUV
Identifiers are used for naming objects.
<identifier> ::=
<ident>
| ,'!
<ident> ::= <letter> {<letter> | <digit> | ’_’}
8 5$3,'NHUQHO
/H[LFDOHOHPHQWV
5HVHUYHGZRUGV
The 56 identifiers listed below are reserved words. They have a special meaning in the
language. They may not be used in any context not specially stated by the syntax.
1XPOLWHUDOV
A num literal represents a numeric value.
A num literal must be in the range specified by the ANSI IEEE 754-1985 standard
(single precision) float format.
5$3,'NHUQHO 9
/H[LFDOHOHPHQWV
%RROOLWHUDOV
A bool literal represents a logical value.
6WULQJOLWHUDOV
A string literal is a sequence of zero or more characters enclosed by the double quote
(") character.
The possibility to use character codes provides a means to include non printable
characters (binary data) in string literals. If a back slash or double quote character
should be included in a string literal it must be written twice.
'HOLPLWHUV
A delimiter is one of the following characters:
{ } ( ) [ ] , . = < > + - * / : ; ! \ ?
10 5$3,'NHUQHO
/H[LFDOHOHPHQWV
3ODFHKROGHUV
Placeholders can be used by Offline and Online programming tools to temporarily
represent "not yet defined" parts of an RAPID program. A program that contains
placeholders is syntactically correct and may be loaded to (and saved) from the task
buffer. If the placeholders in an RAPID program do not cause any semantic errors (see
1.4), such a program can even be executed, but any placeholder encountered causes an
execution error (see 1.4). RAPID recognizes the following 13 placeholders:
&RPPHQWV
A comment starts with an exclamation point and is terminated by a newline character.
A comment can never include a newline character.
Comments have no effect on the meaning of an RAPID code sequence, their sole
purpose is the enlightenment of the reader.
Each RAPID comment occupies an entire source line and may occur either as:
5$3,'NHUQHO 11
/H[LFDOHOHPHQWV
e.g.
! Increase length
length := length + 5;
,) length < 1000 25 length > 14000 7+(1
! Out of bounds
(;,7;
(1',)
...
Comments located between the last data declaration (see 2.18) and the first routine
declaration (see 5) of a module are regarded to be a part of the routine declaration list.
Comments located between the last data declaration and the first statement of a routine
are regarded to be a part of the statement list (see 4.2).
'DWDW\SHV
An RAPID data type is identified by its name and can be either EXLOWLQ, LQVWDOOHGor a
XVHUGHILQHG(defined in RAPID).
Built-in types are part of the RAPID language while the set of installed or user-defined
types may differ from site to site. Please refer to site specific documentation. The
concept of installed types supports the use of installed routines by making it possible
to use appropriate parameter types. The user-defined types make it possible to prepare
understandable and easy programmable application packets for the application
engineer. From the users point of view there is no difference between built-in, installed
and user-defined types.
There are three different kinds of types - DWRPLF typesUHFRUG types and DOLDV types.
Type definitions can occur in the heading section of modules (see 9).
The optional local directive classifies the data object being ORFDO, otherwise JOREDO(see
2.20).
12 5$3,'NHUQHO
/H[LFDOHOHPHQWV
6FRSHUXOHV
The VFRSH of a type definition denotes the area in which the type is YLVLEOH and is
determined by the context and position of its declaration.
A user-defined type is always defined inside a module. The following scope rules are
valid for module type definitions:
- The scope of a local module type definition comprises the module in which it
is contained.
- The scope of a global module type definition in addition comprises any other
module in the task buffer.
- Within its scope a module type definition hides any predefined type with the
same name.
- Within its scope a local module type definition hides any global module type
with the same name.
- Two module objects declared in the same module may not have the same name.
- Two global objects declared in two different modules in the task buffer may not
have the same name.
$WRPLFW\SHV
Atomic types are "atomic" in the sense that they are not defined upon any other type
and cannot be divided into parts or components. The internal structure
(implementation) of an atomic type is hidden. The built-in atomic types are the
numeric type QXP, the logical type ERRO and the text type VWULQJ.
5$3,'NHUQHO 13
/H[LFDOHOHPHQWV
1XPW\SH
A num object represents a numeric value. The num type denotes the domain specified
by the ANSI IEEE 754-1985 standard (single precision) float format.
Within the subdomain -8388607 to (+)8388608, num objects may be used to represent
integer (exact) values. The arithmetic operators +, -, and * (see 3.11) preserves integer
representation as long as operands and result are kept within the integer subdomain of
num.
%RROW\SH
The bool type denotes the domain of twovalued logic - { 758(, )$/6( }.
6WULQJW\SH
The string type denotes the domain of all sequences of graphical characters (ISO 8859-
1) and control characters (non ISO 8859-1 characters in the numeric code range 0 ..
255). A string may consist of 0 to 80 characters (fixed 80 characters storage format).
5HFRUGW\SHV
A record data type is a composite type with named, ordered components. The value of
a record type is a composite value consisting of the values of its components. A
component can have atomic type or record type. Semivalue types cannot be included
in a record type. The built-in record types are SRV, RULHQW and SRVHThe available set of
installed and user-defined record types is by definition not bound by the RAPID
specification. Please refer to site specific documentation
14 5$3,'NHUQHO
/H[LFDOHOHPHQWV
e.g. 5(&25'newtype
num x;
(1'5(&25'
A specific component of a record data object can be accessed by using the name of the
component.
Unless otherwise stated the domain of a record type is the cartesian product of the
domains of its components.
3RVW\SH
A pos object represents a vector (position) in 3D space. The pos type has three
components:
[ x, y, z ]
5$3,'NHUQHO 15
/H[LFDOHOHPHQWV
2ULHQWW\SH
An orient object represents an orientation (rotation) in 3D space. The orient type has
four components:
3RVHW\SH
A pose object represents a 3D frame (coordinate system) in 3D-space. The pose type
has two components:
[ trans, rot ]
16 5$3,'NHUQHO
/H[LFDOHOHPHQWV
$OLDVW\SHV
An alias data type is defined as being equal to another type. Alias types provide a
means to classify objects. The system may use the alias classification to look up and
present type related objects.
e.g. $/,$6numnewtype;
Note that one alias type cannot be defined upon another alias type.
The built-in alias types are HUUQXP and LQWQXP - both aliases for num.
(UUQXPW\SH
The errnum type is an alias for num and is used for the representation of error numbers.
,QWQXPW\SH
The intnum type is an alias for num and is used for the representation of interrupt
numbers.
'DWDW\SHYDOXHFODVVHV
With respect to the relation between object data W\SH and object YDOXH different data
types can be classified as being either a:
An object of value type is simply considered to represent some form of "value" (e.g. 5,
[10, 7, 3.25], "John Smith", 758(. A nonvalue (type) object instead represents a
hidden/encapsulated description (descriptor) of some physical or logical object, e.g.
the LRGHY (file) type.
5$3,'NHUQHO 17
/H[LFDOHOHPHQWV
The content ("value") of nonvalue objects can only be manipulated using installed
routines ("methods"). Nonvalue objects may in RAPID programs only be used as
arguments to YDU or UHI parameters.
Semivalue objects are somewhat special. They really have two types, one "basic"
nonvalue type and one DVVRFLDWHG (value) type that may be used to represent some
property of the nonvalue type. RAPID views a semivalue object as a value object when
used in value context (se table below) and a nonvalue object otherwise. The semantics
(meaning/result) of a read or update (value) operation performed upon a semivalue type
is defined by the type itself.
Note that a semivalue object (type) can reject either reading or updating "by value".
The table below shows which combinations of object usage and type value class that
are possibly legal and which are impossible/illegal:
18 5$3,'NHUQHO
/H[LFDOHOHPHQWV
XLegal/Possible
---Illegal/Impossible Data type value class
Object Declarations value nonvalue semivalue
Constant X ---
Persistent X ---
Variable with initialization X ---
Variable without initialization X X X
Routine Parameter
in X --- ---
var X X X
pers X --- ---
Data object usage
The basic value types are the built-in atomic types num, bool and string. A record type
with all components being value types is itself a value type, e.g the built-in types pos,
orient and pose. An alias type defined upon a value type is itself a value type, e.g. the
built-in types errnum and intnum.
A record type having at least one semivalue component and all other components have
value type is itself a semivalue type. An alias type defined upon a semivalue type is
itself a semivalue type.
All other types are nonvalue types, e.g record types with at least one nonvalue
component and alias types defined upon nonvalue types.
Arrays have the same value class as the element value class.
5$3,'NHUQHO 19
/H[LFDOHOHPHQWV
(TXDOW\SHV
The types of two objects are HTXDO if the objects have the same VWUXFWXUH (degree,
dimension and number of components) and either:
- Both objects have the same type name (any alias type name included is first
replaced by its definition type).
- One of the objects is an aggregate (array or record) and the types of (all)
corresponding elements/components are HTXDO.
- One of the objects has a value type, the other object has a semivalue type and
the type of the first object and the associated type of the semivalue object are
HTXDO. Note that this is only valid in value context.
'DWDGHFODUDWLRQV
There are four kinds of data objects - FRQVWDQWVYDULDEOHVSHUVLVWHQWV and SDUDPHWHUV.
Except for SUHGHILQHGGDWDREMHFWV (see 2.19 and appendix C) and for loop variables
(see 4.15) all data objects must be declared. A GDWDGHFODUDWLRQ introduces a constant,
a variable or a persistent by associating an identifier with a data type. Refer to 5.1 for
information on parameter declarations. A data declaration can be represented by the
placeholder ''1!.
Data declarations can occur in the heading section of modules (see 9) and routines (see
5).
The optional local directive classifies the data object being ORFDO, otherwise JOREDO(see
2.20). Note that the local directive only may be used at module level (not inside a
routine).
20 5$3,'NHUQHO
/H[LFDOHOHPHQWV
The optional task directive classifies persistent data object being task JOREDO as
opposed to system JOREDO. In the scope rules there is no difference between the two
global types. However the current value of a task global persistent will always be
unique to the task and not shared among other tasks. System global persistents in
different tasks share current value if they are declared with the same name and type.
Note that the task directive only may be used at module level (not inside a routine).
3UHGHILQHGGDWDREMHFWV
A predefined data object is supplied by the system and is always available. Predefined
data objects are automatically declared and can be referenced from any module. Refer
to appendix C for the description of built-in data objects.
6FRSHUXOHV
The VFRSH of a data object denotes the area in which the object is YLVLEOH and is
determined by the context and position of its declaration.
- The scope of a local module data object comprises the module in which it is
contained.
- The scope of a global module data object in addition comprises any other
module in the task buffer.
- Within its scope a module data object hides any predefined object with the same
name.
- Within its scope a local module data object hides any global module object with
the same name.
- Two module objects declared in the same module may not have the same name.
- Two global objects declared in two different modules in the task buffer may not
have the same name.
- A global data object and a module may not share the same name.
5$3,'NHUQHO 21
/H[LFDOHOHPHQWV
The following scope rules are valid for routine data objects:
- The scope of a routine data object comprises the routine in which it is contained.
- Within its scope a routine data object hides any predefined or user defined
object with the same name.
- Two routine data objects declared in the same routine may not have the same
name.
- A routine data object may not have the same name as a label declared in the
same routine.
- Refer to 5 and 9 for information on routines and task modules.
6WRUDJHFODVV
The VWRUDJHFODVV of a data object determines when the system allocates and deallocates
memory for the data object. The storage class of a data object is determined by the kind
of data object and the context of its declaration and can be either VWDWLF or YRODWLOH.
Constants, persistents and module variables are static. The memory needed to store the
value of a static data object is allocated when the module that declares the object is
loaded (see 9). This means that any value assigned to a persistent or a module variable
always remains unchanged until the next assignment.
Routine variables (and LQ parameters, see 5.1) are volatile. The memory needed to store
the value of a volatile object is allocated first upon the call of the routine in which the
declaration of the variable is contained. The memory is later deallocated at the point of
the return to the caller of the routine. This means that the value of a routine variable is
always undefined before the call of the routine and is always lost (becomes undefined)
at the end of the execution of the routine.
In a chain of recursive routine calls (a routine calling itself directly or indirectly) each
instance of the routine receives its own memory location for the "same" routine
variable - a number of LQVWDQFHV of the same variable are created.
9DULDEOHGHFODUDWLRQV
A variable is introduced by a variable declaration.
<variable declaration> ::=
9$5 <data type> <variable definition> ’;’
<variable definition> ::=
<identifier> [ ’{’ <dim> { ’,’ <dim> } ’}’ ]
[ ’:=’ <constant expression> ]
<dim> ::= <constant expression>
e.g. 9$5 num x;
9$5 pos curpos := [b+1, cy, 0];
22 5$3,'NHUQHO
/H[LFDOHOHPHQWV
Variables of any type (including installed types) can be given an array (of degree 1, 2
or 3) format by adding dimension information to the declaration. The dimension
expression must represent an integer value (see ) greater than 0.
Variables with value types (see 2.16) may be initialized (given an initial value). The
data type of the constant expression used to initialize a variable must be equal to the
variable type.
3HUVLVWHQWGHFODUDWLRQV
A persistent is introduced by a persistent declaration. Note that persistents can only be
declared at module level (not inside a routine). A persistent can be given any value data
type.
Persistents of any type (including installed types) can be given an array (of degree 1, 2
or 3) format by adding dimension information to the declaration. The dimension
expression must represent an integer value (see ) greater than 0.
e.g. ! 2 x 2 matrix
3(56 num grid{2, 2} := [[0, 0], [0, 0]];
5$3,'NHUQHO 23
/H[LFDOHOHPHQWV
As described in chapter 2.18, persistents can be declared as local, task global or system
global. Local and task global persistents must be initialized (given an initial value). For
system global persistents the initial value may be omitted. The data type of the literal
expression used to initialize a persistent must be equal to the persistent type. Note that
an update of the value of a persistent automatically leads to an update of the
initialization expression of the persistent declaration (if not omitted).
02'8/( ...
3(56 pos refpnt := [100.23, 778.55, 1183.98];
...
refpnt := [x, y, z];
...
(1'02'8/(
&RQVWDQWGHFODUDWLRQV
A constant represents a static value and is introduced by a constant declaration. The
value of a constant cannot be modified. A constant can be given any value data type.
24 5$3,'NHUQHO
/H[LFDOHOHPHQWV
A constant of any type (including installed types) can be given an array (of degree 1,
2 or 3) format by adding dimensioning information to the declaration. The dimension
expression must represent an integer value (see ) greater than 0. The data type of the
constant value must be equal to the constant type.
5$3,'NHUQHO 25
/H[LFDOHOHPHQWV
26 5$3,'NHUQHO
([SUHVVLRQV
([SUHVVLRQV
An expression specifies the evaluation of a value. An expression can be represented by
the placeholder (;3!.
<expression> ::=
<expr>
| (;3!
<expr> ::= [ 127 ] <logical term> { ( 25_;25 ) <logical term> }
<logical term> ::= <relation> { $1'<relation> }
<relation> ::= <simple expr> [ <relop> <simple expr> ]
<simple expr> ::= [ <addop> ] <term> { <addop> <term> }
<term> ::= <primary> { <mulop> <primary> }
<primary> ::=
<literal>
| <variable>
| <persistent>
| <constant>
| <parameter>
| <function call>
| <aggregate>
| ’(’ <expr> ’)’
<relop> ::= ’<’ | ’<=’ | ’=’ | ’>’ | ’>=’ | ’<>’
<addop> ::= ’+’ | ’-’
<mulop> ::= ’*’ | ’/’ | ',9 | 02'
The relative SULRULW\ of the operators determines the order in which they are evaluated.
Parentheses provide a means to override operator priority. The rules above imply the
following operator priority:
An operator with high priority is evaluated prior to an operator with low priority.
Operators of the same priority are evaluated from left to right.
e.g.
a+b+c --> (a + b) + c -- left to right rule
a+b*c --> a + (b * c) -- * higher than +
a 25 b 25 c --> (a 25 b) 25 c -- Left to right rule
a $1' b 25 c $1' d --> (a $1' b) 25 (c $1' d)
a < b $1' c < d --> (a < b) $1' (c < d
5$3,'NHUQHO 27
([SUHVVLRQV
The left operand of a binary operator 1) is evaluated prior to the right operand. Note that
the evaluation of expressions involving $1' and 25 operators is RSWLPLVHG so that the
right operand of the expression will not be evaluated if the result of the operation can
be determined after the evaluation of the left operand.
&RQVWDQWH[SUHVVLRQV
Constant expressions are used to represent values in data declarations.
- Variables, Persistents
- Function calls
/LWHUDOH[SUHVVLRQV
Literal expressions are used to represent initialization values in persistent declarations.
&RQGLWLRQDOH[SUHVVLRQV
Conditional expressions are used to represent logical values.
28 5$3,'NHUQHO
([SUHVVLRQV
/LWHUDOV
A literal is a lexical element (indivisible) that represents a constant value of a specific
data type.
e.g. 0.5, 1E2 - num literals
"limit" - string literal
758( - bool literal
9DULDEOHV
Depending on the type and dimension of a variable it may be referenced in up to three
different ways. A variable reference may mean the entire variable, an element of a
variable (array) or a component of a variable (record).
<variable> ::=
<entire variable>
| <variable element>
| <variable component>
A variable reference denotes, depending on the context, either the value or the location
of the variable.
(QWLUHYDULDEOH
If the variable is an array the reference denotes all elements. If the variable is a record
the reference denotes all components. Note that the placeholder ,'! (see 2.3) cannot
be used to represent an entire variable.
5$3,'NHUQHO 29
([SUHVVLRQV
9DULDEOHHOHPHQW
An array variable element is referenced using the index number of the element.
An index expression must represent an integer value (see ) greater than 0. Index value
1 selects the first element of an array. An index value may not violate the declared
dimension. The number of elements in the index list must fit the declared degree (1, 2
or 3) of the array.
9DULDEOHFRPSRQHQW
Note that the placeholder ,'! (see 2.3) cannot be used to represent a component
name.
3HUVLVWHQWV
A persistent reference may mean the entire persistent, an element of a persistent (array)
or a component of a persistent (record).
<persistent> ::=
<entire persistent>
| <persistent element>
| <persistent component>
The rules concerning persistent references comply with the rules concerning variable
references (see , and respectively).
30 5$3,'NHUQHO
([SUHVVLRQV
&RQVWDQWV
A constant reference may mean the entire constant, an element of a constant (array) or
a component of a constant (record).
<constant> ::=
<entire constant>
| <constant element>
| <constant component>
The rules concerning constant references comply with the rules concerning variable
references (see , and respectively).
3DUDPHWHUV
A parameter reference may mean the entire parameter, an element of a parameter
(array) or a component of a parameter (record).
<parameter> ::=
<entire parameter>
| <parameter element>
| <parameter component>
The rules concerning parameter references comply with the rules concerning variable
references (see , and respectively).
$JJUHJDWHV
An aggregate denotes a composite value, i.e. an array or record value. Each aggregate
member is specified by an expression.
The data type of an aggregate is (must be able to be) determined by the context. The
data type of each aggregate member must be equal to the type of the corresponding
member of the determined type.
e.g.
9$5 pos p1;
p1 := [1, -100, 12]; -- Aggregate type pos - determined by p1
IF [1,-100,12] = [a,b,b] THEN -- Illegal since the data type of neither of
the aggregates can be determined by the
context
5$3,'NHUQHO 31
([SUHVVLRQV
)XQFWLRQFDOOV
A function call initiates the evaluation of a specific function and receives the value
returned by the function. Functions can be either predefined or user defined.
The arguments of a function call is used to transfer data to (and possibly from) the
called function. Arguments are evaluated from left to right. The data type of an
argument must be equal to the type of the corresponding SDUDPHWHU (see 5.1) of the
function. An argument may be either UHTXLUHG, RSWLRQDO or FRQGLWLRQDO. Optional
arguments may be omitted but the order of the (present) arguments must be the same
as the order of the parameters. Two or more parameters may be declared to mutually
exclude each other, in which case at most one of them may be present in the argument
list. Conditional arguments are used to support smooth propagation of optional
arguments through chains of routine calls.
A required argument is separated from a preceding (if any) argument by ",". The
parameter name may be included, or left out.
An optional or conditional argument is preceded by ’\’ and the parameter name. The
specification of the parameter name is mandatory. Switch (See 5.1) type arguments are
somewhat special; they are used only to signal presence (of an argument). Switch
arguments do therefore not include any argument expression. Switch arguments may
be propagated using the conditional syntax.
32 5$3,'NHUQHO
([SUHVVLRQV
.. is interpreted as
The concept of conditional arguments thus eliminates the need for multiple "versions"
of routine calls when dealing with propagation of optional parameters.
More than one conditional argument may be used to match more than one alternative
of mutually excluding parameters (see 5.1). In that case at most one of them may be
"present" (may refer a present optional parameter).
The parameter list (see 5.1) of a function assigns each parameter an DFFHVVPRGH. The
access mode of a parameter puts restrictions on a corresponding argument and
specifies how RAPID transfers the argument. Please refer to 5 for the full description
on routine parameters, access modes and argument restrictions.
5$3,'NHUQHO 33
([SUHVVLRQV
2SHUDWRUV
The tables below view the available operators divided into 4 classes:
- Multiplying operators
- Adding operators
- Relational operators
- Logical operators
The tables specify the legal operand types and the result type of each operator. Note that
the relational operators = and <> are the only operators valid for arrays. The use of
operators in combination with operands of types not equal to (see 2.17) the types
specified below will cause a W\SH HUURU (see 1.4).
0XOWLSOLFDWLRQRSHUDWRUV
1) Preserves integer (exact) representation (see ) as long as operands and result are kept within the integer subdomain of the num type.
2) Must represent an integer (see ) value.
3) Must represent a positive (t 0) integer value.
$GGLWLRQRSHUDWRUV
1) The result receives the same data type as the operand. If the operand has an alias data type (see 2.15) the result receives the alias "base"
type (num or pos).
2) Preserves integer (exact) representation (see ) as long as operands and result are kept within the integer subdomain of the num type.
34 5$3,'NHUQHO
([SUHVVLRQV
5HODWLRQDORSHUDWRUV
Operator Operation Operand types Result type
< less than num < num bool
<= less than or equal to num <= num bool
= equal to anytype 1) = anytype 1) bool
>= greater than or equal to num >= num bool
> greater than num > num bool
<> not equal to anytype 1) <> anytype 1) bool
1) Only YDOXH and VHPLYDOXH data types (see 2.16). Operands must have equal types.
/RJLFDORSHUDWRUV
5$3,'NHUQHO 35
([SUHVVLRQV
36 5$3,'NHUQHO
6WDWHPHQWV
6WDWHPHQWV
The concept of using installed routines (and types) to support the specific needs of the
IRB application programmer has made it possible to limit the number of RAPID
statements to a minimum. The RAPID statements support general programming needs
and there are really no IRB specific RAPID statements. Statements may only occur
inside a routine definition.
<statement> ::=
<simple statement>
| <compound statement>
| <label>
| <comment>
| 607!
5$3,'NHUQHO 37
6WDWHPHQWV
6WDWHPHQWWHUPLQDWLRQ
Compound statements (except for the compact if statement) are terminated by
statement specific keywords. Simple statements are terminated by a semicolon (;).
Labels are terminated by a colon (:). Comments are terminated by a newline character
(see 2.10). Statement terminators are considered to be a part of the statement.
6WDWHPHQWOLVWV
A sequence of zero or more statements is called a VWDWHPHQWOLVW. The statements of a
statement list are executed in succession unless a goto, return, raise, exit, retry or
trynext statement, or the occurrence of an interrupt or error causes the execution to
continue at another point.
Both routines and compound statements contain statement lists. There are no specific
statement list separators. The beginning and end of a statement list is determined by the
context.
38 5$3,'NHUQHO
6WDWHPHQWV
/DEHOVWDWHPHQW
Labels are "no operation" statements used to define named program positions. The
goto statement (see 4.6) causes the execution to continue at the position of a label.
e.g. next:
..
*272 next;
$VVLJQPHQWVWDWHPHQW
The assignment statement is used to replace the current value of a variable, persistent
or parameter (assignment target) with the value defined by an expression. The
assignment target and the expression must have equal types. Note that the assignment
target must have value or semivalue data type (see 2.16). The assignment target can be
represented by the placeholder 9$5!.
5$3,'NHUQHO 39
6WDWHPHQWV
3URFHGXUHFDOO
A procedure call initiates the evaluation of a procedure. After the termination of the
procedure the evaluation continues with the subsequent statement. Procedures can be
either predefined or user defined. The placeholder $5*! may be used to represent
an undefined argument.
The procedure (name) may either be statically specified by using an identifier (HDUO\
ELQGLQJ) or evaluated during runtime from a (string type) expression (ODWHELQGLQJ).
Even though early binding should be considered to be the "normal" procedure call
form, late binding sometimes provides very efficient and compact code.
40 5$3,'NHUQHO
6WDWHPHQWV
Note that late binding is available for procedure calls only, not for function calls.
The general rules concerning the argument list of the procedure call are exactly the
same as those of the function call. Please refer to 3.10 and 5 for more details.
Normally the procedure reference is solved (bind) according to the normal scope
rules, but late binding provide a way to do a deviation from that rule.
The string expression in the statement %<expression>% is in the normal case a string
with the name of a procedure found according to the scope rules, but the string could
also have an enclosing description prefix that specify the location of the routine.
"name1:name2" specify the procedure "name2" inside the module "name1" (note that
the procedure "name2" could be declared local in that module). ":name2" specify the
global procedure "name2" in one of the task modules, this is very useful when a
downwards call must be done from the system level (installed built in object).
5$3,'NHUQHO 41
6WDWHPHQWV
*RWRVWDWHPHQW
The goto statement causes the execution to continue at the position of a label.
e.g. next:
i := i + 1;
..
*272 next;
5HWXUQVWDWHPHQW
The return statement terminates the execution of a routine and, if applicable, specifies
a return value. A routine may contain an arbitrary number of return statements. A return
statement can occur anywhere in the statement list or the error or backward handler of
the routine and at any level of a compound statement. The execution of a return
statement in the entry (see 9) routine of a task terminates the evaluation of the task. The
execution of a return statement in a trap (see 8.3) routine resumes execution at the point
of the interrupt.
The expression type must be equal to the type of the function. Return statements in
procedures and traps must not include the return expression.
42 5$3,'NHUQHO
6WDWHPHQWV
5DLVHVWDWHPHQW
The raise statement is used to explicitly raise or propagate an error.
A raise statement that includes an explicit error number raises an error with that
number. The error number (see 7) expression must represent an integer value (see ) in
the range from 1 to 90. A raise statement including an error number must not appear in
the error handler of a routine.
A raise statement with no error number may only occur in the error handler of a routine
and raises again (reraises) the same (current) error at the point of the call of the routine,
i.e. propagates the error. Since a trap routine can only be called by the system (as a
response to an interrupt), any propagation of an error from a trap routine is made to the
system error handler (see 7).
([LWVWDWHPHQW
The exit statement is used to immediately terminate the execution of a task.
Task termination using the exit statement, unlike returning from the entry routine of
the task, in addition prohibits any attempt from the system to automatically restart the
task.
5$3,'NHUQHO 43
6WDWHPHQWV
5HWU\VWDWHPHQW
The retry statement is used to resume execution after an error, starting with
(reexecuting) the statement that caused the error.
The retry statement can only appear in the error handler of a routine.
e.g. ...
! open logfile
open \append, logfile, "temp.log";
...
(5525
,) ERRNO = ERR_FILEACC 7+(1
! create missing file
create "temp.log";
! resume execution
5(75<;
(1',)
! propagate "unexpected" error
5$,6(;
(1')81&
7U\QH[WVWDWHPHQW
The trynext statement is used to resume execution after an error, starting with the
statement following the statement that caused the error.
The trynext statement can only appear in the error handler of a routine.
e.g. ...
! Remove the logfile
delete logfile;
...
(5525
,) ERRNO = ERR_FILEACC 7+(1
! Logfile already removed - Ignore
75<1(;7;
(1',)
! propagate "unexpected" error
5$,6(;
(1')81&
44 5$3,'NHUQHO
6WDWHPHQWV
&RQQHFWVWDWHPHQW
The connect statement allocates an interrupt number, assigns it to a variable or
parameter (connect target) and connects it to a trap routine. When (if) an interrupt with
that particular interrupt number later occurs the system responds to it by calling the
connected trap routine. The connect target can be represented by the placeholder
9$5!.
The connect target must have num (or alias for num) type and must be (or represent) a
module variable (not a routine variable). If a parameter is used as connect target it must
be a VAR or INOUT/VAR parameter - see 5.1). An allocated interrupt number cannot
be "disconnected" or connected with another trap routine. The same connect target may
not be associated with the same trap routine more than once. This means that the same
connect statement may not be executed more than once and that only one of two
identical connect statements (same connect target and same trap routine) may be
executed during a session. Note though, that more than one interrupt number may be
connected with the same trap routine.
,IVWDWHPHQW
The if statement evaluates one or none of a number of statement lists, depending on the
value of one or more conditional expressions.
5$3,'NHUQHO 45
6WDWHPHQWV
The conditional expressions are evaluated in succession until one of them evaluates to
true. The corresponding statement list is then executed. If none of them evaluates to
true the (optional) else clause is executed. The placeholder (,7! can be used to
represent an undefined elseif clause.
&RPSDFW,)VWDWHPHQW
In addition to the general, structured if-statement presented above (4.13), RAPID
provides an alternative, compact if statement. The compact if statement evaluates a
single, simple statement if a conditional expression evaluates to true.
)RUVWDWHPHQW
The for statement repeats the evaluation of a statement list while a loop variable is
incremented (or decremented) within a specified range. An optional step clause makes
it possible to select the increment (or decrement) value.
Initially thefrom, to and step expressions are evaluated and their values are kept. They
are evaluated only once. The loop variable is initiated with the from value. If no step
value is specified it defaults to 1 (or -1 if the range is descending).
46 5$3,'NHUQHO
6WDWHPHQWV
Before each new (not the first) loop, the loop variable is updated and the new value is
checked against the range. As soon as the value of the loop variable violates (is outside)
the range the execution continues with the subsequent statement.
The from, to and step expressions must all have num (numeric) type.
:KLOHVWDWHPHQW
The while statement repeats the evaluation of a statement list as long as the specified
conditional expression evaluates to true.
The conditional expression is evaluated and checked before each new loop. As soon as
it evaluates to false the execution continues with the subsequent statement.
7HVWVWDWHPHQW
The test statement evaluates one or none of a number of statement lists, depending on
the value of an expression.
Each statement list is preceded by a list of test values, specifying the values for which
that particular alternative is to be selected. The test expression can have any value or
semivalue data type (see 2.16). The type of a test value must be equal to the type of the
test expression. The execution of a test statement will choose one or no alternative. In
case more than one test value fits the test expression only the first is recognized. The
placeholder &6(! can be used to represent an undefined case clause.
5$3,'NHUQHO 47
6WDWHPHQWV
The optional default clause is evaluated if no case clause fits the expression.
48 5$3,'NHUQHO
5RXWLQHGHFODUDWLRQV
5RXWLQHGHFODUDWLRQV
A routine is a named carrier of executable code. A XVHU routine is defined by an RAPID
routine declaration A SUHGHILQHG routine is supplied by the system and is always
available. There are three types of routines - SURFHGXUHV, IXQFWLRQV and WUDSV. A
function returns a value of a specific type and is used in expression context (see 3.10).
A procedure does not return any value and is used in statement context (see 4.5). Trap
routines provide a means to respond to interrupts (see 8). A trap routine can be
associated with a specific interrupt (using the connect statement - see 4.12) and is then
later automatically executed if that particular interrupt occurs. A trap routine can never
be explicitly called from RAPID code. A routine declaration can be represented by the
placeholder 5'1!.
- Name
- Data Type (only valid for functions)
- Parameters (not for traps)
- Data Declarations and Statements (body)
- Backward Handler (only valid for procedures)
- Error Handler
- Undo Handler
Routine declarations may only occur in the last section of a module (see 9). Routine
declarations cannot be nested, i.e. it is not possible to declare a routine inside a routine
declaration.
5$3,'NHUQHO 49
5RXWLQHGHFODUDWLRQV
3DUDPHWHUGHFODUDWLRQV
The parameter list of a routine declaration specifies the arguments (actual parameters)
that must/can be supplied when the routine is called. Parameters are either UHTXLUHG or
RSWLRQDO. An optional parameter may be omitted from the argument list of a routine call
(see 2.20). Two or more optional parameters may be declared to mutually exclude each
other, in which case at most one of them may be present in a routine call. An optional
parameter is said to be SUHVHQW if the routine call supplies a corresponding argument,
QRWSUHVHQW otherwise. The value of a not present, optional parameter may not be set or
used. The predefined function Present can be used to test the presence of an optional
parameter. The placeholders 3$5!, $/7!, ',0! can be used to represent
undefined parts of a parameter list.
The data type of an argument must be equal to the data type of the corresponding
parameter.
Each parameter has an DFFHVVPRGH Available access modes are LQ (default), YDU, SHUV,
LQRXW and UHI 1)The access mode specifies how RAPID transfers a corresponding
argument to a parameter:
1. RAPID routines cannot have UHI parameters, only predefined routines can.
50 5$3,'NHUQHO
5RXWLQHGHFODUDWLRQV
pers X --- X X X
inout:
var X X --- 2 X X
pers X --- X X X
b
The built-in routines ’IsPers’ and ’IsVar’ can be used to test if an LQRXW parameter is an
alias for a variable or persistent argument.
The special type ’switch’ may (only) be assigned to optional parameters and provides
a means to use "switch arguments", i.e. arguments given only by their names (no
values). The domain of the switch type is empty and no value can be transferred to a
switch parameter. The only way to use a switch parameter is to check its presence using
the predefined function Present, or to pass it as an argument in a routine call.
5$3,'NHUQHO 51
5RXWLQHGHFODUDWLRQV
Arrays may be passed as arguments. The degree of an array argument must comply
with the degree of the corresponding parameter. The dimension of an array parameter
is "conformant" (marked by ’*’). The actual dimension is later bound by the dimension
of the corresponding argument of a routine call. A routine can determine the actual
dimension of a parameter using the predefined function ’Dim’.
6FRSHUXOHV
The VFRSH of an object denotes the area in which the name is YLVLEOH.
- The scope of a local user routine comprises the module in which it is contained.
- The scope of a global user routine in addition comprises any other module in
the task buffer.
- Within its scope a user routine hides any predefined object with the same name.
- Within its scope a local user routine hides any global module object with the
same name.
- Two module objects declared in the same module may not have the same name.
- Two global objects declared in two different modules in the task buffer may not
have the same name.
- A global user routine and a module may not share the same name.
The scope rules concerning parameters comply with the scope rules concerning routine
variables. Refer to 2.20 for information on routine variable scope.
3URFHGXUHGHFODUDWLRQV
A procedure declaration binds an identifier to a procedure definition.
52 5$3,'NHUQHO
5RXWLQHGHFODUDWLRQV
Note that a data declaration list can include comments (see 2.10).
Procedures which are going to be used in late binding calls are treated as a special case.
I.e. the parameters for the procedures, which are called from the same late binding
statement, should be matching as regards optional/required parameters and mode, and
should also be of the same basic type. E.g. if the second parameter of one procedure is
required and declared as 9$5 num then the second parameter of other procedures,
which are called by the same late binding statement, should have a second parameter
which is a required 9$5 with basic type num. The procedures should also have the
same number of parameters. If there are mutually exclusive optional parameters, they
also have to be matching in the same sense.
)XQFWLRQGHFODUDWLRQV
A function declaration binds an identifier to a function definition.
Functions can have (return) any value data type (including any available installed
type). A function cannot be dimensioned, i.e. a function cannot return an array value.
5$3,'NHUQHO 53
5RXWLQHGHFODUDWLRQV
7UDSGHFODUDWLRQV
A trap declaration binds an identifier to a trap definition. A trap routine can be
associated with an interrupt (number) by using the connect statement (see 4.12). Note
that one trap routine may be associated with many (or no) interrupts.
The evaluation of the trap routine is explicitly terminated using the return statement
(see 4.7) or implicitly terminated by reaching the end (endtrap, error or undo) of the
trap routine. The execution continues at the point of the interrupt.
54 5$3,'NHUQHO
%DFNZDUGH[HFXWLRQ
%DFNZDUGH[HFXWLRQ
RAPID supports stepwise, backward execution of statements. Backward execution is
very useful for debugging, test and adjustment purposes during RAPID program
development. RAPID procedures may contain a backward handler (statement list) that
defines the backward execution "behaviour" of the procedure (call).
%DFNZDUGKDQGOHUV
Procedures may contain a backward handler that defines the backward execution of a
procedure call.
The backward handler is really a part of the procedure and the scope of any routine data
also comprises the backward handler of the procedure.
5$3,'NHUQHO 55
%DFNZDUGH[HFXWLRQ
When the procedure is called during forward execution, the following occurs:
PROC MoveTo ()
.. MoveL p1,v500,z10,tool1;
MoveTo; MoveC p2,p3,v500,z10,tool1;
.. MoveL p4,v500,z10,tool1;
BACKWARD
MoveL p4,v500,z10,tool1;
MoveC p2,p3,v500,z10,tool1;
MoveL p1,v500,z10,tool1;
ENDPROC
When the procedure is called during backwards execution, the following occurs:
PROC MoveTo ()
.. MoveL p1,v500,z10,tool1;
MoveTo; MoveC p2,p3,v500,z10,tool1;
.. MoveL p4,v500,z10,tool1;
BACKWARD
MoveL p4,v500,z10,tool1;
MoveC p2,p3,v500,z10,tool1;
MoveL p1,v500,z10,tool1;
ENDPROC
Instructions in the backward or error handler of a routine may not be executed
backwards. Backward execution cannot be nested, i.e. two instructions in a call chain
may not simultaneously be executed backwards.
/LPLWDWLRQRIPRYHLQVWUXFWLRQVLQWKHEDFNZDUGKDQGOHU
The move instruction type and sequence in the backward handler must be a mirror of
the move instruction type and sequence for forward execution in the same routine:
56 5$3,'NHUQHO
%DFNZDUGH[HFXWLRQ
PROC MoveTo ()
MoveL p1,v500,z10,tool1;
MoveC p2,p3,v500,z10,tool1; Mirror plane
MoveL p4,v500,z10,tool1;
BACKWARD
MoveL p4,v500,z10,tool1;
MoveC p2,p3,v500,z10,tool1;
MoveL p1,v500,z10,tool1;
ENDPROC
Note that the order of CirPoint S and ToPoint S in the MoveC should be the same.
By move instructions is meant all instructions that result in some movement of the
robot or external axes such as MoveL, SearchC, TriggJ, ArcC, PaintL ...
$Q\GHSDUWXUHVIURPWKLVSURJUDPPLQJOLPLWDWLRQLQWKHEDFNZDUGKDQGOHUFDQ
UHVXOWLQIDXOW\EDFNZDUGPRYHPHQW/LQHDUPRYHPHQWFDQUHVXOWLQFLUFXODU
PRYHPHQWDQGYLFHYHUVDIRUVRPHSDUWRIWKHEDFNZDUGSDWK
5$3,'NHUQHO 57
%DFNZDUGH[HFXWLRQ
58 5$3,'NHUQHO
(UURUUHFRYHU\
(UURUUHFRYHU\
An execution error (see 1.4) is an abnormal situation, related to the execution of a
specific piece of RAPID program code. An error makes further execution impossible
(or at least hazardous). "Overflow" and "division by zero" are examples of errors.
Errors are identified by their unique HUURUQXPEHU and are always recognized by the
system. The occurrence of an error causes suspension of the normal program execution
and the control is passed to an HUURUKDQGOHU. The concept of error handlers makes it
possible to respond to, and possibly recover from errors that arise during program
execution. If further execution is not possible, at least the error handler can assure that
the task is given a graceful abortion.
(UURUKDQGOHUV
Any routine may include an error handler. The error handler is really a part of the
routine and the scope of any routine data object (variable, constant, parameter) also
comprises the error handler of the routine. If an error occurs during the evaluation of
the routine the control is transferred to the error handler.
The predefined (readonly) variable (5512 contains the error number of the (most
recent) error and can be used by the error handler to identify the error. After necessary
actions have been taken the error handler can:
- Resume execution starting with the statement in which the error occurred. This
is made using the 5(75< statement (see 4.10).
- Resume execution starting with the statement after the statement in which the
error occurred. This is made using the 75<1(;7 statement (see 4.11).
- Return control to the caller of the routine by using the 5(7851 statement (see
4.7). If the routine is a function the 5(7851 statement must specify an
appropriate return value.
- Propagate the error to the caller of the routine by using the 5$,6( statement
(see 4.8) - "Since I‘m not familiar with this error it’s up to my caller to deal with
it".
If an error occurs in a routine that does not contain an error handler or reaching the end
of the error handler ((1')81&(1'352& or (1'75$3), the V\VWHPHUURU
KDQGOHU is called. The system error handler just reports the error and stops the
execution.
5$3,'NHUQHO 59
(UURUUHFRYHU\
In a chain of routine calls, each routine may have its own error handler. If an error
occurs in a routine with an error handler, and the error is explicitly propagated using
the 5$,6( statement, the same error is raised again at the point of the call of the routine
- the error is SURSDJDWHG. If the top of the call chain (the entry routine of the task) is
reached without any error handler found or if reaching the end of any error handler
within the call chain, the system error handler is called. The system error handler just
reports the error and stops the execution. Since a trap routine can only be called by the
system (as a response to an interrupt), any propagation of an error from a trap routine
is made to the system error handler.
In addition to errors detected and raised by the system, a program can explicitly raise
errors using the 5$,6( statement (see 4.8). The facility can be used to recover from
complex situations. For example it can be used to escape from deeply nested code
positions. Error numbers in the range from 1 to 90 may be used.
Note that it is not possible to recover from or respond to errors that occur ZLWKLQ an error
handler or backward handler. Such errors are always propagated to the system error
handler.
(UURUUHFRYHU\ZLWKORQJMXPS
Error recovery with long jump may be used to bypass the normal routine call and return
mechanism to handle abnormal or exceptional conditions. To accomplish this, a
specific error recovery point must be specified. By using the 5$,6( instruction the long
jump will be performed and the execution control is passed to that error recovery point.
Error recovery with long jump is typically used to pass execution control from a deeply
nested code position, regardless of execution level, as quickly and simple as possible
to a higher level.
60 5$3,'NHUQHO
(UURUUHFRYHU\
([HFXWLRQOHYHOV
An execution level is a specific context that the RAPID program is running in.
There are three execution levels in the system, Normal, Trap, and User:
- Normal level: All program are started at this level. This is the lowest level.
- Trap level: Trap routines are executed at this level. This level overrides the
Normal level but can be overridden by the User level.
- User level: Event routines and Service routines are executed at this level. This
level overrides Normal and Trap level. This level is the highest one and cannot
be overridden by any other level.
(UURUUHFRYHU\SRLQW
The essential thing for error recovery with long jump is the characteristic error
recovery point.
The error recovery point is a normal (5525 clause but with an extended syntax, a list
of error numbers enclosed by a pair of parentheses, see example below:
Example:
MODULE example1
PROC main()
! Do something important
myRoutine;
ERROR (55B',9=(52
RETRY;
ENDPROC
ENDMODULE
6\QWD[
5$3,'NHUQHO 61
(UURUUHFRYHU\
8VLQJHUURUUHFRYHU\ZLWKORQJMXPS
02'8/( example2
352& main()
routine1;
! Error recovery point
(5525 (56)
5(75<;
(1'352&
352& routine1()
routine2;
(1'352&
352& routine2()
5$,6( 56;
(5525
! This will propagate the error 56 to main
5$,6(;
(1'352&
(1'02'8/(
- The raised error number is search, starting at calling routine’s error handler and
to the top of the current call chain. If there is an error recovery point with the
raise error number, at any routine in the chain, the program execution continues
in that routine’s error handler.
- If no error recovery point is found in the current execution level the searching
is continued in the previous execution level until the NORMAL level is
reached.
- If no error recovery point is found in any execution level the error will be raised
and handled in the calling routine’s error handler, if any.
(UURUUHFRYHU\WKURXJKH[HFXWLRQOHYHOERXQGDULHV
It is possible to pass the execution control through the execution level boundaries by
using long jump, i.e. the program execution can jump from a TRAP, USER routine to
the Main routine regardless how deep the call chains are in the TRAP, USER, and
NORMAL level.
This is useful way to handle abnormal situation that requires the program to continue
or start over from good and safely defined position in the program.
When a long jump is done from one execution level to another level there can be an
active instructions at that level. Since the long jump is done from one error handler to
another, the active instruction will be undone by the system (e.g. an active MoveX
instruction will clear its part of the path).
62 5$3,'NHUQHO
(UURUUHFRYHU\
5HPDUNV
• Do not assume that the execution mode (cont, cycle, or forward step) is the same at
the error recovery point as it was where the error occurred. The execution mode is not
inherited at long jump.
• Be careful when using 6WRUH3DWK. Always call 5HVWR3DWK before doing a long jump,
otherwise the results are unpredictable.
• The numbers of retries are not set to zero at the error recovery point after a long jump.
• Be careful when using TRYNEXT at the error recovery point, the result can be
unpredictable if the error occurs in a function call as in the example below:
Example:
02'8/( Example3
352& main
:+,/( myFunction() = TRUE '2
myRoutine;
(1':+,/(
(;,7;
(5525 (LONG_JMP_ALL_ERR)
75<1(;7;
(1'352&
(1'02'8/(
If the error occurs in the function myFunction and the error is caught in the main
routine, the instruction TRYNEXT will pass the execution control to the next
instruction, in this case EXIT. This is because the WHILE instruction considers to be
the one that fails
81'2KDQGOHU
When using long jump, one or several procedures may be dropped without executing
the end of the routine or the error handler. If no undo handler is used these routine may
leave loose ends. In the example below, URXWLQH would leave the file log open if the
long jump was used and there was no undo handler in URXWLQH.
To make sure that each routine cleans up after itself, use an undo handler in any routine
that may not finish the execution due to a long jump.
Example:
02'8/( example4
352& main()
routine1;
! Error recovery point
(5525 (56)
5(75<;
(1'352&
5$3,'NHUQHO 63
(UURUUHFRYHU\
352& routine1()
9$5 iodev log;
Open "HOME:" \File:= "FILE1.DOC", log;
routine2;
Write log, "routine1 ends with normal execution";
Close log;
(5525
! Another error handler
81'2
Close log;
(1'352&
352& routine2()
5$,6( 56;
(5525
! This will propagate the error 56 to main
5$,6(;
(1'352&
(1'02'8/(
1RVWHSLQURXWLQHV
The nostepin routines in a nostepin module can call each other in call chains. Using the
5$,6( instruction in the error handler of one of the routines in the call chain will
propagate the error one step up in the call chain. In order to raise the error to the user
level (outside the nostepin module) with the 5$,6( instruction, every routine in the call
chain must have an error handler that raise the error.
By using the 5DLVH7R8VHU instruction, the error can be propagated several steps up in
the call chain. The error will then be handled by the error handler in the last routine in
the call chain that is not a nostepin routine.
64 5$3,'NHUQHO
(UURUUHFRYHU\
If 5DLVH7R8VHU is called with the argument?&RQWLQXH, the instruction (in the nostepin
routine) that caused the error will be remembered. If the error handler that handles the
error ends with 5(75< or 75<1(;7, the execution will continue from where the error
occured.
NOSTEPIN module
1. PROC routine2()
... 2.
routine3;PROC routine3()
...
UNDO ERROR
... ...
ENDPROC RaiseToUser \Continue;
ENDPROC
4.
3.
1. routine2 is called
2. routine3 is called
1RWH One or several routines may be dropped without executing the end of the routine
or the error handler. In the example this would have been the case for URXWLQH if
5DLVH7R8VHU had used the argument ?%UHDN2IIinstead of ?&RQWLQXH. To make sure such
a routine does not leave any loose ends (such as open files) make sure there is an undo
handler that cleans up (e.g. close files).
1RWH If the routine that calls the nostepin routine (URXWLQH in the example) is made to
a nostepin routine, the error will no longer be handled by its error handler. Changing a
routine to a nostepin routine can require the error handler to be moved to the user layer.
$V\QFKURQRXVO\UDLVHGHUURUV
$ERXWDV\QFKURQRXVO\UDLVHGHUURUV
If a move instruction ends in a corner zone, the next move instruction must be executed
before the first move instruction has finishedits path. Otherwise the robot would not
know how to move in the corner zone. If each move instruction only move a short
distance with large corner zones, several move instructions may have to be executed
ahead.
An error may occur if something goes wrong during the robot movement. However, if
the program execution has continued, it is not obvious which move instruction the
robot is carrying out when the error occur. The handling of asynchronously raised
errors solve this problem.
5$3,'NHUQHO 65
(UURUUHFRYHU\
The basic idea is that an asynchronously raised error is connected to a move instruction
and is handled by the error handler in the routine that called that instruction.
7ZRW\SHVRIDV\QFKURQRXVO\UDLVHGHUURUV
There are two ways of creating asynchronously raised errors, resulting in slightly
different behavior:
If an error occurs during the first path but when the program is calculating the second
path (see illustration below), the behavior depends on the argument of
3URFHUU5HFRYHU\. If the error is created with ?6\QF2UJ0RYH,QVW, it is connected to the
first move instruction (the instruction that created the first path). If the error is created
with ?6\QF/DVW0RYH,QVW, it is connected to the second move instruction (the instruction
that created the second path).
F irs t path
Corner zone
p0 p1
S econd
path
Part of firs t path when the
program is executing the
s econd move ins truction.
p2
$WWHPSWWRKDQGOHHUURUVLQWKHURXWLQHWKDWFDOOHGWKHPRYHLQVWUXFWLRQ
If you create a routine with error handling to take care of process errors that may occur
during robot movement, you want these errors to be handled in this routine. If the error
is raised when the program pointer is in a subroutine, you do not want the error handler
of that subroutine to handle the error.
Asynchronously raised errors are connected to the path that the robot is currently
performing. An asynchronously raised error can be handled by the error handler in the
routine whose move instruction created the path the robot is carrying out when the error
occurs.
66 5$3,'NHUQHO
(UURUUHFRYHU\
In the example shown below, a process error occurs before the robot has reached p1,
but the program pointer has already continued to the subroutine ZULWHBORJ.
PROC my_process()
...
MoveL p1, v300, z10, tool1;
write_log; PROC write_log()
MoveL p2, v300,...
z10, tool1;
... ERROR
ERROR ...
... ENDPROC
ENDPROC
If there was no handling of asynchronously raised errors, an error that was raised when
the program pointer was in ZULWHBORJwould be handled by the error handler in
ZULWHBORJ. The handling of asynchronously raised errors will make sure that the error
is handled by the error handler in P\BSURFHVV.
1RWH If a subroutine (ZULWHBORJ in the example) were to have move instructions and
?6\QF/DVW0RYH,QVW is used, the error might be handled by the error handler in the
subroutine.
If the error handler in P\BSURFHVV ends with (;,7, all program execution is stopped.
If the error handler in P\BSURFHVV ends with 5$,6(, the error is handled by the error
handler in PDLQ. The routine calls to P\BSURFHVV and ZULWHBORJ are dropped. If the error
handler in PDLQ ends with 5(75<, the execution of P\BSURFHVV starts over.
1RWH In this case TRYNEXT works the same way as RETRY because the system can
be restarted from where the error occurred.
5$3,'NHUQHO 67
(UURUUHFRYHU\
:KDWKDSSHQVZKHQDURXWLQHFDOOLVGURSSHG"
When the execution reach the end of a routine, that routine call is dropped. The error
handler of that routine call cannot be called if the routine call has been dropped. In the
example below, the robot movement will continue after the first P\BSURFHVV routine
call has been dropped (since the last move instruction has a corner zone).
PROC my_process()
...
MoveL p1, v300, z10, tool1;
MoveL p2, v300, z10, tool1;
ERROR
...
ENDPROC
If the program pointer is in PDLQ when an error originating from the first P\BSURFHVV
occurs, it cannot be handled by the error handler in the P\BSURFHVV routine call. Where
this error is handled will then depend on how the asynchronous error is created:
7LS: To make sure asynchronously raised errors are handled in a routine, make sure the
last move instruction ends with a stop point (not corner zone) and does not use ?&RQF.
&RGHH[DPSOH
In this example, asynchronously raised errors can be created in the routine P\BSURFHVV.
The error handler in P\BSURFHVV is made to handle these errors.
A process flow is started by setting the signal GRBP\SURF to 1. The signal GLBSURFBVXS
supervise the process, and an asynchronous error is raised if GLBSURFBVXSbecomes 1.
In this simple example, the error is resolved by setting GRBP\SURFto 1 again before
resuming the movement.
02'8/( user_module
9$5 intnum proc_sup_int;
9$5 iodev logfile;
352& main()
...
my_process;
my_process;
...
68 5$3,'NHUQHO
(UURUUHFRYHU\
(5525
...
(1'352&
352& my_process()
my_proc_on;
MoveL p1, v300, z10, tool1;
write_log;
MoveL p2, v300, z10, tool1;
my_proc_off;
(5525
,) ERRNO = ERR_PATH_STOP 7+(1
my_proc_on;
StartMove;
5(75<;
(1',)
(1'352&
352& write_log()
Open “HOME:” \File:= “log.txt”, logfile \Append;
Write logfile “my_process executing”;
Close logfile;
(5525
,) ERRNO = ERR_FILEOPEN 7+(1
75<1(;7;
(1',)
81'2
Close logfile;
(1'352&
75$3 iprocfail
my_proc_off;
ProcerrRecovery \SyncLastMoveInst;
5(7851;
(1'75$3
352& my_proc_on()
SetDO do_myproc, 1;
&211(&7 proc_sup_int :,7+ iprocfail;
ISignalDI di_proc_sup, 1, proc_sup_int;
(1'352&
352& my_proc_off()
SetDO do_myproc, 0;
IDelete proc_sup_int;
(1'352&
(1'02'8/(
5$3,'NHUQHO 69
(UURUUHFRYHU\
(UURUZKHQ33LVLQZULWHBORJ
What will happen if a process error occurs when the robot is on its way to p1, but the
program pointer is already in the subroutine ZULWHBORJ?
The error is raised in the routine that called the move instruction, i.e. P\BSURFHVV, and
is handled by its error handler.
If 3URFHUU5HFRYHU\had used the switch ?6\QF2UJ0RYH,QVW, the error would have been
raised in P\BSURFHVV instantly.
(UURUZKHQH[HFXWLRQRIP\BSURFHVVKDVILQLVKHG
What will happen if a process error occurs when the robot is on its way to p2, but the
program pointer has already left the routine P\BSURFHVV?
The routine call that caused the error (the first P\BSURFHVV) has been dropped and its
error handler cannot handle the error. Where this error is raised depends on which
switch is used when calling 3URFHUU5HFRYHU\.
If 3URFHUU5HFRYHU\had used the switch ?6\QF2UJ0RYH,QVW, the error would have been
raised in PDLQ. The way ?6\QF2UJ0RYH,QVW works is that if the routine call that caused
the error (P\BSURFHVV) has been dropped, the routine that called that routine (PDLQ) will
raise the error.
1RWH If there had been a move instruction between the P\BSURFHVV calls in PDLQ, and
?6\QF/DVW0RYH,QVWwas used, the error would be handled by the error handler in PDLQ.
If another routine with move instructions had been called between the P\BSURFHVV
calls, the error would have been handled in that routine. This shows that when using
?6\QF/DVW0RYH,QVWyou must have some control over which is the next move
instruction.
1RVWHSLQPRYHLQVWUXFWLRQVDQGDV\QFKURQRXVO\UDLVHGHUURUV
70 5$3,'NHUQHO
(UURUUHFRYHU\
This requires that the user only use this type of move instruction during the entire
movement sequence. The movement sequence must begin and end in stop points. Only
if two instructions have identical error handlers can they be used in the same movement
sequence. This means that one linear move instruction and one circular, using the same
process and the same error handler, can be used in the same movement sequence.
If an error should be raised to the user, use RaiseToUser \Continue. After the error has
been resolved, the execution can then continue from where the error occured.
81'2KDQGOHU
The execution of a routine can be abruptly ended without running the error handler in
that routine. This means that the routine will not clean up after itself.
In the example below, we assume that an asynchronously raised error occurs while the
robot is on its way to p1 but the program pointer is at the :ULWH instruction in ZULWHBORJ.
If there was no undo handler, the file ORJILOH would not be closed.
PROC my_process()
MoveL p1, v300, z10, tool1;
write_log; PROC write_log()
MoveL p2, v300,Open
z10,.. logfile ..;
tool1;
ERROR Write logfile ..;
... Close logfile;
ENDPROC ERROR
...
UNDO
Close logfile;
ENDPROC
This problem can be solved by using undo handlers in all routines that can be
interrupted by an asynchronously raised error. It is in the nature of asynchronously
raised errors that it is difficult to know where the program pointer will be when they
occur. Therefore, when using asynchronously raised errors, use undo handlers
whenever clean up may be necessary.
6NLS:DUQ
An error that is handled in an error handler still generates a warning in the event log.
If, for some reason, you do not want any warning to be written to the event log, the
instruction 6NLS:DUQ can be used.
([DPSOH
In the following example code, a routine tries to write to a file that other robot systems
also have access to. If the file is busy, the routine waits 0.1 seconds and tries again. If
6NLS:DUQ was not used, the log file would write a warning for every attempt, even
though these warnings are totally unnecessary. By adding the 6NLS:DUQ instruction, the
operator may not notice that the file was busy at the first attempt.
Note that the maximum number of retries is determined by the parameter 1R2I5HWU\.
To make more than 4 retries, you must configure this parameter.
5$3,'NHUQHO 71
(UURUUHFRYHU\
352& routine1()
9$5 iodev report;
Open "HOME:" \File:= "FILE1.DOC", report;
Write report, "No parts from Rob1="\Num:=reg1;
Close report;
(5525
,) ERRNO = ERR_FILEOPEN 7+(1
WaitTime 0.1;
SkipWarn;
5(75<;
(1',)
(1'352&
72 5$3,'NHUQHO
,QWHUUXSWV
,QWHUUXSWV
Interrupts are program defined events identified by LQWHUUXSWQXPEHUV. An interrupt
occurs as a consequence of an LQWHUUXSWFRQGLWLRQ turning true. Unlike errors, the
occurrence of an interrupt is not directly related to (synchronous with) a specific code
position. The occurrence of an interrupt causes suspension of the normal program
execution and the control is passed to aWUDSURXWLQH. Interrupt numbers are allocated
and connected (associated) with a trap routine using the connect statement (see 4.12).
Interrupt conditions are defined and manipulated using predefined routines. A task
may define an arbitrary number of interrupts.
,QWHUUXSWUHFRJQLWLRQDQGUHVSRQVH
Even though the system recognizes the occurrence of an interrupt immediately, the
response in the form of calling the corresponding trap routine can only take place at
specific program positions, namely:
- at the entry of next (after interrupt recognition) statement (of any type).
- after the last statement of a statement list.
- any time during the execution of a waiting routine (e.g. WaitTime).
This means that, after the recognition of an interrupt, the normal program execution
always continues until one of these positions are reached. This normally results in a
delay of 5-120 ms between interrupt recognition and response, depending on what type
of movement is being performed at the time of the interrupt.
,QWHUUXSWPDQLSXODWLRQ
Interrupt numbers are used to identify interrupts/interrupt conditions. Interrupt
numbers are not just "any" numbers. They are "owned" by the system and must be
allocated and connected with a trap routine using the connect statement (see 4.12)
before they may be used to identify interrupts.
Interrupts are defined and manipulated using predefined routines. The GHILQLWLRQ of an
interrupt specifies an interrupt condition and associates it with an interrupt number.
5$3,'NHUQHO 73
,QWHUUXSWV
The GHOHWLRQ of an interrupt deallocates the interrupt number and removes the interrupt
condition. It is not necessary to explicitly delete interrupts. Interrupts are automatically
deleted when the evaluation of a task is terminated.
The raising of interrupts may be GLVDEOHG and HQDEOHG. If interrupts are disabled any
interrupt that occurs is queued and raised first when interrupts are enabled again. Note
that the interrupt queue may contain more than one waiting interrupt. Queued interrupts
are raised in ILIR order. Interrupts are always disabled during the evaluation of a trap
routine (see 8.3 below).
! disable interrupts
IDisable;
7UDSURXWLQHV
Trap routines provide a means to respond to interrupts. A trap routine is connected with
a particular interrupt number using the connect statement (see 4.12). If an interrupt
occurs, the control is immediately (see 8.1) transferred to it’s connected trap routine.
352& main()
...
! Connect feeder interrupts
&211(&7 empty :,7+ ftrap;
&211(&7 full :,7+ ftrap;
! define feeder interrupts
ISignalDI sig1, high, empty;
ISignalDI sig3, high, full;
...
(1'352&
74 5$3,'NHUQHO
,QWHUUXSWV
75$3 ftrap
7(67 INTNO
&$6( empty:
open_valve
&$6( full:
close_valve;
(1'7(67
5(7851;
(1'75$3
More than one interrupt may be connected with the same trap routine. The predefined
(readonly) variable ,1712 contains the interrupt number and can be used by a trap
routine to identify the interrupt. After necessary actions have been taken a trap routine
can be terminated using the return statement (see 4.7) or by reaching the end (endtrap
or error) of the trap routine. The execution continues at the point of the interrupt. Note
that interrupts are always disabled (see 8.2) during the evaluation of a trap routine.
Since a trap routine can only be called by the system (as a response to an interrupt),
any propagation of an error from a trap routine is made to the system error handler (see
7).
5$3,'NHUQHO 75
,QWHUUXSWV
76 5$3,'NHUQHO
7DVNPRGXOHV
7DVNPRGXOHV
An RAPID application is called a WDVN. A task is composed ofa set of PRGXOHV. A
module contains a set of type definitions, data and routine declarations. The WDVN EXIIHU
is used to host modules currently in use (execution, development) on a system. RAPID
program code in the task buffer may be loaded/stored from/to file oriented external
devices (normally disk files) either as separate modules or as a group of modules - a
7DVN.
While small applications usually are contained in a single task module (besides the
system module/s), larger applications may have a "main" task module that in turn
references routines and/or data contained in one or more other, "library" task modules.
Task Buffer
Disk (ram, hard, floppy)
System Modules
system module
system module
system module
system module
task load/store
"Library" module
"Library" module
"Library" module
"Library" module
A "library" module may for example define the interface of a physical or logical object
(gripper, feeder, counter etc.) or contain geometry data generated from a CAD-system
or created on-line by digitizing (teach in).
One task module contains the HQWU\procedure of the task. 5XQQLQJ the task really
means that the entry routine is executed. Entry routines must be parameterless.
5$3,'NHUQHO 77
7DVNPRGXOHV
0RGXOHGHFODUDWLRQV
A module declaration specifies the name, DWWULEXWHV and body of a module. A module
name hides any predefined object with the same name. Two different modules may not
share the same name. A module and a global module object (type, data object or
routine) may not share the same name. Module attributes provide a means to modify
some aspects of the systems treatment of a module when it is loaded to the task buffer.
The body of a module declaration contains a sequence of data declarations followed by
a sequence of routine declarations.
An attribute may not be specified more than once. If present, attributes must be
specified in table order (see above). The specification of QRYLHZexcludes QRVWHSLQ,
YLHZRQO\ and UHDGRQO\ (and vice versa)The specification of YLHZRQO\ excludes
UHDGRQO\ (and vice versa).
78 5$3,'NHUQHO
7DVNPRGXOHV
02'8/( weldlib
/2&$/9$5 welddata w1 := sysw1;
! weldlib init procedure
352& initweld()
! override speed
w1.speed := 100;
(1'352&
352& arcweld(pose position \ num speed | num time)
...
(1'352&
(1'02'8/(
5$3,'NHUQHO 79
7DVNPRGXOHV
6\VWHPPRGXOHV
System modules are used to (pre)define system specific data objects (tools, weld data,
move data ..), interfaces (printer, logfile ..) etc. Normally, system modules are
automatically loaded to the task buffer during system start-up.
80 5$3,'NHUQHO
6\QWD[VXPPDU\
6\QWD[VXPPDU\
Each rule or group of rules are prefixed by a reference to the section where the rule is
introduced.
<digit> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
<letter> ::=
<upper case letter>
| <lower case letters>
5$3,'NHUQHO 81
6\QWD[VXPPDU\
82 5$3,'NHUQHO
6\QWD[VXPPDU\
3: <expression> ::=
<expr>
| (;3!
<primary> ::=
<literal>
| <variable>
| <persistent>
| <constant>
| <parameter>
| <function call>
| <aggregate>
| ’(’ <expr> ’)’
5$3,'NHUQHO 83
6\QWD[VXPPDU\
84 5$3,'NHUQHO
6\QWD[VXPPDU\
4: <statement> ::=
<simple statement>
| <compound statement>
| <label>
| <comment>
| 607!
5$3,'NHUQHO 85
6\QWD[VXPPDU\
<procedure> ::=
<identifier>
| ’%’ <expression> ’%’
86 5$3,'NHUQHO
6\QWD[VXPPDU\
5$3,'NHUQHO 87
6\QWD[VXPPDU\
88 5$3,'NHUQHO
6\QWD[VXPPDU\
5$3,'NHUQHO 89
6\QWD[VXPPDU\
90 5$3,'NHUQHO
%XLOWLQURXWLQHV
%XLOWLQURXWLQHV
Dim
The dim function is used to get the size of an array (datobj). It returns the number of array
elements of the specified dimension.
Present
The present function is used to test if the argument (datobj) is present (see 5.1). It returns
)$/6( if datobj is a not present optional parameter, 758( otherwise.
Break
The break (breakpoint) procedure causes a temporary stop of program execution. Break is
used for RAPID program code debugging purposes.
352& Break ()
IWatch
The iwatch procedure activates the specified interrupt (ino). The interrupt can later be deac-
tivated again using the isleep procedure.
ISleep
The isleep procedure deactivates the specified interrupt (ino). The interrupt can later be ac-
tivated again using the iwatch procedure.
IsPers
The ispers function is used to test if a data object (datobj) is (or is an alias for) a persistent
(see 5.1). It returns 758( in that case, )$/6( otherwise.
IsVar
1. Refer to 3.10 for more information on the UHI access mode. Note that RAPID routines cannot have REF parameters.
2. The argument can have any data type. Note that DQ\W\SH is just a marker for this property and should not be confused with a “real”
data type. Also note that RAPID routines cannot be given DQ\W\SH parameters.
5$3,'NHUQHO 91
%XLOWLQURXWLQHV
The isvar function is used to test if a data object (datobj) is (or is an alias for) a variable (see
5.1). It returns 758( in that case, )$/6( otherwise.
1. The argument can have any data type. Note that DQ\W\SH is just a marker for this property and should not be confused with a “real” data
type. Also note that RAPID routines cannot be given DQ\W\SH parameters.
92 5$3,'NHUQHO
%XLOWLQGDWDREMHFWV
%XLOWLQGDWDREMHFWV
7DEOH
Object Name Object Kind Data Type Description
ERR_CALLPROC constant errnum "procedure call error (syntax, not procedure) at run time
(late binding)"
ERR_REFUNKPRC constant errnum "reference to unknown procedure at linking time or at run time
(late binding)"
*) Read only - can only be updated by the system - not by a RAPID program.
5$3,'NHUQHO 93
%XLOWLQGDWDREMHFWV
94 5$3,'NHUQHO
%XLOWLQREMHFWV
%XLOWLQREMHFWV
There are three groups of “Built in objects”: /DQJXDJHNHUQHOUHVHUYHGREMHFWV
,QVWDOOHGREMHFWV and 8VHULQVWDOOHGREMHFWV.
The objects could be any RAPID object, that is procedure, function, record, record
component, alias, const, var or pers. Object values of pers and var could be changed,
but not the code it self, because of that a modpos of a built in constant declared
robtarget is not allowed.
2EMHFWVFRSH
The scope of object denotes the area in which the object is visible. A EXLOWLQREMHFW is
visible at all other levels in the task, if not the same object name is used for another
object at a level between the use of the reference and the built in level.
The table below show the order of scope levels lookup, for a object referred from
different places:
5$3,'NHUQHO 95
%XLOWLQREMHFWV
7DEOH2EMHFWVHDUFKDFFRUGLQJWRVFRSHUXOHV
Global in the
Scope level
Own module program
Built in
Own routine (local (global
objects
declared) declared in
The object is used in a
one module)
There are ways to bind a reference in runtime to objects (not functions) outside its
scope. For data object see the “RAPID Reference Manual” 6HW'DWD6HDUFK and for
procedures use late binding with lookup, described in the “RAPID Kernel Reference
Manual” chapter “Procedure call”.
7KHYDOXHRIDEXLOWLQGDWDREMHFWGXUDELOLW\
The init value of a EXLOWLQ PERS or VAR object is set when the object is installed. It
could though be changed from the normal program. The object will always keep its
latest value even if the normal program is reset, erased or replaced. The only way to
reinit the object is to do a P-start or to change the configuration (then an automatic P-
start will be performed).
Note that a EXLOWLQ PERS object is not replacing its init value with its latest as a normal
PERS object do.
7KHZD\WRGHILQHXVHULQVWDOOHGREMHFWV
The only way to install a XVHULQVWDOOHGREMHFW is to define the object in a RAPID
module, create an new instance in the system parameter 7DVNPRGXOHV with the file path
to that module. The attribute 6WRUDJH must then be set to %XLOWLQ. (see system parameter,
type &RQWUROOHU). There are also an attribute for 7DVNPRGXOHV named 7H[W5HVRXUFH thats
only valid for %XLOWLQ objects, this make it possible to use national language or site
depended names in the RAPID code for identifiers, without changing the code itself. In
the normal case that attribute should not be changed, but for the advanced users see
“Text files” in this manual.
96 5$3,'NHUQHO
%XLOWLQREMHFWV
Note that all used references in a %XLOWLQ module must be known to the system at the
time for that module installation.
5$3,'NHUQHO 97
%XLOWLQREMHFWV
98 5$3,'NHUQHO
,QWHUWDVNREMHFWV
,QWHUWDVNREMHFWV
There are two groups of ,QWHUWDVNREMHFWV : %XLOWLQVKDUHGREMHFWand 6\VWHPJOREDO
SHUVLVWHQWGDWDREMHFW.
- A built in object could be configurated as shared for all tasks. This make it
possible to save memory by reusing RAPID code for more than one task. Its
also the only way to share non-value and semi-value data object. (see %XLOWLQ
REMHFWV in this manual). The object could be any RAPID object, that is
procedure, function, const ,var or pers.
- The current value of a system global persistent data object is shared by all tasks
where it is declared with the same name and type.
6\PEROOHYHOV
A symbol in RAPID could be found at different levels, in a routine, in a module (local),
in the program of one task (in one module and defined as global) or at the system level.
Built in objects are on the system level.
The system level is departed into two part, a shared part and a task part. Objects in the
task part are local to that task, but objects in the shared part is global to all task.
The shared part is only existing physical ones, and are a part of task 0 (the main task),
but existing logical in each task. A %XLOWLQVKDUHGREMHFW should be installed shared in
task 0.
Shared part
system level system level system level
Task part
)LJXUH6\PEROOHYHOVZLWKDGHSDUWHGV\VWHPOHYHO
The symbol search will start from that position (level) where the object is referred and
then, if not found in nearest level above and so on. See the “Symbol lookup direction”
- arrow in Figure 1.
5$3,'NHUQHO 99
,QWHUWDVNREMHFWV
'DWDREMHFWKDQGOLQJ
Even if the definition is shared for an data object the value of it could be local in the
task .That are the fact for the installed system variables HUUQRLQWQR and all stack
allocated object (object defined in a routine). All other data object share the value with
other tasks. This fact will demand a careful manipulation and reading of those values.
If the object has an atomic type (num, bool ,,,) there are no problem. But if not, make
sure that the total object are read/manipulated without any interfering from another
task. E.g. if the object is of a record type and each component are assign one by one, a
reading (between the setting of two record component ) from another task will get an
inconsistent record.
Also remember that a routine could be called from more than one task at the same time
and therefore should be reentrant, that is use local stack allocated object (parameters
and data object declared in the routine).
7KHZD\WRGHILQH%XLOWLQVKDUHGREMHFW
The only way to install a %XLOWLQVKDUHGREMHFW is to define the object in a RAPID
module, create an new instance of 7DVNPRGXOHV for task 0, in the system parameter with
the file path to the module. The attribute 6WRUDJH must then be set to %XLOWLQ, and the
attribute VKDUHG set to YES (see also system parameter type &RQWUROOHU).
6\VWHPJOREDOSHUVLVWHQWGDWDREMHFW
The current value of a system global persistent data object (e.g., not declared as task or
local) is shared by all tasks where it is declared with the same name and type. The
object will still exist even if one module where it is declared is removed as long as that
module do not contain the last declaration for that object. A persistent object could only
be of value type.
A declaration can specify an inital value to a persistent object, it will update the current
value of the persistent when the module is installed or loaded. If no inital value is
specified and the object already exists the current value will not be changed. If the
object do not already exists the current value will be initialized like a variable without
inital value.
Note that the current value of WRRO will be updated with the initial value of WRRO in the
last loaded module. This is a problem if the initial value differs in the two tasks. This
is solved by specifying initial value in one declaration only.
100 5$3,'NHUQHO
,QWHUWDVNREMHFWV
It is recommended to use this technique for types such as WRROGDWD, ZREMGDWD and
ORDGGDWD. Specify initial value along with data declaration in the motiontask and omitt
initial value in other tasks.
5$3,'NHUQHO 101
,QWHUWDVNREMHFWV
102 5$3,'NHUQHO
7H[WILOHV
7H[WILOHV
This is a most effective tool that should be used when the demand for the application
includes:
In a Text file you can use ASCII strings, with the help of an off-line editor, and fetch
them from the RAPID code. The RAPID code should not be changed in any way even
if the result from the execution may look totally different.
6\QWD[IRUDWH[WILOH
The application programmer must build one (or serval) ASCII file(s), the “Text
file(s)”, that contains the strings for a text resource.
<text_resource>::
# <comment>
<index1>:
“<text_string>”
# <comment>
<index2>:
“<text_string>”
...
The parameters
<text_resource>
This name identifies the text resource. The name must end with “::”. If the name does
not exist in the system, the system will create a new text resource, otherwise the
indexes in the file will be added to a resource that already exists. The application
developer is responsible for ensuring that one’s own resources do not crash with
another application. A good rule is to use the application name as a prefix to the
resource name, e.g. MYAPP_TXRES. The name of the resource must not exceed 80
characters. Do not use exclusively alphanumeric as the name to avoid a collision with
system resources.
<index>
This number identifies the <text_string> in the text resource. This number is
application defined and it must end with a “:”
5$3,'NHUQHO 103
7H[WILOHV
<text_string>
The text string starts on a new line and ends at the end of the line or, if the text string
must be formatted on several lines, the new line character string “\n” must be inserted.
<comment>
A comment always starts on a new line and goes to the end of the line. A comment is
always preceded by “#”. The comment will not be loaded into the system.
5$3,'LGHQWLILHU
All kinds of RAPID identifier (routines, const, variables, parameters, records, record
components, alias, or persistents) can be connected to a text index instead of a hard
coded name, if the object is a “User Installed object” (see also chapter “Built in objects”
in this manual).
The RAPID identifier in the code should be defined as: <name>#<text index>#, where
the <name> is a hard coded name that could be used for references to the object as well
as the name found at the text index.
The text resource should be defined under system parameters for the module containing
the symbols that should be “Built in”.
The example below describes a complete site with configuration, text file, and a “Built
in” module. The example is a shell routine that handles a gripper with analog pressure.
The alternative name for the routine gripper in the example will be Claw. An example
of use could look like “Claw CLAWMAX;”.
104 5$3,'NHUQHO
7H[WILOHV
The configuration
CAB_TASK_MODULES:
-File ram1disk:gripper.sys -Task MAIN -Storage BUILTIN -Txres
GRIPP_TXRES
)LJXUH7KHJULSSHUH[DPSOH
5HWULHYLQJWH[WGXULQJSURJUDPH[HFXWLRQ
It is also possible to retrieve a text string from the RAPID code. The functions 7H[W*HW
and 7H[W7DE*HW are used for this, see the chapter RAPID Support Functions.
/RDGLQJWH[WILOHV
Loading of the text file into the system can be done with the RAPID instruction
7H[W7DE,QVWDOOand the function 7H[W7DE)UHH7R8VH, see the chapter RAPID Support
Functions.
5$3,'NHUQHO 105
7H[WILOHV
106 5$3,'NHUQHO
6WRUDJHDOORFDWLRQIRU5$3,'REMHFWV
6WRUDJHDOORFDWLRQIRU5$3,'REMHFWV
All RAPID programs stored on diskette or RAM memory have ASCII format.
At loading of RAPID program from mass memory into the program memory (internal
format), the storage of the program needs about 4 times more memory space.
For memory optimize of RAPID programs, the storage allocation in program memory
(internal format in bytes) for some common instructions, datas etc. are specified below.
For other instructions or datas the storage allocation can be read from the operating
message 10040 after loading of a program or program module.
0RGXOHURXWLQHSURJUDPIORZDQGRWKHUEDVLFLQVWUXFWLRQ
7DEHOO6WRUDJHDOORFDWLRQIRUPRGXOHURXWLQHSURJUDPIORZDQGRWKHUEDVLFLQVWUXFWLRQV
Storage in
Instruction or data
bytes
New empty procedure without parameters: PROC proc1() ... ENDPROC 244
0RGXOHQXPHULFYDULDEOHGHFODUDWLRQ9$5QXPUHJ
0RGXOHVWULQJFRQVWDQWGHFODUDWLRQZLWKFKDUVLQLWVWULQJYDOXH
&2167VWULQJVWULQJ ³FKDUDFWHUV³
0RGXOHVWULQJYDULDEOHGHFODUDWLRQZLWKFKDUVLQLWVWULQJYDOXH
9$5VWULQJVWULQJ ³FKDUDFWHUV³
0RGXOHVWULQJYDULDEOHGHFODUDWLRQ9$5VWULQJVWULQJ
:ULWHWH[WRQ)OH[3HQGDQW73:ULWH³FKDUDFWHUV´
5$3,'NHUQHO 107
6WRUDJHDOORFDWLRQIRU5$3,'REMHFWV
0RYHLQVWUXFWLRQV
7DEHOO6WRUDJHDOORFDWLRQIRUPRYHLQVWUXFWLRQV
Storage in
Instruction or data
bytes
,2LQVWUXFWLRQV
7DEHOO6WRUDJHDOORFDWLRQIRU,2LQVWUXFWLRQV
Storage in
Instruction or data
bytes
Wait until two digital inputs are high: WaitUntil di1=1 AND di2=1; 220
108 5$3,'NHUQHO
,QGH[
$ Function Declarations 53
Aggregates 31 *
Alias types 17
Assignment Statement 39 Goto Statement 42
Atomic Types 13
,
% If Statement 45
Backward Execution 3 Installed Data Types 5
backward handler 3 Interrupt Manipulation 73
Backward Handlers 55 Interrupt Recognition and Response 73
Break 91 Interrupts 4, 73
Built in objects 95 ISleep 91
Built-in Data Objects 93 IsPers 91
Built-in Data Types 4 IsVar 91
Built-in Routines 91 IWatch 91
& /
5$3,'NHUQHO 109
Routine Declarations 49
Routines 2
scope
data scope 95, 103
Scope Rules 13, 52
Statement Lists 38
Statement Termination 38
Statements 37
Syntax Summary 81
System Modules 80
system modules 1
7
Task - Modules 1
task buffer 1
Task Modules 77
task modules 1
Test Statement 47
Trap Routines 74
Trynext Statement 44
8
9
variable 95, 99
Variable Declarations 22
:
While Statement 47
110 5$3,'NHUQHO