0% found this document useful (0 votes)
3K views37 pages

KUKA User Defined Messages

User-defined messages can be programmed in KRL and displayed in the smartHMI message window. There are five message types - notification, acknowledgement, wait, status, and dialog - each with a specific purpose. Messages can include up to three parameters displayed in the message text. Messages are generated either through predefined KRL methods like MsgNotify, which creates a notification message with an optional placeholder, or through expert KRL programming.

Uploaded by

predsa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3K views37 pages

KUKA User Defined Messages

User-defined messages can be programmed in KRL and displayed in the smartHMI message window. There are five message types - notification, acknowledgement, wait, status, and dialog - each with a specific purpose. Messages can include up to three parameters displayed in the message text. Messages are generated either through predefined KRL methods like MsgNotify, which creates a notification message with an optional placeholder, or through expert KRL programming.

Uploaded by

predsa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 37

09.06.

22 11:26 Programming user-defined messages

Identification number: SS2262

Programming user-defined messages


Description
User-defined messages can be programmed using KRL (KUKA Robot Language).
User-defined messages, like system messages, are displayed in the message window of the smartHMI. Once sent,
the messages remain displayed until they are cleared.

Structure of a message

Structure of a message

Item Description
1 Message type
2 Time at which the message was generated
3 Originator of the message
Note: To differentiate them from system messages, the originator of user-defined messages is
displayed in angle brackets <>.
4 Message number
5 Button for confirming, acknowledging and/or clearing the message
6 Message text

Message types
There are 5 message types available. Each type of message has a specific symbol assigned to it.
No predefined reactions of the robot are linked to the different message types. The desired reactions must be
programmed.

https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductCa… 1/37
09.06.22 11:26 Programming user-defined messages

Symbol Type
Notification message
Notification messages are suitable for displaying general information.
Notification messages are not managed in the message buffer and can only be cleared using the
buttons OK and Confirm all.
Acknowledgement message
Acknowledgement messages are suitable for displaying information of which the user must be
made aware.
Acknowledgement messages can be cleared (acknowledged) using the buttons OK and Confirm
all. In the case of an acknowledgement message (unlike a notification message), it is possible to
check whether or not the user has acknowledged it. It is possible, for example, to stop the
program until the message has been acknowledged.
Wait message
Wait messages indicate a state for which the system is waiting.
They can be cleared by means of a function from the program.
The user can also clear the message using the Simulate button.
Status message
Status messages are suitable for indicating a change of status (e.g. variable X changes from
TRUE to FALSE).
They are cleared by means of a function from the program. The message is then cleared when
the status that triggered it is no longer applicable.
Dialog message
Dialog messages are suitable for displaying questions that must be answered by the user.
Dialog messages can be cleared using a button that can be labeled by the programmer. Up to 7
buttons can be defined. How program execution continues can be made dependent on which
button the user selects.
A dialog message can only be generated if no other dialog message is active.

Parameters in messages
Up to 3 parameters can be displayed in a message. The parameters are displayed instead of the placeholders in
the message text and can have the following forms:
Text as directly transferred string
CHAR, INT, REAL or BOOL variable
Text from a KXR file (e.g. for language-specific messages) (>>> Programming language-specific messages)

Options for programming messages


Messages can be programmed in two different ways:
Using predefined methods (subprograms) (>>> Generating messages by means of KRL methods)
This procedure is particularly suitable for simple messages and is comparatively quick and easy to implement.
Little knowledge of KRL is required. Many messages can be created and generated with a single line of
program code. The functional scope of the messages is slightly limited compared to manual programming.
Expert programming of messages (>>> Expert programming of messages)
A higher level of KRL knowledge is required for this procedure. All message components must be defined
individually. Generating and clearing the message are programmed using KRL functions.
It is also possible to use both options in parallel within a program.

https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductCa… 2/37
09.06.22 11:26 Programming user-defined messages

Generating messages by means of KRL methods


Overview
The KUKA System Software has the following predefined KRL methods:
MsgNotify: generating a notification message with 1 optional placeholder
(>>> MsgNotify: generating a notification message with 1 optional placeholder)
MsgNotifyTextPar: generating a notification message with up to 2 placeholders
(>>> MsgNotifyTextPar: generating a notification message with up to 2 placeholders)
MsgQuit: generating an acknowledgement message
(>>> MsgQuit: generating an acknowledgement message)
MsgLoop: generating a status message
(>>> MsgLoop: generating a status message)
MsgDialog: generating a dialog message
(>>> MsgDialog: generating a dialog message)

MsgNotify: generating a notification message with 1 optional placeholder


Description
The MsgNotify method can be used to generate a notification message. Output of a CHAR or INT parameter in
the message text is possible using a placeholder (%1).
Syntax
MsgNotify( Text[], Modul[], NumPar, TextPar[], MsgNr, MsgOpt )

Explanation of the syntax

https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductCa… 3/37
09.06.22 11:26 Programming user-defined messages

Element Description
Text[] Type: CHAR
Mandatory parameter
Type of transfer: IN parameter
Message text
Notes:
Maximum 80 characters
Permissible characters: letters, numbers, underscores
The text must not consist of blanks.
The text can contain %1 as a placeholder.

Modul[] Type: CHAR


Optional parameter
Type of transfer: IN parameter
Originator of the message
Note: Maximum 24 characters
NumPar Type: INT
Optional parameter
Type of transfer: IN parameter
Numerical value that is output for the placeholder %1.
TextPar[] Type: CHAR
Optional parameter
Type of transfer: IN parameter
Text that is output for the placeholder %1.
Notes:
Maximum 26 characters
If sTextPar[] is used, the place of sNumPar[] in the method call must be left blank: “,,”.

MsgNr Type: INT


Optional parameter
Type of transfer: IN parameter
Message number
Notes:
If no message number has been assigned, the message number 1 is displayed by default.
Message number must be > 0.

https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductCa… 4/37
09.06.22 11:26 Programming user-defined messages

Element Description
MsgOpt Type: KrlMsgOpt_T
Optional parameter
Type of transfer: IN parameter
MsgOpt = { vl_stop TRUE|FALSE, clear_p_reset TRUE|FALSE, log_to_DB
TRUE|FALSE }
Variable with the following options for the effect of the message of the robot system:
vl_stop, type: BOOL
TRUE: message triggers an advance run stop.
FALSE: message does not trigger an advance run stop.
Default: TRUE
clear_p_reset, type: BOOL
Note: Has no function in the case of notification messages
Default: TRUE
log_to_DB, type: BOOL
TRUE: message is logged.
FALSE: message is not logged.
Default: FALSE

Example 1
In the following example, a notification message is generated with a text only.

MsgNotify("This is a notify message.")

Display in the message window:

Simple notification message

Example 2
In the following example, a notification message is generated with a text inserted via the placeholder %1,
specification of the originator and a defined message number.

MsgNotify("Check %1.", "MyTech", , "gripper", 123)

Display in the message window:

Notification message

MsgNotifyTextPar: generating a notification message with up to 2 placeholders


Description
The MsgNotifyTextPar method can be used to generate a notification message with a maximum of 2 placeholders
for INT and CHAR parameters. The following combinations are possible for the transfer of parameters:

https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductCa… 5/37
09.06.22 11:26 Programming user-defined messages

1 INT parameter (%1) and 1 CHAR parameter (%2)


2 CHAR parameters (%1 and %2)
Syntax
MsgNotifyTextPar( Text[], Modul[], NumPar, TextPar1[], TextPar2[], MsgNr, MsgOpt )

Explanation of the syntax

https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductCa… 6/37
09.06.22 11:26 Programming user-defined messages

Element Description
Text[] Type: CHAR
Mandatory parameter
Type of transfer: IN parameter
Message text
Notes:
Maximum 80 characters
Permissible characters: letters, numbers, underscores.
The text must not consist of blanks.
The text can contain %1 and %2as placeholders.

Modul[] Type: CHAR


Optional parameter
Type of transfer: IN parameter
Originator of the message
Note: Maximum 24 characters
NumPar Type: INT
Optional parameter
Type of transfer: IN parameter
Numerical value that is output for the placeholder %1
Note: If TextPar1[] is used, the place of NumPar[] in the method call must be left blank: “,,”.
TextPar1[] Type: CHAR
Optional parameter
Type of transfer: IN parameter
Text that is output for the placeholder %1.
Note: Maximum 26 characters
TextPar2[] Type: CHAR
Optional parameter
Type of transfer: IN parameter
Text that is output for the placeholder %2.
Note: Maximum 26 characters
MsgNr Type: INT
Optional parameter
Type of transfer: IN parameter
Message number
Notes:
If no message number has been assigned, the message number 1 is displayed by default.
The message number must be > 0.

https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductCa… 7/37
09.06.22 11:26 Programming user-defined messages

Element Description
MsgOpt Type: KrlMsgOpt_T
Optional parameter
Type of transfer: IN parameter
MsgOpt = { vl_stop TRUE|FALSE, clear_p_reset TRUE|FALSE, log_to_DB
TRUE|FALSE }
Variable with the following options for the effect of the message:
vl_stop, type: BOOL
TRUE: message triggers an advance run stop.
FALSE: message does not trigger an advance run stop.
Default: TRUE
clear_p_reset, type: BOOL
Note: Has no function in the case of notification messages
Default: TRUE
log_to_DB, type: BOOL
TRUE: message is logged.
FALSE: message is not logged.
Default: FALSE

Example 1
In the following example, a notification message is generated with 2 CHAR parameters and a defined message
number.
The text fragments Task 4 and is finished are transferred as CHAR parameters and output for the placeholders
%1 and %2.

MsgNotifyTextPar("%1 %2.", "MyTech", 0, "Task 4", "is finished", 5678)

Display in the message window:

Notification message

Example 2
In this example, the same notification message as in example 1 is implemented with 1 INT and 1 CHAR parameter.
The numerical value 4 is transferred as an INT parameter and output for the placeholder %1.
The word finished is transferred as a CHAR parameter and output for the placeholder %2.

MsgNotifyTextPar("Task %1 is %2.", "MyTech", 4, "finished", , 5678)

Display in the message window:

Notification message

https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductCa… 8/37
09.06.22 11:26 Programming user-defined messages

MsgQuit: generating an acknowledgement message


Description
The MsgQuit method can be used to generate an acknowledgement message. Output of a CHAR or INT
parameter in the message text is possible using a placeholder (%1).
Syntax
MsgQuit( Text[], Modul[], NumPar, TextPar[], MsgNr, MsgOpt )

Explanation of the syntax

https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductCa… 9/37
09.06.22 11:26 Programming user-defined messages

Element Description
Text[] Type: CHAR
Mandatory parameter
Type of transfer: IN parameter
Message text
Notes:
Maximum 80 characters
Permissible characters: letters, numbers, underscores
The text must not consist of blanks.
The message text can contain “%1” as a placeholder.

Modul[] Type: CHAR


Optional parameter
Type of transfer: IN parameter
Originator of the message
Note: Maximum 24 characters
nNumPar Type: INT
Optional parameter
Type of transfer: IN parameter
Numerical value that is output for the placeholder %1.
TextPar[] Type: CHAR
Optional parameter
Type of transfer: IN parameter
Text that is output for the placeholder %1.
Notes:
Maximum 26 characters
If TextPar[] is used, the place of NumPar[] in the method call must be left blank: “,,”.

MsgNr Type: INT


Optional parameter
Type of transfer: IN parameter
Message number
Notes:
If no message number has been assigned, the message number 1 is displayed by default.
Message number must be > 0.

https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductC… 10/37
09.06.22 11:26 Programming user-defined messages

Element Description
MsgOpt Type: KrlMsgOpt_T
Optional parameter
Type of transfer: IN parameter
MsgOpt = { vl_stop TRUE|FALSE, clear_p_reset TRUE|FALSE, log_to_DB
TRUE|FALSE }
Variable with the following options for the effect of the message of the robot system:
vl_stop, type: BOOL
TRUE: message triggers an advance run stop.
FALSE: message does not trigger an advance run stop.
Default: TRUE
clear_p_reset, type: BOOL
TRUE: the message is cleared when the program is deselected or reset.
FALSE: the message is still displayed when the program is deselected or reset.
Default: TRUE
log_to_DB, type: BOOL
TRUE: message is logged.
FALSE: message is not logged.
Default: FALSE

Example 1
In the following example, an acknowledgement message is generated with a message number and specification
of the originator. When the program is deselected or reset, the message is to be cleared if it has not yet been
acknowledged. The message is additionally to be logged.

KrlMsgOpt_T MsgOpt
MsgQuit("Check tool.", "MyTech",,, 231, {vl_stop TRUE, clear_p_reset TRUE, log_to_DB
TRUE})

Display in the message window:

Acknowledgement message

Example 2
Example of an acknowledgement message in which a variable of type INT is output by means of the placeholder
%1.

INT myInt
myInt = 123
MsgQuit("This is quit message %1.", "MyMod", myInt)

Display in the message window:

Acknowledgement message
https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductC… 11/37
09.06.22 11:26 Programming user-defined messages

MsgLoop: generating a status message


Description
The MsgLoop method can be used to generate a simple status message. The message is cleared again by calling
MsgLoop with transfer of an empty string (“ ”).
Syntax
MsgLoop( sText[], sModul[] )

Explanation of the syntax


Element Description
sText[] Type: CHAR
Mandatory parameter
Type of transfer: IN parameter
Message text
Notes:
Maximum 80 characters
Permissible characters: letters, numbers, underscores

sModul[] Type: CHAR


Optional parameter
Type of transfer: IN parameter
Originator of the message
Note: Maximum 24 characters

Example
In the following example, a status message is generated with the text This is a loop message. The message is
cleared after 60 seconds.

MsgLoop("This is a loop message.")


WAIT SEC 60
MsgLoop(" ")

Display in the message window:

Status message

MsgDialog: generating a dialog message


Description
The MsgDialog method can be used to generate a dialog message with up to 7 buttons. The return value can, for
example, be assigned to a variable for further use.
Syntax
MsgDialog( nAnswer, sModul[], sTextPar[], sDialogSK1, sDialogSK2, sDialogSK3, sDialogSK4, sDialogSK5,
sDialogSK6, sDialogSK7, NoBrakes, nMsgNr, MsgOpt )
Explanation of the syntax

https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductC… 12/37
09.06.22 11:26 Programming user-defined messages

Element Description
nAnswer Type: INT
Mandatory parameter
Type of transfer: OUT parameter
Return value of the method. Saves which button was pressed by the user.
sText[] Mandatory parameter
Type: CHAR
Type of transfer: IN parameter
Message text
Notes:
Maximum 80 characters
Permissible characters: letters, numbers, underscores.
The text must not consist of blanks.
The text can contain %1 as a placeholder.

sModul[] Type: INT


Optional parameter
Type of transfer: IN parameter
Originator of the message
Note: Maximum 24 characters
sTextPar[] Type: CHAR
Optional parameter
Type of transfer: IN parameter
Type of transfer: IN parameter
Text that is output for the placeholder %1.
Note: Maximum 26 characters
sDialogSK1 ... Type: CHAR
sDialogSK7 Mandatory parameter
Type of transfer: IN parameter
Buttons
Note: The buttons are displayed in descending numerical order from left to right. sDialogSK1
is therefore always on the far right.
NoBrakes Type: BOOL
Optional parameter
Type of transfer: IN parameter
TRUE: brakes remain released.
FALSE: brakes are closed.
Default: FALSE
Note: In the case of TRUE, the robot remains in a continuous motion to the position in
which it is currently located as long as the message is waiting for an input. The robot thus
stops moving, but without closing the brakes. Starting from this state, it is possible for the
robot to start moving again particularly quickly.

https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductC… 13/37
09.06.22 11:26 Programming user-defined messages

Element Description
nMsgNr Type: INT
Optional parameter
Type of transfer: IN parameter
Message number
Notes:
If no message number has been assigned, the message number 1 is displayed by default.
Message number must be > 0.

MsgOpt Type: KrlMsgOpt_T


Optional parameter
Type of transfer: IN parameter
MsgOpt = { vl_stop TRUE|FALSE, clear_p_reset TRUE|FALSE, log_to_DB
TRUE|FALSE }
Variable with the following options for the effect of the message:
vl_stop, type: BOOL
TRUE: message triggers an advance run stop.
FALSE: message does not trigger an advance run stop.
Default: TRUE
clear_p_reset, type: BOOL
TRUE: the message is cleared when the program is deselected or reset.
FALSE: the message is still displayed when the program is deselected or reset.
Default: TRUE
log_to_DB, type: BOOL
TRUE: message is logged.
FALSE: message is not logged.
Default: FALSE

Example 1
In the following example, a dialog message is generated with 2 buttons, specification of the originator and a
defined message number. The return value is assigned to the variable DialogAnswer.

 
INT nAnswer
nAnswer = 0
MsgDialog(nAnswer, "Continue?","MyTech", , "yes", "no", , , , , , , 7)

Display in the message window:

Dialog message

https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductC… 14/37
09.06.22 11:26 Programming user-defined messages

Example 2
In the following example, a dialog message is generated with 5 buttons, 1 CHAR placeholder, specification of the
originator and a defined message number.

INT nAnswer
nAnswer = 0
MsgDialog(nAnswer, "Please select a %1 mode:", "MyTech", "welding", "5", "4", "3", "2",
"1", , , , 12345)

Display in the message window:

Dialog message

Expert programming of messages


Expert programming is more time-intensive, but enables all message components and the message response to
be precisely defined.

Overview
The procedure for programming a message is generally as follows:

1. Declare the required variables and initialize them if necessary.


2. Define the originator, number and message text. (>>> Defining the originator, message number and
message text)
3. Define the parameters. (>>> Defining parameters)
4. Only for dialog messages: Label the buttons. (>>> Labeling buttons for dialog messages)
5. Define the message response. (>>> Defining the message response)
6. Generate the message. (>>> SET_KRLMSG: Generate message) (>>> SET_KRLDLG: Generate dialog
message)
7. Check or clear the message. (>>> EXISTS_KRLMSG: Check message) (>>> CLEAR_KRLMSG: Clear message)

Defining the originator, message number and message text


Description
A variable of type KrlMsg_T defines the originator of the message, the message number and the message text.
Syntax
name = {modul[] " originator ", nr number , msg_txt[] " text "}
Explanation of the syntax

https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductC… 15/37
09.06.22 11:26 Programming user-defined messages

Element Description
name Type: KrlMsg_T
Name of the variable for the message
originator Type: CHAR
Originator of the message
Note: The originator must not consist of blanks.
Maximum 24 characters
Number Type: INT
Message number
Notes:
Message number must be > 0.
Message numbers may be used more than once.

text Type: CHAR


Message text
Direct entry as string
Or: Entry of a key to a text element in a KXR file (>>> Programming language-specific
messages)
Notes:
Maximum 80 characters
Permissible characters: letters, numbers, underscores. The text must not start with a
number, however.
The text must not consist of blanks.
The text or key can contain %1, %2 and/or %3 as placeholders. If this is the case, the
placeholders must be assigned parameters.
(>>> Defining parameters)

KrlMsg_T
STRUC KrlMsg_T CHAR modul[24], INT nr, CHAR msg_txt[80]

Example
In this example, the originator mymodule, the message number 57 and the message text This is my message.
are defined for a message with the name mymessage.

DECL KrlMsg_T mymessage


mymessage = {modul[] "mymodule", nr 57, msg_txt "This is my message."}

Defining parameters
Description
To display the content of parameters, a maximum of 3 placeholders, %1, %2 and %3, can be integrated into the
message text. The file type and content of the parameters must be defined in advance.

When the message is generated, all 3 parameters must always be transferred, even if the parameters
are not used. Accordingly, each of the 3 parameters must either be assigned a value or defined as empty.

A text or string (CHAR parameter), a numerical value (INT or REAL parameter) or a Boolean value (BOOL
parameter) can be generated for the placeholders.

https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductC… 16/37
09.06.22 11:26 Programming user-defined messages

Syntax
param[n] = {par_type type , par_txt[] " text " | par_int int | par_real real | par_bool
bool }
Explanation of the syntax
Element Description
param[n] Type: KrlMsgPar_T
Array for the 3 possible parameters

Array index[n]:

1: Parameter for placeholder “%1”


2: Parameter for placeholder “%2”
3: Parameter for placeholder “%3”

type Type: KrlMsgParType_T


Type of parameter
#VALUE: The parameter contains a text (CHAR), a numerical value (INT, REAL) or a
Boolean value (BOOL).
#KEY: The parameter is a key to a text element in a KXR file. (>>> Programming language-
specific messages)
#EMPTY: The parameter is empty.

text Type: CHAR


If a text is to be displayed for the placeholder.
Direct entry as string
Or: Entry of a key to a text element in a KXR file
Notes:
Maximum 26 characters
The text must not consist of blanks.

int Type: INT


If an INT value is to be assigned to the parameter.
Note: It can only be used in conjunction with type=#VALUE.
real Type: REAL
If a REAL value is to be assigned to the parameter.
Note: It can only be used in conjunction with type=#VALUE.
bool Type: BOOL
If a BOOL value is to be assigned to the parameter.
Note:
It can only be used in conjunction with type=#VALUE.
The value is displayed in the message text as TRUE or FALSE.

Please note the following:


All components and the overall structure may be left not initialized. Structures that are not initialized will be
interpreted as #EMPTY.
If the component par_type is not initialized, this parameter is interpreted as #EMPTY.
If the component par_type is initialized with #VALUE or #KEY, but none of the subsequent components
(par_txt[], par_int, par_real, par_bool) is initialized, this parameter is interpreted as #EMPTY.

https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductC… 17/37
09.06.22 11:26 Programming user-defined messages

If the component par_type is initialized with #KEY, the component par_txt[] is not initialized, but one of the
remaining components is initialized (par_int, par_real, par_bool), this results in an error message.
If the component par_type is initialized with #VALUE or #KEY, and if more than one of the remaining
components (par_txt[], par_int, par_real, par_bool) is initialized, the first initialized component is always
deemed to be valid. (Order: par_txt[], par_int, par_real, par_bool)
Example: par[1]={par_type #value, par_int 7, par_bool true} : The value of the parameter is
7.
KrlMsgPar_T
STRUC KrlMsgPar_T KrlMsgParType_T par_type, CHAR par_txt[26], INT par_int, REAL
par_real, BOOL par_bool

Par_int int, par_real real and par_bool bool enable the programmer to use an INT, REAL or BOOL
value as a parameter without first having to convert the value to a string. Conversion is carried out
automatically. Par_Bool is converted to the string TRUE or FALSE.

KrlMsgParType_T
ENUM KrlMsgParType_T value, key, empty

Example 1
In this example, a text is assigned to the parameter for %1 and an INT value is assigned to the parameter for %2.
The 3rd parameter is defined as empty.

1 DECL KrlMsgPar_T Parameter[3]


2 DECL INT part_number
3 ...
4 part_number = 5
5 ...
6 Parameter[1] = {Par_Type #VALUE, Par_txt[] "gripper"}
7 Parameter[2] = {Par_Type #VALUE}
8 Parameter[2].Par_Int = part_number
9 Parameter[3] = {Par_Type #EMPTY}

Line Description
1 Declaration of the parameter array
2 Declaration of an INT variable, the value of which is to be transferred
4 Initialization of the INT variable
6 The parameter for placeholder %1 is assigned the text gripper .
7 ... 8 The parameter for placeholder %2 is assigned the value of the INT variable part_number .
9 Placeholder %3 is not used; the parameter remains empty.

Example 2
In this example, the value of analog output $ANOUT[5] is displayed for placeholder %1.

decl KrlMsgPar_t par[3]


...
par[1] = {par_type #value, par_real 0.0}
par[1].par_real = $anout[5]

Labeling buttons for dialog messages


https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductC… 18/37
09.06.22 11:26 Programming user-defined messages

Description
Up to 7 buttons can be displayed in dialog messages. The buttons must be declared and initialized.
Syntax
softkey[n] = {sk_type keytype , sk_txt[] " keyname "}
Explanation of the syntax
Element Description
softkey[n] Type: KrlMsgDlgSK_T
Name of the variable for the buttons

Array index[n] = 1 …7:

1: Label for the 1st button from the left


2: Label for the 2nd button from the left
etc.

keytype Type: KrlMsgParType_T


Type of button label
#VALUE: sk_txt[ ] corresponds to the button label.
#KEY: sk_txt[ ] is the key to a text element in a KXR file. The text element contains the
label of the button. (>>> Programming language-specific messages)
#EMPTY: The button is not assigned.

keyname Type: CHAR


Label of the button
Direct entry as string
Or: Entry of a key to a text element in a KXR file.
Notes:
The text must not consist of blanks.
Maximum 10 characters

KrlMsgDlgSK_T
STRUC KrlMsgDlgSK_T KrlMsgParType_T sk_type, CHAR sk_txt[10]

Example
Example for labeling 2 buttons with the words yes and no.

Dialog message

Declaration and initialization of the buttons:

DECL KRLMSGDLGSK_T softkey[2]


https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductC… 19/37
09.06.22 11:26 Programming user-defined messages

softkey[1] = {sk_type #value, sk_txt[] "yes"}


softkey[2] = {sk_type #value, sk_txt[] "no"}

Defining the message response


Description
The message response is defined with a variable of type KrlMsgOpt_T.
Syntax
options = {vl_stop TRUE|FALSE, clear_p_reset TRUE|FALSE, clear_p_SAW TRUE|FALSE,
log_to_DB TRUE|FALSE}

Explanation of the syntax


Element Description
options Type: KrlMsgOpt_T
Name of the variable for the message response
vl_stop Type: BOOL
TRUE: SET_KRLMSG/SET_KRLDLG triggers an advance run stop.
FALSE: SET_KRLMSG/SET_KRLDLG does not trigger an advance run stop
Default: TRUE
clear_p_reset Type: BOOL
Clear message when the program is reset or deselected
TRUE: All status messages, acknowledgement messages and wait messages generated by
SET_KRLMSG with the variable options are cleared.
FALSE: The messages are not cleared.
Default: TRUE
Note: The following always applies for dialog messages: clear_p_reset = TRUE.
clear_p_SAW Type: BOOL
Clear message when a block selection is carried out using the Block selection button
TRUE: All status messages, acknowledgement messages and wait messages generated by
SET_KRLMSG with the variable options are cleared.
FALSE: The messages are not cleared.
Default: FALSE
log_to_DB Type: BOOL
TRUE: The message is logged.
FALSE: The message is not logged.
Default: FALSE

KrlMsgOpt_T
STRUC KrlMsgOpt_T BOOL vl_stop, BOOL clear_p_reset, BOOL clear_p_SAW, BOOL
log_to_DB

Example
In this example, the response of the message is defined as follows:
The message is to trigger an advance run stop.
On resetting or deselecting the program, all status, acknowledgement and wait messages generated with the
variable “opt” are to be cleared.
https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductC… 20/37
09.06.22 11:26 Programming user-defined messages

In the case of a block selection, the messages generated with the variable “opt” are not to be cleared.
The message is to be logged.

decl KrlMsgOpt_T opt


opt = {vl_stop TRUE, clear_p_reset TRUE, clear_p_SAW FALSE, log_to_DB TRUE}

SET_KRLMSG: Generate message


Description
The SET_KRLMSG function generates a message. This means that the message is transferred to the message
buffer and displayed in the message window.

Exceptions:

Notification messages are not managed in the message buffer.


Dialog messages are generated using the SET_KRLDLG function.
(>>> SET_KRLDLG: Generate dialog message)
Syntax
handle = SET_KRLMSG( type , name , parameter [], options )
Explanation of the syntax
Element Description
handle Type: INT
Return value
-1: The message could not be generated.
> 0: The message was generated successfully.
The return value is a valid handle that can be used in further operations for this message,
e.g. for clearing the message with CLEAR_KRLMSG.
Note: For notification messages, the handle is always 0.
type Type: EKrlMsgType
Type of transfer: IN parameter
Defines the type of the message to be generated.
#NOTIFY: Notification message
#STATE: Status message
#QUIT: Acknowledgement message
#WAITING: Wait message

name Type: KrlMsg_T


Type of transfer: IN parameter
Variable containing name, originator and text of the message (>>> Defining the originator,
message number and message text)
parameter Type: KrlMsgPar_T
Type of transfer: IN parameter
Variable containing the message parameters (>>> Defining parameters)
options Type: KrlMsgOpt_T
Type of transfer: IN parameter
Variable containing the message response (>>> Defining the message response)

EKrlMsgType
https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductC… 21/37
09.06.22 11:26 Programming user-defined messages

ENUM EKrlMsgType notify, state, quit, dialog, waiting

Example
In the following example, an acknowledgement message is generated.

decl KrlMsg_T message


decl KrlMsgPar_T parameter[3]
decl KrlMsgOpt_T options
int handle
...
handle = SET_KRLMSG (#QUIT, message, parameter[], options)
...

SET_KRLDLG: Generate dialog message


Description
The SET_KRLDLG function generates a dialog message. This means that the message is transferred to the
message buffer and displayed in the message window.
The function merely generates the dialog. It does not wait until the dialog has been answered.
The SET_KRLMSG function is available for other message types. (>>> SET_KRLMSG: Generate message)
Syntax
handle = SET_KRLDLG( name , parameter [], softkey [], options )
Explanation of the syntax
Element Description
handle Type: INT
Return value
-1: The dialog message could not be generated (e.g. because another dialog has not yet
been answered).
> 0: The dialog message was generated successfully.
The return value is a valid handle that can be used in further operations for this dialog
message.
name Type: KrlMsg_T
Type of transfer: IN parameter
Variable containing name, originator and text of the message (>>> Defining the originator,
message number and message text)
parameter Type: KrlMsgPar_T
Type of transfer: IN parameter
Variable containing the message parameters (>>> Defining parameters)
softkey Type: KrlMsgDlgSK_T
Type of transfer: IN parameter
Variable containing the button assignment (>>> Labeling buttons for dialog messages)
options Type: KrlMsgOpt_T
Type of transfer: IN parameter
Variable containing the message response (>>> Defining the message response)

Example
In the following example, a dialog message is generated.

https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductC… 22/37
09.06.22 11:26 Programming user-defined messages

decl KrlMsg_T message


decl KrlMsgPar_T parameter[3]
decl KrlMsgDlgSK_T SK[7]
decl KrlMsgOpt_T options
int Handle, keynumber
...
Handle = Set_KrlDlg (message, parameter[], SK[], options)
...

CLEAR_KRLMSG: Clear message


Description
The CLEAR_KRLMSG function can be used to clear a message. This means that the message is removed from the
message buffer and the message window.
Syntax
result = CLEAR_KRLMSG( clear )
Explanation of the syntax
Element Description
result Type: BOOL
Variable for the return value
TRUE: The message has been cleared.
FALSE: The message could not be cleared.

handle Type: INT


Type of transfer: IN parameter
Handle of the message to be cleared provided by the SET_KRLMSG or SET_KRLDLG function
The following values can also be transferred instead of the handle:
-1: All messages initiated by this process are cleared.
-99: All user-defined messages for all processes are cleared.

Example
A message is generated and cleared again later in the program sequence.

DECL INT handle


DECL BOOL result
...
handle = Set_KrlMsg(Type, MyMessage, Parameter[], Options)
...
result = ClearKrlMsg(handle)

EXISTS_KRLMSG: Check message


Description
The EXIST_KRLMSG function is used to check whether a specific message is still “active” and thus in the message
buffer.
The query in the KRL program must be executed cyclically until the message has been cleared.
Syntax
https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductC… 23/37
09.06.22 11:26 Programming user-defined messages

result = EXIST_KRLMSG( handle )


Explanation of the syntax
Element Description
result Type: BOOL
Return value
TRUE: The message is in the message buffer.
FALSE: The message is not in the message buffer.

handle Type: INT


Type of transfer: IN parameter
Handle provided for the message by the SET_KRLMSG function

Example
DECL INT handle
DECL BOOL result
...
handle = SetKrlMsg(Type, MyMessage, Parameter[], Options)
...
result = Exists_KrlMsg(handle)

EXISTS_KRLDLG: Check dialog message


Description
The EXISTS_KRLDLG function can be used to check whether a specific dialog message is still “active” and thus in
the message buffer.
The query in the KRL program must be executed cyclically until the message has been cleared.
Syntax
result = EXISTS_KRLDLG( handle )
Explanation of the syntax
Element Description
result Type: BOOL
Return value
TRUE: The message is in the message buffer.
FALSE: The message is not in the message buffer.

handle Type: INT


Type of transfer: IN parameter
Handle provided for the message by the SET_KRLDLG function

Example
DECL INT handle
DECL BOOL result
...
handle = SET_KRLDLG(Type, MyMessage, Parameter[], Options)
...
result = EXISTS_KRLDLG(handle)

https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductC… 24/37
09.06.22 11:26 Programming user-defined messages

GET_MSGBUFFER: Read message buffer


Description
The GET_MSGBUFFER function reads the message buffer and writes the messages it contains into an array of
type MsgBuf_T.
A maximum of 150 messages can be read.
Syntax
count = GET_MSGBUFFER( MsgBuf [])
Explanation of the syntax
Element Description
count Type: INT
Return value
Number of messages read
MsgBuf Type: MsgBuf_T
Transfer value: OUT parameter
Array into which the messages from the message buffer are written
Maximum of 150 messages

MsgBuf_T
STRUC MsgBuf_T MsgBufMsgType_T type, INT nr, modul[24], CHAR msg_txt[80],
KrlMsgParType_T par_type1, CHAR par_txt1[40], KrlMsgParType_T par_type2, CHAR
par_txt2[40], KrlMsgParType_T par_type3, CHAR par_txt3[40], INT handle

Element Description
type Message type
#SYS_STATE: Kernel system status message
#SYS_QUIT: Kernel system acknowledgement message
#USR_STATE: User-defined status message
#USR_QUIT: User-defined acknowledgement message
#USR_DLG: User-defined dialog message
#USR_WAIT: User-defined wait message

nr Message number
modul[ ] Originator of the message
Note: Only initialized with user-defined messages
msg_txt[ ] Message text or KXR key
Note: Only initialized with user-defined messages
par_type1 ... Type of parameter
par_type3 #VALUE
#KEY
#EMPTY

part_txt1 ... par_txt3 Text or KXR key of the parameter


handle Internal handle for the message
Note: Only initialized with user-defined messages

Example
In this example, the messages from the message buffer are written into the variable “buffer[]” using
GET_MSGBUFFER. The relevant message type of the read message is then requested using a FOR loop.
https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductC… 25/37
09.06.22 11:26 Programming user-defined messages

Def ReadMsgBuffer ( )
decl MsgBuf_T buffer[100]
int message_count
 
message_count = GET_MSGBUFFER (buffer[])
FOR n=1 TO message_count
if (buffer[n].type==#SYS_QUIT) then
...
endif
ENDFOR
End

ISMESSAGESET: Check whether message is in message buffer


Description
The ISMESSAGESET function can be used to check whether a specific message is still “active” and thus in the
message buffer.
Unlike with the EXISTS_KRLMSG and EXISTS_KRLDLG functions, the message number rather than the internal
handle of the message is transferred. Both system messages as well as user-defined messages can be checked.
Syntax
result = ISMESSAGESET( msg_nr )
Explanation of the syntax
Element Description
result Type: BOOL
Return value
TRUE: The message is in the message buffer.
FALSE: The message is not in the message buffer.

msg_nr Type: INT


Type of transfer: IN parameter
Message number of the message to be checked

Example
In the example, a check is carried out to see whether the message with the number 123 is in the message buffer.

DECL BOOL result


DECL INT msg_nr
msg_nr = 123
...
result = IsMessageSet(msg_nr)

Examples

Example of a notification message


Description
The following notification message is to be displayed:

https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductC… 26/37
09.06.22 11:26 Programming user-defined messages

Notification message

The word gripper is to be inserted via a placeholder.


Program
...
1 decl KrlMsg_T message
2 decl KrlMsgPar_T parameter[3]
3 decl KrlMsgOpt_T options
4 int handle
5 message = {modul[] "MyTech", nr 123, msg_txt[] "Check %1."}
6 parameter[1] = {par_type #VALUE, par_txt[] "gripper"}
7 options = {vl_stop TRUE, clear_p_reset TRUE, clear_p_SAW FALSE, log_to_DB FALSE}
8 handle = SET_KRLMSG (#NOTIFY, message, parameter[], options)
...

Line Description
1 … 4 The required variables are declared:
message : Variable for the definition of message name, number, and text
parameter[3] : Variables for the definition of the parameters
options : Variable for the definition of the message response

2 Variables of type KrlMsgPar_t must always be declared with 3 array elements.


6 The originator, the message number and the message text are assigned to the variable
message .
The message text contains the placeholder %1.
7 The parameter for placeholder %1 is assigned a type and content.
Note: As there are no placeholders %2 and %3, parameter[2] and parameter[3] may be
left not initialized. The parameters are then automatically empty.
8 Each parameter has its own default value here. For this reason, the line could also be omitted.
(The function call of SET_KRLMSG must always contain the variable options , however.)
10 The SET_KRLMSG function generates the message msg . #NOTIFY defines that the message is
generated as a notification message.

Example of an acknowledgement message


Description
The following acknowledgement message is to be displayed:

Acknowledgement message

The words Check and tool are to be inserted via placeholders. The program is not to continue until the message
has been acknowledged.
Program

https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductC… 27/37
09.06.22 11:26 Programming user-defined messages

...
1 decl KrlMsg_T message
2 decl KrlMsgPar_T parameter[3]
3 decl KrlMsgOpt_T options
4 int handle
5 ...
6 message = {modul[] "MyTech", nr 231, msg_txt[] "%1 %2."}
7 parameter[1] = {par_type #VALUE, par_txt[] "Check"}
8 parameter[2] = {par_type #VALUE, par_txt[] "tool"}
9 options = {vl_stop true, clear_p_reset TRUE, clear_p_SAW FALSE, log_to_DB TRUE}
10 ...
11 handle = SET_KRLMSG (#QUIT, message, parameter[], options)
12 while (EXISTS_KRLMSG(handle))
13 wait sec 0.1
14 endwhile

Line Description
1 … 4 The required variables are declared:
message : Variable for the definition of message name, number, and text
parameter[3] : Variables for the definition of the parameters
options : Variable for the definition of the message response

2 Variables of type KrlMsgPar_T must always be declared with 3 array elements.


6 The originator, the message number and the message text are assigned to the variable
message .
The message text contains placeholders %1 and %2.
7 The parameter for placeholder %1 is assigned a type and content.
8 The parameter for placeholder %2 is assigned a type and content.
Note: As there is no placeholder %3, parameter[3] may be left not initialized. The
parameter is then automatically empty.
9 The message response is defined in the variable options , e.g. that the message is to be
logged.
11 The SET_KRLMSG function generates the message message . #QUIT defines that the
message is generated as an acknowledgement message.
13 … 15 Program execution remains in the wait loop until the user has acknowledged the message.

Example of a wait message


Description
The following wait message is to be displayed:

Wait message

The wait message is to be removed from the message window when a valid program number is received from
the PLC (valid program numbers in this example are ≥ 1.)
In the case of wait messages, the user can also hide the message using the Simulate button. In this example,
program number 0 is simulated by means of Simulate.

https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductC… 28/37
09.06.22 11:26 Programming user-defined messages

Program
...
1 decl KrlMsg_T message
2 decl KrlMsgPar_T parameter[3]
3 decl KrlMsgOpt_T options
4 int handle, validPgNo
5 bool retVal
6 ...
7 message = {modul[] "MsgTech", Nr 1, msg_txt[] "This is a test."
8 validPgNo = -1
9 ...
10 handle = SET_KRLMSG (#WAITING, message, parameter[], options)
11 IF (handle > 0) THEN
12    repeat
13       validPgNo = GETPGNOFROMPLC()
14       if (EXISTS_KRLMSG (handle) == FALSE) then
15         validPgNo = 0
16       endif
17    until (validPgNo > -1)
18  
19    if (EXISTS_KRLMSG (handle) == TRUE) then
20       retVal = CLEAR_KRLMSG (handle)
21    endif
22 ENDIF
...

https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductC… 29/37
09.06.22 11:26 Programming user-defined messages

Line Description
1 … 5 The required variables are declared:
message : Variable for the definition of message name, number, and text
parameter[3]: Variables for the definition of the parameters
options : Variable for the definition of the message response
handle : Variable for the return value of the SET_KRLMSG function
validPgNo : Variable for the program number from the PLC
retVal : Variable for the return value of the CLEAR_KRLMSG function

2 Variables of type KrlMsgPar_T must always be declared with 3 array elements.


7 The originator, the message number and the message text are assigned to the variable
“message”.
8 The variable for the program number is initialized with a value that must not be from the PLC.
10 The SET_KRLMSG function generates the message. #WAITING defines that the message is
generated as a wait message.
11 … 22 This statement block is to be executed once the message has been generated successfully.
12 … 17 This statement block is repeated until a valid program number is present or the user has cleared
the message by means of Simulate.
13 The robot controller requests a program number from the PLC. This is assigned to the variable
validPgNo .
14 … 16 Check whether the user has pressed Simulate. (In this case, the message is already hidden, i.e.
EXISTS_KRLMSG(handle) == FALSE .)
If so, the variable validPgNo is to be set to 0.
19 … 21 If the user has not pressed Simulate, the message is still active. It is then cleared here using the
CLEAR_KRLMSG function.

Example of a status message


Description
The following status message is to be displayed:

Status message

The container number is to be taken from a KXR file. The message is to be triggered by state_OK = FALSE .
Once this status has been eliminated, the message is to be reset.
Program
1 decl KrlMsg_T message
2 decl KrlMsgPar_T parameter[3]
3 decl KrlMsgOpt_T options
4 int handle
5 bool state_OK, result
6 ...
7 IF state_OK == FALSE THEN
8    message = {modul[] "MyTech", Nr 5, msg_txt[] "Container nr %1 is empty."}
9    parameter[1] = {par_type #KEY, par_txt[] "mytech_container_nr"}
10    options = {vl_stop TRUE, clear_p_reset TRUE, clear_p_SAW FALSE, log_to_DB FALSE}

https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductC… 30/37
09.06.22 11:26 Programming user-defined messages

11    
12    handle = SET_KRLMSG (#STATE, message, parameter[], options)
13 ENDIF
14 ...
15 REPEAT
16 IF (handle > 0) THEN
17 ENDIF
18 ...
19 REPEAT
20    IF (handle > 0) THEN
21       IF state_OK == TRUE THEN
22          result = CLEAR_KRLMSG (handle)
23       ENDIF
24    ENDIF
25    wait sec 0.5
26 UNTIL state_OK == TRUE
27 ...

Line Description
1 … 5 The required variables are declared:
message : Variable for the definition of message name, number, and text
parameter[3] : Variables for the definition of the parameters
options : Variable for the definition of the message response
handle : Variable for the return value of the SET_KRLMSG function
state_OK : Variable for the “state” that causes the message to be generated
result : Variable for the return value of the CLEAR_KRLMSG function

2 Variables of type KrlMsgPar_T must always be declared with 3 array elements.


7 … 13 The status message is triggered if state_OK == FALSE .
8 The originator, the message number and the message text are assigned to the variable
message .
The message text contains the placeholder %1.
9 The parameter for placeholder %1 is assigned a type and content.
#KEY defines that the content of par_txt[] is a text element from a KXR file.
Note: As there are no placeholders %2 and %3, parameter[2] and parameter[3] may be
left not initialized. The parameters are then automatically empty.
10 The message response is defined in the variable options , e.g. that the message is to be
logged.
12 The SET_KRLMSG function generates the message message . #STATE defines the message as
a status message.
15 … 22 A REPEAT loop is used to check every 0.5 s whether the message has been generated and
whether the state that triggered it is still active. If this is no longer the case, the message is
cleared and the REPEAT loop is exited.
16 If handle > 0 , the message has been generated successfully.
17 … 19 The system queries whether the status that triggered the message ( state_OK == FALSE ) is
still applicable. If the state is no longer applicable, the status message is to be cleared.

Example of a dialog message


Description
https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductC… 31/37
09.06.22 11:26 Programming user-defined messages

The following dialog is to be displayed:

Dialog message

Program
...
1 decl KrlMsg_T msg
2 decl KrlMsgPar_T par[3]
3 decl KrlMsgOpt_T opt
4 decl KrlMsgDlgSK_T SK[7]
5 int nHandle, keynumber
6 ...
7 msg = {modul[] "MyTech", Nr 7, msg_txt[] "Continue?"}
8 SK[1] = {sk_Type #value, sk_txt[] "yes"}
9 SK[2] = {sk_Type #value, sk_txt[] "no"}
10 nHandle = Set_KrlDlg (msg, par[], SK[], opt)
11 IF (nHandle > 0) THEN
12    while (Exists_KrlDlg(nHandle, keynumber))
13       wait Sec 0.1
14    endwhile
15    switch keynumber
16       case 1
17       ...
18       case 2
19       ...
20       case 0
21       ...
22    endswitch
23    ENDIF
...

https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductC… 32/37
09.06.22 11:26 Programming user-defined messages

Line Description
1 … 5 The required variables are declared:
msg : Variable for the definition of message name, number, and text
par[3]: Variables for the definition of the parameters
opt : Variable for the definition of the message response
SK[7] : Variable for labels of the 7 buttons
nHandle : Variable for the return value of the SET_KRLMSG function
keynumber : Variable for addressing a button

2 Variables of type KrlMsgPar_T must always be declared with 3 array elements.


4 Variables of type KrlMsgDlgSK_T must always be declared with 7 array elements.
7 The originator, the message number and the message text are assigned to the variable msg .
The message text contains the placeholder %1.
8, 9 Each button is assigned a type and content.
The 1st button from the left is labeled with yes. The 2nd button from the left is labeled with no.
The other buttons are not to be labeled. SK[3] … SK[7] thus remain not initialized.
11 The SET_KRLDLG function generates the message msg .
Note:SET_KRLDLG must always also contain a variable for parameters (type KrlMsgPar_T) and a
variable for the message response (type KrlMsgOpt_T), even if the message contains no
parameters or the default message response is retained.
12 … 24 This statement block is to be executed once the message has been generated successfully.
13 … 15 Wait until the user has answered the dialog. In this case, the dialog in the message window is
cleared and EXISTS_KRLDLG(nHandle, keynumber) == FALSE.
The variable keynumber does not have to be initialized. It is written by the system.
If the dialog is not answered, but otherwise cleared (e.g. by means of CLEAR_KRLMSG via an
interrupt or by a different process), EXISTS_KRLDLG has the return value 0.
16 … 23 If the dialog has been answered or otherwise cleared, different statement blocks are executed
in accordance with the specific answer.

Programming language-specific messages


Description
Language-specific messages can be implemented using KXR files. The texts to be displayed are stored in the
desired languages in a KXR file. The texts can be referenced using their key and displayed as a message text or as
text parameters (for a placeholder).
Texts referenced from KXR files are displayed in the language currently set for the smartHMI.

Precondition
Work computer with text editor, e.g. Notepad++.
USB stick

Procedure
1. Create a new file with the extension *.kxr on the work computer.
2. Name the KXR file after the originator of the associated message. Example: MyTech.kxr
3. Open the KXR file in the text editor.

https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductC… 33/37
09.06.22 11:26 Programming user-defined messages

4. Edit the KXR file as shown in the following example.


In this example, 3 texts are created, in German and English in each case. The texts are written to text
elements with specific keys. A module name is also required for unambiguous identification.

KXR file name, KXR module name and the originator specified in the message must match.

The languages are distinguished from one another by specifying language abbreviations. (>>> Language
abbreviation)

1 <?xml version="1.0" encoding="utf-8"?>


2  <resources xmlns="http://www.kuka.com/schemas/kxr/2009">
3   <module name="MyTech">
4     <message key="Notify_Text_1">
5       <text xml:lang="de-DE">Greifer prüfen.</text>
6       <text xml:lang="en-US">Check gripper.</text>
7     </message>
8     <message key="Quit_Textpara_1">
9       <text xml:lang="de-DE">Schweisspistole</text>
10       <text xml:lang="en-US">welding gun</text>
11     </message>
12     <message key="Quit_Textpara_2">
13       <text xml:lang="de-DE">Bitte warten.</text>
14       <text xml:lang="en-US">Please wait.</text>
15     </message>
16   </module>
17  </resources>

Line Description
3 Module name/originator of the message
4 Message key for text 1
5 Text 1 in German
6 Text 1 in English
8 Message key for text 2
9 Text 2 in German
10 Text 2 in English
12 Message key for text 3
13 Text 3 in German
14 Text 3 in English

5. Save and close the file.


6. Transfer the file to the robot controller, e.g. with a USB stick, and save it in the directory C:\KRC\DATA.

The texts can now be freely referenced in messages.

Example 1
Example of a notification message created without placeholders using the MsgNotify method.
The text Check gripper. is loaded via the key Notify_Text_1 from the KXR language file MyTech.kxr.
In accordance with the language currently set on the smartHMI, the string is displayed in English.

https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductC… 34/37
09.06.22 11:26 Programming user-defined messages

MsgNotify("Notify_Text_1", "MyTech", , 123)

Display in the message window in English:

Notification message

Example 2
Example of a manually programmed acknowledgement message with 2 string placeholders.
The text fragments Check and tool. are loaded using the keys Quit_Textpara_1 and Quit_Textpara_2 from the
language file MyTech.kxr.
In accordance with the language currently set on the smartHMI, the texts are displayed in English.

1 DECL KRLMSG_T mymessage


2 DECL KRLMSGPAR_T Parameter[3]
3 DECL KRLMSGOPT_T Option
4 DECL INT handle
5 DECL BOOL present
6  
7 handle = 0
8  
9  
10 mymessage = {modul[] "MyTech", Nr 231, msg_txt[] " %1 %2."}
11  
12 Option = {VL_STOP FALSE, Clear_P_Reset TRUE, Clear_P_SAW FALSE, Log_to_DB FALSE}
13  
14 Parameter[1] = {PAR_TYPE #KEY, PAR_TXT[] "Quit_Textpara_1"}
15 Parameter[2] = {PAR_TYPE #KEY, PAR_TXT[] "Quit_Textpara_2"}
16 Parameter[3] = {PAR_TYPE #EMPTY}
17  
18 handle = SET_KRLMSG(#QUIT, mymessage, Parameter[], Option)
19  
20 REPEAT
21 present = EXISTS_KRLMSG(handle)
22 UNTIL NOT (present)

https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductC… 35/37
09.06.22 11:26 Programming user-defined messages

Line Description
1 ... 5 Declarations
7 The variable handle is initialized with the value 0.
10 The general message information is transferred: the originator MyTech, the message number and the
message text with placeholders.
12 Options for the effects of the message are defined.
14 The text with the message key Quit_Textpara_1 is assigned to placeholder %1.
15 The text with the message key Quit_Textpara_2 is assigned to placeholder %2.
16 Placeholder %3 is not used; the parameter therefore remains empty.
18 The acknowledgement message is generated. The message type (#QUIT) and all required parameters
are transferred.
20 ... 22 The acknowledgement message is repeated with a loop until it has been acknowledged with OK or All
OK and thus cleared.

Display in the message window in English:

Acknowledgement message

Language abbreviation
The following table provides an overview of the language abbreviations used in the KUKA System Software.

https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductC… 36/37
09.06.22 11:26 Programming user-defined messages

Language abbreviation Language


de-DE German
en-US English
fr-FR French
it-IT Italian
es-ES Spanish
pt-PT Portuguese
nl-NL Dutch
pl-PL Polish
sv-SE Swedish
da-DK Danish
cs-CZ Czech
ru-RU Russian
zh-CN Chinese
fi-FI Finnish
sl-SI Slovenian
hu-HU Hungarian
sk-SK Slovak
ja-JP Japanese
ko-KR Korean
tr-TR Turkish
ro-RO Romanian
el-GR Greek
vi-VN Vietnamese
(from KSS 8.6 onwards)

https://xpert.kuka.com/service-express/portal/project1_p/document/kuka-project1_p-basic_SS2262_en?context=%7B"filter"%3A%7B"ProductC… 37/37

You might also like