Você está na página 1de 4

ReadErrData

Instruction

Advanced RAPID

ReadErrData - Gets information about an error


ReadErrData is to be used in a trap routine, to get information (domain, type, number
and intermixed strings %s) about an error, a state change, or a warning, that caused the
trap routine to be executed.
Refer to User Guide - Error Management, System and Error Messages
for more information.

Example
VAR errdomain err_domain;
VAR num err_number;
VAR errtype err_type;
VAR trapdata err_data;
VAR string string1;
VAR string string2;
...
TRAP trap_err
GetTrapData err_data;
ReadErrData err_data, err_domain, err_number,
err_type \Str1:=string1 \Str2:=string2;
ENDTRAP
When an error is trapped to the trap routine trap_err, the error domain, the error
number, the error type and the two first intermixed strings in the error message
are saved into appropriate variables.

Arguments
ReadErrData TrapEvent ErrorDomain ErrorId ErrorType [\Str1]
[\Str2] [\Str3] [\Str4] [\Str5]
TrapEvent

Data type: trapdata

Variable containing the information about what caused the trap to be executed.
ErrorDomain

Data type: errdomain

The error domain to which the error, state change, or warning that occurred
belongs. Ref. to predefined data of type errdomain.
ErrorId

Data type: num

The number of the error that occurred.


The error number is returned without the first digit (error domain) and without
the initial zeros of the complete error number.
E.g. 10008 Program restarted, is returned as 8.
RAPID reference part 1, Instructions A-Z

335

ReadErrData
Advanced RAPID

Instruction

ErrorType

Data type: errtype

The type of event such as error, state change, or warning that occurred.
Ref. to predefined data of type errtype.
[ \Str1 ] ... [ \Str5 ]

Data type: string

The string holding information that is intermixed into the error message. There
could be up to five strings in a message. Str1 holds the first string, Str2 holds the
second string and so on. Information about how many strings there are in a message is found in User Guide - Error Management, System and Error Messages.
The intermixed string are maked as %s, %d or %f in that document.

Program execution
The ErrorDomain, ErrorId, ErrorType and Str1 ... Str5 variables are updated according
to the contents of TrapEvent.
If different events are connected to the same trap routine, the program must make sure
that the event is related to error monitoring. This can be done by testing that INTNO
matches the interrupt number used in the instruction IError;

Example
VAR intnum err_interrupt;
VAR trapdata err_data;
VAR errdomain err_domain;
VAR num err_number;
VAR errtype err_type;
...
CONNECT err_interrupt WITH trap_err;
IError COMMON_ERR, TYPE_ERR, err_interupt;
...
IDelete err_interrupt;
...
TRAP trap_err
GetTrapData err_data;
ReadErrData err_data, err_domain, err_number, err_type;
! Set domain no 1 ... 13
SetGO go_err1, err_domain;
! Set error no 1 ...9999
SetGO go_err2, err_number;
ENDTRAP
When an error occurs (only errors, not warning or state change), the error number
is retrieved in the trap routine and its value is used to set 2 groups of digital outputs.

336

RAPID reference part 1, Instructions A-Z

ReadErrData
Instruction

Advanced RAPID

Limitation
It is not possible obtain information about internal errors.

Syntax
ReadErrData
[TrapEvent :=] <variable (VAR) of trapdata>,
[ErrorDomain :=] <variable (VAR) of errdomain>,
[ErrorId:=] <variable (VAR) of num>,
[ErrorType :=] <variable (VAR) of errtype>
[\Str1 :=<variable (VAR) of string>]
[\Str2 :=<variable (VAR) of string>]
[\Str3 :=<variable (VAR) of string>]
[\Str4 :=<variable (VAR) of string>]
[\Str5 :=<variable (VAR) of string>];

Related information
Described in:
Summary of interrupts

RAPID Summary - Interrupts

More information on interrupt management

Basic Characteristics- Interrupts

Error domains, predefined constants

Data Types - errdomain

Error types, predefined constants

Data Types - errtype

Orders an interrupt on errors

Instructions - IError

Get interrupt data for current TRAP

Instructions - GetTrapData

RAPID reference part 1, Instructions A-Z

337

ReadErrData
Advanced RAPID

338

Instruction

RAPID reference part 1, Instructions A-Z

Você também pode gostar